[ 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-client-campaigns.php (source)

   1  <?php // $Revision: 2.0.2.12 $
   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+phpAds_Client);
  28  
  29  
  30  // Set default values
  31  $tabindex = 1;
  32  
  33  
  34  
  35  /*********************************************************/
  36  /* Client interface security                             */
  37  /*********************************************************/
  38  
  39  if (phpAds_isUser(phpAds_Client))
  40  {
  41      $clientid = phpAds_getUserID();
  42  }
  43  
  44  
  45  
  46  /*********************************************************/
  47  /* HTML framework                                        */
  48  /*********************************************************/
  49  
  50  if (phpAds_isUser(phpAds_Admin))
  51  {
  52      if (isset($Session['prefs']['stats-global-client.php']['listorder']))
  53          $navorder = $Session['prefs']['stats-global-client.php']['listorder'];
  54      else
  55          $navorder = '';
  56      
  57      if (isset($Session['prefs']['stats-global-client.php']['orderdirection']))
  58          $navdirection = $Session['prefs']['stats-global-client.php']['orderdirection'];
  59      else
  60          $navdirection = '';
  61      
  62      $res = phpAds_dbQuery("
  63          SELECT
  64              *
  65          FROM
  66              ".$phpAds_config['tbl_clients']."
  67          WHERE
  68              parent = 0
  69          ".phpAds_getListOrder ($navorder, $navdirection)."
  70      ") or phpAds_sqlDie();
  71      
  72      while ($row = phpAds_dbFetchArray($res))
  73      {
  74          phpAds_PageContext (
  75              phpAds_buildClientName ($row['clientid'], $row['clientname']),
  76              "stats-client-campaigns.php?clientid=".$row['clientid'],
  77              $clientid == $row['clientid']
  78          );
  79      }
  80      
  81      phpAds_PageShortcut($strClientProperties, 'client-edit.php?clientid='.$clientid, 'images/icon-client.gif');
  82      
  83      phpAds_PageHeader("2.1.2");
  84          echo "<img src='images/icon-client.gif' align='absmiddle'>&nbsp;<b>".phpAds_getClientName($clientid)."</b><br><br><br>";
  85          phpAds_ShowSections(array("2.1.1", "2.1.2"));
  86  }
  87  
  88  if (phpAds_isUser(phpAds_Client))
  89  {
  90      phpAds_PageHeader("1.2");
  91      
  92      if ($phpAds_config['client_welcome'])
  93      {
  94          echo "<br><br>";
  95          // Show welcome message
  96          if (!empty($phpAds_client_welcome_msg))
  97              echo $phpAds_client_welcome_msg;
  98          else
  99              include ('templates/welcome-advertiser.html');
 100          echo "<br><br>";
 101      }
 102      
 103      phpAds_ShowSections(array("1.1", "1.2"));
 104  }
 105  
 106  
 107  
 108  /*********************************************************/
 109  /* Get preferences                                       */
 110  /*********************************************************/
 111  
 112  if (!isset($hideinactive))
 113  {
 114      if (isset($Session['prefs']['stats-client-campaigns.php']['hideinactive']))
 115          $hideinactive = $Session['prefs']['stats-client-campaigns.php']['hideinactive'];
 116      else
 117          $hideinactive = ($phpAds_config['gui_hide_inactive'] == 't');
 118  }
 119  
 120  if (!isset($listorder))
 121  {
 122      if (isset($Session['prefs']['stats-client-campaigns.php']['listorder']))
 123          $listorder = $Session['prefs']['stats-client-campaigns.php']['listorder'];
 124      else
 125          $listorder = '';
 126  }
 127  
 128  if (!isset($orderdirection))
 129  {
 130      if (isset($Session['prefs']['stats-client-campaigns.php']['orderdirection']))
 131          $orderdirection = $Session['prefs']['stats-client-campaigns.php']['orderdirection'];
 132      else
 133          $orderdirection = '';
 134  }
 135  
 136  if (isset($Session['prefs']['stats-client-campaigns.php']['nodes']))
 137      $node_array = explode (",", $Session['prefs']['stats-client-campaigns.php']['nodes']);
 138  else
 139      $node_array = array();
 140  
 141  
 142  if (!isset($period))
 143  {
 144      if (isset($Session['prefs']['stats-client-campaigns.php']['period']))
 145          $period = $Session['prefs']['stats-client-campaigns.php']['period'];
 146      else
 147          $period = '';
 148  }
 149  
 150  
 151  if (!isset($period_range))
 152  {
 153      if (isset($Session['prefs']['stats-client-campaigns.php']['period_range']))
 154          $period_range = $Session['prefs']['stats-client-campaigns.php']['period_range'];
 155      else
 156          $period_range = array (
 157              'start_day' => 0,
 158              'start_month' => 0,
 159              'start_year' => 0,
 160              'end_day' => 0,
 161              'end_month' => 0,
 162              'end_year' => 0
 163          );
 164  }
 165  
 166  
 167  
 168  /*********************************************************/
 169  /* Main code                                             */
 170  /*********************************************************/
 171  
 172  $res_campaigns = phpAds_dbQuery("
 173      SELECT 
 174          *
 175      FROM 
 176          ".$phpAds_config['tbl_clients']."
 177      WHERE
 178          parent = ".$clientid."
 179      ".phpAds_getListOrder ($listorder, $orderdirection)."
 180  ") or phpAds_sqlDie();
 181  
 182  while ($row_campaigns = phpAds_dbFetchArray($res_campaigns))
 183  {
 184      $campaigns[$row_campaigns['clientid']] = $row_campaigns;
 185      $campaigns[$row_campaigns['clientid']]['expand'] = 0;
 186      $campaigns[$row_campaigns['clientid']]['count'] = 0;
 187  }
 188  
 189  
 190  // Get the banners for each campaign
 191  $res_banners = phpAds_dbQuery("
 192      SELECT 
 193          bannerid,
 194          clientid,
 195          alt,
 196          description,
 197          active,
 198          storagetype
 199      FROM 
 200          ".$phpAds_config['tbl_banners']."
 201          ".phpAds_getBannerListOrder ($listorder, $orderdirection)."
 202      ") or phpAds_sqlDie();
 203  
 204  while ($row_banners = phpAds_dbFetchArray($res_banners))
 205  {
 206      if (isset($campaigns[$row_banners['clientid']]))
 207      {
 208          $banners[$row_banners['bannerid']] = $row_banners;
 209          $banners[$row_banners['bannerid']]['clicks'] = 0;
 210          $banners[$row_banners['bannerid']]['views'] = 0;
 211          $campaigns[$row_banners['clientid']]['count']++;
 212          
 213          $bannerids[] = $row_banners['bannerid'];
 214      }
 215  }
 216  
 217  
 218  
 219  
 220  // Check period range
 221  if ($period_range['start_month'] == 0 || $period_range['start_day'] == 0 || $period_range['start_year'] == 0)
 222  {
 223      $period_begin = 0;
 224      $period_range['start_day'] = $period_range['start_month'] = $period_range['start_year'] = 0;
 225  }
 226  else
 227      $period_begin = mktime(0, 0, 0, $period_range['start_month'], $period_range['start_day'], $period_range['start_year']);
 228  
 229  
 230  if ($period_range['end_month'] == 0 || $period_range['end_day'] == 0 || $period_range['end_year'] == 0)
 231  {
 232      $period_end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y'));
 233      $period_range['end_day'] = $period_range['end_month'] = $period_range['end_year'] = 0;
 234  }
 235  else
 236      $period_end = mktime(0, 0, 0, $period_range['end_month'], $period_range['end_day'], $period_range['end_year']);
 237  
 238  
 239  
 240  if (!$phpAds_config['compact_stats'])
 241  {
 242      switch ($period)
 243      {
 244          case 'r':    $limit                 = " AND t_stamp >= ".date('YmdHis', $period_begin)." AND t_stamp < ".date('YmdHis', $period_end);
 245                      break;
 246                  
 247          case 'y':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));    
 248                      $timestamp_end        = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
 249                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin)." AND t_stamp < ".date('YmdHis', $timestamp_end);
 250                      break;
 251                  
 252          case 't':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
 253                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin);
 254                      break;
 255                  
 256          case 'w':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d') - 6, date('Y'));
 257                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin);
 258                      break;
 259                  
 260          case 'm':    $timestamp_begin    = mktime(0, 0, 0, date('m'), 1, date('Y'));
 261                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin);
 262                      break;
 263                  
 264          case 'l':    $timestamp_begin    = mktime(0, 0, 0, date('m')-1, 1, date('Y'));
 265                      $timestamp_end        = mktime(0, 0, 0, date('m'), 1, date('Y'));
 266                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin)." AND t_stamp < ".date('YmdHis', $timestamp_end);
 267                      break;
 268                  
 269          case 'z':    $timestamp_begin    = mktime(0, 0, 0, 1, 1, date('Y'));
 270                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin);
 271                      break;
 272  
 273          case 'x':    $timestamp_begin    = mktime(0, 0, 0, 1, 1, date('Y')-1);
 274                      $timestamp_end        = mktime(0, 0, 0, 1, 1, date('Y'));
 275                      $limit                 = " AND t_stamp >= ".date('YmdHis', $timestamp_begin)." AND t_stamp < ".date('YmdHis', $timestamp_end);
 276                      break;
 277  
 278          default:    $limit = '';
 279                      $period = '';
 280                      break;
 281      }
 282  }
 283  else
 284  {
 285      switch ($period)
 286      {
 287          case 'r':    $limit                 = " AND day >= ".date('Ymd', $period_begin)." AND day < ".date('Ymd', $period_end);
 288                      break;
 289                  
 290          case 'y':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'));
 291                      $timestamp_end        = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
 292                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin)." AND day < ".date('Ymd', $timestamp_end);
 293                      break;
 294                  
 295          case 't':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
 296                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin);
 297                      break;
 298                  
 299          case 'w':    $timestamp_begin    = mktime(0, 0, 0, date('m'), date('d') - 6, date('Y'));
 300                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin);
 301                      break;
 302                  
 303          case 'm':    $timestamp_begin    = mktime(0, 0, 0, date('m'), 1, date('Y'));
 304                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin);
 305                      break;
 306                  
 307          case 'l':    $timestamp_begin    = mktime(0, 0, 0, date('m')-1, 1, date('Y'));
 308                      $timestamp_end        = mktime(0, 0, 0, date('m'), 1, date('Y'));
 309                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin)." AND day < ".date('Ymd', $timestamp_end);
 310                      break;
 311                  
 312          case 'z':    $timestamp_begin    = mktime(0, 0, 0, 1, 1, date('Y'));
 313                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin);
 314                      break;
 315  
 316          case 'x':    $timestamp_begin    = mktime(0, 0, 0, 1, 1, date('Y')-1);
 317                      $timestamp_end        = mktime(0, 0, 0, 1, 1, date('Y'));
 318                      $limit                 = " AND day >= ".date('Ymd', $timestamp_begin)." AND day < ".date('Ymd', $timestamp_end);
 319                      break;
 320  
 321          default:    $limit = '';
 322                      $period = '';
 323                      break;
 324      }
 325  }
 326  
 327  
 328  
 329  // Get the adviews/clicks for each banner
 330  if (count($bannerids))
 331  {
 332      if ($phpAds_config['compact_stats'])
 333      {
 334              $res_stats = phpAds_dbQuery("
 335                  SELECT
 336                      bannerid,
 337                      sum(views) as views,
 338                      sum(clicks) as clicks
 339                  FROM 
 340                      ".$phpAds_config['tbl_adstats']."
 341                  WHERE
 342                      bannerid IN (".join(', ', $bannerids).")".$limit."
 343                  GROUP BY
 344                      bannerid
 345                  ") or phpAds_sqlDie();
 346              
 347              while ($row_stats = phpAds_dbFetchArray($res_stats))
 348              {
 349                  $banners[$row_stats['bannerid']]['clicks'] = $row_stats['clicks'];
 350                  $banners[$row_stats['bannerid']]['views'] = $row_stats['views'];
 351              }
 352      }
 353      else
 354      {
 355          $res_stats = phpAds_dbQuery("
 356              SELECT
 357                  bannerid,
 358                  count(*) as views
 359              FROM 
 360                  ".$phpAds_config['tbl_adviews']."
 361              WHERE
 362                  bannerid IN (".join(', ', $bannerids).")".$limit."
 363              GROUP BY
 364                  bannerid
 365              ") or phpAds_sqlDie();
 366          
 367          while ($row_stats = phpAds_dbFetchArray($res_stats))
 368          {
 369              $banners[$row_stats['bannerid']]['views'] = $row_stats['views'];
 370              $banners[$row_stats['bannerid']]['clicks'] = 0;
 371          }
 372  
 373  
 374          $res_stats = phpAds_dbQuery("
 375              SELECT
 376                  bannerid,
 377                  count(*) as clicks
 378              FROM 
 379                  ".$phpAds_config['tbl_adclicks']."
 380              WHERE
 381                  bannerid IN (".join(', ', $bannerids).")".$limit."
 382              GROUP BY
 383                  bannerid
 384              ") or phpAds_sqlDie();
 385          
 386          while ($row_stats = phpAds_dbFetchArray($res_stats))
 387          {
 388              $banners[$row_stats['bannerid']]['clicks'] = $row_stats['clicks'];
 389          }
 390      }
 391  }
 392  
 393  
 394  
 395  // Add ID found in expand to expanded nodes
 396  if (isset($expand) && $expand != '')
 397  {
 398      switch ($expand)
 399      {
 400          case 'all' :    $node_array   = array();
 401                          if (isset($campaigns)) while (list($key,) = each($campaigns)) $node_array[] = $key;
 402                          break;
 403                          
 404          case 'none':    $node_array   = array();
 405                          break;
 406                          
 407          default:        $node_array[] = $expand;
 408                          break;
 409      }
 410  }
 411  
 412  
 413  $node_array_size = sizeof($node_array);
 414  for ($i=0; $i < $node_array_size;$i++)
 415  {
 416      if (isset($collapse) && $collapse == $node_array[$i])
 417          unset ($node_array[$i]);
 418      else
 419      {
 420          if (isset($campaigns[$node_array[$i]]))
 421              $campaigns[$node_array[$i]]['expand'] = 1;
 422      }
 423  }
 424  
 425  
 426  
 427  // Build Tree
 428  $campaignshidden = 0;
 429  
 430  if (isset($banners) && is_array($banners) && count($banners) > 0)
 431  {
 432      // Add banner to campaigns
 433      reset ($banners);
 434      while (list ($bkey, $banner) = each ($banners))
 435          if ($hideinactive == false || $banner['active'] == 't')
 436              $campaigns[$banner['clientid']]['banners'][$bkey] = $banner;
 437      
 438      unset ($banners);
 439  }
 440  
 441  if (isset($campaigns) && is_array($campaigns) && count($campaigns) > 0)
 442  {
 443      reset ($campaigns);
 444      while (list ($key, $campaign) = each ($campaigns))
 445      {
 446          if (!isset($campaign['banners']))
 447              $campaign['banners'] = array();
 448          
 449          if ($hideinactive == true && ($campaign['active'] == 'f' || $campaign['active'] == 't' && 
 450              count($campaign['banners']) == 0 && count($campaign['banners']) < $campaign['count']))
 451          {
 452              $campaignshidden++;
 453              unset($campaigns[$key]);
 454          }
 455      }
 456  }
 457  
 458  
 459  $totalviews = 0;
 460  $totalclicks = 0;
 461  
 462  if (isset($campaigns) && is_array($campaigns) && sizeof ($campaigns) > 0)
 463  {
 464      // Calculate statistics for campaigns
 465      foreach (array_keys($campaigns) as $ckey)
 466      {
 467          $campaignviews = 0;
 468          $campaignclicks = 0;
 469          
 470          if (isset($campaigns[$ckey]['banners']) && sizeof ($campaigns[$ckey]['banners']) > 0)
 471          {
 472              $banners = $campaigns[$ckey]['banners'];
 473              foreach (array_keys($banners) as $bkey)
 474              {
 475                  $campaignviews += $banners[$bkey]['views'];
 476                  $campaignclicks += $banners[$bkey]['clicks'];
 477              }
 478          }
 479          
 480          $totalviews += $campaignviews;
 481          $totalclicks += $campaignclicks;
 482          
 483          $campaigns[$ckey]['views'] = $campaignviews;
 484          $campaigns[$ckey]['clicks'] = $campaignclicks;
 485      }
 486      
 487      unset ($banners);
 488  }
 489  
 490  
 491  echo "<form action='".$HTTP_SERVER_VARS['PHP_SELF']."'>";
 492  echo "<input type='hidden' name='clientid' value='".$clientid."'>";
 493  
 494  echo "<select name='period' onChange='this.form.submit();' accesskey='".$keyList."' tabindex='".($tabindex++)."'>";
 495      echo "<option value=''".($period == '' ? ' selected' : '').">".$strCollectedAll."</option>";
 496      echo "<option value='' disabled>-----------------------------------------</option>";
 497      echo "<option value='t'".($period == 't' ? ' selected' : '').">".$strCollectedToday."</option>";
 498      echo "<option value='y'".($period == 'y' ? ' selected' : '').">".$strCollectedYesterday."</option>";
 499      echo "<option value='w'".($period == 'w' ? ' selected' : '').">".$strCollected7Days."</option>";
 500      echo "<option value='m'".($period == 'm' ? ' selected' : '').">".$strCollectedMonth."</option>";
 501      echo "<option value='l'".($period == 'l' ? ' selected' : '').">".$strCollectedLastMonth."</option>";
 502      echo "<option value='z'".($period == 'z' ? ' selected' : '').">".$strCollectedYear."</option>";
 503      echo "<option value='x'".($period == 'x' ? ' selected' : '').">".$strCollectedLastYear."</option>";
 504      echo "<option value='' disabled>-----------------------------------------</option>";
 505      echo "<option value='r'".($period == 'r' ? ' selected' : '').">".$strCollectedRange."</option>";
 506  echo "</select>";
 507  
 508  
 509  if ($period == 'r')
 510  {
 511      phpAds_ShowBreak();
 512      echo $strFrom."&nbsp;&nbsp;";
 513      
 514      // Starting date
 515      echo "<select name='period_range[start_day]'>\n";
 516      echo "<option value='0'".($period_range['start_day'] == 0 ? ' selected' : '').">-</option>\n";
 517      for ($i=1;$i<=31;$i++)
 518          echo "<option value='$i'".($i == $period_range['start_day'] ? ' selected' : '').">$i</option>\n";
 519      echo "</select>&nbsp;\n";
 520      
 521      echo "<select name='period_range[start_month]'>\n";
 522      echo "<option value='0'".($period_range['start_month'] == 0 ? ' selected' : '').">-</option>\n";
 523      for ($i=1;$i<=12;$i++)
 524          echo "<option value='$i'".($i == $period_range['start_month'] ? ' selected' : '').">".$strMonth[$i-1]."</option>\n";
 525      echo "</select>&nbsp;\n";
 526      
 527      echo "<select name='period_range[start_year]'>\n";
 528      echo "<option value='0'".($period_range['start_year'] == 0 ? ' selected' : '').">-</option>\n";
 529      for ($i=date('Y')-4;$i<=date('Y');$i++)
 530          echo "<option value='$i'".($i == $period_range['start_year'] ? ' selected' : '').">$i</option>\n";
 531      echo "</select>\n";    
 532      
 533      // To
 534      echo "&nbsp;$strTo&nbsp;&nbsp;";
 535      
 536      // End date
 537      echo "<select name='period_range[end_day]'>\n";
 538      echo "<option value='0'".($period_range['end_day'] == 0 ? ' selected' : '').">-</option>\n";
 539      for ($i=1;$i<=31;$i++)
 540          echo "<option value='$i'".($i == $period_range['end_day'] ? ' selected' : '').">$i</option>\n";
 541      echo "</select>&nbsp;\n";
 542      
 543      echo "<select name='period_range[end_month]'>\n";
 544      echo "<option value='0'".($period_range['end_month'] == 0 ? ' selected' : '').">-</option>\n";
 545      for ($i=1;$i<=12;$i++)
 546          echo "<option value='$i'".($i == $period_range['end_month'] ? ' selected' : '').">".$strMonth[$i-1]."</option>\n";
 547      echo "</select>&nbsp;\n";
 548      
 549      echo "<select name='period_range[end_year]'>\n";
 550      echo "<option value='0'".($period_range['end_year'] == 0 ? ' selected' : '').">-</option>\n";
 551      for ($i=date('Y')-4;$i<=date('Y');$i++)
 552          echo "<option value='$i'".($i == $period_range['end_year'] ? ' selected' : '').">$i</option>\n";
 553      echo "</select>\n";    
 554      
 555      echo "&nbsp;";
 556      echo "<input type='image' src='images/".$phpAds_TextDirection."/go_blue.gif'>";
 557  }
 558  
 559  phpAds_ShowBreak();
 560  echo "</form>";
 561  
 562  
 563  
 564  
 565  
 566  if ($campaignshidden > 0 || $totalviews > 0 || $totalclicks > 0)
 567  {
 568      echo "<br><br>";
 569      echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";    
 570      
 571      echo "<tr height='25'>";
 572      echo '<td height="25" width="40%"><b>&nbsp;&nbsp;<a href="stats-client-campaigns.php?clientid='.$clientid.'&listorder=name">'.$GLOBALS['strName'].'</a>';
 573      if (($listorder == "name") || ($listorder == ""))
 574      {
 575          if  (($orderdirection == "") || ($orderdirection == "down"))
 576          {
 577              echo ' <a href="stats-client-campaigns.php?clientid='.$clientid.'&orderdirection=up">';
 578              echo '<img src="images/caret-ds.gif" border="0" alt="" title="">';
 579          }
 580          else
 581          {
 582              echo ' <a href="stats-client-campaigns.php?clientid='.$clientid.'&orderdirection=down">';
 583              echo '<img src="images/caret-u.gif" border="0" alt="" title="">';
 584          }
 585          echo '</a>';
 586      }
 587      echo '</b></td>';
 588      echo '<td height="25"><b><a href="stats-client-campaigns.php?clientid='.$clientid.'&listorder=id">'.$GLOBALS['strID'].'</a>';
 589      if ($listorder == "id")
 590      {
 591          if  (($orderdirection == "") || ($orderdirection == "down"))
 592          {
 593              echo ' <a href="stats-client-campaigns.php?clientid='.$clientid.'&orderdirection=up">';
 594              echo '<img src="images/caret-ds.gif" border="0" alt="" title="">';
 595          }
 596          else
 597          {
 598              echo ' <a href="stats-client-campaigns.php?clientid='.$clientid.'&orderdirection=down">';
 599              echo '<img src="images/caret-u.gif" border="0" alt="" title="">';
 600          }
 601          echo '</a>';
 602      }
 603      echo '</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
 604      echo "<td height='25' align='".$phpAds_TextAlignRight."'><b>".$GLOBALS['strViews']."</b></td>";
 605      echo "<td height='25' align='".$phpAds_TextAlignRight."'><b>".$GLOBALS['strClicks']."</b></td>";
 606      echo "<td height='25' align='".$phpAds_TextAlignRight."'><b>".$GLOBALS['strCTRShort']."</b>&nbsp;&nbsp;</td>";
 607      echo "</tr>";
 608      
 609      echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 610      
 611      $i=0;
 612      foreach (array_keys($campaigns) as $ckey)
 613      {
 614          // Icon & name
 615          echo "<tr height='25' ".($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "")."><td height='25'>";
 616          echo "&nbsp;";
 617          
 618          if (isset($campaigns[$ckey]['banners']))
 619          {
 620              if ($campaigns[$ckey]['expand'] == '1')
 621                  echo "<a href='stats-client-campaigns.php?clientid=".$clientid."&collapse=".$campaigns[$ckey]['clientid']."'><img src='images/triangle-d.gif' align='absmiddle' border='0'></a>&nbsp;";
 622              else
 623                  echo "<a href='stats-client-campaigns.php?clientid=".$clientid."&expand=".$campaigns[$ckey]['clientid']."'><img src='images/".$phpAds_TextDirection."/triangle-l.gif' align='absmiddle' border='0'></a>&nbsp;";
 624          }
 625          else
 626              echo "<img src='images/spacer.gif' height='16' width='16'>&nbsp;";
 627          
 628          
 629          if ($campaigns[$ckey]['active'] == 't')
 630              echo "<img src='images/icon-campaign.gif' align='absmiddle'>&nbsp;";
 631          else
 632              echo "<img src='images/icon-campaign-d.gif' align='absmiddle'>&nbsp;";
 633          
 634          echo "<a href='stats-campaign-history.php?clientid=".$clientid."&campaignid=".$campaigns[$ckey]['clientid']."'>".$campaigns[$ckey]['clientname']."</td>";
 635          echo "</td>";
 636          
 637          // ID
 638          echo "<td height='25'>".$campaigns[$ckey]['clientid']."</td>";
 639          
 640          // Button 1
 641          echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($campaigns[$ckey]['views'])."</td>";
 642          
 643          // Button 2
 644          echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($campaigns[$ckey]['clicks'])."</td>";
 645          
 646          // Button 3
 647          echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_buildCTR($campaigns[$ckey]['views'], $campaigns[$ckey]['clicks'])."&nbsp;&nbsp;</td>";
 648          
 649          
 650          
 651          if ($campaigns[$ckey]['expand'] == '1' && isset($campaigns[$ckey]['banners']))
 652          {
 653              $banners = $campaigns[$ckey]['banners'];
 654              foreach (array_keys($banners) as $bkey)
 655              {
 656                  $name = $strUntitled;
 657                  if (isset($banners[$bkey]['alt']) && $banners[$bkey]['alt'] != '') $name = $banners[$bkey]['alt'];
 658                  if (isset($banners[$bkey]['description']) && $banners[$bkey]['description'] != '') $name = $banners[$bkey]['description'];
 659                  
 660                  $name = phpAds_breakString ($name, '30');
 661                  
 662                  // Divider
 663                  echo "<tr height='1'>";
 664                  echo "<td ".($i%2==0?"bgcolor='#F6F6F6'":"")."><img src='images/spacer.gif' width='1' height='1'></td>";
 665                  echo "<td colspan='4' bgcolor='#888888'><img src='images/break-l.gif' height='1' width='100%'></td>";
 666                  echo "</tr>";
 667                  
 668                  // Icon & name
 669                  echo "<tr height='25' ".($i%2==0?"bgcolor='#F6F6F6'":"").">";
 670                  echo "<td height='25'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
 671                  
 672                  if ($banners[$bkey]['active'] == 't' && $campaigns[$ckey]['active'] == 't')
 673                  {
 674                      if ($banners[$bkey]['storagetype'] == 'html')
 675                          echo "<img src='images/icon-banner-html.gif' align='absmiddle'>";
 676                      elseif ($banners[$bkey]['storagetype'] == 'txt')
 677                          echo "<img src='images/icon-banner-text.gif' align='absmiddle'>";
 678                      elseif ($banners[$bkey]['storagetype'] == 'url')
 679                          echo "<img src='images/icon-banner-url.gif' align='absmiddle'>";
 680                      else
 681                          echo "<img src='images/icon-banner-stored.gif' align='absmiddle'>";
 682                  }
 683                  else
 684                  {
 685                      if ($banners[$bkey]['storagetype'] == 'html')
 686                          echo "<img src='images/icon-banner-html-d.gif' align='absmiddle'>";
 687                      elseif ($banners[$bkey]['storagetype'] == 'txt')
 688                          echo "<img src='images/icon-banner-text-d.gif' align='absmiddle'>";
 689                      elseif ($banners[$bkey]['storagetype'] == 'url')
 690                          echo "<img src='images/icon-banner-url-d.gif' align='absmiddle'>";
 691                      else
 692                          echo "<img src='images/icon-banner-stored-d.gif' align='absmiddle'>";
 693                  }
 694                  
 695                  echo "&nbsp;<a href='stats-banner-history.php?clientid=".$clientid."&campaignid=".$campaigns[$ckey]['clientid']."&bannerid=".$banners[$bkey]['bannerid']."'>".$name."</a></td>";
 696                  
 697                  // ID
 698                  echo "<td height='25'>".$banners[$bkey]['bannerid']."</td>";
 699                  
 700                  // Empty
 701                  echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($banners[$bkey]['views'])."</td>";
 702                  
 703                  // Button 2
 704                  echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($banners[$bkey]['clicks'])."</td>";
 705                  
 706                  // Button 1
 707                  echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_buildCTR($banners[$bkey]['views'], $banners[$bkey]['clicks'])."&nbsp;&nbsp;</td>";
 708              }
 709          }
 710          
 711          echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 712          $i++;
 713      }
 714      
 715      // Total
 716      echo "<tr height='25' ".($i % 2 == 0 ? "bgcolor='#F6F6F6'" : "")."><td height='25'>&nbsp;&nbsp;<b>".$strTotal."</b></td>";
 717      echo "<td height='25'>&nbsp;</td>";
 718      echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($totalviews)."</td>";
 719      echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_formatNumber($totalclicks)."</td>";
 720      echo "<td height='25' align='".$phpAds_TextAlignRight."'>".phpAds_buildCTR($totalviews, $totalclicks)."&nbsp;&nbsp;</td>";
 721      echo "</tr>";
 722      echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 723      
 724      echo "<tr height='25'><td colspan='2' height='25' align='".$phpAds_TextAlignLeft."' nowrap>";
 725      
 726      if ($hideinactive == true)
 727      {
 728          echo "&nbsp;&nbsp;<img src='images/icon-activate.gif' align='absmiddle' border='0'>";
 729          echo "&nbsp;<a href='stats-client-campaigns.php?clientid=".$clientid."&hideinactive=0'>".$strShowAll."</a>";
 730          echo "&nbsp;&nbsp;|&nbsp;&nbsp;".$campaignshidden." ".$strInactiveCampaignsHidden;
 731      }
 732      else
 733      {
 734          echo "&nbsp;&nbsp;<img src='images/icon-hideinactivate.gif' align='absmiddle' border='0'>";
 735          echo "&nbsp;<a href='stats-client-campaigns.php?clientid=".$clientid."&hideinactive=1'>".$strHideInactiveCampaigns."</a>";
 736      }
 737      
 738      echo "</td>";
 739      echo "<td colspan='3' height='25' align='".$phpAds_TextAlignRight."' nowrap>";
 740      echo "<img src='images/triangle-d.gif' align='absmiddle' border='0'>";
 741      echo "&nbsp;<a href='stats-client-campaigns.php?clientid=".$clientid."&expand=all' accesskey='".$keyExpandAll."'>".$strExpandAll."</a>";
 742      echo "&nbsp;&nbsp;|&nbsp;&nbsp;";
 743      echo "<img src='images/".$phpAds_TextDirection."/triangle-l.gif' align='absmiddle' border='0'>";
 744      echo "&nbsp;<a href='stats-client-campaigns.php?clientid=".$clientid."&expand=none' accesskey='".$keyCollapseAll."'>".$strCollapseAll."</a>&nbsp;&nbsp;";
 745      echo "</td>";
 746      echo "</tr>";
 747      
 748      
 749      echo "</table>";
 750      echo "<br><br><br><br>";
 751  }
 752  else
 753  {
 754      echo "<br><div class='errormessage'><img class='errormessage' src='images/info.gif' width='16' height='16' border='0' align='absmiddle'>";
 755      echo $strNoStats.'</div>';
 756  }
 757  
 758  
 759  
 760  /*********************************************************/
 761  /* Store preferences                                     */
 762  /*********************************************************/
 763  
 764  $Session['prefs']['stats-client-campaigns.php']['hideinactive'] = $hideinactive;
 765  $Session['prefs']['stats-client-campaigns.php']['listorder'] = $listorder;
 766  $Session['prefs']['stats-client-campaigns.php']['orderdirection'] = $orderdirection;
 767  $Session['prefs']['stats-client-campaigns.php']['nodes'] = implode (",", $node_array);
 768  
 769  $Session['prefs']['stats-client-campaigns.php']['period'] = $period;
 770  $Session['prefs']['stats-client-campaigns.php']['period_range'] = $period_range;
 771  
 772  phpAds_SessionDataStore();
 773  
 774  
 775  
 776  /*********************************************************/
 777  /* HTML framework                                        */
 778  /*********************************************************/
 779  
 780  phpAds_PageFooter();
 781  
 782  ?>


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