[ Index ]

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

title

Body

[close]

/include/inc_module/mod_ads/inc/ -> ads.fe_init.inc.php (source)

   1  <?php
   2  
   3  /*************************************************************************************
   4     Copyright notice
   5     
   6     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   7   
   8     This script is part of PHPWCMS. The PHPWCMS web content management system is
   9     free software; you can redistribute it and/or modify it under the terms of
  10     the GNU General Public License as published by the Free Software Foundation;
  11     either version 2 of the License, or (at your option) any later version.
  12    
  13     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  14     A copy is found in the textfile GPL.txt and important notices to the license 
  15     from the author is found in LICENSE.txt distributed with these scripts.
  16    
  17     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  18     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  19     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  20   
  21     This copyright notice MUST APPEAR in all copies of the script!
  22  *************************************************************************************/
  23  
  24  // some mod ADS functions only needed in frontend, but done right after opening page
  25  // script contains everything necessary to track ad banner clicks and so on...
  26  
  27  // ----------------------------------------------------------------
  28  // obligate check for phpwcms constants
  29  if (!defined('PHPWCMS_ROOT')) {
  30     die("You Cannot Access This Script Directly, Have a Nice Day.");
  31  }
  32  // ----------------------------------------------------------------
  33  
  34  
  35  // first check
  36  if(isset($_GET['u']) && $_GET['u'] == PHPWCMS_USER_KEY) {
  37  
  38      $ads_id = intval($_GET['adclickval']);
  39  
  40      $sql  = 'SELECT * FROM '.DB_PREPEND.'phpwcms_ads_campaign ';
  41      $sql .= 'WHERE adcampaign_id='.$ads_id.' AND adcampaign_status=1 LIMIT 1';
  42      $ad_data = _dbQuery($sql);
  43      
  44      if(!empty($ad_data[0]['adcampaign_data'])) {
  45          $ad_data = @unserialize($ad_data[0]['adcampaign_data']);
  46  
  47          $ads_userip        = getRemoteIP();
  48          $ads_useragent    = $_SERVER['HTTP_USER_AGENT'];
  49          $ads_ref        = isset($_GET['r']) ? trim($_GET['r']) : '';
  50          $ads_cat        = empty($_GET['c']) ? 0 : intval($_GET['c']);
  51          $ads_article    = empty($_GET['a']) ? 0 : intval($_GET['a']);
  52      
  53          if(empty($_COOKIE['phpwcmsAdsUserId']) || !preg_match('/^[0-9a-f]{32}$/', ($ads_userid = $_COOKIE['phpwcmsAdsUserId']) ) ) {
  54              $ads_userid    = md5($ads_userip.microtime());
  55              setcookie('phpwcmsAdsUserId', $ads_userid, time()+63072000, '/', getCookieDomain() );
  56          }
  57          
  58          $sql  =    'INSERT DELAYED INTO '.DB_PREPEND.'phpwcms_ads_tracking (';
  59          $sql .= 'adtracking_created, adtracking_campaignid, adtracking_ip, adtracking_cookieid, ';
  60          $sql .= 'adtracking_countclick, adtracking_countview, adtracking_useragent, adtracking_ref, ';
  61          $sql .= 'adtracking_catid, adtracking_articleid) VALUES (';
  62          $sql .= "NOW(), ".$ads_id.", '".mysql_escape_string($ads_userip)."', '".mysql_escape_string($ads_userid)."', ";
  63          $sql .= "1, 0, '".mysql_escape_string($ads_useragent)."', '".mysql_escape_string($ads_ref)."', ".$ads_cat.", ".$ads_article.")";
  64          
  65          @_dbQuery($sql, 'INSERT');
  66          
  67          $sql  = 'UPDATE LOW_PRIORITY '.DB_PREPEND.'phpwcms_ads_campaign SET ';
  68          $sql .= 'adcampaign_curclick=adcampaign_curclick+1 WHERE adcampaign_id='.$ads_id;
  69          
  70          @_dbQuery($sql, 'UPDATE');
  71          
  72          headerRedirect($ad_data['url']);
  73  
  74      }
  75  }
  76  
  77  headerRedirect(PHPWCMS_URL);
  78  
  79  ?>


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