[ PHPXref.com ] [ Generated: Sun Jul 20 19:31:32 2008 ] [ phpAdsNew 2.0.8 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/admin/ -> stats-global-affiliates.php (source)

   1  <?php // $Revision: 2.0.2.8 $
   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  require  ("lib-size.inc.php");
  21  require  ("lib-zones.inc.php");
  22  
  23  
  24  // Register input variables
  25  phpAds_registerGlobal ('expand', 'collapse', 'listorder', 'orderdirection', 'period', 'period_range');
  26  
  27  
  28  // Security check
  29  phpAds_checkAccess(phpAds_Admin);
  30  
  31  
  32  // Set default values
  33  $tabindex = 1;
  34  
  35  
  36  
  37  /*********************************************************/
  38  /* HTML framework                                        */
  39  /*********************************************************/
  40  
  41  phpAds_PageHeader("2.4");
  42  phpAds_ShowSections(array("2.1", "2.4", "2.2", "2.5"));
  43  
  44  
  45  
  46  /*********************************************************/
  47  /* Get preferences                                       */
  48  /*********************************************************/
  49  
  50  if (!isset($listorder))
  51  {
  52      if (isset($Session['prefs']['stats-global-affiliates.php']['listorder']))
  53          $listorder = $Session['prefs']['stats-global-affiliates.php']['listorder'];
  54      else
  55          $listorder = '';
  56  }
  57  
  58  if (!isset($orderdirection))
  59  {
  60      if (isset($Session['prefs']['stats-global-affiliates.php']['orderdirection']))
  61          $orderdirection = $Session['prefs']['stats-global-affiliates.php']['orderdirection'];
  62      else
  63          $orderdirection = '';
  64  }
  65  
  66  if (isset($Session['prefs']['stats-global-affiliates.php']['nodes']))
  67      $node_array = explode (",", $Session['prefs']['stats-global-affiliates.php']['nodes']);
  68  else
  69      $node_array = array();
  70  
  71  
  72  if (!isset($period))
  73  {
  74      if (isset($Session['prefs']['stats-global-affiliates.php']['period']))
  75          $period = $Session['prefs']['stats-global-affiliates.php']['period'];
  76      else
  77          $period = '';
  78  }
  79  
  80  
  81  if (!isset($period_range))
  82  {
  83      if (isset($Session['prefs']['stats-global-affiliates.php']['period_range']))
  84          $period_range = $Session['prefs']['stats-global-affiliates.php']['period_range'];
  85      else
  86          $period_range = array (
  87              'start_day' => 0,
  88              'start_month' => 0,
  89              'start_year' => 0,
  90              'end_day' => 0,
  91              'end_month' => 0,
  92              'end_year' => 0
  93          );
  94  }
  95  
  96  
  97  
  98  /*********************************************************/
  99  /* Main code                                             */
 100  /*********************************************************/
 101  
 102  // Get affiliates and build the tree
 103  $res_affiliates = phpAds_dbQuery("
 104      SELECT 
 105          affiliateid, name
 106      FROM 
 107          ".$phpAds_config['tbl_affiliates']."
 108      ".phpAds_getAffiliateListOrder ($listorder, $orderdirection)."
 109      ") or phpAds_sqlDie();
 110  
 111  
 112  while ($row_affiliates = phpAds_dbFetchArray($res_affiliates))
 113  {
 114      $affiliates[$row_affiliates['affiliateid']] = $row_affiliates;
 115      $affiliates[$row_affiliates['affiliateid']]['expand'] = 0;
 116      $affiliates[$row_affiliates['affiliateid']]['count'] = 0;
 117  }
 118  
 119  // Get the zones for each affiliate
 120  $res_zones = phpAds_dbQuery("
 121      SELECT 
 122          zoneid, affiliateid, zonename, delivery
 123      FROM 
 124          ".$phpAds_config['tbl_zones']."
 125          ".phpAds_getZoneListOrder ($listorder, $orderdirection)."
 126      ") or phpAds_sqlDie();
 127  
 128  while ($row_zones = phpAds_dbFetchArray($res_zones))
 129  {
 130      if (isset($affiliates[$row_zones['affiliateid']]))
 131      {
 132          $zones[$row_zones['zoneid']] = $row_zones;
 133          $affiliates[$row_zones['affiliateid']]['count']++;
 134          
 135          $zones[$row_zones['zoneid']]['views'] = 0;
 136          $zones[$row_zones['zoneid']]['clicks'] = 0;
 137      }
 138      
 139      $zoneids[] = $row_zones['zoneid'];
 140  }
 141  
 142  
 143  
 144  
 145  
 146  // Check period range
 147  if ($period_range['start_month'] == 0 || $period_range['start_day'] == 0 || $period_range['start_year'] == 0)
 148  {
 149      $period_begin = 0;
 150      $period_range['start_day'] = $period_range['start_month'] = $period_range['start_year'] = 0;
 151  }
 152  else
 153      $period_begin = mktime(0, 0, 0, $period_range['start_month'], $period_range['start_day'], $period_range['start_year']);
 154  
 155  
 156  if ($period_range['end_month'] == 0 || $period_range['end_day'] == 0 || $period_range['end_year'] == 0)
 157  {
 158      $period_end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y'));
 159      $period_range['end_day'] = $period_range['end_month'] = $period_range['end_year'] = 0;
 160  }
 161  else
 162      $period_end = mktime(0, 0, 0, $period_range['end_month'], $period_range['end_day'], $period_range['end_year']);
 163  
 164  
 165  
 166  if (!$phpAds_config['compact_stats'])
 167  {
 168      switch ($period)
 169      {
 170          case 'r':    $limit                 = " AND t_stamp >= ".date('YmdHis', $period_begin)." AND t_stamp < ".date('YmdHis', $period_end);
 171                      break;
 172                  
 173          case 'y':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));    
 174                      $timestamp_end        = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
 175                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin)." AND t_stamp < ".date('YmdHis', $timestamp_end);
 176                      break;
 177                  
 178          case 't':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
 179                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin);
 180                      break;
 181                  
 182          case 'w':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d') - 6, date('Y'));
 183                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin);
 184                      break;
 185                  
 186          case 'm':    $timestamp_begin    = mktime(0, 0, 0, date('m'), 1, date('Y'));
 187                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin);
 188                      break;
 189                  
 190          case 'l':    $timestamp_begin    = mktime(0, 0, 0, date('m')-1, 1, date('Y'));
 191                      $timestamp_end        = mktime(0, 0, 0, date('m'), 1, date('Y'));
 192                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin)." AND t_stamp < ".date('YmdHis', $timestamp_end);
 193                      break;
 194                  
 195          case 'z':    $timestamp_begin    = mktime(0, 0, 0, 1, 1, date('Y'));
 196                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin);
 197                      break;
 198  
 199          case 'x':    $timestamp_begin    = mktime(0, 0, 0, 1, 1, date('Y')-1);
 200                      $timestamp_end        = mktime(0, 0, 0, 1, 1, date('Y'));
 201                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin)." AND t_stamp < ".date('YmdHis', $timestamp_end);
 202                      break;
 203  
 204          default:    $limit = '';
 205                      $period = '';
 206                      break;
 207      }
 208  }
 209  else
 210  {
 211      switch ($period)
 212      {
 213          case 'r':    $limit                 = " AND day >= ".date('Ymd', $period_begin)." AND day < ".date('Ymd', $period_end);
 214                      break;
 215                  
 216          case 'y':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
 217                      $timestamp_end        = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
 218                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin)." AND day < ".date('Ymd', $timestamp_end);
 219                      break;
 220                  
 221          case 't':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
 222                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin);
 223                      break;
 224                  
 225          case 'w':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d') - 6, date('Y'));
 226                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin);
 227                      break;
 228                  
 229          case 'm':    $timestamp_begin    = mktime(0, 0, 0, date('m'), 1, date('Y'));
 230                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin);
 231                      break;
 232                  
 233          case 'l':    $timestamp_begin    = mktime(0, 0, 0, date('m')-1, 1, date('Y'));
 234                      $timestamp_end        = mktime(0, 0, 0, date('m'), 1, date('Y'));
 235                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin)." AND day < ".date('Ymd', $timestamp_end);
 236                      break;
 237                  
 238          case 'z':    $timestamp_begin    = mktime(0, 0, 0, 1, 1, date('Y'));
 239                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin);
 240                      break;
 241  
 242          case 'x':    $timestamp_begin    = mktime(0, 0, 0, 1, 1, date('Y')-1);
 243                      $timestamp_end        = mktime(0, 0, 0, 1, 1, date('Y'));
 244                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin)." AND day < ".date('Ymd', $timestamp_end);
 245                      break;
 246  
 247          default:    $limit = '';
 248                      $period = '';
 249                      break;
 250      }
 251  }
 252  
 253  
 254  // Get the adviews/clicks for each banner
 255  if (count($zoneids))
 256  {
 257      if ($phpAds_config['compact_stats'])
 258      {
 259          $res_stats = phpAds_dbQuery("
 260              SELECT
 261                  zoneid,
 262                  sum(views) as views,
 263                  sum(clicks) as clicks
 264              FROM 
 265                  ".$phpAds_config['tbl_adstats']."
 266              WHERE
 267                  zoneid IN (".join(', ', $zoneids).")".$limit."
 268              GROUP BY
 269                  zoneid
 270              ") or phpAds_sqlDie();
 271          
 272          while ($row_stats = phpAds_dbFetchArray($res_stats))
 273          {
 274              $zones[$row_stats['zoneid']]['clicks'] = $row_stats['clicks'];
 275              $zones[$row_stats['zoneid']]['views'] = $row_stats['views'];
 276          }
 277      }
 278      else
 279      {
 280          $res_stats = phpAds_dbQuery("
 281              SELECT
 282                  zoneid,
 283                  count(*) as views
 284              FROM 
 285                  ".$phpAds_config['tbl_adviews']."
 286              WHERE
 287                  zoneid IN (".join(', ', $zoneids).")".$limit."
 288              GROUP BY
 289                  zoneid
 290              ") or phpAds_sqlDie();
 291          
 292          while ($row_stats = phpAds_dbFetchArray($res_stats))
 293          {
 294              $zones[$row_stats['zoneid']]['views'] = $row_stats['views'];
 295              $zones[$row_stats['zoneid']]['clicks'] = 0;
 296          }
 297          
 298          
 299          $res_stats = phpAds_dbQuery("
 300              SELECT
 301                  zoneid,
 302                  count(*) as clicks
 303              FROM 
 304                  ".$phpAds_config['tbl_adclicks']."
 305              WHERE
 306                  zoneid IN (".join(', ', $zoneids).")".$limit."
 307              GROUP BY
 308                  zoneid
 309              ") or phpAds_sqlDie();
 310          
 311          while ($row_stats = phpAds_dbFetchArray($res_stats))
 312          {
 313              $zones[$row_stats['zoneid']]['clicks'] = $row_stats['clicks'];
 314          }
 315      }
 316  }
 317  
 318  
 319  // Add ID found in expand to expanded nodes
 320  if (isset($expand) && $expand != '')
 321  {
 322      switch ($expand)
 323      {
 324          case 'all' :    $node_array   = array();
 325                          if (isset($affiliates)) foreach (array_keys($affiliates) as $key)    $node_array[] = $key;
 326                          break;
 327                          
 328          case 'none':    $node_array   = array();
 329                          break;
 330                          
 331          default:        $node_array[] = $expand;
 332                          break;
 333      }
 334  }
 335  
 336  $node_array_size = sizeof($node_array); 
 337  for ($i=0; $i < $node_array_size;$i++) 
 338  {
 339      if (isset($collapse) && $collapse == $node_array[$i])
 340          unset ($node_array[$i]);
 341      else
 342      {
 343          if (isset($affiliates[$node_array[$i]]))
 344              $affiliates[$node_array[$i]]['expand'] = 1;
 345      }
 346  }
 347  
 348  
 349  
 350  // Build Tree
 351  if (isset($zones) && is_array($zones) && count($zones) > 0)
 352  {
 353      // Add zone to affiliate
 354      foreach (array_keys($zones) as $zkey)
 355          $affiliates[$zones[$zkey]['affiliateid']]['zones'][$zkey] = $zones[$zkey];
 356      
 357      unset ($zones);
 358  }
 359  
 360  $totalviews = 0;
 361  $totalclicks = 0;
 362  
 363  if (isset($affiliates) && is_array($affiliates) && count($affiliates) > 0)
 364  {
 365      // Calculate statistics for affiliates
 366      foreach (array_keys($affiliates) as $key)
 367      {
 368          $affiliatesviews = 0;
 369          $affiliatesclicks = 0;
 370          
 371          if (isset($affiliates[$key]['zones']) && sizeof ($affiliates[$key]['zones']) > 0)
 372          {
 373              $zones = $affiliates[$key]['zones'];
 374              
 375              // Calculate statistics for zones
 376              foreach (array_keys($zones) as $zkey)
 377              {
 378                  $affiliatesviews += $zones[$zkey]['views'];
 379                  $affiliatesclicks += $zones[$zkey]['clicks'];
 380              }
 381          }
 382          
 383          $totalviews += $affiliatesviews;
 384          $totalclicks += $affiliatesclicks;
 385          
 386          $affiliates[$key]['clicks'] = $affiliatesclicks;
 387          $affiliates[$key]['views'] = $affiliatesviews;
 388      }
 389      
 390      unset ($zones);
 391  }
 392  
 393  
 394  
 395  echo "<form action='".$HTTP_SERVER_VARS['PHP_SELF']."'>";
 396  
 397  echo "<select name='period' onChange='this.form.submit();' accesskey='".$keyList."' tabindex='".($tabindex++)."'>";
 398      echo "<option value=''".($period == '' ? ' selected' : '').">".$strCollectedAll."</option>";
 399      echo "<option value='' disabled>-----------------------------------------</option>";
 400      echo "<option value='t'".($period == 't' ? ' selected' : '').">".$strCollectedToday."</option>";
 401      echo "<option value='y'".($period == 'y' ? ' selected' : '').">".$strCollectedYesterday."</option>";
 402      echo "<option value='w'".($period == 'w' ? ' selected' : '').">".$strCollected7Days."</option>";
 403      echo "<option value='m'".($period == 'm' ? ' selected' : '').">".$strCollectedMonth."</option>";
 404      echo "<option value='l'".($period == 'l' ? ' selected' : '').">".$strCollectedLastMonth."</option>";
 405      echo "<option value='z'".($period == 'z' ? ' selected' : '').">".$strCollectedYear."</option>";
 406      echo "<option value='x'".($period == 'x' ? ' selected' : '').">".$strCollectedLastYear."</option>";
 407      echo "<option value='' disabled>-----------------------------------------</option>";
 408      echo "<option value='r'".($period == 'r' ? ' selected' : '').">".$strCollectedRange."</option>";
 409  echo "</select>";
 410  
 411  
 412  if ($period == 'r')
 413  {
 414      phpAds_ShowBreak();
 415      echo $strFrom."&nbsp;&nbsp;";
 416      
 417      // Starting date
 418      echo "<select name='period_range[start_day]'>\n";
 419      echo "<option value='0'".($period_range['start_day'] == 0 ? ' selected' : '').">-</option>\n";
 420      for ($i=1;$i<=31;$i++)
 421          echo "<option value='$i'".($i == $period_range['start_day'] ? ' selected' : '').">$i</option>\n";
 422      echo "</select>&nbsp;\n";
 423      
 424      echo "<select name='period_range[start_month]'>\n";
 425      echo "<option value='0'".($period_range['start_month'] == 0 ? ' selected' : '').">-</option>\n";
 426      for ($i=1;$i<=12;$i++)
 427          echo "<option value='$i'".($i == $period_range['start_month'] ? ' selected' : '').">".$strMonth[$i-1]."</option>\n";
 428      echo "</select>&nbsp;\n";
 429      
 430      echo "<select name='period_range[start_year]'>\n";
 431      echo "<option value='0'".($period_range['start_year'] == 0 ? ' selected' : '').">-</option>\n";
 432      for ($i=date('Y')-4;$i<=date('Y');$i++)
 433          echo "<option value='$i'".($i == $period_range['start_year'] ? ' selected' : '').">$i</option>\n";
 434      echo "</select>\n";    
 435      
 436      // To
 437      echo "&nbsp;$strTo&nbsp;&nbsp;";
 438      
 439      // End date
 440      echo "<select name='period_range[end_day]'>\n";
 441      echo "<option value='0'".($period_range['end_day'] == 0 ? ' selected' : '').">-</option>\n";
 442      for ($i=1;$i<=31;$i++)
 443          echo "<option value='$i'".($i == $period_range['end_day'] ? ' selected' : '').">$i</option>\n";
 444      echo "</select>&nbsp;\n";
 445      
 446      echo "<select name='period_range[end_month]'>\n";
 447      echo "<option value='0'".($period_range['end_month'] == 0 ? ' selected' : '').">-</option>\n";
 448      for ($i=1;$i<=12;$i++)
 449          echo "<option value='$i'".($i == $period_range['end_month'] ? ' selected' : '').">".$strMonth[$i-1]."</option>\n";
 450      echo "</select>&nbsp;\n";
 451      
 452      echo "<select name='period_range[end_year]'>\n";
 453      echo "<option value='0'".($period_range['end_year'] == 0 ? ' selected' : '').">-</option>\n";
 454      for ($i=date('Y')-4;$i<=date('Y');$i++)
 455          echo "<option value='$i'".($i == $period_range['end_year'] ? ' selected' : '').">$i</option>\n";
 456      echo "</select>\n";    
 457      
 458      echo "&nbsp;";
 459      echo "<input type='image' src='images/".$phpAds_TextDirection."/go_blue.gif'>";
 460  }
 461  
 462  phpAds_ShowBreak();
 463  echo "</form>";
 464  
 465  
 466  
 467  if ($totalviews > 0 || $totalclicks > 0)
 468  {
 469      echo "<br><br>";
 470      echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";    
 471      
 472      echo "<tr height='25'>";
 473      echo '<td height="25"><b>&nbsp;&nbsp;<a href="stats-global-affiliates.php?listorder=name">'.$GLOBALS['strName'].'</a>';
 474      
 475      if (($listorder == "name") || ($listorder == ""))
 476      {
 477          if  (($orderdirection == "") || ($orderdirection == "down"))
 478          {
 479              echo ' <a href="stats-global-affiliates.php?orderdirection=up">';
 480              echo '<img src="images/caret-ds.gif" border="0" alt="" title="">';
 481          }
 482          else
 483          {
 484              echo ' <a href="stats-global-affiliates.php?orderdirection=down">';
 485              echo '<img src="images/caret-u.gif" border="0" alt="" title="">';
 486          }
 487          echo '</a>';
 488      }
 489      
 490      echo '</b></td>';
 491      echo '<td height="25"><b><a href="stats-global-affiliates.php?listorder=id">'.$GLOBALS['strID'].'</a>';
 492      
 493      if ($listorder == "id")
 494      {
 495          if  (($orderdirection == "") || ($orderdirection == "down"))
 496          {
 497              echo ' <a href="stats-global-affiliates.php?orderdirection=up">';
 498              echo '<img src="images/caret-ds.gif" border="0" alt="" title="">';
 499          }
 500          else
 501          {
 502              echo ' <a href="stats-global-affiliates.php?orderdirection=down">';
 503              echo '<img src="images/caret-u.gif" border="0" alt="" title="">';
 504          }
 505          echo '</a>';
 506      }
 507      
 508      echo '</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
 509      echo "<td height='25' align='".$phpAds_TextAlignRight."'><b>".$GLOBALS['strViews']."</b></td>";
 510      echo "<td height='25' align='".$phpAds_TextAlignRight."'><b>".$GLOBALS['strClicks']."</b></td>";
 511      echo "<td height='25' align='".$phpAds_TextAlignRight."'><b>".$GLOBALS['strCTRShort']."</b>&nbsp;&nbsp;</td>";
 512      echo "</tr>";
 513      
 514      echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 515      
 516      
 517      $i=0;
 518      foreach (array_keys($affiliates) as $key)
 519      {
 520          $affiliate = $affiliates[$key];
 521          
 522          echo "<tr height='25' ".($i%2==0?"bgcolor='#F6F6F6'":"").">";
 523          
 524          // Icon & name
 525          echo "<td height='25'>";
 526          if (isset($affiliate['zones']))
 527          {
 528              if ($affiliate['expand'] == '1')
 529                  echo "&nbsp;<a href='stats-global-affiliates.php?listorder=".$listorder."&orderdirection=".$orderdirection."&collapse=".$affiliate['affiliateid']."'><img src='images/triangle-d.gif' align='absmiddle' border='0'></a>&nbsp;";
 530              else
 531                  echo "&nbsp;<a href='stats-global-affiliates.php?listorder=".$listorder."&orderdirection=".$orderdirection."&expand=".$affiliate['affiliateid']."'><img src='images/".$phpAds_TextDirection."/triangle-l.gif' align='absmiddle' border='0'></a>&nbsp;";
 532          }
 533          else
 534              echo "&nbsp;<img src='images/spacer.gif' height='16' width='16'>&nbsp;";
 535              
 536          echo "<img src='images/icon-affiliate.gif' align='absmiddle'>&nbsp;";
 537          echo "<a href='stats-affiliate-history.php?affiliateid=".$affiliate['affiliateid']."'>".$affiliate['name']."</a>";
 538          echo "</td>";
 539          
 540          echo "<td height='25'>".$affiliate['affiliateid']."</td>";
 541          echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($affiliate['views'])."</td>";
 542          echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($affiliate['clicks'])."</td>";
 543          echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_buildCTR($affiliate['views'], $affiliate['clicks'])."&nbsp;&nbsp;</td>";
 544          echo "</tr>";
 545          
 546          
 547          
 548          if (isset($affiliate['zones']) && sizeof ($affiliate['zones']) > 0 && $affiliate['expand'] == '1')
 549          {
 550              $zones = $affiliate['zones'];
 551              
 552              foreach (array_keys($zones) as $zkey)
 553              {
 554                  // Divider
 555                  echo "<tr height='1'>";
 556                  echo "<td ".($i%2==0?"bgcolor='#F6F6F6'":"")."><img src='images/spacer.gif' width='1' height='1'></td>";
 557                  echo "<td colspan='5' bgcolor='#888888'><img src='images/break-l.gif' height='1' width='100%'></td>";
 558                  echo "</tr>";
 559                  
 560                  // Icon & name
 561                  echo "<tr height='25' ".($i%2==0?"bgcolor='#F6F6F6'":"")."><td height='25'>";
 562                  echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
 563                  echo "<img src='images/spacer.gif' height='16' width='16' align='absmiddle'>&nbsp;";
 564                  
 565                  if ($zones[$zkey]['delivery'] == phpAds_ZoneBanner)
 566                      echo "<img src='images/icon-zone.gif' align='absmiddle'>&nbsp;";
 567                  elseif ($zones[$zkey]['delivery'] == phpAds_ZoneInterstitial)
 568                      echo "<img src='images/icon-interstitial.gif' align='absmiddle'>&nbsp;";
 569                  elseif ($zones[$zkey]['delivery'] == phpAds_ZonePopup)
 570                      echo "<img src='images/icon-popup.gif' align='absmiddle'>&nbsp;";
 571                  elseif ($zones[$zkey]['delivery'] == phpAds_ZoneText)
 572                      echo "<img src='images/icon-textzone.gif' align='absmiddle'>&nbsp;";
 573                  
 574                  echo "<a href='stats-zone-history.php?affiliateid=".$affiliate['affiliateid']."&zoneid=".$zones[$zkey]['zoneid']."'>".$zones[$zkey]['zonename']."</td>";
 575                  echo "</td>";
 576                  
 577                  echo "<td height='25'>".$zones[$zkey]['zoneid']."</td>";
 578                  echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($zones[$zkey]['views'])."</td>";
 579                  echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($zones[$zkey]['clicks'])."</td>";
 580                  echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_buildCTR($zones[$zkey]['views'], $zones[$zkey]['clicks'])."&nbsp;&nbsp;</td>";
 581                  echo "</tr>";
 582              }
 583          }
 584          
 585          echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 586          $i++;
 587      }
 588      
 589      // Total
 590      echo "<tr height='25' ".($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "")."><td height='25'>&nbsp;&nbsp;<b>".$strTotal."</b></td>";
 591      echo "<td height='25'>&nbsp;</td>";
 592      echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($totalviews)."</td>";
 593      echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($totalclicks)."</td>";
 594      echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_buildCTR($totalviews, $totalclicks)."&nbsp;&nbsp;</td>";
 595      echo "</tr>";
 596      echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 597      
 598      echo "<tr><td height='25' colspan='5' align='".$phpAds_TextAlignRight."'>";
 599      echo "<img src='images/triangle-d.gif' align='absmiddle' border='0'>";
 600      echo "&nbsp;<a href='stats-global-affiliates.php?expand=all' accesskey='".$keyExpandAll."'>".$strExpandAll."</a>";
 601      echo "&nbsp;&nbsp;|&nbsp;&nbsp;";
 602      echo "<img src='images/".$phpAds_TextDirection."/triangle-l.gif' align='absmiddle' border='0'>";
 603      echo "&nbsp;<a href='stats-global-affiliates.php?expand=none' accesskey='".$keyCollapseAll."'>".$strCollapseAll."</a>";
 604      echo "</td></tr>";
 605      
 606      echo "</table>";
 607      echo "<br><br>";
 608  }
 609  else
 610  {
 611      echo "<br><div class='errormessage'><img class='errormessage' src='images/info.gif' width='16' height='16' border='0' align='absmiddle'>";
 612      echo $strNoStats.'</div>';
 613  }
 614  
 615  
 616  
 617  /*********************************************************/
 618  /* Store preferences                                     */
 619  /*********************************************************/
 620  
 621  $Session['prefs']['stats-global-affiliates.php']['listorder'] = $listorder;
 622  $Session['prefs']['stats-global-affiliates.php']['orderdirection'] = $orderdirection;
 623  $Session['prefs']['stats-global-affiliates.php']['nodes'] = implode (",", $node_array);
 624  
 625  $Session['prefs']['stats-global-affiliates.php']['period'] = $period;
 626  $Session['prefs']['stats-global-affiliates.php']['period_range'] = $period_range;
 627  
 628  phpAds_SessionDataStore();
 629  
 630  
 631  
 632  /*********************************************************/
 633  /* HTML framework                                        */
 634  /*********************************************************/
 635  
 636  phpAds_PageFooter();
 637  
 638  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]