Ejemplo n.º 1
0
 /**
  * check if openads tables already exist in the specified database
  *
  * @return boolean
  */
 function checkExistingTables()
 {
     $result = true;
     $aExistingTables = OA_DB_Table::listOATablesCaseSensitive();
     $oldTableMessagePrefix = 'Your database contains an old OpenX configuration table: ';
     $oldTableMessagePostfix = 'If you are trying to upgrade this database, please copy your existing configuration file into the var folder of this install. If you wish to proceed with a fresh installation, please either choose a new Table Prefix or a new Database.';
     if (in_array($this->aDsn['table']['prefix'] . 'config', $aExistingTables)) {
         $this->oLogger->logError($oldTableMessagePrefix . $this->aDsn['table']['prefix'] . 'config. ' . $oldTableMessagePostfix);
         return false;
     }
     if (in_array($this->aDsn['table']['prefix'] . 'preference', $aExistingTables)) {
         $this->oLogger->logError($oldTableMessagePrefix . $this->aDsn['table']['prefix'] . 'preference. ' . $oldTableMessagePostfix);
         return false;
     }
     if (in_array($this->aDsn['table']['prefix'] . 'preferences', $aExistingTables)) {
         $this->oLogger->logError($oldTableMessagePrefix . $this->aDsn['table']['prefix'] . 'preferences. ' . $oldTableMessagePostfix);
         return false;
     }
     $tablePrefixError = false;
     foreach ($aExistingTables as &$tablename) {
         if (substr($tablename, 0, strlen($this->aDsn['table']['prefix'])) == $this->aDsn['table']['prefix']) {
             $result = false;
             $this->oLogger->log('Table with the prefix ' . $this->aDsn['table']['prefix'] . ' found: ' . $tablename);
             if ($tablePrefixError == false) {
                 $this->oLogger->logError('The database you have chosen already contains tables with the prefix ' . $this->aDsn['table']['prefix']);
                 $this->oLogger->logError('Please either remove these tables or choose a new prefix');
                 $tablePrefixError = true;
             }
         }
     }
     return $result;
 }