function migrateData()
 {
     $phpAdsNew = new OA_phpAdsNew();
     $aPanConfig = $phpAdsNew->_getPANConfig();
     $aValues['warn_limit_days'] = $aPanConfig['warn_limit_days'] ? $aPanConfig['warn_limit_days'] : 1;
     $sql = OA_DB_SQL::sqlForInsert('preference', $aValues);
     $result = $this->oDBH->exec($sql);
     return !PEAR::isError($result);
 }
 function execute($aParams)
 {
     $this->oUpgrade = $aParams[0];
     if ($this->oUpgrade->oDbh->dbsyntax == 'pgsql') {
         $prefix = $this->oUpgrade->oDBUpgrader->prefix;
         $result = $this->oUpgrade->oDbh->exec("ALTER TABLE {$prefix}zones ALTER zonename TYPE varchar(245)");
         // This ALTER TABLE needs to run in UTC because it stores a UTC timestamp
         $result = $this->oUpgrade->oDbh->exec("SET timezone = 'UTC'");
         $result = $this->oUpgrade->oDbh->exec("ALTER TABLE {$prefix}session ALTER lastused TYPE timestamp");
         $result = $this->oUpgrade->oDbh->exec("SET timezone = DEFAULT");
         $result = $this->oUpgrade->oDbh->exec("ALTER TABLE {$prefix}images ALTER t_stamp TYPE timestamp");
         $result = $this->oUpgrade->oDbh->exec("DROP INDEX " . OA_phpAdsNew::phpPgAdsPrefixedIndex('banners_clientid_idx', $prefix));
         $result = $this->oUpgrade->oDbh->exec("DROP INDEX " . OA_phpAdsNew::phpPgAdsPrefixedIndex('clients_parent_idx', $prefix));
         $result = $this->oUpgrade->oDbh->exec("DROP INDEX " . OA_phpAdsNew::phpPgAdsPrefixedIndex('zones_affiliateid_idx', $prefix));
         $aForeignKeys = $this->oUpgrade->oDbh->getAssoc("\n                SELECT\n                    r.conname AS fk,\n                    c.relname AS table\n                FROM\n                    pg_catalog.pg_class c JOIN\n                    pg_catalog.pg_constraint r ON (r.conrelid = c.oid)\n                WHERE\n                    c.relname IN ('{$prefix}acls', '{$prefix}banners', '{$prefix}clients', '{$prefix}zones') AND\n                    pg_catalog.pg_table_is_visible(c.oid) AND\n                    r.contype = 'f'\n                ORDER BY\n                    1,2\n            ");
         foreach ($aForeignKeys as $fkey => $table) {
             $result = $this->oUpgrade->oDbh->exec("ALTER TABLE {$table} DROP CONSTRAINT {$fkey}");
         }
         $aIndexes = array(OA_phpAdsNew::phpPgAdsPrefixedIndex('acls_bannerid_idx', $prefix) => 'acls_bannerid', OA_phpAdsNew::phpPgAdsPrefixedIndex('acls_bannerid_executionorder_udx', $prefix) => 'acls_bannerid_executionorder', OA_phpAdsNew::phpPgAdsPrefixedIndex('acls_bannerid_idx', $prefix) => 'acls_bannerid', OA_phpAdsNew::phpPgAdsPrefixedIndex('adclicks_bid_date_idx', $prefix) => 'adclicks_bannerid_date', OA_phpAdsNew::phpPgAdsPrefixedIndex('adclicks_date_idx', $prefix) => 'adclicks_date', OA_phpAdsNew::phpPgAdsPrefixedIndex('adclicks_zoneid_idx', $prefix) => 'adclicks_zoneid', OA_phpAdsNew::phpPgAdsPrefixedIndex('adstats_bid_day_idx', $prefix) => 'adstats_bannerid_day', OA_phpAdsNew::phpPgAdsPrefixedIndex('adstats_zoneid_idx', $prefix) => 'adstats_zoneid', OA_phpAdsNew::phpPgAdsPrefixedIndex('adviews_bid_date_idx', $prefix) => 'adviews_bannerid_date', OA_phpAdsNew::phpPgAdsPrefixedIndex('adviews_date_idx', $prefix) => 'adviews_date', OA_phpAdsNew::phpPgAdsPrefixedIndex('adviews_zoneid_idx', $prefix) => 'adviews_zoneid', OA_phpAdsNew::phpPgAdsPrefixedIndex('zones_zonename_zoneid_idx', $prefix) => 'zones_zonenameid');
         foreach ($aIndexes as $oldIndex => $newIndex) {
             $result = $this->oUpgrade->oDbh->exec("ALTER INDEX {$oldIndex} RENAME TO {$prefix}{$newIndex}");
         }
         $aFunctions = array('unix_timestamp(timestamptz)', 'from_unixtime(int4)', 'to_days(timestamptz)', 'dayofmonth(timestamptz)', 'month(timestamptz)', 'year(timestamptz)', 'week(timestamptz)', 'hour(timestamptz)', 'date_format(timestamptz, text)', 'if(bool, varchar, varchar)');
         foreach ($aFunctions as $function) {
             $result = $this->oUpgrade->oDbh->exec("DROP FUNCTION {$function}");
         }
         OA_DB::createFunctions();
     }
     return true;
 }
 function test_migratePANConfig()
 {
     $oPAN = new OA_phpAdsNew();
     // Test 1
     $this->_putPanConfigFile('pan.config.inc.php');
     $aResult = $oPAN->_migratePANConfig($oPAN->_getPANConfig());
     $this->_deletePanConfigFile();
     $this->assertEqual($aResult['database']['host'], 'pan_host', 'host not set');
     $this->assertEqual($aResult['database']['port'], '9999', 'port not set');
     $this->assertEqual($aResult['database']['username'], 'pan_user', 'username not set');
     $this->assertEqual($aResult['database']['password'], 'pan_password', 'password not set');
     $this->assertEqual($aResult['database']['name'], 'pan_database', 'database not set');
     $this->assertFalse($aResult['database']['persistent'], 'persistent incorrect');
     $this->assertTrue($aResult['ui']['enabled'], '"UI Enabled" incorrect');
     $this->assertFalse($aResult['openads']['requireSSL'], 'requireSSL incorrect');
     $this->assertTrue($aResult['maintenance']['autoMaintenance'], 'autoMaintenance incorrect');
     $this->assertFalse($aResult['logging']['reverseLookup'], 'reverseLookup incorrect');
     $this->assertFalse($aResult['logging']['proxyLookup'], 'proxyLookup incorrect');
     $this->assertTrue($aResult['logging']['adImpressions'], 'adImpressions incorrect');
     $this->assertTrue($aResult['logging']['adClicks'], 'adClicks incorrect');
     //        $this->assertFalse($aResult[''][''] = $phpAds_config['log_beacon'],' incorrect');;
     //        $this->assertFalse($aResult[''][''] = $phpAds_config['ignore_hosts'],' incorrect');;
     $this->assertEqual($aResult['logging']['blockAdImpressions'], 0, 'blockAdImpressions incorrect');
     $this->assertEqual($aResult['logging']['blockAdClicks'], 0, 'blockAdClicks incorrect');
     $this->assertTrue($aResult['p3p']['policies'], 'policies incorrect');
     $this->assertEqual($aResult['p3p']['compactPolicy'], 'NOI CUR ADM OUR NOR STA NID', 'compactPolicy incorrect');
     $this->assertEqual($aResult['p3p']['policyLocation'], 'pan_p3p_policy_location', 'policyLocation incorrect');
     $this->assertTrue($aResult['delivery']['acls'], 'acls incorrect');
     $aExpections = $this->_getMigrationExpectations();
     foreach ($aExpections as $i => $v) {
         $this->_setPanConfigFile($v['source']);
         $aResult = $oPAN->_migratePANConfig($oPAN->_getPANConfig());
         $this->assertEqual($aResult['database']['protocol'], $v['target']['database']['protocol'], $v['desc'] . ' protocol');
         $this->assertEqual($aResult['database']['host'], $v['target']['database']['host'], $v['desc'] . ' host');
         $this->assertEqual($aResult['database']['port'], $v['target']['database']['port'], $v['desc'] . ' port');
         $this->assertEqual($aResult['database']['socket'], $v['target']['database']['socket'], $v['desc'] . ' socket');
         $this->assertEqual($aResult['database']['type'], $v['target']['database']['type'], $v['desc'] . ' db type');
         $this->assertEqual($aResult['table']['type'], $v['target']['table']['type'], $v['desc'] . ' table type');
     }
     $this->_deletePanConfigFile();
 }
 function statsCompacted()
 {
     $phpAdsNew = new OA_phpAdsNew();
     $aConfig = $phpAdsNew->_getPANConfig();
     return $this->compactStats || $aConfig['compact_stats'];
 }
 function getDatabaseSetting($geotracking_location)
 {
     $geotracking_conf = OA_phpAdsNew::phpAds_geoip_getConf($geotracking_location);
     $sDatabaseType = $this->getDatabaseType($geotracking_conf);
     if ($sDatabaseType === false) {
         return $this->_logErrorAndReturnFalse('Could not set the geotracking database configuration');
     }
     return "{$sDatabaseType}={$geotracking_location}\n";
 }
Пример #6
0
 function applySchemaDefinitionChanges($version)
 {
     if ($version == '049') {
         // We need to ensure that the XML index definition matches the actual name, which might be truncated
         foreach ($this->aDefinitionNew['tables'] as $tableName => &$aTable) {
             foreach ($aTable['indexes'] as $indexName => &$aIndex) {
                 $newIndexName = OA_phpAdsNew::phpPgAdsIndexToOpenads($indexName, $tableName, $this->prefix);
                 if (empty($aIndex['primary']) && $indexName != $newIndexName) {
                     $this->_logOnly('phppgads index detected, renaming ' . $indexName . ' to ' . $newIndexName);
                     $aIndex['was'] = $newIndexName;
                     $this->aDefinitionNew['tables'][$tableName]['indexes'][$newIndexName] = $aIndex;
                     unset($this->aDefinitionNew['tables'][$tableName]['indexes'][$indexName]);
                 }
             }
         }
     }
     return true;
 }