[ Index ]

PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10)

title

Body

[close]

/include/inc_module/mod_ads/setup/ -> setup.php (source)

   1  <?php
   2  
   3  // do everything in here which is neccessary for module setup
   4  
   5  // ceate neccessary db table
   6  $sql = array();
   7  
   8  $sql[0] = "CREATE TABLE IF NOT EXISTS `".DB_PREPEND."phpwcms_ads_formats` (
   9          `adformat_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  10          `adformat_created` DATETIME NOT NULL ,
  11          `adformat_changed` DATETIME NOT NULL ,
  12          `adformat_status` INT( 1 ) NOT NULL ,
  13          `adformat_title` VARCHAR( 25 ) NOT NULL ,
  14          `adformat_width` INT( 5 ) NOT NULL ,
  15          `adformat_height` INT( 5 ) NOT NULL ,
  16          `adformat_comment` TEXT NOT NULL ,
  17          INDEX ( `adformat_status` )
  18          ) TYPE=MyISAM"._dbGetCreateCharsetCollation();
  19  
  20  $sql[1] = "CREATE TABLE IF NOT EXISTS `".DB_PREPEND."phpwcms_ads_campaign` (
  21          `adcampaign_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  22          `adcampaign_created` DATETIME NOT NULL ,
  23          `adcampaign_changed` DATETIME NOT NULL ,
  24          `adcampaign_status` INT( 1 ) NOT NULL ,
  25          `adcampaign_title` VARCHAR( 255 ) NOT NULL ,
  26          `adcampaign_comment` TEXT NOT NULL ,
  27          `adcampaign_datestart` DATETIME NOT NULL ,
  28          `adcampaign_dateend` DATETIME NOT NULL ,
  29          `adcampaign_maxview` INT NOT NULL,
  30          `adcampaign_maxclick` INT NOT NULL,
  31          `adcampaign_maxviewuser` INT NOT NULL,
  32          `adcampaign_curview` INT NOT NULL,
  33          `adcampaign_curclick` INT NOT NULL,
  34          `adcampaign_curviewuser` INT NOT NULL,
  35          `adcampaign_type` INT NOT NULL ,
  36          `adcampaign_place` INT NOT NULL ,
  37          `adcampaign_data` MEDIUMTEXT NOT NULL ,
  38          INDEX ( `adcampaign_status` , `adcampaign_datestart` , `adcampaign_dateend` , `adcampaign_type`, `adcampaign_place`, `adcampaign_maxview`, `adcampaign_maxclick`, `adcampaign_maxviewuser`, `adcampaign_curview`, `adcampaign_curclick`, `adcampaign_curviewuser` )
  39          ) TYPE=MyISAM"._dbGetCreateCharsetCollation();
  40          
  41  $sql[2] = "CREATE TABLE IF NOT EXISTS `".DB_PREPEND."phpwcms_ads_tracking` (
  42          `adtracking_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  43          `adtracking_created` DATETIME NOT NULL ,
  44          `adtracking_campaignid` INT NOT NULL ,
  45          `adtracking_ip` VARCHAR( 30 ) NOT NULL ,
  46          `adtracking_cookieid` varchar(50) NOT NULL ,
  47          `adtracking_countclick` INT NOT NULL ,
  48          `adtracking_countview` INT NOT NULL ,
  49          `adtracking_useragent` VARCHAR( 255 ) NOT NULL ,
  50          `adtracking_ref` TEXT NOT NULL ,
  51          `adtracking_catid` INT NOT NULL ,
  52          `adtracking_articleid` INT NOT NULL ,
  53          INDEX ( `adtracking_campaignid` , `adtracking_ip` , `adtracking_cookieid` , `adtracking_countclick` , `adtracking_countview` )
  54          ) TYPE=MyISAM"._dbGetCreateCharsetCollation();
  55          
  56  $sql[3] = "CREATE TABLE IF NOT EXISTS `".DB_PREPEND."phpwcms_ads_place` (
  57          `adplace_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  58          `adplace_created` DATETIME NOT NULL ,
  59          `adplace_changed` DATETIME NOT NULL ,
  60          `adplace_status` INT( 1 ) NOT NULL ,
  61          `adplace_title` VARCHAR( 255 ) NOT NULL ,
  62          `adplace_format` INT NOT NULL ,
  63          `adplace_width` INT NOT NULL ,
  64          `adplace_height` INT NOT NULL ,
  65          `adplace_prefix` VARCHAR( 255 ) NOT NULL ,
  66          `adplace_suffix` VARCHAR( 255 ) NOT NULL ,
  67          INDEX ( `adplace_status` )
  68          ) TYPE=MyISAM"._dbGetCreateCharsetCollation();
  69          
  70  $sql[4] = "INSERT INTO `".DB_PREPEND."phpwcms_ads_formats` VALUES 
  71          (1, NOW(), NOW(), 1, 'Leaderboard', 728, 90, ''),
  72          (2, NOW(), NOW(), 1, 'Banner', 468, 60, ''),
  73          (3, NOW(), NOW(), 1, 'Small Square', 200, 200, ''),
  74          (4, NOW(), NOW(), 1, 'Square', 250, 250, ''),
  75          (5, NOW(), NOW(), 1, 'Medium Rectangle', 300, 250, ''),
  76          (6, NOW(), NOW(), 1, 'Large Rectangle', 336, 280, ''),
  77          (7, NOW(), NOW(), 1, 'Skyscraper', 120, 600, ''),
  78          (8, NOW(), NOW(), 1, 'Wide Skyscraper', 160, 600, ''),
  79          (10, NOW(), NOW(), 1, 'Half Banner', 234, 60, ''),
  80          (11, NOW(), NOW(), 1, 'Square Button', 125, 125, ''),
  81          (12, NOW(), NOW(), 1, 'Small Rectangle', 180, 150, ''),
  82          (13, NOW(), NOW(), 1, 'Vertical Banner', 120, 240, ''),
  83          (14, NOW(), NOW(), 1, 'Mini Square', 120, 120, ''),
  84          (15, NOW(), NOW(), 1, 'Medium Scyscraper', 120, 450, ''),
  85          (16, NOW(), NOW(), 1, 'Micro Bar', 88, 31, ''),
  86          (17, NOW(), NOW(), 1, 'Vertical Rectangle', 240, 400, ''),
  87          (18, NOW(), NOW(), 1, 'Vertical Button', 120, 90, ''),
  88          (19, NOW(), NOW(), 1, 'Half Mini Square', 120, 60, ''),
  89          (20, NOW(), NOW(), 1, 'Half Page Ad', 300, 600, ''),
  90          (21, NOW(), NOW(), 1, 'Universal Flash Layer', 400, 400, ''),
  91          (22, NOW(), NOW(), 1, 'PopUp', 250, 300, ''),
  92          (23, NOW(), NOW(), 1, 'Target Button', 120, 150, '')";
  93  
  94  
  95  // setup inital ad formats
  96  $sql_error = array();
  97  
  98  // first create db tables
  99  if(!_dbQuery($sql[0], 'CREATE')) {
 100  
 101      $sql_error[0] = '<p class="error">Error creating <b>banner ads formats</b> initial database table: '.html_entities(@mysql_error()).'</p>';
 102  
 103  }
 104  if(!_dbQuery($sql[1], 'CREATE')) {
 105  
 106      $sql_error[1] = '<p class="error">Error creating <b>banner ads campaign</b> initial database table: '.html_entities(@mysql_error()).'</p>';
 107  
 108  }
 109  if(!_dbQuery($sql[2], 'CREATE')) {
 110  
 111      $sql_error[2] = '<p class="error">Error creating <b>banner ads tracking</b> initial database table: '.html_entities(@mysql_error()).'</p>';
 112  
 113  }
 114  if(!_dbQuery($sql[3], 'CREATE')) {
 115  
 116      $sql_error[3] = '<p class="error">Error creating <b>banner ad place</b> initial database table: '.html_entities(@mysql_error()).'</p>';
 117  
 118  }
 119  
 120  // insert default settings
 121  if(!isset($sql_error[0]) && !_dbQuery("SELECT COUNT(*) FROM ".DB_PREPEND."phpwcms_ads_formats", 'COUNT')) {
 122  
 123      @_dbQuery($sql[4], 'INSERT');
 124      if(@mysql_error()) {
 125          $sql_error[4] = '<p class="error">Error inserting default <b>banner ads formats</b> entries: '.html_entities(@mysql_error()).'</p>';    
 126      }
 127  }
 128  
 129  if(!is_dir(PHPWCMS_CONTENT.'ads')) {
 130      // try to create the ads directory
 131      if(!@is_writable(PHPWCMS_CONTENT)) {
 132          @chmod(PHPWCMS_CONTENT, 0777);
 133      }
 134      umask(0);
 135      if(!@mkdir(PHPWCMS_CONTENT.'ads', 0777)) {
 136          $sql_error[5]  = '<p class="error">The necessary folder &quot;ads&quot; does not exist.<br />';
 137          $sql_error[5] .= 'Script was not able to create it here &quot;<strong>'.PHPWCMS_BASEPATH.$phpwcms["content_path"].'</strong>ads&quot; inside of web root directory.</p>';
 138          $sql_error[5] .= '<p class="error"><strong>Check permissions or create missing folder &quot;ads&quot; using FTP client.<br />Set permissions to 777.</strong></p>';
 139      } else {    
 140          // thanks wordpress ;-)
 141          $stat = @stat(dirname(PHPWCMS_CONTENT.'ads'));
 142          @chmod(PHPWCMS_CONTENT.'ads', $stat['mode'] & 0007777);
 143      }
 144  }
 145  if(is_dir(PHPWCMS_CONTENT.'ads') && !file_exists(PHPWCMS_CONTENT.'ads/adtracking.php')) {
 146      if(!copy($phpwcms['modules'][$module]['path'].'setup/adtracking.php', PHPWCMS_CONTENT.'ads/adtracking.php')) {
 147          $sql_error[6]  = '<p class="error">Adtracking file &quot;adtracking.php&quot; could not be written to ';
 148          $sql_error[6] .= '<strong>&quot;'.PHPWCMS_BASEPATH.$phpwcms["content_path"].'ads&quot;</strong>.</p>';
 149      }
 150  }
 151  
 152  
 153          
 154  echo '<p class="title">Banner ads setup</p>';
 155  
 156  if(!count($sql_error)) {
 157  
 158      echo '<p>All inital db tables and values were created.</p>';
 159      echo '<p>Please delete folder <b>setup</b> which can be found inside the module folder here:<br />';
 160      echo str_replace(PHPWCMS_ROOT, '', $phpwcms['modules'][$module]['path']).'</p>';
 161      if(!is_writable(PHPWCMS_CONTENT.'ads')) {
 162          echo '<p class="error">Before you continue please check permissions of <strong>&quot;'.PHPWCMS_BASEPATH.$phpwcms["content_path"].'ads&quot;</strong>. It has to b set to chmod 777.</p>';
 163      }
 164      
 165  } else {
 166  
 167      echo implode(LF, $sql_error);
 168  
 169  }
 170  
 171  
 172  ?>


Generated: Tue Nov 16 22:51:00 2010 Cross-referenced by PHPXref 0.7