Changeset 1512 in ExiteCMS for themes/PLi-Fusion/PLiThemeCentered/php-files/themes/PLiThemeCentered/theme_functions.php
- Timestamp:
- 07/02/08 18:58:52 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
themes/PLi-Fusion/PLiThemeCentered/php-files/themes/PLiThemeCentered/theme_functions.php
r1410 r1512 52 52 } 53 53 } 54 /* 55 [download_id] => 35 56 [download_title] => DM500 57 [download_description] => PLi® Iolite 2008 Edition - for the Dreambox DM500 58 [download_url] => http://downloads.pli-images.org/dm500/pli-Iolite-dm500-20071230-4014.zip 59 [download_cat] => 8 60 [download_license] => GPL 61 [download_os] => tuxbox - Enigma1 62 [download_version] => Iolite 2008 Edition 63 [download_filesize] => 5,878Mb 64 [download_bar] => 1 65 [download_datestamp] => 1199046320 66 [download_count] => 2138 67 [image_url] => /files/cache/pli-images.dev.vnvadvies.nl.PLiTheme.977ecf39a1186353f643b8b55ce34d5c.png 68 [image_height] => 10 69 [image_width] => 28 70 [percentage] => 5 71 [value] => 7 72 */ 54 73 55 74 /*------------------------------------------------------+ … … 58 77 function downloadbars() { 59 78 global $db_prefix, $settings; 60 79 61 80 // define the font2image array 62 81 $font2png = array(); … … 78 97 $font2png['return_link'] = true; 79 98 99 // define the download records we want a bar graph from 100 $downloads = array(); 101 102 $total = 0; 103 // get the defined download bars 104 $result = dbquery("SELECT * FROM ".$db_prefix."dlstats_counters ORDER BY dlsc_order"); 105 while ($data = dbarray($result)) { 106 // start with a count of zero 107 $download = array('download_count' => 0); 108 // check if we need to get a local download counter 109 if ($data['dlsc_download_id']) { 110 $result2 = dbquery("SELECT d.*, c.download_cat_access FROM ".$db_prefix."downloads d LEFT JOIN ".$db_prefix."download_cats c ON d.download_cat = c.download_cat_id WHERE d.download_id = '".$data['dlsc_download_id']."'"); 111 if ($data2 = dbarray($result2)) { 112 // check if this user has the right to download it 113 $access = true; 114 $cat_id = $data2['download_cat']; 115 while(true) { 116 // check if the user has access to this download item 117 $data3 = dbarray(dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id = '".$cat_id."'")); 118 if (!checkgroup($data3['download_cat_access'])) { 119 $access = false; 120 break; 121 } 122 // if this was a sub-category, check the parent as well 123 $cat_id = $data3['download_parent']; 124 // if no more parents are present, end the loop 125 if ($cat_id == 0) break; 126 } 127 // if the user has access, add the info from the download record 128 if ($access) { 129 $download = array_merge($download, $data2); 130 } 131 } 132 } 133 // check if we need to add file counters 134 $files = explode("\n", $data['dlsc_files']); 135 foreach($files as $file) { 136 $result2 = dbquery("SELECT * FROM ".$db_prefix."dlstats_files WHERE dlsf_file = '".trim($file)."'"); 137 if ($data2 = dbarray($result2)) { 138 // get the counter 139 $download['download_count'] += $data2['dlsf_counter']; 140 } 141 } 142 // and add some data from the counter definition 143 $download['download_title'] = $data['dlsc_name']; 144 $download['download_description'] = $data['dlsc_description']; 145 // make sure the title is properly formatted and fits 146 if (strlen($download['download_title']) > 6) $download['download_title'] = substr($download['download_title'],0,6); 147 $download['download_title'] = strtoupper(trim($download['download_title'])); 148 $font2png['font_text'] = $download['download_title']; 149 $download['image_url'] = font2image($font2png); 150 $size = getimagesize(PATH_ROOT.$download['image_url']); 151 $download['image_height'] =$size[1]; 152 $download['image_width'] = $size[0]; 153 $total += $download['download_count']; 154 $downloads[] = $download; 155 } 156 80 157 // define the max width of a bar in pixels 81 158 $barheight = 65; 82 83 // define the download records we want a bar graph from84 $download = array();85 86 // get the download statistics for the required download records87 $total = 0;88 $result = dbquery("SELECT * FROM ".$db_prefix."downloads WHERE download_bar > '0' ORDER BY download_bar ASC");89 while ($data = dbarray($result)) {90 $access = true;91 $cat_id = $data['download_cat'];92 while(true) {93 // check if the user has access to this download item94 $data2 = dbarray(dbquery("SELECT * FROM ".$db_prefix."download_cats WHERE download_cat_id = '".$cat_id."'"));95 if (!checkgroup($data2['download_cat_access'])) {96 $access = false;97 break;98 }99 // if this was a sub-category, check the parent as well100 $cat_id = $data2['download_parent'];101 // if no more parents are present, end the loop102 if ($cat_id == 0) break;103 104 }105 // if the user has access, add this download to the bar panel106 if ($access) {107 if (strlen($data['download_title']) > 6) $data['download_title'] = substr($data['download_title'],0,6);108 $data['download_title'] = strtoupper(trim($data['download_title']));109 $font2png['font_text'] = $data['download_title'];110 $data['image_url'] = font2image($font2png);111 $download[] = $data;112 $total += $data['download_count'];113 }114 }115 159 116 160 // calculate the percentages of the grand total of all the entries listed (in $total) 117 161 $maxperc = 0; 118 foreach ($download as $key => $value) {162 foreach ($downloads as $key => $value) { 119 163 if ($total == 0) 120 $download [$key]['percentage'] = 0;164 $downloads[$key]['percentage'] = 0; 121 165 else 122 $download [$key]['percentage'] = floor($value['download_count'] / $total * 100);166 $downloads[$key]['percentage'] = floor($value['download_count'] / $total * 100); 123 167 // add 1 to make sure 'percentage' is never zero (to work around a Firefox DIV bug) 124 $download [$key]['percentage']++;125 $maxperc = max($maxperc, $download [$key]['percentage']);168 $downloads[$key]['percentage']++; 169 $maxperc = max($maxperc, $downloads[$key]['percentage']); 126 170 } 127 171 // calculate the percentage multiplier to fill out the bars nicely … … 130 174 // display the panel with the download statistics 131 175 $i=1; 132 foreach ($download as $key => $value) {133 $download [$key]['value'] = floor($value['percentage'] * $multiplier);176 foreach ($downloads as $key => $value) { 177 $downloads[$key]['value'] = floor($value['percentage'] * $multiplier); 134 178 $i++; 135 179 } 136 return $download; 180 181 return $downloads; 137 182 } 138 183 … … 149 194 } 150 195 151 $result = dbquery("SELECT download_cat_name FROM ".$db_prefix."download_cats WHERE download_cat_id = '0'"); 152 if ($data = dbarray($result)) { 153 if ($data['download_cat_name'] != "") { 154 $bar_title = trim($data['download_cat_name']). " : ".$total." | "; 155 } 156 } 196 $bar_title = sprintf(html_entity_decode($settings['dlstats_title']),$total); 197 157 198 if (!isset($bar_title)) $bar_title = "Current image downloads "; 158 199
Note: See TracChangeset
for help on using the changeset viewer.
