| [ PHPXref.com ] | [ Generated: Sun Jul 20 19:31:32 2008 ] | [ phpAdsNew 2.0.8 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php // $Revision: 2.1.2.22 $ 2 3 /************************************************************************/ 4 /* phpAdsNew 2 */ 5 /* =========== */ 6 /* */ 7 /* Copyright (c) 2000-2006 by the phpAdsNew developers */ 8 /* For more information visit: http://www.phpadsnew.com */ 9 /* */ 10 /* This program is free software. You can redistribute it and/or modify */ 11 /* it under the terms of the GNU General Public License as published by */ 12 /* the Free Software Foundation; either version 2 of the License. */ 13 /************************************************************************/ 14 15 16 17 // Include required files 18 require ("config.php"); 19 require ("lib-statistics.inc.php"); 20 21 22 // Register input variables 23 phpAds_registerGlobal ('expand', 'collapse', 'hideinactive', 'listorder', 'orderdirection', 'period', 'period_range'); 24 25 26 // Security check 27 phpAds_checkAccess(phpAds_Admin); 28 29 30 // Set default values 31 $tabindex = 1; 32 33 34 35 /*********************************************************/ 36 /* HTML framework */ 37 /*********************************************************/ 38 39 $extra = "<br><br><br>"; 40 $extra .= "<b>$strMaintenance</b><br>"; 41 $extra .= "<img src='images/break.gif' height='1' width='160' vspace='4'><br>"; 42 $extra .= "<a href='stats-reset.php?all=true'".phpAds_DelConfirm($strConfirmResetStats).">"; 43 $extra .= "<img src='images/".$phpAds_TextDirection."/icon-undo.gif' align='absmiddle' border='0'> $strResetStats</a>"; 44 $extra .= "<br><br>"; 45 46 phpAds_PageHeader("2.1", $extra); 47 phpAds_ShowSections(array("2.1", "2.4", "2.2", "2.5")); 48 49 50 51 /*********************************************************/ 52 /* Get preferences */ 53 /*********************************************************/ 54 55 if (!isset($hideinactive)) 56 { 57 if (isset($Session['prefs']['stats-global-client.php']['hideinactive'])) 58 $hideinactive = $Session['prefs']['stats-global-client.php']['hideinactive']; 59 else 60 $hideinactive = ($phpAds_config['gui_hide_inactive'] == 't'); 61 } 62 63 if (!isset($listorder)) 64 { 65 if (isset($Session['prefs']['stats-global-client.php']['listorder'])) 66 $listorder = $Session['prefs']['stats-global-client.php']['listorder']; 67 else 68 $listorder = ''; 69 } 70 71 if (!isset($orderdirection)) 72 { 73 if (isset($Session['prefs']['stats-global-client.php']['orderdirection'])) 74 $orderdirection = $Session['prefs']['stats-global-client.php']['orderdirection']; 75 else 76 $orderdirection = ''; 77 } 78 79 if (isset($Session['prefs']['stats-global-client.php']['nodes'])) 80 $node_array = explode (",", $Session['prefs']['stats-global-client.php']['nodes']); 81 else 82 $node_array = array(); 83 84 85 86 if (!isset($period)) 87 { 88 if (isset($Session['prefs']['stats-global-client.php']['period'])) 89 $period = $Session['prefs']['stats-global-client.php']['period']; 90 else 91 $period = ''; 92 } 93 94 95 if (!isset($period_range)) 96 { 97 if (isset($Session['prefs']['stats-global-client.php']['period_range'])) 98 $period_range = $Session['prefs']['stats-global-client.php']['period_range']; 99 else 100 $period_range = array ( 101 'start_day' => 0, 102 'start_month' => 0, 103 'start_year' => 0, 104 'end_day' => 0, 105 'end_month' => 0, 106 'end_year' => 0 107 ); 108 } 109 110 111 112 113 114 115 /*********************************************************/ 116 /* Main code */ 117 /*********************************************************/ 118 119 // Get clients & campaign and build the tree 120 if (phpAds_isUser(phpAds_Admin)) 121 { 122 $res_clients = phpAds_dbQuery(" 123 SELECT 124 * 125 FROM 126 ".$phpAds_config['tbl_clients']." 127 ".phpAds_getListOrder ($listorder, $orderdirection)." 128 ") or phpAds_sqlDie(); 129 } 130 else 131 { 132 $res_clients = phpAds_dbQuery(" 133 SELECT 134 * 135 FROM 136 ".$phpAds_config['tbl_clients']." 137 WHERE 138 clientid = ".phpAds_getUserID()." OR 139 parent = ".phpAds_getUserID()." 140 ".phpAds_getListOrder ($listorder, $orderdirection)." 141 ") or phpAds_sqlDie(); 142 } 143 144 while ($row_clients = phpAds_dbFetchArray($res_clients)) 145 { 146 if ($row_clients['parent'] == 0) 147 { 148 $clients[$row_clients['clientid']] = $row_clients; 149 $clients[$row_clients['clientid']]['expand'] = 0; 150 $clients[$row_clients['clientid']]['count'] = 0; 151 $clients[$row_clients['clientid']]['hideinactive'] = 0; 152 } 153 else 154 { 155 $campaigns[$row_clients['clientid']] = $row_clients; 156 $campaigns[$row_clients['clientid']]['expand'] = 0; 157 $campaigns[$row_clients['clientid']]['count'] = 0; 158 } 159 } 160 161 162 // Check period range 163 if ($period_range['start_month'] == 0 || $period_range['start_day'] == 0 || $period_range['start_year'] == 0) 164 { 165 $period_begin = 0; 166 $period_range['start_day'] = $period_range['start_month'] = $period_range['start_year'] = 0; 167 } 168 else 169 $period_begin = mktime(0, 0, 0, $period_range['start_month'], $period_range['start_day'], $period_range['start_year']); 170 171 172 if ($period_range['end_month'] == 0 || $period_range['end_day'] == 0 || $period_range['end_year'] == 0) 173 { 174 $period_end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')); 175 $period_range['end_day'] = $period_range['end_month'] = $period_range['end_year'] = 0; 176 } 177 else 178 $period_end = @mktime(0, 0, 0, $period_range['end_month'], $period_range['end_day'] + 1, $period_range['end_year']); 179 180 181 182 if (!$phpAds_config['compact_stats']) 183 { 184 switch ($period) 185 { 186 case 'r': $limit = "t_stamp >= ".date('YmdHis', $period_begin)." AND t_stamp < ".date('YmdHis', $period_end); 187 break; 188 189 case 'y': $timestamp_begin = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')); 190 $timestamp_end = mktime(0, 0, 0, date('m'), date('d'), date('Y')); 191 $limit = "t_stamp >= ".date('YmdHis', $timestamp_begin)." AND t_stamp < ".date('YmdHis', $timestamp_end); 192 break; 193 194 case 't': $timestamp_begin = mktime(0, 0, 0, date('m'), date('d'), date('Y')); 195 $limit = "t_stamp >= ".date('YmdHis', $timestamp_begin); 196 break; 197 198 case 'w': $timestamp_begin = mktime(0, 0, 0, date('m'), date('d') - 6, date('Y')); 199 $limit = "t_stamp >= ".date('YmdHis', $timestamp_begin); 200 break; 201 202 case 'm': $timestamp_begin = mktime(0, 0, 0, date('m'), 1, date('Y')); 203 $limit = "t_stamp >= ".date('YmdHis', $timestamp_begin); 204 break; 205 206 case 'l': $timestamp_begin = mktime(0, 0, 0, date('m')-1, 1, date('Y')); 207 $timestamp_end = mktime(0, 0, 0, date('m'), 1, date('Y')); 208 $limit = "t_stamp >= ".date('YmdHis', $timestamp_begin)." AND t_stamp < ".date('YmdHis', $timestamp_end); 209 break; 210 211 case 'z': $timestamp_begin = mktime(0, 0, 0, 1, 1, date('Y')); 212 $limit = "t_stamp >= ".date('YmdHis', $timestamp_begin); 213 break; 214 215 case 'x': $timestamp_begin = mktime(0, 0, 0, 1, 1, date('Y')-1); 216 $timestamp_end = mktime(0, 0, 0, 1, 1, date('Y')); 217 $limit = "t_stamp >= ".date('YmdHis', $timestamp_begin)." AND t_stamp < ".date('YmdHis', $timestamp_end); 218 break; 219 220 default: $limit = ''; 221 $period = ''; 222 break; 223 } 224 } 225 else 226 { 227 switch ($period) 228 { 229 case 'r': $limit = "day >= ".date('Ymd', $period_begin)." AND day < ".date('Ymd', $period_end); 230 break; 231 232 case 'y': $timestamp_begin = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')); 233 $timestamp_end = mktime(0, 0, 0, date('m'), date('d'), date('Y')); 234 $limit = "day >= ".date('Ymd', $timestamp_begin)." AND day < ".date('Ymd', $timestamp_end); 235 break; 236 237 case 't': $timestamp_begin = mktime(0, 0, 0, date('m'), date('d'), date('Y')); 238 $limit = "day >= ".date('Ymd', $timestamp_begin); 239 break; 240 241 case 'w': $timestamp_begin = mktime(0, 0, 0, date('m'), date('d') - 6, date('Y')); 242 $limit = "day >= ".date('Ymd', $timestamp_begin); 243 break; 244 245 case 'm': $timestamp_begin = mktime(0, 0, 0, date('m'), 1, date('Y')); 246 $limit = "day >= ".date('Ymd', $timestamp_begin); 247 break; 248 249 250 case 'l': $timestamp_begin = mktime(0, 0, 0, date('m')-1, 1, date('Y')); 251 $timestamp_end = mktime(0, 0, 0, date('m'), 1, date('Y')); 252 $limit = "day >= ".date('Ymd', $timestamp_begin)." AND day < ".date('Ymd', $timestamp_end); 253 break; 254 255 case 'z': $timestamp_begin = mktime(0, 0, 0, 1, 1, date('Y')); 256 $limit = "day >= ".date('Ymd', $timestamp_begin); 257 break; 258 259 case 'x': $timestamp_begin = mktime(0, 0, 0, 1, 1, date('Y')-1); 260 $timestamp_end = mktime(0, 0, 0, 1, 1, date('Y')); 261 $limit = "day >= ".date('Ymd', $timestamp_begin)." AND day < ".date('Ymd', $timestamp_end); 262 break; 263 264 default: $limit = ''; 265 $period = ''; 266 break; 267 } 268 } 269 270 271 // Get the banners for each campaign 272 $res_banners = phpAds_dbQuery(" 273 SELECT 274 bannerid, 275 clientid, 276 alt, 277 description, 278 active, 279 storagetype 280 FROM 281 ".$phpAds_config['tbl_banners']." 282 ".phpAds_getBannerListOrder ($listorder, $orderdirection)." 283 ") or phpAds_sqlDie(); 284 285 while ($row_banners = phpAds_dbFetchArray($res_banners)) 286 { 287 if (isset($clients[$row_banners['clientid']])) 288 { 289 $clients[$row_banners['clientid']]['count']++; 290 } 291 292 if (isset($campaigns[$row_banners['clientid']])) 293 { 294 $banners[$row_banners['bannerid']] = $row_banners; 295 $banners[$row_banners['bannerid']]['clicks'] = 0; 296 $banners[$row_banners['bannerid']]['views'] = 0; 297 $campaigns[$row_banners['clientid']]['count']++; 298 299 $bannerids[] = $row_banners['bannerid']; 300 } 301 } 302 303 if (count($bannerids)) 304 { 305 // Create WHERE clause 306 $where = $limit ? "WHERE ".$limit : ''; 307 308 if (!$phpAds_config['compact_stats']) 309 { 310 $res_stats = phpAds_dbQuery(" 311 SELECT 312 bannerid, 313 count(*) as views 314 FROM 315 ".$phpAds_config['tbl_adviews']." 316 ".$where." 317 GROUP BY 318 bannerid 319 ") or phpAds_sqlDie(); 320 321 while ($row_stats = phpAds_dbFetchArray($res_stats)) 322 { 323 $banners[$row_stats['bannerid']]['views'] = $row_stats['views']; 324 $banners[$row_stats['bannerid']]['clicks'] = 0; 325 } 326 327 328 $res_stats = phpAds_dbQuery(" 329 SELECT 330 bannerid, 331 count(*) as clicks 332 FROM 333 ".$phpAds_config['tbl_adclicks']." 334 ".$where." 335 GROUP BY 336 bannerid 337 ") or phpAds_sqlDie(); 338 339 while ($row_stats = phpAds_dbFetchArray($res_stats)) 340 { 341 $banners[$row_stats['bannerid']]['clicks'] = $row_stats['clicks']; 342 } 343 } 344 else 345 { 346 $res_stats = phpAds_dbQuery(" 347 SELECT 348 bannerid, 349 sum(views) as views, 350 sum(clicks) as clicks 351 FROM 352 ".$phpAds_config['tbl_adstats']." 353 ".$where." 354 GROUP BY 355 bannerid 356 ") or phpAds_sqlDie(); 357 358 while ($row_stats = phpAds_dbFetchArray($res_stats)) 359 { 360 $banners[$row_stats['bannerid']]['clicks'] = $row_stats['clicks']; 361 $banners[$row_stats['bannerid']]['views'] = $row_stats['views']; 362 } 363 } 364 } 365 366 367 368 // Add ID found in expand to expanded nodes 369 if (isset($expand) && $expand != '') 370 { 371 switch ($expand) 372 { 373 case 'all' : $node_array = array(); 374 if (isset($clients)) while (list($key,) = each($clients)) $node_array[] = $key; 375 if (isset($campaigns)) while (list($key,) = each($campaigns)) $node_array[] = $key; 376 break; 377 378 case 'none': $node_array = array(); 379 break; 380 381 default: $node_array[] = $expand; 382 break; 383 } 384 } 385 386 387 $node_array_size = sizeof($node_array); 388 for ($i=0; $i < $node_array_size;$i++) 389 { 390 if (isset($collapse) && $collapse == $node_array[$i]) 391 unset ($node_array[$i]); 392 else 393 { 394 if (isset($clients[$node_array[$i]])) 395 $clients[$node_array[$i]]['expand'] = 1; 396 if (isset($campaigns[$node_array[$i]])) 397 $campaigns[$node_array[$i]]['expand'] = 1; 398 } 399 } 400 401 402 403 // Build Tree 404 $clientshidden = 0; 405 406 if (isset($banners) && is_array($banners) && count($banners) > 0) 407 { 408 // Add banner to campaigns 409 reset ($banners); 410 while (list ($bkey, $banner) = each ($banners)) 411 if ($hideinactive == false || $banner['active'] == 't') 412 $campaigns[$banner['clientid']]['banners'][$bkey] = $banner; 413 414 unset ($banners); 415 } 416 417 if (isset($campaigns) && is_array($campaigns) && count($campaigns) > 0) 418 { 419 reset ($campaigns); 420 while (list ($ckey, $campaign) = each ($campaigns)) 421 { 422 if (!isset($campaign['banners'])) 423 $campaign['banners'] = array(); 424 425 if ($hideinactive == false || $campaign['active'] == 't' && 426 (count($campaign['banners']) != 0 || count($campaign['banners']) == $campaign['count'])) 427 $clients[$campaign['parent']]['campaigns'][$ckey] = $campaign; 428 else 429 $clients[$campaign['parent']]['hideinactive']++; 430 } 431 432 unset ($campaigns); 433 } 434 435 if (isset($clients) && is_array($clients) && count($clients) > 0) 436 { 437 reset ($clients); 438 while (list ($key, $client) = each ($clients)) 439 { 440 if (!isset($client['campaigns'])) 441 $client['campaigns'] = array(); 442 443 if (count($client['campaigns']) == 0 && $client['hideinactive'] > 0) 444 { 445 $clientshidden++; 446 unset($clients[$key]); 447 } 448 } 449 } 450 451 452 453 $totalviews = 0; 454 $totalclicks = 0; 455 456 if (isset($clients) && is_array($clients) && count($clients) > 0) 457 { 458 // Calculate statistics for clients 459 foreach (array_keys($clients) as $key) 460 { 461 $clientviews = 0; 462 $clientclicks = 0; 463 464 if (isset($clients[$key]['campaigns']) && sizeof ($clients[$key]['campaigns']) > 0) 465 { 466 $campaigns = $clients[$key]['campaigns']; 467 468 // Calculate statistics for campaigns 469 foreach (array_keys($campaigns) as $ckey) 470 { 471 $campaignviews = 0; 472 $campaignclicks = 0; 473 474 if (isset($campaigns[$ckey]['banners']) && sizeof ($campaigns[$ckey]['banners']) > 0) 475 { 476 $banners = $campaigns[$ckey]['banners']; 477 foreach (array_keys($banners) as $bkey) 478 { 479 $campaignviews += $banners[$bkey]['views']; 480 $campaignclicks += $banners[$bkey]['clicks']; 481 } 482 } 483 484 $clientviews += $campaignviews; 485 $clientclicks += $campaignclicks; 486 487 $clients[$key]['campaigns'][$ckey]['views'] = $campaignviews; 488 $clients[$key]['campaigns'][$ckey]['clicks'] = $campaignclicks; 489 } 490 } 491 492 $totalviews += $clientviews; 493 $totalclicks += $clientclicks; 494 495 $clients[$key]['clicks'] = $clientclicks; 496 $clients[$key]['views'] = $clientviews; 497 } 498 499 unset ($campaigns); 500 unset ($banners); 501 } 502 503 504 505 506 echo "<form action='".$HTTP_SERVER_VARS['PHP_SELF']."'>"; 507 508 echo "<select name='period' onChange='this.form.submit();' accesskey='".$keyList."' tabindex='".($tabindex++)."'>"; 509 echo "<option value=''".($period == '' ? ' selected' : '').">".$strCollectedAll."</option>"; 510 echo "<option value='' disabled>-----------------------------------------</option>"; 511 echo "<option value='t'".($period == 't' ? ' selected' : '').">".$strCollectedToday."</option>"; 512 echo "<option value='y'".($period == 'y' ? ' selected' : '').">".$strCollectedYesterday."</option>"; 513 echo "<option value='w'".($period == 'w' ? ' selected' : '').">".$strCollected7Days."</option>"; 514 echo "<option value='m'".($period == 'm' ? ' selected' : '').">".$strCollectedMonth."</option>"; 515 echo "<option value='l'".($period == 'l' ? ' selected' : '').">".$strCollectedLastMonth."</option>"; 516 echo "<option value='z'".($period == 'z' ? ' selected' : '').">".$strCollectedYear."</option>"; 517 echo "<option value='x'".($period == 'x' ? ' selected' : '').">".$strCollectedLastYear."</option>"; 518 echo "<option value='' disabled>-----------------------------------------</option>"; 519 echo "<option value='r'".($period == 'r' ? ' selected' : '').">".$strCollectedRange."</option>"; 520 echo "</select>"; 521 522 523 if ($period == 'r') 524 { 525 phpAds_ShowBreak(); 526 echo $strFrom." "; 527 528 // Starting date 529 echo "<select name='period_range[start_day]'>\n"; 530 echo "<option value='0'".($period_range['start_day'] == 0 ? ' selected' : '').">-</option>\n"; 531 for ($i=1;$i<=31;$i++) 532 echo "<option value='$i'".($i == $period_range['start_day'] ? ' selected' : '').">$i</option>\n"; 533 echo "</select> \n"; 534 535 echo "<select name='period_range[start_month]'>\n"; 536 echo "<option value='0'".($period_range['start_month'] == 0 ? ' selected' : '').">-</option>\n"; 537 for ($i=1;$i<=12;$i++) 538 echo "<option value='$i'".($i == $period_range['start_month'] ? ' selected' : '').">".$strMonth[$i-1]."</option>\n"; 539 echo "</select> \n"; 540 541 echo "<select name='period_range[start_year]'>\n"; 542 echo "<option value='0'".($period_range['start_year'] == 0 ? ' selected' : '').">-</option>\n"; 543 for ($i=date('Y')-4;$i<=date('Y');$i++) 544 echo "<option value='$i'".($i == $period_range['start_year'] ? ' selected' : '').">$i</option>\n"; 545 echo "</select>\n"; 546 547 // To 548 echo " $strTo "; 549 550 // End date 551 echo "<select name='period_range[end_day]'>\n"; 552 echo "<option value='0'".($period_range['end_day'] == 0 ? ' selected' : '').">-</option>\n"; 553 for ($i=1;$i<=31;$i++) 554 echo "<option value='$i'".($i == $period_range['end_day'] ? ' selected' : '').">$i</option>\n"; 555 echo "</select> \n"; 556 557 echo "<select name='period_range[end_month]'>\n"; 558 echo "<option value='0'".($period_range['end_month'] == 0 ? ' selected' : '').">-</option>\n"; 559 for ($i=1;$i<=12;$i++) 560 echo "<option value='$i'".($i == $period_range['end_month'] ? ' selected' : '').">".$strMonth[$i-1]."</option>\n"; 561 echo "</select> \n"; 562 563 echo "<select name='period_range[end_year]'>\n"; 564 echo "<option value='0'".($period_range['end_year'] == 0 ? ' selected' : '').">-</option>\n"; 565 for ($i=date('Y')-4;$i<=date('Y');$i++) 566 echo "<option value='$i'".($i == $period_range['end_year'] ? ' selected' : '').">$i</option>\n"; 567 echo "</select>\n"; 568 569 echo " "; 570 echo "<input type='image' src='images/".$phpAds_TextDirection."/go_blue.gif'>"; 571 } 572 573 phpAds_ShowBreak(); 574 echo "</form>"; 575 576 577 578 579 580 581 if ($clientshidden > 0 || $totalviews > 0 || $totalclicks > 0) 582 { 583 echo "<br><br>"; 584 echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>"; 585 586 echo "<tr height='25'>"; 587 echo '<td height="25" width="40%"><b> <a href="stats-global-client.php?listorder=name">'.$GLOBALS['strName'].'</a>'; 588 if (($listorder == "name") || ($listorder == "")) 589 { 590 if (($orderdirection == "") || ($orderdirection == "down")) 591 { 592 echo ' <a href="stats-global-client.php?orderdirection=up">'; 593 echo '<img src="images/caret-ds.gif" border="0" alt="" title="">'; 594 } 595 else 596 { 597 echo ' <a href="stats-global-client.php?orderdirection=down">'; 598 echo '<img src="images/caret-u.gif" border="0" alt="" title="">'; 599 } 600 echo '</a>'; 601 } 602 echo '</b></td>'; 603 echo '<td height="25"><b><a href="stats-global-client.php?listorder=id">'.$GLOBALS['strID'].'</a>'; 604 if ($listorder == "id") 605 { 606 if (($orderdirection == "") || ($orderdirection == "down")) 607 { 608 echo ' <a href="stats-global-client.php?orderdirection=up">'; 609 echo '<img src="images/caret-ds.gif" border="0" alt="" title="">'; 610 } 611 else 612 { 613 echo ' <a href="stats-global-client.php?orderdirection=down">'; 614 echo '<img src="images/caret-u.gif" border="0" alt="" title="">'; 615 } 616 echo '</a>'; 617 } 618 echo '</b> </td>'; 619 echo "<td height='25' align='".$phpAds_TextAlignRight."'><b>".$GLOBALS['strViews']."</b></td>"; 620 echo "<td height='25' align='".$phpAds_TextAlignRight."'><b>".$GLOBALS['strClicks']."</b></td>"; 621 echo "<td height='25' align='".$phpAds_TextAlignRight."'><b>".$GLOBALS['strCTRShort']."</b> </td>"; 622 echo "</tr>"; 623 624 echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>"; 625 626 627 $i=0; 628 foreach (array_keys($clients) as $key) 629 { 630 $client = $clients[$key]; 631 632 echo "<tr height='25' ".($i%2==0?"bgcolor='#F6F6F6'":"").">"; 633 634 // Icon & name 635 echo "<td height='25'>"; 636 if (isset($client['campaigns'])) 637 { 638 if ($client['expand'] == '1') 639 echo " <a href='stats-global-client.php?collapse=".$client['clientid']."'><img src='images/triangle-d.gif' align='absmiddle' border='0'></a> "; 640 else 641 echo " <a href='stats-global-client.php?expand=".$client['clientid']."'><img src='images/".$phpAds_TextDirection."/triangle-l.gif' align='absmiddle' border='0'></a> "; 642 } 643 else 644 echo " <img src='images/spacer.gif' height='16' width='16'> "; 645 646 echo "<img src='images/icon-client.gif' align='absmiddle'> "; 647 echo "<a href='stats-client-history.php?clientid=".$client['clientid']."'>".$client['clientname']."</a>"; 648 echo "</td>"; 649 650 // ID 651 echo "<td height='25'>".$client['clientid']."</td>"; 652 653 // Button 1 654 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($client['views'])."</td>"; 655 656 // Empty 657 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($client['clicks'])."</td>"; 658 659 // Button 3 660 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_buildCTR($client['views'], $client['clicks'])." </td>"; 661 662 663 664 if (isset($client['campaigns']) && sizeof ($client['campaigns']) > 0 && $client['expand'] == '1') 665 { 666 $campaigns = $client['campaigns']; 667 668 foreach (array_keys($campaigns) as $ckey) 669 { 670 // Divider 671 echo "<tr height='1'>"; 672 echo "<td ".($i%2==0?"bgcolor='#F6F6F6'":"")."><img src='images/spacer.gif' width='1' height='1'></td>"; 673 echo "<td colspan='5' bgcolor='#888888'><img src='images/break-l.gif' height='1' width='100%'></td>"; 674 echo "</tr>"; 675 676 // Icon & name 677 echo "<tr height='25' ".($i%2==0?"bgcolor='#F6F6F6'":"")."><td height='25'>"; 678 echo " "; 679 680 if (isset($campaigns[$ckey]['banners'])) 681 { 682 if ($campaigns[$ckey]['expand'] == '1') 683 echo "<a href='stats-global-client.php?collapse=".$campaigns[$ckey]['clientid']."'><img src='images/triangle-d.gif' align='absmiddle' border='0'></a> "; 684 else 685 echo "<a href='stats-global-client.php?expand=".$campaigns[$ckey]['clientid']."'><img src='images/".$phpAds_TextDirection."/triangle-l.gif' align='absmiddle' border='0'></a> "; 686 } 687 else 688 echo "<img src='images/spacer.gif' height='16' width='16' align='absmiddle'> "; 689 690 691 if ($campaigns[$ckey]['active'] == 't') 692 echo "<img src='images/icon-campaign.gif' align='absmiddle'> "; 693 else 694 echo "<img src='images/icon-campaign-d.gif' align='absmiddle'> "; 695 696 echo "<a href='stats-campaign-history.php?clientid=".$client['clientid']."&campaignid=".$campaigns[$ckey]['clientid']."'>".$campaigns[$ckey]['clientname']."</td>"; 697 echo "</td>"; 698 699 // ID 700 echo "<td height='25'>".$campaigns[$ckey]['clientid']."</td>"; 701 702 // Button 1 703 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($campaigns[$ckey]['views'])."</td>"; 704 705 // Button 2 706 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($campaigns[$ckey]['clicks'])."</td>"; 707 708 // Button 3 709 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_buildCTR($campaigns[$ckey]['views'], $campaigns[$ckey]['clicks'])." </td>"; 710 711 712 713 if ($campaigns[$ckey]['expand'] == '1' && isset($campaigns[$ckey]['banners'])) 714 { 715 $banners = $campaigns[$ckey]['banners']; 716 foreach (array_keys($banners) as $bkey) 717 { 718 $name = $strUntitled; 719 if (isset($banners[$bkey]['alt']) && $banners[$bkey]['alt'] != '') $name = $banners[$bkey]['alt']; 720 if (isset($banners[$bkey]['description']) && $banners[$bkey]['description'] != '') $name = $banners[$bkey]['description']; 721 722 $name = phpAds_breakString ($name, '30'); 723 724 // Divider 725 echo "<tr height='1'>"; 726 echo "<td ".($i%2==0?"bgcolor='#F6F6F6'":"")."><img src='images/spacer.gif' width='1' height='1'></td>"; 727 echo "<td colspan='4' bgcolor='#888888'><img src='images/break-l.gif' height='1' width='100%'></td>"; 728 echo "</tr>"; 729 730 // Icon & name 731 echo "<tr height='25' ".($i%2==0?"bgcolor='#F6F6F6'":"").">"; 732 echo "<td height='25'> "; 733 734 if ($banners[$bkey]['active'] == 't' && $campaigns[$ckey]['active'] == 't') 735 { 736 if ($banners[$bkey]['storagetype'] == 'html') 737 echo "<img src='images/icon-banner-html.gif' align='absmiddle'>"; 738 elseif ($banners[$bkey]['storagetype'] == 'txt') 739 echo "<img src='images/icon-banner-text.gif' align='absmiddle'>"; 740 elseif ($banners[$bkey]['storagetype'] == 'url') 741 echo "<img src='images/icon-banner-url.gif' align='absmiddle'>"; 742 else 743 echo "<img src='images/icon-banner-stored.gif' align='absmiddle'>"; 744 } 745 else 746 { 747 if ($banners[$bkey]['storagetype'] == 'html') 748 echo "<img src='images/icon-banner-html-d.gif' align='absmiddle'>"; 749 elseif ($banners[$bkey]['storagetype'] == 'txt') 750 echo "<img src='images/icon-banner-text-d.gif' align='absmiddle'>"; 751 elseif ($banners[$bkey]['storagetype'] == 'url') 752 echo "<img src='images/icon-banner-url-d.gif' align='absmiddle'>"; 753 else 754 echo "<img src='images/icon-banner-stored-d.gif' align='absmiddle'>"; 755 } 756 757 echo " <a href='stats-banner-history.php?clientid=".$client['clientid']."&campaignid=".$campaigns[$ckey]['clientid']."&bannerid=".$banners[$bkey]['bannerid']."'>".$name."</a></td>"; 758 759 // ID 760 echo "<td height='25'>".$banners[$bkey]['bannerid']."</td>"; 761 762 // Empty 763 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($banners[$bkey]['views'])."</td>"; 764 765 // Button 2 766 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($banners[$bkey]['clicks'])."</td>"; 767 768 // Button 1 769 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_buildCTR($banners[$bkey]['views'], $banners[$bkey]['clicks'])." </td>"; 770 } 771 } 772 } 773 } 774 775 if (isset ($client['banners']) && sizeof($client['banners']) > 0) 776 { 777 // Divider 778 echo "<tr height='1'><td colspan='1'></td><td colspan='3' bgcolor='#888888'><img src='images/break-l.gif' height='1' width='100%'></td></tr>"; 779 780 echo "<tr height='25' ".($i%2==0?"bgcolor='#F6F6F6'":"").">"; 781 echo "<td height='25'>$strBannersWithoutCampaign</td>"; 782 echo "<td height='25'> - </td>"; 783 echo "<td> </td>"; 784 echo "<td> </td>"; 785 echo "<td> </td>"; 786 echo "</tr>"; 787 } 788 789 echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>"; 790 $i++; 791 } 792 793 794 // Total 795 echo "<tr height='25' ".($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "")."><td height='25'> <b>".$strTotal."</b></td>"; 796 echo "<td height='25'> </td>"; 797 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($totalviews)."</td>"; 798 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($totalclicks)."</td>"; 799 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_buildCTR($totalviews, $totalclicks)." </td>"; 800 echo "</tr>"; 801 echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>"; 802 803 804 echo "<tr><td height='25' colspan='3' align='".$phpAds_TextAlignLeft."' nowrap>"; 805 806 if ($hideinactive == true) 807 { 808 echo " <img src='images/icon-activate.gif' align='absmiddle' border='0'>"; 809 echo " <a href='stats-global-client.php?hideinactive=0'>".$strShowAll."</a>"; 810 echo " | ".$clientshidden." ".$strInactiveAdvertisersHidden; 811 } 812 else 813 { 814 echo " <img src='images/icon-hideinactivate.gif' align='absmiddle' border='0'>"; 815 echo " <a href='stats-global-client.php?hideinactive=1'>".$strHideInactiveAdvertisers."</a>"; 816 } 817 818 echo "</td><td height='25' colspan='2' align='".$phpAds_TextAlignRight."' nowrap>"; 819 echo "<img src='images/triangle-d.gif' align='absmiddle' border='0'>"; 820 echo " <a href='stats-global-client.php?expand=all' accesskey='".$keyExpandAll."'>".$strExpandAll."</a>"; 821 echo " | "; 822 echo "<img src='images/".$phpAds_TextDirection."/triangle-l.gif' align='absmiddle' border='0'>"; 823 echo " <a href='stats-global-client.php?expand=none' accesskey='".$keyCollapseAll."'>".$strCollapseAll."</a> "; 824 echo "</td></tr>"; 825 826 827 /* 828 829 // Spacer 830 echo "<tr><td colspan='5' height='40'> </td></tr>"; 831 832 833 834 // Stats today 835 $adviews = (int)phpAds_totalViews("", "day"); 836 $adclicks = (int)phpAds_totalClicks("", "day"); 837 $ctr = phpAds_buildCTR($adviews, $adclicks); 838 echo "<tr><td height='25' colspan='2'> <b>".$strToday."</b></td>"; 839 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($adviews)."</td>"; 840 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($adclicks)."</td>"; 841 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".$ctr." </td></tr>"; 842 echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>"; 843 844 845 // Stats this week 846 $adviews = (int)phpAds_totalViews("", "week"); 847 $adclicks = (int)phpAds_totalClicks("", "week"); 848 $ctr = phpAds_buildCTR($adviews, $adclicks); 849 echo "<tr><td height='25' colspan='2'> ".$strLast7Days."</td>"; 850 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($adviews)."</td>"; 851 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($adclicks)."</td>"; 852 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".$ctr." </td></tr>"; 853 echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>"; 854 855 856 // Stats this month 857 $adviews = (int)phpAds_totalViews("", "month"); 858 $adclicks = (int)phpAds_totalClicks("", "month"); 859 $ctr = phpAds_buildCTR($adviews, $adclicks); 860 echo "<tr><td height='25' colspan='2'> ".$strThisMonth."</td>"; 861 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($adviews)."</td>"; 862 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($adclicks)."</td>"; 863 echo "<td height='25' align='".$phpAds_TextAlignRight."'>".$ctr." </td></tr>"; 864 echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>"; 865 866 */ 867 868 echo "</table>"; 869 echo "<br><br>"; 870 } 871 else 872 { 873 echo "<br><br><div class='errormessage'><img class='errormessage' src='images/info.gif' width='16' height='16' border='0' align='absmiddle'>"; 874 echo $strNoStats.'</div>'; 875 } 876 877 878 879 /*********************************************************/ 880 /* Store preferences */ 881 /*********************************************************/ 882 883 $Session['prefs']['stats-global-client.php']['hideinactive'] = $hideinactive; 884 $Session['prefs']['stats-global-client.php']['listorder'] = $listorder; 885 $Session['prefs']['stats-global-client.php']['orderdirection'] = $orderdirection; 886 $Session['prefs']['stats-global-client.php']['nodes'] = implode (",", $node_array); 887 888 $Session['prefs']['stats-global-client.php']['period'] = $period; 889 $Session['prefs']['stats-global-client.php']['period_range'] = $period_range; 890 891 phpAds_SessionDataStore(); 892 893 894 895 /*********************************************************/ 896 /* HTML framework */ 897 /*********************************************************/ 898 899 phpAds_PageFooter(); 900 901 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |