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

title

Body

[close]

/admin/ -> client-campaigns.php (source)

   1  <?php // $Revision: 2.2.2.9 $
   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');
  24  
  25  
  26  // Security check
  27  phpAds_checkAccess(phpAds_Admin);
  28  
  29  
  30  
  31  /*********************************************************/
  32  /* HTML framework                                        */
  33  /*********************************************************/
  34  
  35  if (isset($Session['prefs']['client-index.php']['listorder']))
  36      $navorder = $Session['prefs']['client-index.php']['listorder'];
  37  else
  38      $navorder = '';
  39  
  40  if (isset($Session['prefs']['client-index.php']['orderdirection']))
  41      $navdirection = $Session['prefs']['client-index.php']['orderdirection'];
  42  else
  43      $navdirection = '';
  44  
  45  
  46  // Get other clients
  47  $res = phpAds_dbQuery("
  48      SELECT
  49          *
  50      FROM
  51          ".$phpAds_config['tbl_clients']."
  52      WHERE
  53          parent = 0
  54      ".phpAds_getListOrder ($navorder, $navdirection)."
  55  ") or phpAds_sqlDie();
  56  
  57  while ($row = phpAds_dbFetchArray($res))
  58  {
  59      phpAds_PageContext (
  60          phpAds_buildClientName ($row['clientid'], $row['clientname']),
  61          "client-campaigns.php?clientid=".$row['clientid'],
  62          $clientid == $row['clientid']
  63      );
  64  }
  65  
  66  phpAds_PageShortcut($strClientHistory, 'stats-client-history.php?clientid='.$clientid, 'images/icon-statistics.gif');
  67  
  68  phpAds_PageHeader("4.1.3");
  69      echo "<img src='images/icon-client.gif' align='absmiddle'>&nbsp;<b>".phpAds_getClientName($clientid)."</b><br><br><br>";
  70      phpAds_ShowSections(array("4.1.2", "4.1.3"));
  71  
  72  
  73  
  74  /*********************************************************/
  75  /* Get preferences                                       */
  76  /*********************************************************/
  77  
  78  if (!isset($hideinactive))
  79  {
  80      if (isset($Session['prefs']['client-campaigns.php'][$clientid]['hideinactive']))
  81          $hideinactive = $Session['prefs']['client-campaigns.php'][$clientid]['hideinactive'];
  82      else
  83          $hideinactive = ($phpAds_config['gui_hide_inactive'] == 't');
  84  }
  85  
  86  if (!isset($listorder))
  87  {
  88      if (isset($Session['prefs']['client-campaigns.php'][$clientid]['listorder']))
  89          $listorder = $Session['prefs']['client-campaigns.php'][$clientid]['listorder'];
  90      else
  91          $listorder = '';
  92  }
  93  
  94  if (!isset($orderdirection))
  95  {
  96      if (isset($Session['prefs']['client-campaigns.php'][$clientid]['orderdirection']))
  97          $orderdirection = $Session['prefs']['client-campaigns.php'][$clientid]['orderdirection'];
  98      else
  99          $orderdirection = '';
 100  }
 101  
 102  if (isset($Session['prefs']['client-campaigns.php'][$clientid]['nodes']))
 103      $node_array = explode (",", $Session['prefs']['client-campaigns.php'][$clientid]['nodes']);
 104  else
 105      $node_array = array();
 106  
 107  
 108  
 109  /*********************************************************/
 110  /* Main code                                             */
 111  /*********************************************************/
 112  
 113  // Get clients & campaign and build the tree
 114  $res_clients = phpAds_dbQuery("
 115      SELECT 
 116          *,
 117          DATE_FORMAT(expire, '$date_format') AS expire_f,
 118          DATE_FORMAT(activate, '$date_format') AS activate_f
 119      FROM 
 120          ".$phpAds_config['tbl_clients']."
 121      WHERE
 122          parent = ".$clientid."
 123      ".phpAds_getListOrder ($listorder, $orderdirection)."
 124  ") or phpAds_sqlDie();
 125  
 126  
 127  while ($row_clients = phpAds_dbFetchArray($res_clients))
 128  {
 129      $campaigns[$row_clients['clientid']] = $row_clients;
 130      $campaigns[$row_clients['clientid']]['expand'] = 0;
 131      $campaigns[$row_clients['clientid']]['count'] = 0;
 132  }
 133  
 134  
 135  // Get the banners for each campaign
 136  $res_banners = phpAds_dbQuery("
 137      SELECT 
 138          bannerid,
 139          clientid,
 140          alt,
 141          description,
 142          active,
 143          storagetype
 144      FROM 
 145          ".$phpAds_config['tbl_banners']."
 146          ".phpAds_getBannerListOrder ($listorder, $orderdirection)."
 147      ") or phpAds_sqlDie();
 148  
 149  while ($row_banners = phpAds_dbFetchArray($res_banners))
 150  {
 151      if (isset($campaigns[$row_banners['clientid']]))
 152      {
 153          $banners[$row_banners['bannerid']] = $row_banners;
 154          $campaigns[$row_banners['clientid']]['count']++;
 155      }
 156  }
 157  
 158  
 159  
 160  // Add ID found in expand to expanded nodes
 161  if (isset($expand) && $expand != '')
 162  {
 163      switch ($expand)
 164      {
 165          case 'all' :    $node_array   = array();
 166                          if (isset($campaigns)) while (list($key,) = each($campaigns)) $node_array[] = $key;
 167                          break;
 168                          
 169          case 'none':    $node_array   = array();
 170                          break;
 171                          
 172          default:        $node_array[] = $expand;
 173                          break;
 174      }
 175  }
 176  
 177  
 178  $node_array_size = sizeof($node_array);
 179  for ($i=0; $i < $node_array_size;$i++)
 180  {
 181      if (isset($collapse) && $collapse == $node_array[$i])
 182          unset ($node_array[$i]);
 183      else
 184      {
 185          if (isset($campaigns[$node_array[$i]]))
 186              $campaigns[$node_array[$i]]['expand'] = 1;
 187      }
 188  }
 189  
 190  
 191  // Build Tree
 192  $campaignshidden = 0;
 193  
 194  if (isset($banners) && is_array($banners) && count($banners) > 0)
 195  {
 196      // Add banner to campaigns
 197      reset ($banners);
 198      while (list ($bkey, $banner) = each ($banners))
 199          if ($hideinactive == false || $banner['active'] == 't')
 200              $campaigns[$banner['clientid']]['banners'][$bkey] = $banner;
 201      
 202      unset ($banners);
 203  }
 204  
 205  if (isset($campaigns) && is_array($campaigns) && count($campaigns) > 0)
 206  {
 207      reset ($campaigns);
 208      while (list ($key, $campaign) = each ($campaigns))
 209      {
 210          if (!isset($campaign['banners']))
 211              $campaign['banners'] = array();
 212          
 213          if ($hideinactive == true && ($campaign['active'] == 'f' || $campaign['active'] == 't' && 
 214              count($campaign['banners']) == 0 && count($campaign['banners']) < $campaign['count']))
 215          {
 216              $campaignshidden++;
 217              unset($campaigns[$key]);
 218          }
 219      }
 220  }
 221  
 222  
 223  echo "<img src='images/icon-campaign-new.gif' border='0' align='absmiddle'>&nbsp;";
 224  echo "<a href='campaign-edit.php?clientid=".$clientid."' accesskey='".$keyAddNew."'>".$strAddCampaign_Key."</a>&nbsp;&nbsp;";
 225  phpAds_ShowBreak();
 226  
 227  
 228  
 229  echo "<br><br>";
 230  echo "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";    
 231  
 232  echo "<tr height='25'>";
 233  echo "<td height='25' width='40%'><b>&nbsp;&nbsp;<a href='client-campaigns.php?clientid=".$clientid."&listorder=name'>".$GLOBALS['strName']."</a>";
 234  
 235  if (($listorder == "name") || ($listorder == ""))
 236  {
 237      if  (($orderdirection == "") || ($orderdirection == "down"))
 238      {
 239          echo ' <a href="client-campaigns.php?clientid='.$clientid.'&orderdirection=up">';
 240          echo '<img src="images/caret-ds.gif" border="0" alt="" title="">';
 241      }
 242      else
 243      {
 244          echo ' <a href="client-campaigns.php?clientid='.$clientid.'&orderdirection=down">';
 245          echo '<img src="images/caret-u.gif" border="0" alt="" title="">';
 246      }
 247      echo '</a>';
 248  }
 249  
 250  echo '</b></td>';
 251  echo '<td height="25"><b><a href="client-campaigns.php?clientid='.$clientid.'&listorder=id">'.$GLOBALS['strID'].'</a>';
 252  
 253  if ($listorder == "id")
 254  {
 255      if  (($orderdirection == "") || ($orderdirection == "down"))
 256      {
 257          echo ' <a href="client-campaigns.php?clientid='.$clientid.'&orderdirection=up">';
 258          echo '<img src="images/caret-ds.gif" border="0" alt="" title="">';
 259      }
 260      else
 261      {
 262          echo ' <a href="client-campaigns.php?clientid='.$clientid.'&orderdirection=down">';
 263          echo '<img src="images/caret-u.gif" border="0" alt="" title="">';
 264      }
 265      echo '</a>';
 266  }
 267  
 268  echo '</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>';
 269  echo "<td height='25'>&nbsp;</td>";
 270  echo "<td height='25'>&nbsp;</td>";
 271  echo "<td height='25'>&nbsp;</td>";
 272  echo "</tr>";
 273  
 274  echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 275  
 276  
 277  if (!isset($campaigns) || !is_array($campaigns) || count($campaigns) == 0)
 278  {
 279      echo "<tr height='25' bgcolor='#F6F6F6'><td height='25' colspan='5'>";
 280      echo "&nbsp;&nbsp;".$strNoCampaigns;
 281      echo "</td></tr>";
 282      
 283      echo "<td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td>";
 284  }
 285  else
 286  {
 287      $i=0;
 288      
 289      
 290      foreach (array_keys($campaigns) as $ckey)
 291      {
 292          // Icon & name
 293          echo "<tr height='25' ".($i%2==0?"bgcolor='#F6F6F6'":"")."><td height='25'>";
 294          echo "&nbsp;";
 295          
 296          if (isset($campaigns[$ckey]['banners']))
 297          {
 298              if ($campaigns[$ckey]['expand'] == '1')
 299                  echo "<a href='client-campaigns.php?clientid=".$clientid."&collapse=".$campaigns[$ckey]['clientid']."'><img src='images/triangle-d.gif' align='absmiddle' border='0'></a>&nbsp;";
 300              else
 301                  echo "<a href='client-campaigns.php?clientid=".$clientid."&expand=".$campaigns[$ckey]['clientid']."'><img src='images/".$phpAds_TextDirection."/triangle-l.gif' align='absmiddle' border='0'></a>&nbsp;";
 302          }
 303          else
 304              echo "<img src='images/spacer.gif' height='16' width='16' align='absmiddle'>&nbsp;";
 305          
 306          
 307          if ($campaigns[$ckey]['active'] == 't')
 308              echo "<img src='images/icon-campaign.gif' align='absmiddle'>&nbsp;";
 309          else
 310              echo "<img src='images/icon-campaign-d.gif' align='absmiddle'>&nbsp;";
 311          
 312          echo "<a href='campaign-edit.php?clientid=".$clientid."&campaignid=".$campaigns[$ckey]['clientid']."'>".$campaigns[$ckey]['clientname']."</td>";
 313          echo "</td>";
 314          
 315          // ID
 316          echo "<td height='25'>".$campaigns[$ckey]['clientid']."</td>";
 317          
 318          // Button 1
 319          echo "<td height='25' align='".$phpAds_TextAlignRight."'>";
 320          if ($campaigns[$ckey]['expand'] == '1' || !isset($campaigns[$ckey]['banners']))
 321              echo "<a href='banner-edit.php?clientid=".$clientid."&campaignid=".$campaigns[$ckey]['clientid']."'><img src='images/icon-banner-new.gif' border='0' align='absmiddle' alt='$strCreate'>&nbsp;$strCreate</a>&nbsp;&nbsp;&nbsp;&nbsp;";
 322          else
 323              echo "&nbsp;";
 324          echo "</td>";
 325          
 326          // Button 2
 327          echo "<td height='25' align='".$phpAds_TextAlignRight."'>";
 328          echo "<a href='campaign-banners.php?clientid=".$clientid."&campaignid=".$campaigns[$ckey]['clientid']."'><img src='images/icon-overview.gif' border='0' align='absmiddle' alt='$strOverview'>&nbsp;$strOverview</a>&nbsp;&nbsp;&nbsp;&nbsp;";
 329          echo "</td>";
 330          
 331          // Button 3
 332          echo "<td height='25' align='".$phpAds_TextAlignRight."'>";
 333          echo "<a href='campaign-delete.php?clientid=".$clientid."&campaignid=".$campaigns[$ckey]['clientid']."&returnurl=client-campaigns.php'".phpAds_DelConfirm($strConfirmDeleteCampaign)."><img src='images/icon-recycle.gif' border='0' align='absmiddle' alt='$strDelete'>&nbsp;$strDelete</a>&nbsp;&nbsp;&nbsp;&nbsp;";
 334          echo "</td></tr>";
 335          
 336          if ($campaigns[$ckey]['expand'] == '1' && isset($campaigns[$ckey]['banners']))
 337          {
 338              $banners = $campaigns[$ckey]['banners'];
 339              foreach (array_keys($banners) as $bkey)
 340              {
 341                  $name = $strUntitled;
 342                  if (isset($banners[$bkey]['alt']) && $banners[$bkey]['alt'] != '') $name = $banners[$bkey]['alt'];
 343                  if (isset($banners[$bkey]['description']) && $banners[$bkey]['description'] != '') $name = $banners[$bkey]['description'];
 344                  
 345                  $name = phpAds_breakString ($name, '30');
 346                  
 347                  // Divider
 348                  echo "<tr height='1'>";
 349                  echo "<td ".($i%2==0?"bgcolor='#F6F6F6'":"")."><img src='images/spacer.gif' width='1' height='1'></td>";
 350                  echo "<td colspan='4' bgcolor='#888888'><img src='images/break-l.gif' height='1' width='100%'></td>";
 351                  echo "</tr>";
 352                  
 353                  // Icon & name
 354                  echo "<tr height='25' ".($i%2==0?"bgcolor='#F6F6F6'":"").">";
 355                  echo "<td height='25'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
 356                  
 357                  if ($banners[$bkey]['active'] == 't' && $campaigns[$ckey]['active'] == 't')
 358                  {
 359                      if ($banners[$bkey]['storagetype'] == 'html')
 360                          echo "<img src='images/icon-banner-html.gif' align='absmiddle'>";
 361                      elseif ($banners[$bkey]['storagetype'] == 'txt')
 362                          echo "<img src='images/icon-banner-text.gif' align='absmiddle'>";
 363                      elseif ($banners[$bkey]['storagetype'] == 'url')
 364                          echo "<img src='images/icon-banner-url.gif' align='absmiddle'>";
 365                      else
 366                          echo "<img src='images/icon-banner-stored.gif' align='absmiddle'>";
 367                  }
 368                  else
 369                  {
 370                      if ($banners[$bkey]['storagetype'] == 'html')
 371                          echo "<img src='images/icon-banner-html-d.gif' align='absmiddle'>";
 372                      elseif ($banners[$bkey]['storagetype'] == 'txt')
 373                          echo "<img src='images/icon-banner-text-d.gif' align='absmiddle'>";
 374                      elseif ($banners[$bkey]['storagetype'] == 'url')
 375                          echo "<img src='images/icon-banner-url-d.gif' align='absmiddle'>";
 376                      else
 377                          echo "<img src='images/icon-banner-stored-d.gif' align='absmiddle'>";
 378                  }
 379                  
 380                  echo "&nbsp;<a href='banner-edit.php?clientid=".$clientid."&campaignid=".$campaigns[$ckey]['clientid']."&bannerid=".$banners[$bkey]['bannerid']."'>".$name."</a></td>";
 381                  
 382                  // ID
 383                  echo "<td height='25'>".$banners[$bkey]['bannerid']."</td>";
 384                  
 385                  // Empty
 386                  echo "<td>&nbsp;</td>";
 387                  
 388                  // Button 2
 389                  echo "<td height='25' align='".$phpAds_TextAlignRight."'>";
 390                  echo "<a href='banner-acl.php?clientid=".$clientid."&campaignid=".$campaigns[$ckey]['clientid']."&bannerid=".$banners[$bkey]['bannerid']."'><img src='images/icon-acl.gif' border='0' align='absmiddle' alt='$strACL'>&nbsp;$strACL</a>&nbsp;&nbsp;&nbsp;&nbsp;";
 391                  echo "</td>";
 392                  
 393                  // Button 3
 394                  echo "<td height='25' align='".$phpAds_TextAlignRight."'>";
 395                  echo "<a href='banner-delete.php?clientid=".$clientid."&campaignid=".$campaigns[$ckey]['clientid']."&bannerid=".$banners[$bkey]['bannerid']."&returnurl=client-campaigns.php'".phpAds_DelConfirm($strConfirmDeleteBanner)."><img src='images/icon-recycle.gif' border='0' align='absmiddle' alt='$strDelete'>&nbsp;$strDelete</a>&nbsp;&nbsp;&nbsp;&nbsp;";
 396                  echo "</td></tr>";
 397              }
 398          }
 399          
 400          if ($phpAds_config['gui_show_campaign_info'])
 401          {
 402              echo "<tr height='1'>";
 403              echo "<td ".($i%2==0?"bgcolor='#F6F6F6'":"")."><img src='images/spacer.gif' width='1' height='1'></td>";
 404              echo "<td colspan='4' bgcolor='#888888'><img src='images/break-l.gif' height='1' width='100%'></td>";
 405              echo "</tr>";
 406              
 407              echo "<tr ".($i%2==0?"bgcolor='#F6F6F6'":"")."><td colspan='1'>&nbsp;</td><td colspan='4'>";
 408              echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>";
 409              
 410              echo "<tr height='25'><td width='50%'>".$strViewsPurchased.": ".($campaigns[$ckey]['views'] >= 0 ? $campaigns[$ckey]['views'] : $strUnlimited)."</td>";
 411              echo "<td width='50%'>".$strClicksPurchased.": ".($campaigns[$ckey]['clicks'] >= 0 ? $campaigns[$ckey]['clicks'] : $strUnlimited)."</td></tr>";
 412              
 413              echo "<tr height='15'><td width='50%'>".$strActivationDate.": ".($campaigns[$ckey]['activate'] != '0000-00-00' ? $campaigns[$ckey]['activate_f'] : '-')."</td>";
 414              echo "<td width='50%'>".$strExpirationDate.": ".($campaigns[$ckey]['expire'] != '0000-00-00' ? $campaigns[$ckey]['expire_f'] : '-')."</td></tr>";
 415              
 416              echo "<tr height='25'><td width='50%'>".$strPriority.": ".($campaigns[$ckey]['target'] > 0 ? $strHigh : $strLow)."</td>";
 417              
 418              if ($campaigns[$ckey]['target'] > 0)
 419                  echo "<td width='50%'>".$strCampaignTarget.": ".$campaigns[$ckey]['target']."</td></tr>";
 420              else
 421                  echo "<td width='50%'>".$strWeight.": ".$campaigns[$ckey]['weight']."</td></tr>";
 422              
 423              echo "</table><br></td></tr>";
 424          }
 425          
 426          echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break.gif' height='1' width='100%'></td></tr>";
 427          $i++;
 428      }
 429  }
 430  
 431  echo "<tr height='25'><td colspan='2' height='25' nowrap>";
 432  
 433  if ($hideinactive == true)
 434  {
 435      echo "&nbsp;&nbsp;<img src='images/icon-activate.gif' align='absmiddle' border='0'>";
 436      echo "&nbsp;<a href='client-campaigns.php?clientid=".$clientid."&hideinactive=0'>".$strShowAll."</a>";
 437      echo "&nbsp;&nbsp;|&nbsp;&nbsp;".$campaignshidden." ".$strInactiveCampaignsHidden;
 438  }
 439  else
 440  {
 441      echo "&nbsp;&nbsp;<img src='images/icon-hideinactivate.gif' align='absmiddle' border='0'>";
 442      echo "&nbsp;<a href='client-campaigns.php?clientid=".$clientid."&hideinactive=1'>".$strHideInactiveCampaigns."</a>";
 443  }
 444  
 445  echo "</td>";
 446  echo "<td colspan='3' height='25' align='".$phpAds_TextAlignRight."' nowrap>";
 447  echo "<img src='images/triangle-d.gif' align='absmiddle' border='0'>";
 448  echo "&nbsp;<a href='client-campaigns.php?clientid=".$clientid."&expand=all' accesskey='".$keyExpandAll."'>".$strExpandAll."</a>";
 449  echo "&nbsp;&nbsp;|&nbsp;&nbsp;";
 450  echo "<img src='images/".$phpAds_TextDirection."/triangle-l.gif' align='absmiddle' border='0'>";
 451  echo "&nbsp;<a href='client-campaigns.php?clientid=".$clientid."&expand=none' accesskey='".$keyCollapseAll."'>".$strCollapseAll."</a>&nbsp;&nbsp;";
 452  echo "</td>";
 453  echo "</tr>";
 454  
 455  if (isset($campaigns) && count($campaigns))
 456  {
 457      echo "<tr height='1'><td colspan='5' bgcolor='#888888'><img src='images/break-el.gif' height='1' width='100%'></td></tr>";
 458      echo "<tr height='25'>";
 459      echo "<td colspan='5' height='25' align='".$phpAds_TextAlignRight."'>";
 460      echo "<img src='images/icon-recycle.gif' border='0' align='absmiddle'>&nbsp;<a href='campaign-delete.php?clientid=".$clientid."&returnurl=client-campaigns.php'".phpAds_DelConfirm($strConfirmDeleteAllCampaigns).">$strDeleteAllCampaigns</a>&nbsp;&nbsp;";
 461      echo "</td>";
 462      echo "</tr>";
 463  }
 464  
 465  echo "</table>";
 466  echo "<br><br>";
 467  
 468  
 469  
 470  /*********************************************************/
 471  /* Store preferences                                     */
 472  /*********************************************************/
 473  
 474  $Session['prefs']['client-campaigns.php'][$clientid]['hideinactive'] = $hideinactive;
 475  $Session['prefs']['client-campaigns.php'][$clientid]['listorder'] = $listorder;
 476  $Session['prefs']['client-campaigns.php'][$clientid]['orderdirection'] = $orderdirection;
 477  $Session['prefs']['client-campaigns.php'][$clientid]['nodes'] = implode (",", $node_array);
 478  
 479  phpAds_SessionDataStore();
 480  
 481  
 482  
 483  /*********************************************************/
 484  /* HTML framework                                        */
 485  /*********************************************************/
 486  
 487  phpAds_PageFooter();
 488  
 489  ?>


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