[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_module/mod_ads/inc/ -> listing.campaign.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // ----------------------------------------------------------------
  24  // obligate check for phpwcms constants
  25  if (!defined('PHPWCMS_ROOT')) {
  26     die("You Cannot Access This Script Directly, Have a Nice Day.");
  27  }
  28  // ----------------------------------------------------------------
  29  
  30  // create pagination
  31  if(isset($_GET['c'])) {
  32      $_SESSION['list_user_count'] = $_GET['c'] == 'all' ? '99999' : intval($_GET['c']);
  33  }
  34  if(isset($_GET['page'])) {
  35      $_SESSION['ads_page'] = intval($_GET['page']);
  36  }
  37  
  38  // set default values for paginating
  39  if(empty($_SESSION['list_user_count'])) {
  40      $_SESSION['list_user_count'] = 25;
  41  }
  42  
  43  // paginate and search form processing
  44  if(isset($_POST['do_pagination'])) {
  45  
  46      $_SESSION['list_active']    = empty($_POST['showactive']) ? 0 : 1;
  47      $_SESSION['list_inactive']    = empty($_POST['showinactive']) ? 0 : 1;
  48  
  49      $_SESSION['filter']            = clean_slweg($_POST['filter']);
  50      if(empty($_SESSION['filter'])) {
  51          unset($_SESSION['filter']);
  52      } else {
  53          $_SESSION['filter']    = convertStringToArray($_SESSION['filter'], ' ');
  54          $_POST['filter']    = $_SESSION['filter'];
  55      }
  56      
  57      $_SESSION['ads_page'] = intval($_POST['page']);
  58  
  59  }
  60  
  61  if(empty($_SESSION['ads_page'])) {
  62      $_SESSION['ads_page'] = 1;
  63  }
  64  
  65  $_entry['list_active']        = isset($_SESSION['list_active'])    ? $_SESSION['list_active']        : 1;
  66  $_entry['list_inactive']    = isset($_SESSION['list_inactive'])    ? $_SESSION['list_inactive']    : 1;
  67  
  68  
  69  // set correct status query
  70  if($_entry['list_active'] != $_entry['list_inactive']) {
  71      
  72      if(!$_entry['list_active']) {
  73          $_entry['query'] .= 'adcampaign_status=0';
  74      }
  75      if(!$_entry['list_inactive']) {
  76          $_entry['query'] .= 'adcampaign_status=1';
  77      }
  78      
  79  } else {
  80      $_entry['query'] .= 'adcampaign_status!=9';
  81  }
  82  
  83  if(isset($_SESSION['filter']) && is_array($_SESSION['filter']) && count($_SESSION['filter'])) {
  84      
  85      $_entry['filter_array'] = array();
  86  
  87      foreach($_SESSION['filter'] as $_entry['filter']) {
  88          //usr_name, usr_login, usr_email
  89          $_entry['filter_array'][] = "CONCAT(adcampaign_title, adcampaign_comment) LIKE '%".aporeplace($_entry['filter'])."%'";
  90      }
  91      if(count($_entry['filter_array'])) {
  92          
  93          $_SESSION['filter'] = ' AND ('.implode(' OR ', $_entry['filter_array']).')';
  94          $_entry['query'] .= $_SESSION['filter'];
  95      
  96      }
  97  
  98  } elseif(isset($_SESSION['filter']) && is_string($_SESSION['filter'])) {
  99  
 100      $_entry['query'] .= $_SESSION['filter'];
 101  
 102  }
 103  
 104  
 105  // paginating values
 106  $_entry['count_total'] = _dbQuery('SELECT * FROM '.DB_PREPEND.'phpwcms_ads_campaign WHERE '.$_entry['query'], 'COUNT');
 107  $_entry['pages_total'] = ceil($_entry['count_total'] / $_SESSION['list_user_count']);
 108  if($_SESSION['ads_page'] > $_entry['pages_total']) {
 109      $_SESSION['ads_page'] = empty($_entry['pages_total']) ? 1 : $_entry['pages_total'];
 110  }
 111  
 112  
 113  
 114  ?>
 115  <form action="<?php echo MODULE_HREF ?>&amp;listcampaign=1" method="post" name="paginate" id="paginate"><input type="hidden" name="do_pagination" value="1" />
 116  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="paginate" summary="">
 117      <tr>
 118          <td><table border="0" cellpadding="0" cellspacing="0" summary="">
 119              <tr>
 120                  
 121                  <td><input type="checkbox" name="showactive" id="showactive" value="1" onclick="this.form.submit();"<?php is_checked(1, $_entry['list_active'], 1) ?> /></td>
 122                  <td><label for="showactive"><img src="img/button/aktiv_12x13_1.gif" alt="" style="margin:1px 1px 0 1px;" /></label></td>
 123                  <td><input type="checkbox" name="showinactive" id="showinactive" value="1" onclick="this.form.submit();"<?php is_checked(1, $_entry['list_inactive'], 1) ?> /></td>
 124                  <td><label for="showinactive"><img src="img/button/aktiv_12x13_0.gif" alt="" style="margin:1px 1px 0 1px;" /></label></td>
 125  
 126  <?php 
 127  if($_entry['pages_total'] > 1) {
 128  
 129      echo '<td class="chatlist">|&nbsp;</td>';
 130      echo '<td>';
 131      if($_SESSION['ads_page'] > 1) {
 132          echo '<a href="'.MODULE_HREF.'&amp;listcampaign=1&amp;page='.($_SESSION['ads_page']-1).'">';
 133          echo '<img src="img/famfamfam/action_back.gif" alt="" border="0" /></a>';
 134      } else {
 135          echo '<img src="img/famfamfam/action_back.gif" alt="" border="0" class="inactive" />';
 136      }
 137      echo '</td>';
 138      echo '<td><input type="text" name="page" id="page" maxlength="4" size="4" value="'.$_SESSION['ads_page'];
 139      echo '"  class="textinput" style="margin:0 3px 0 5px;width:30px;font-weight:bold;" /></td>';
 140      echo '<td class="chatlist">/'.$_entry['pages_total'].'&nbsp;</td>';
 141      echo '<td>';
 142      if($_SESSION['ads_page'] < $_entry['pages_total']) {
 143          echo '<a href="'.MODULE_HREF.'&amp;listcampaign=1&amp;page='.($_SESSION['ads_page']+1).'">';
 144          echo '<img src="img/famfamfam/action_forward.gif" alt="" border="0" /></a>';
 145      } else {
 146          echo '<img src="img/famfamfam/action_forward.gif" alt="" border="0" class="inactive" />';
 147      }
 148      echo '</td><td class="chatlist">&nbsp;|&nbsp;</td>';
 149  
 150  } else {
 151  
 152      echo '<td class="chatlist">|&nbsp;<input type="hidden" name="page" id="page" value="1" /></td>';
 153  
 154  }
 155  ?>
 156                  <td><input type="text" name="filter" id="filter" size="10" value="<?php 
 157                  
 158                  if(isset($_POST['filter']) && is_array($_POST['filter']) ) {
 159                      echo html_specialchars(implode(' ', $_POST['filter']));
 160                  }
 161                  
 162                  ?>" class="textinput" style="margin:0 2px 0 0;width:110px;text-align:left;" title="filter results by username, name or email" /></td>
 163                  <td><input type="image" name="gofilter" src="img/famfamfam/action_go.gif" style="margin-right:3px;" /></td>
 164              
 165              </tr>
 166          </table></td>
 167  
 168      <td class="chatlist" align="right">
 169          <a href="<?php echo MODULE_HREF ?>&amp;listcampaign=1&amp;c=10">10</a>
 170          <a href="<?php echo MODULE_HREF ?>&amp;listcampaign=1&amp;c=25">25</a>
 171          <a href="<?php echo MODULE_HREF ?>&amp;listcampaign=1&amp;c=50">50</a>
 172          <a href="<?php echo MODULE_HREF ?>&amp;listcampaign=1&amp;c=100">100</a>
 173          <a href="<?php echo MODULE_HREF ?>&amp;listcampaign=1&amp;c=250">250</a>
 174          <a href="<?php echo MODULE_HREF ?>&amp;listcampaign=1&amp;c=all"><?php echo $BL['be_ftptakeover_all'] ?></a>
 175      </td>
 176  
 177      </tr>
 178  </table>
 179  </form>
 180  
 181  <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="" class="ads">
 182  
 183      <tr>
 184          <th width="25">&nbsp;</th>
 185          <th><?php echo $BLM['campaign_entry'] ?></th>
 186          <th class="listFormat" nowrap="nowrap"><?php echo $BLM['ad_from-to'] ?></th>
 187          <th class="listFormat"><?php echo $BLM['adplace'] ?></th>
 188          <th>&nbsp;</th>
 189      </tr>
 190      
 191  <?php
 192  // loop listing available newsletters
 193  $row_count = 0;                
 194  
 195  
 196  $sql  = 'SELECT *, UNIX_TIMESTAMP(ac.adcampaign_datestart) AS adcampaign_start, ';
 197  $sql .= 'UNIX_TIMESTAMP(ac.adcampaign_dateend) AS adcampaign_end ';
 198  $sql .= 'FROM '.DB_PREPEND.'phpwcms_ads_campaign ac ';
 199  $sql .= 'LEFT JOIN '.DB_PREPEND.'phpwcms_ads_place ap ON ';
 200  $sql .=    'ac.adcampaign_place=ap.adplace_id  ';
 201  $sql .= 'WHERE '.$_entry['query'];
 202  if($_SESSION['ads_page'] > 0 && $_SESSION['list_user_count']) {
 203      $sql .= ' LIMIT '.(($_SESSION['ads_page']-1) * $_SESSION['list_user_count']).','.$_SESSION['list_user_count'];
 204  }
 205  $data = _dbQuery($sql);
 206  
 207  foreach($data as $row) {
 208  
 209      echo '<tr'.( ($row_count % 2) ? ' class="adsAltRow"' : '' ).'>'.LF;
 210      echo '    <td width="25" style="padding:2px 3px 2px 4px;"><img src="img/famfamfam/transmit.gif" alt="'.$BLM['campaign_entry'].'" /></td>'.LF;
 211      echo '    <td width="50%">'.html_specialchars($row["adcampaign_title"])."</td>\n";
 212      
 213      echo '    <td class="listFormat">'.html_specialchars(date($BLM['list_date_format'], $row["adcampaign_start"]).'&#8211;'.date($BLM['list_date_format'], $row["adcampaign_end"]))."</td>\n";
 214  
 215      echo '    <td class="listFormat" nowrap="nowrap">'.$row["adplace_width"].'x'.$row["adplace_height"].' {ADS_'.$row["adplace_id"]."}&nbsp;</td>\n";
 216      
 217      echo '    <td align="right" nowrap="nowrap" class="button_td">';
 218      
 219      echo '<a href="'.MODULE_HREF.'&amp;campaign=1&amp;edit='.$row["adcampaign_id"].'">';        
 220      echo '<img src="img/button/edit_22x13.gif" border="0" alt="" /></a>';
 221  
 222      echo '<a href="'.MODULE_HREF.'&amp;campaign=1&amp;duplicate='.$row["adcampaign_id"].'" ';
 223      echo 'title="'.$BLM['duplicate_title'].'" onclick="return confirm(\''.js_singlequote($BLM['duplicate_campaign']).' \n'.js_singlequote($BLM['campaign_title'].': '.html_specialchars('"'.$row["adcampaign_title"].'"')).'\');"';
 224      echo '><img src="img/button/copy_13x13.gif" border="0" alt="" /></a>';
 225      
 226      echo '<a href="'.MODULE_HREF.'&amp;campaign=1&amp;editid='.$row["adcampaign_id"].'&amp;verify=';
 227      echo (($row["adcampaign_status"]) ? '0' : '1').'">';        
 228      echo '<img src="img/button/aktiv_12x13_'.$row["adcampaign_status"].'.gif" border="0" alt="" /></a>';
 229      
 230      echo '<a href="'.MODULE_HREF.'&amp;campaign=1&amp;delete='.$row["adcampaign_id"];
 231      echo '" title="delete: '.html_specialchars($row["adcampaign_title"]).'"';
 232      echo ' onclick="return confirm(\''.$BLM['delete_entry'].js_singlequote($row["adcampaign_title"]).'\');">';
 233      echo '<img src="img/button/trash_13x13_1.gif" border="0" alt=""></a>';
 234  
 235      echo "</td>\n</tr>\n";
 236  
 237      $row_count++;
 238  }
 239  
 240  
 241  if($row_count) {
 242      echo '<tr><td colspan="5" bgcolor="#92A1AF"><img src="img/leer.gif" alt="" width="1" height="1"></td></tr>';
 243  }
 244  
 245  ?>    
 246  </table>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7