[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
1 <?php 2 // 3 // +----------------------------------------------------------------------+ 4 // |zen-cart Open Source E-commerce | 5 // +----------------------------------------------------------------------+ 6 // | Copyright (c) 2003 The zen-cart developers | 7 // | | 8 // | http://www.zen-cart.com/index.php | 9 // | | 10 // | Portions Copyright (c) 2003 osCommerce | 11 // +----------------------------------------------------------------------+ 12 // | This source file is subject to version 2.0 of the GPL license, | 13 // | that is bundled with this package in the file LICENSE, and is | 14 // | available through the world-wide-web at the following url: | 15 // | http://www.zen-cart.com/license/2_0.txt. | 16 // | If you did not receive a copy of the zen-cart license and are unable | 17 // | to obtain it through the world-wide-web, please send a note to | 18 // | license@zen-cart.com so we can mail you a copy immediately. | 19 // +----------------------------------------------------------------------+ 20 // $Id: html_graphs.php 1969 2005-09-13 06:57:21Z drbyte $ 21 // 22 23 //// 24 // calls routines to initialize defaults, set up table 25 // print data, and close table. 26 function html_graph($names, $values, $bars, $vals, $dvalues = 0, $dbars = 0) { 27 // set the error level on entry and exit so as not to interfear with anyone elses error checking. 28 $er = error_reporting(1); 29 30 // set the values that the user didn't 31 $vals = hv_graph_defaults($vals); 32 $html_graph_string = start_graph($vals, $names); 33 34 if ($vals['type'] == 0) { 35 $html_graph_string .= horizontal_graph($names, $values, $bars, $vals); 36 } elseif ($vals['type'] == 1) { 37 $html_graph_string .= vertical_graph($names, $values, $bars, $vals); 38 } elseif ($vals['type'] == 2) { 39 $html_graph_string .= double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars); 40 } elseif ($vals['type'] == 3) { 41 $html_graph_string .= double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars); 42 } 43 44 $html_graph_string .= end_graph(); 45 46 // Set the error level back to where it was. 47 error_reporting($er); 48 49 return $html_graph_string; 50 } 51 52 //// 53 // sets up the $vals array by initializing all values to null. Used to avoid 54 // warnings from error_reporting being set high. This routine only needs to be 55 // called if you are worried about using uninitialized variables. 56 function html_graph_init() { 57 $vals = array('vlabel'=>'', 58 'hlabel'=>'', 59 'type'=>'', 60 'cellpadding'=>'', 61 'cellspacing'=>'', 62 'border'=>'', 63 'width'=>'', 64 'background'=>'', 65 'vfcolor'=>'', 66 'hfcolor'=>'', 67 'vbgcolor'=>'', 68 'hbgcolor'=>'', 69 'vfstyle'=>'', 70 'hfstyle'=>'', 71 'noshowvals'=>'', 72 'scale'=>'', 73 'namebgcolor'=>'', 74 'valuebgcolor'=>'', 75 'namefcolor'=>'', 76 'valuefcolor'=>'', 77 'namefstyle'=>'', 78 'valuefstyle'=>'', 79 'doublefcolor'=>''); 80 81 return($vals); 82 } 83 84 //// 85 // prints out the table header and graph labels 86 function start_graph($vals, $names) { 87 $start_graph_string = '<table cellpadding="' . $vals['cellpadding'] . '" cellspacing="' . $vals['cellspacing'] . '" border="' . $vals['border'] . '"'; 88 89 if ($vals['width'] != 0) $start_graph_string .= ' width="' . $vals['width'] . '"'; 90 if ($vals['background']) $start_graph_string .= ' background="' . $vals['background'] . '"'; 91 92 $start_graph_string .= '>' . "\n"; 93 94 if ( ($vals['vlabel']) || ($vals['hlabel']) ) { 95 if ( ($vals['type'] == 0) || ($vals['type'] == 2) ) { 96 // horizontal chart 97 $rowspan = sizeof($names) + 1; 98 $colspan = 3; 99 } elseif ( ($vals['type'] == 1) || ($vals['type'] == 3) ) { 100 // vertical chart 101 $rowspan = 3; 102 $colspan = sizeof($names) + 1; 103 } 104 105 $start_graph_string .= ' <tr>' . "\n" . 106 ' <td align="center" valign="center"'; 107 108 // if a background was choosen don't print cell BGCOLOR 109 if (!$vals['background']) $start_graph_string .= ' bgcolor="' . $vals['hbgcolor'] . '"'; 110 111 $start_graph_string .= ' colspan="' . $colspan . '"><font color="' . $vals['hfcolor'] . '" style="' . $vals['hfstyle'] . '"><b>' . $vals['hlabel'] . '</b></font></td>' . "\n" . 112 ' </tr>' . "\n" . 113 ' <tr>' . "\n" . 114 ' <td align="center" valign="center"'; 115 116 // if a background was choosen don't print cell BGCOLOR 117 if (!$vals['background']) $start_graph_string .= ' bgcolor="' . $vals['vbgcolor'] . '"'; 118 119 $start_graph_string .= ' rowspan="' . $rowspan . '"><font color="' . $vals['vfcolor'] . '" style="' . $vals['vfstyle'] . '"><b>' . $vals['vlabel'] . '</b></font></td>' . "\n" . 120 ' </tr>' . "\n"; 121 } 122 123 return $start_graph_string; 124 } 125 126 //// 127 // prints out the table footer 128 function end_graph() { 129 return '</table>' . "\n"; 130 } 131 132 //// 133 // sets the default values for the $vals array 134 function hv_graph_defaults($vals) { 135 if (!$vals['vfcolor']) $vals['vfcolor'] = '#000000'; 136 if (!$vals['hfcolor']) $vals['hfcolor'] = '#000000'; 137 if (!$vals['vbgcolor']) $vals['vbgcolor'] = '#FFFFFF'; 138 if (!$vals['hbgcolor']) $vals['hbgcolor'] = '#FFFFFF'; 139 if (!$vals['cellpadding']) $vals['cellpadding'] = '0'; 140 if (!$vals['cellspacing']) $vals['cellspacing'] = '0'; 141 if (!$vals['border']) $vals['border'] = '0'; 142 if (!$vals['scale']) $vals['scale'] = '1'; 143 if (!$vals['namebgcolor']) $vals['namebgcolor'] = '#FFFFFF'; 144 if (!$vals['valuebgcolor']) $vals['valuebgcolor'] = '#FFFFFF'; 145 if (!$vals['namefcolor']) $vals['namefcolor'] = '#000000'; 146 if (!$vals['valuefcolor']) $vals['valuefcolor'] = '#000000'; 147 if (!$vals['doublefcolor']) $vals['doublefcolor'] = '#886666'; 148 149 return $vals; 150 } 151 152 //// 153 // prints out the actual data for the horizontal chart 154 function horizontal_graph($names, $values, $bars, $vals) { 155 $horizontal_graph_string = ''; 156 for($i = 0, $n = sizeof($values); $i < $n; $i++) { 157 $horizontal_graph_string .= ' <tr>' . "\n" . 158 ' <td align="right"'; 159 // if a background was choosen don't print cell BGCOLOR 160 if (!$vals['background']) $horizontal_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"'; 161 162 $horizontal_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n" . 163 ' <td'; 164 165 // if a background was choosen don't print cell BGCOLOR 166 if (!$vals['background']) $horizontal_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"'; 167 168 $horizontal_graph_string .= '>'; 169 170 // decide if the value in bar is a color code or image. 171 if (ereg('^#', $bars[$i])) { 172 $horizontal_graph_string .= '<table cellpadding="0" cellspacing="0" bgcolor="' . $bars[$i] . '" width="' . ($values[$i] * $vals['scale']) . '">' . "\n" . 173 ' <tr>' . "\n" . 174 ' <td> </td>' . "\n" . 175 ' </tr>' . "\n" . 176 '</table>'; 177 } else { 178 $horizontal_graph_string .= '<img src="' . $bars[$i] . '" height="10" width="' . ($values[$i] * $vals['scale']) . '">'; 179 } 180 181 if (!$vals['noshowvals']) { 182 $horizontal_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i>'; 183 } 184 185 $horizontal_graph_string .= '</td>' . "\n" . 186 ' </tr>' . "\n"; 187 } // endfor 188 189 return $horizontal_graph_string; 190 } 191 192 //// 193 // prints out the actual data for the vertical chart 194 function vertical_graph($names, $values, $bars, $vals) { 195 $vertical_graph_string = ' <tr>' . "\n"; 196 197 for ($i = 0, $n = sizeof($values); $i < $n; $i++) { 198 $vertical_graph_string .= ' <td align="center" valign="bottom"'; 199 200 // if a background was choosen don't print cell BGCOLOR 201 if (!$vals['background']) $vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"'; 202 203 $vertical_graph_string .= '>'; 204 205 if (!$vals['noshowvals']) { 206 $vertical_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i><br>'; 207 } 208 209 $vertical_graph_string .= '<img src="' . $bars[$i] . '" width="5" height="'; 210 211 // values of zero are displayed wrong because a image height of zero 212 // gives a strange behavior in Netscape. For this reason the height 213 // is set at 1 pixel if the value is zero. - Jan Diepens 214 if ($values[$i] != 0) { 215 $vertical_graph_string .= $values[$i] * $vals['scale']; 216 } else { 217 $vertical_graph_string .= '1'; 218 } 219 220 $vertical_graph_string .= '"></td>' . "\n"; 221 } // endfor 222 223 $vertical_graph_string .= ' </tr>' . "\n" . 224 ' <tr>' . "\n"; 225 226 for ($i = 0, $n = sizeof($values); $i < $n; $i++) { 227 $vertical_graph_string .= ' <td align="center" valign="top"'; 228 229 // if a background was choosen don't print cell BGCOLOR 230 if (!$vals['background']) $vertical_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"'; 231 232 $vertical_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n"; 233 } // endfor 234 235 $vertical_graph_string .= ' </tr>' . "\n"; 236 237 return $vertical_graph_string; 238 } 239 240 //// 241 // prints out the actual data for the double horizontal chart 242 function double_horizontal_graph($names, $values, $bars, $vals, $dvalues, $dbars) { 243 $double_horizontal_graph_string = ''; 244 for($i = 0, $n = sizeof($values); $i < $n; $i++) { 245 $double_horizontal_graph_string .= ' <tr>' . "\n" . 246 ' <td align="right"'; 247 248 // if a background was choosen don't print cell BGCOLOR 249 if (!$vals['background']) $double_horizontal_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"'; 250 251 $double_horizontal_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n" . 252 ' <td'; 253 254 // if a background was choosen don't print cell BGCOLOR 255 if (!$vals['background']) $double_horizontal_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"'; 256 257 $double_horizontal_graph_string .= '><table align="left" cellpadding="0" cellspacing="0" width="' . ($dvalues[$i] * $vals['scale']) . '">' . "\n" . 258 ' <tr>' . "\n" . 259 ' <td'; 260 261 // set background to a color if it starts with # or an image otherwise. 262 if (ereg('^#', $dbars[$i])) { 263 $double_horizontal_graph_string .= ' bgcolor="' . $dbars[$i] . '">'; 264 } else { 265 $double_horizontal_graph_string .= ' background="' . $dbars[$i] . '">'; 266 } 267 268 $double_horizontal_graph_string .= '<nowrap>'; 269 270 // decide if the value in bar is a color code or image. 271 if (ereg('^#', $bars[$i])) { 272 $double_horizontal_graph_string .= '<table align="left" cellpadding="0" cellspacing="0" bgcolor="' . $bars[$i] . '" width="' . ($values[$i] * $vals['scale']) . '">' . "\n" . 273 ' <tr>' . "\n" . 274 ' <td> </td>' . "\n" . 275 ' </tr>' . "\n" . 276 '</table>'; 277 } else { 278 $double_horizontal_graph_string .= '<img src="' . $bars[$i] . '" height="10" width="' . ($values[$i] * $vals['scale']) . '">'; 279 } 280 281 if (!$vals['noshowvals']) { 282 $double_horizontal_graph_string .= '<i><font size="-3" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i>'; 283 } 284 285 $double_horizontal_graph_string .= '</nowrap></td>' . "\n" . 286 ' </tr>' . "\n" . 287 ' </table>'; 288 289 if (!$vals['noshowvals']) { 290 $double_horizontal_graph_string .= '<i><font size="-3" color="' . $vals['doublefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $dvalues[$i] . ')</font></i>'; 291 } 292 293 $double_horizontal_graph_string .= '</td>' . "\n" . 294 ' </tr>' . "\n"; 295 } // endfor 296 297 return $double_horizontal_graph_string; 298 } 299 300 //// 301 // prints out the actual data for the double vertical chart 302 function double_vertical_graph($names, $values, $bars, $vals, $dvalues, $dbars) { 303 $double_vertical_graph_string = ' <tr>' . "\n"; 304 for ($i = 0, $n = sizeof($values); $i < $n; $i++) { 305 $double_vertical_graph_string .= ' <td align="center" valign="bottom"'; 306 307 // if a background was choosen don't print cell BGCOLOR 308 if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"'; 309 310 $double_vertical_graph_string .= '><table>' . "\n" . 311 ' <tr>' . "\n" . 312 ' <td align="center" valign="bottom"'; 313 314 // if a background was choosen don't print cell BGCOLOR 315 if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"'; 316 317 $double_vertical_graph_string .= '>'; 318 319 if (!$vals['noshowvals'] && $values[$i]) { 320 $double_vertical_graph_string .= '<i><font size="-2" color="' . $vals['valuefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $values[$i] . ')</font></i><br>'; 321 } 322 323 $double_vertical_graph_string .= '<img src="' . $bars[$i] . '" width="10" height="'; 324 325 if ($values[$i] != 0) { 326 $double_vertical_graph_string .= $values[$i] * $vals['scale']; 327 } else { 328 $double_vertical_graph_string .= '1'; 329 } 330 331 $double_vertical_graph_string .= '"></td>' . "\n" . 332 ' <td align="center" valign="bottom"'; 333 334 // if a background was choosen don't print cell BGCOLOR 335 if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['valuebgcolor'] . '"'; 336 337 $double_vertical_graph_string .= '>'; 338 339 if (!$vals['noshowvals'] && $dvalues[$i]) { 340 $double_vertical_graph_string .= '<i><font size="-2" color="' . $vals['doublefcolor'] . '" style="' . $vals['valuefstyle'] . '">(' . $dvalues[$i] . ')</font></i><br>'; 341 } 342 343 $double_vertical_graph_string .= '<img src="' . $dbars[$i] . '" width="10" height="'; 344 345 if ($dvalues[$i] != 0) { 346 $double_vertical_graph_string .= $dvalues[$i] * $vals['scale']; 347 } else { 348 $double_vertical_graph_string .= '1'; 349 } 350 351 $double_vertical_graph_string .= '"></td>' . "\n" . 352 ' </tr>' . "\n" . 353 ' </table></td>' . "\n"; 354 } // endfor 355 356 $double_vertical_graph_string .= ' </tr>' . "\n" . 357 ' <tr>' . "\n"; 358 359 for ($i = 0, $n = sizeof($values); $i < $n; $i++) { 360 $double_vertical_graph_string .= ' <td align="center" valign="top"'; 361 362 // if a background was choosen don't print cell BGCOLOR 363 if (!$vals['background']) $double_vertical_graph_string .= ' bgcolor="' . $vals['namebgcolor'] . '"'; 364 365 $double_vertical_graph_string .= '><font size="-1" color="' . $vals['namefcolor'] . '" style="' . $vals['namefstyle'] . '">' . $names[$i] . '</font></td>' . "\n"; 366 } // endfor 367 368 $double_vertical_graph_string .= ' </tr>' . "\n"; 369 370 return $double_vertical_graph_string; 371 } 372 373 //// 374 // draws a double vertical bar graph for the banner views vs clicks statistics 375 function zen_banner_graph_infoBox($banner_id, $days) { 376 global $db; 377 $names = array(); 378 $values = array(); 379 $dvalues = array(); 380 381 $banner_stats = $db->Execute("select dayofmonth(banners_history_date) as name, 382 banners_shown as value, banners_clicked as dvalue 383 from " . TABLE_BANNERS_HISTORY . " 384 where banners_id = '" . $banner_id . "' 385 and to_days(now()) - to_days(banners_history_date) < " . $days . " 386 order by banners_history_date"); 387 388 while (!$banner_stats->EOF) { 389 $names[] = $banner_stats->fields['name']; 390 $values[] = $banner_stats->fields['value']; 391 $dvalues[] = $banner_stats->fields['dvalue']; 392 $banner_stats->MoveNext(); 393 } 394 $largest = @max($values); 395 396 $bars = array(); 397 $dbars = array(); 398 for ($i = 0, $n = sizeof($values); $i < $n; $i++) { 399 $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif'; 400 $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif'; 401 } 402 403 $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA, 404 'hlabel'=>TEXT_BANNERS_LAST_3_DAYS, 405 'type'=>'3', 406 'cellpadding'=>'', 407 'cellspacing'=>'1', 408 'border'=>'', 409 'width'=>'', 410 'vfcolor'=>'#ffffff', 411 'hfcolor'=>'#ffffff', 412 'vbgcolor'=>'#81a2b6', 413 'hbgcolor'=>'#81a2b6', 414 'vfstyle'=>'Verdana, Arial, Helvetica', 415 'hfstyle'=>'Verdana, Arial, Helvetica', 416 'scale'=>100/$largest, 417 'namebgcolor'=>'#f3f5fe', 418 'valuebgcolor'=>'#f3f5fe', 419 'namefcolor'=>'', 420 'valuefcolor'=>'#0000d0', 421 'namefstyle'=>'Verdana, Arial, Helvetica', 422 'valuefstyle'=>'', 423 'doublefcolor'=>'#ff7339'); 424 425 return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars); 426 } 427 428 //// 429 // draws a double vertical bar graph for the banner views vs clicks statistics 430 function zen_banner_graph_yearly($banner_id) { 431 global $db, $banner, $_GET; 432 433 $banner_stats = $db->Execute("select year(banners_history_date) as year, 434 sum(banners_shown) as value, sum(banners_clicked) as dvalue 435 from " . TABLE_BANNERS_HISTORY . " 436 where banners_id = '" . $banner_id . "' 437 group by year(banners_history_date)"); 438 439 while (!$banner_stats->EOF) { 440 $names[] = $banner_stats->fields['year']; 441 $values[] = (($banner_stats->fields['value']) ? $banner_stats->fields['value'] : '0'); 442 $dvalues[] = (($banner_stats->fields['dvalue']) ? $banner_stats->fields['dvalue'] : '0'); 443 $banner_stats->MoveNext(); 444 } 445 446 $largest = @max($values); 447 448 $bars = array(); 449 $dbars = array(); 450 for ($i = 0, $n = sizeof($values); $i < $n; $i++) { 451 $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif'; 452 $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif'; 453 } 454 455 $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA, 456 'hlabel'=>sprintf(TEXT_BANNERS_YEARLY_STATISTICS, $banner->fields['banners_title']), 457 'type'=>'3', 458 'cellpadding'=>'', 459 'cellspacing'=>'1', 460 'border'=>'', 461 'width'=>'', 462 'vfcolor'=>'#ffffff', 463 'hfcolor'=>'#ffffff', 464 'vbgcolor'=>'#81a2b6', 465 'hbgcolor'=>'#81a2b6', 466 'vfstyle'=>'Verdana, Arial, Helvetica', 467 'hfstyle'=>'Verdana, Arial, Helvetica', 468 'scale'=>100/$largest, 469 'namebgcolor'=>'#f3f5fe', 470 'valuebgcolor'=>'#f3f5fe', 471 'namefcolor'=>'', 472 'valuefcolor'=>'#0000d0', 473 'namefstyle'=>'Verdana, Arial, Helvetica', 474 'valuefstyle'=>'', 475 'doublefcolor'=>'#ff7339'); 476 477 return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars); 478 } 479 480 //// 481 // draws a double vertical bar graph for the banner views vs clicks statistics 482 function zen_banner_graph_monthly($banner_id) { 483 global $db, $banner, $_GET; 484 485 $year = (($_GET['year']) ? $_GET['year'] : date('Y')); 486 487 for ($i=1; $i<13; $i++) { 488 $names[] = strftime('%b', mktime(0,0,0,$i)); 489 $values[] = '0'; 490 $dvalues[] = '0'; 491 } 492 493 $banner_stats = $db->Execute("select month(banners_history_date) as banner_month, sum(banners_shown) as value, 494 sum(banners_clicked) as dvalue 495 from " . TABLE_BANNERS_HISTORY . " 496 where banners_id = '" . $banner_id . "' 497 and year(banners_history_date) = '" . $year . "' 498 group by month(banners_history_date)"); 499 500 while (!$banner_stats->EOF) { 501 $names[($banner_stats->fields['banner_month']-1)] = strftime('%b', mktime(0,0,0,$banner_stats->fields['banner_month'])); 502 $values[($banner_stats->fields['banner_month']-1)] = (($banner_stats->fields['value']) ? $banner_stats->fields['value'] : '0'); 503 $dvalues[($banner_stats->fields['banner_month']-1)] = (($banner_stats->fields['dvalue']) ? $banner_stats->fields['dvalue'] : '0'); 504 $banner_stats->MoveNext(); 505 } 506 507 $largest = @max($values); 508 509 $bars = array(); 510 $dbars = array(); 511 for ($i = 0, $n = sizeof($values); $i < $n; $i++) { 512 $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif'; 513 $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif'; 514 } 515 516 $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA, 517 'hlabel'=>sprintf(TEXT_BANNERS_MONTHLY_STATISTICS, $banner->fields['banners_title'], date('Y')), 518 'type'=>'3', 519 'cellpadding'=>'', 520 'cellspacing'=>'1', 521 'border'=>'', 522 'width'=>'', 523 'vfcolor'=>'#ffffff', 524 'hfcolor'=>'#ffffff', 525 'vbgcolor'=>'#81a2b6', 526 'hbgcolor'=>'#81a2b6', 527 'vfstyle'=>'Verdana, Arial, Helvetica', 528 'hfstyle'=>'Verdana, Arial, Helvetica', 529 'scale'=>100/$largest, 530 'namebgcolor'=>'#f3f5fe', 531 'valuebgcolor'=>'#f3f5fe', 532 'namefcolor'=>'', 533 'valuefcolor'=>'#0000d0', 534 'namefstyle'=>'Verdana, Arial, Helvetica', 535 'valuefstyle'=>'', 536 'doublefcolor'=>'#ff7339'); 537 538 return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars); 539 } 540 541 //// 542 // draws a double vertical bar graph for the banner views vs clicks statistics 543 function zen_banner_graph_daily($banner_id) { 544 global $db, $banner, $_GET; 545 546 $year = (isset($_GET['year']) ? $_GET['year'] : date('Y')); 547 $month = (isset($_GET['month']) ? $_GET['month'] : date('n')); 548 549 $days = (date('t', mktime(0,0,0,$month))+1); 550 $stats = array(); 551 for ($i=1; $i<$days; $i++) { 552 $names[] = $i; 553 $values[] = '0'; 554 $dvalues[] = '0'; 555 } 556 557 $banner_stats = $db->Execute("select dayofmonth(banners_history_date) as banner_day, 558 banners_shown as value, banners_clicked as dvalue 559 from " . TABLE_BANNERS_HISTORY . " 560 where banners_id = '" . $banner_id . "' 561 and month(banners_history_date) = '" . $month . "' 562 and year(banners_history_date) = '" . $year . "'"); 563 564 while (!$banner_stats->EOF) { 565 $names[($banner_stats->fields['banner_day']-1)] = $banner_stats->fields['banner_day']; 566 $values[($banner_stats->fields['banner_day']-1)] = (($banner_stats->fields['value']) ? $banner_stats->fields['value'] : '0'); 567 $dvalues[($banner_stats->fields['banner_day']-1)] = (($banner_stats->fields['dvalue']) ? $banner_stats->fields['dvalue'] : '0'); 568 $banner_stats->MoveNext(); 569 } 570 571 $largest = @max($values); 572 573 $bars = array(); 574 $dbars = array(); 575 for ($i = 0, $n = sizeof($values); $i < $n; $i++) { 576 $bars[$i] = DIR_WS_IMAGES . 'graph_hbar_blue.gif'; 577 $dbars[$i] = DIR_WS_IMAGES . 'graph_hbar_red.gif'; 578 } 579 580 $graph_vals = @array('vlabel'=>TEXT_BANNERS_DATA, 581 'hlabel'=>sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner->fields['banners_title'], strftime('%B', mktime(0,0,0,$month)), $year), 582 'type'=>'3', 583 'cellpadding'=>'', 584 'cellspacing'=>'1', 585 'border'=>'', 586 'width'=>'', 587 'vfcolor'=>'#ffffff', 588 'hfcolor'=>'#ffffff', 589 'vbgcolor'=>'#81a2b6', 590 'hbgcolor'=>'#81a2b6', 591 'vfstyle'=>'Verdana, Arial, Helvetica', 592 'hfstyle'=>'Verdana, Arial, Helvetica', 593 'scale'=>100/$largest, 594 'namebgcolor'=>'#f3f5fe', 595 'valuebgcolor'=>'#f3f5fe', 596 'namefcolor'=>'', 597 'valuefcolor'=>'#0000d0', 598 'namefstyle'=>'Verdana, Arial, Helvetica', 599 'valuefstyle'=>'', 600 'doublefcolor'=>'#ff7339'); 601 602 return html_graph($names, $values, $bars, $graph_vals, $dvalues, $dbars); 603 } 604 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |