function test_runScript()
 {
     $GLOBALS['_MAX']['CONF']['table']['prefix'] = $this->prefix;
     $oUpgrade = new OA_Upgrade();
     $oUpgrade->initDatabaseConnection();
     $oDbh =& $oUpgrade->oDbh;
     $oTable = new OA_DB_Table();
     $testfile = MAX_PATH . "/etc/changes/tests/data/schema_tables_core_dashboard.xml";
     $oTable->init($testfile);
     $table = 'preference';
     $aExistingTables = OA_DB_Table::listOATablesCaseSensitive();
     if (in_array($this->prefix . $table, $aExistingTables)) {
         $this->assertTrue($oTable->dropTable($this->prefix . $table), 'error dropping ' . $this->prefix . $table);
     }
     $this->assertTrue($oTable->createTable($table), 'error creating ' . $this->prefix . $table);
     $aExistingTables = OA_DB_Table::listOATablesCaseSensitive();
     $this->assertTrue(in_array($this->prefix . $table, $aExistingTables), $this->prefix . $table . ' table not found');
     $this->assertTrue($oUpgrade->runScript('postscript_openads_upgrade_2.3.36-beta-rc1.php'));
     $aExistingColumns = $oDbh->manager->listTableFields($this->prefix . $table);
     $aColumns = array('ad_clicks_sum', 'ad_views_sum', 'ad_clicks_per_second', 'ad_views_per_second', 'ad_cs_data_last_sent', 'ad_cs_data_last_sent', 'ad_cs_data_last_received');
     foreach ($aColumns as $column) {
         $this->assertFalse(in_array($column, $aExistingColumns, $column . ' found in column list'));
     }
     TestEnv::restoreConfig();
     TestEnv::restoreEnv();
 }
 /**
  * Try to get platform hash.
  * If it's upgrade it try to read database (searches old config/preference tables)
  *  If this fails it returns 'OXP_upgrade-unknown_platform_hash'
  * If it's fresh install then it checks if there is already generated 
  * platformHash by previous call of this method, or use suggested one, or generate new one.
  * New platform hash is stored as already generated.  
  *
  * @param string $suggestedPlatformHash
  * @param boolean $forceCheck should check be done once again (or we can use cached results) 
  * @return string platform Hash
  */
 public function getPlatformHash($suggestedPlatformHash = null, $forceCheck = false)
 {
     if (!$forceCheck && isset(self::$foundPlatformHash)) {
         return self::$foundPlatformHash;
     }
     // is it upgrade?
     $oUpgrader = new OA_Upgrade();
     if (!$oUpgrader->isFreshInstall()) {
         // YES:
         // prepare database connection data
         $oUpgrader->canUpgradeOrInstall();
         $oUpgrader->initDatabaseConnection();
         // try read platform hash from database (3 possible locations)
         $platformHash = $this->readPlatformHashFromDatabase();
         // if can't find platformHash - set 'OXP_upgrade-unknown_platform_hash'
         $platformHash = $platformHash ? $platformHash : self::$UNKNOWN_PLATFORM_HASH;
     } else {
         // NO:
         // is already set generatedPlatformHash
         if (isset(self::$generatedPlatformHash)) {
             $platformHash = self::$generatedPlatformHash;
         } else {
             // use sugested or generate new one (and remember)
             if (isset($suggestedPlatformHash)) {
                 $platformHash = $suggestedPlatformHash;
             } else {
                 $platformHash = OA_Dal_ApplicationVariables::generatePlatformHash();
             }
             // remember genereted platform hash
             self::$generatedPlatformHash = $platformHash;
         }
     }
     self::$foundPlatformHash = $platformHash;
     return $platformHash;
 }
 /**
  * Delete upgrade tasks file, to not trigger this tasks during another upgrade
  *
  * @param OA_Upgrade $oUpgrade optional
  * @return bool true on success
  */
 static function cleanUpTaskListFile(OA_Upgrade $oUpgrade = null)
 {
     // init OA_Upgrade if needed
     if (!isset($oUpgrade)) {
         $oUpgrade = new OA_Upgrade();
     }
     return $oUpgrade->pickupPostUpgradeTasksFile();
 }
 function test_runScript()
 {
     $aExpectation = $this->_generateTestData();
     $oUpgrade = new OA_Upgrade();
     $oUpgrade->initDatabaseConnection();
     $this->assertTrue($oUpgrade->runScript('postscript_openads_upgrade_2.7.11-dev.php'));
     $this->_assertTestData($aExpectation);
     DataGenerator::cleanUp();
 }
 function execute($aParams)
 {
     $this->oUpgrade =& $aParams[0];
     $this->oDbh =& OA_DB::singleton();
     $aConf = $GLOBALS['_MAX']['CONF']['table'];
     $prefix = $aConf['prefix'];
     foreach (array('tblAppVar' => 'application_variable', 'tblAccounts' => 'accounts', 'tblAgency' => 'agency', 'tblClients' => 'clients', 'tblCampaigns' => 'campaigns', 'tblBanners' => 'banners', 'tblAcls' => 'acls', 'tblPrefs' => 'preferences', 'tblAccPrefs' => 'account_preference_assoc') as $k => $v) {
         ${$k} = $this->oDbh->quoteIdentifier($prefix . ($aConf[$v] ? $aConf[$v] : $v), true);
     }
     // Get admin account ID
     $adminAccountId = (int) $this->oDbh->queryOne("SELECT value FROM {$tblAppVar} WHERE name = 'admin_account_id'");
     if (PEAR::isError($adminAccountId)) {
         $this->logError("No admin account ID");
         return false;
     }
     // Get preference ID for timezone
     $tzId = $this->oDbh->queryOne("SELECT preference_id FROM {$tblPrefs} WHERE preference_name = 'timezone'");
     if (empty($tzId) || PEAR::isError($tzId)) {
         // Upgrading from 2.4 maybe?
         $tzId = 0;
         $this->logOnly("No timezone preference available, using default server timezone");
         $adminTz = date_default_timezone_get();
         if (empty($adminTz)) {
             // C'mon you should have set the timezone in your php.ini!
             $this->logOnly("No default server timezone, using UTC");
             $adminTz = 'UTC';
         }
     } else {
         // Get admin timezone
         $adminTz = $this->oDbh->queryOne("SELECT value FROM {$tblAccPrefs} WHERE preference_id = {$tzId} AND account_id = {$adminAccountId}");
         if (empty($adminTz) || PEAR::isError($adminTz)) {
             $this->logOnly("No admin timezone, using UTC");
             $adminTz = 'UTC';
         }
     }
     $joinList = "{$tblBanners} b JOIN\n                    {$tblCampaigns} ca USING (campaignid) JOIN\n                    {$tblClients} cl USING (clientid) JOIN\n                    {$tblAgency} a USING (agencyid) LEFT JOIN\n                    {$tblAccPrefs} p ON (p.account_id = a.account_id AND p.preference_id = {$tzId})";
     $tzPart = "COALESCE(p.value, " . $this->oDbh->quote($adminTz) . ")";
     $wherePart = "\n                    ac.bannerid = b.bannerid AND\n                \tac.type LIKE 'deliveryLimitations:Time:%' AND\n                \tac.data NOT LIKE '%@%'\n        ";
     if ($this->oDbh->dbsyntax == 'pgsql') {
         $query = "\n                UPDATE\n                    {$tblAcls} ac\n                SET\n                    data = data || '@' || {$tzPart}\n                FROM\n                    {$joinList}\n                WHERE\n                    {$wherePart}\n            ";
     } else {
         $query = "\n                UPDATE\n                    {$tblAcls} ac,\n                    {$joinList}\n                SET\n                    ac.data = CONCAT(ac.data, '@', {$tzPart})\n                WHERE\n                    {$wherePart}\n            ";
     }
     $ret = $this->oDbh->exec($query);
     if (PEAR::isError($ret)) {
         $this->logError($ret->getUserInfo());
         return false;
     }
     // Rebuild ACLs
     $this->oUpgrade->addPostUpgradeTask('Recompile_Acls');
     // Also rebuild banner cache for OX-5184
     $this->oUpgrade->addPostUpgradeTask('Rebuild_Banner_Cache');
     $this->logOnly("Appended timezone information to {$ret} time based delivery limitations");
     return true;
 }
 protected function initInstallStatus($forceInit = false)
 {
     $oStorage = OX_Admin_UI_Install_InstallUtils::getSessionStorage();
     $oStatus = $oStorage->get('installStatus');
     //initialize status if :
     // 1) it's null
     // 2) recovery was recently discovered
     // 3) upgrader reports need for recovery
     // AD1) If recovery was finished we need to give installer a chanse to
     //      reset to new state after recovery
     // AD2) If upgrader requires recovery we need to enforce it
     if ($oStatus == null || $oStatus->isRecovery() || $this->oUpgrader->isRecoveryRequired() || $forceInit) {
         //ask upgrader to determine installation status, also reset any data
         //stored by wizard
         $oStatus = new OX_Admin_UI_Install_InstallStatus($this->oUpgrader);
         $oStorage->set('installStatus', $oStatus);
         $oWizard = new OX_Admin_UI_Install_Wizard($oStatus);
         $oWizard->reset();
         // Rebild component hooks to avoid problems with previous plugin installation
         require_once LIB_PATH . '/Extension/ExtensionCommon.php';
         $oExtensionManager = new OX_Extension_Common();
         $oExtensionManager->cacheComponentHooks();
     }
     $this->oInstallStatus = $oStatus;
 }
function expandOSURow($id)
{
    $oUpgrader = new OA_Upgrade();
    $oUpgrader->initDatabaseConnection();
    $html = getDBAuditTable($oUpgrader->oAuditor->queryAuditBackupTablesByUpgradeId($id));
    $objResponse = new xajaxResponse();
    $objResponse->addAssign('cell_' . $id, "style.display", 'block');
    $objResponse->addAssign('cell_' . $id, 'text-align', 'center');
    $objResponse->addAssign('cell_' . $id, 'innerHTML', $html);
    $objResponse->addAssign('img_expand_' . $id, "style.display", 'none');
    $objResponse->addAssign('img_collapse_' . $id, "style.display", 'inline');
    $objResponse->addAssign('text_expand_' . $id, "style.display", 'none');
    $objResponse->addAssign('text_collapse_' . $id, "style.display", 'inline');
    $objResponse->addAssign('info_expand_' . $id, "style.display", 'none');
    $objResponse->addAssign('info_collapse_' . $id, "style.display", 'inline');
    return $objResponse;
}
 function test_runScript()
 {
     $oUpgrade = new OA_Upgrade();
     $this->oConfiguration = $oUpgrade->oConfiguration;
     $oUpgrade->initDatabaseConnection();
     $oDbh =& $oUpgrade->oDbh;
     $oTable = new OA_DB_Table();
     $table = 'database_action';
     $testfile = MAX_PATH . "/lib/OA/Upgrade/tests/data/{$table}.xml";
     $oTable->init($testfile);
     $this->assertTrue($oTable->dropTable($this->prefix . $table), 'error dropping ' . $this->prefix . $table);
     $this->assertTrue($oTable->createTable($table), 'error creating ' . $this->prefix . $table);
     $aExistingTables = OA_DB_Table::listOATablesCaseSensitive();
     $this->assertTrue(in_array($this->prefix . $table, $aExistingTables), 'old database_action table not found');
     $this->assertTrue($oUpgrade->runScript('prescript_openads_upgrade_2.3.33-beta-rc4.php'));
     TestEnv::restoreConfig();
 }
Example #9
0
 /**
  * Check administrator login during the upgrade steps
  *
  * @return boolean True if login succeded
  */
 function checkLogin()
 {
     if (empty($_COOKIE['oat']) || $_COOKIE['oat'] != OA_UPGRADE_UPGRADE) {
         return true;
     }
     // Clean up session
     $GLOBALS['session'] = array();
     // Detection needs to happen every time to make sure that database parameters are
     $oUpgrader = new OA_Upgrade();
     $openadsDetected = $oUpgrader->detectOpenads(true) || $oUpgrader->existing_installation_status == OA_STATUS_CURRENT_VERSION;
     // Sequentially check, to avoid useless work
     if (!$openadsDetected) {
         if (!($panDetected = $oUpgrader->detectPAN(true))) {
             if (!($maxDetected = $oUpgrader->detectMAX(true))) {
                 if (!($max01Detected = $oUpgrader->detectMAX01(true))) {
                     // No upgrade-able version detected, return
                     return false;
                 }
             }
         }
     }
     phpAds_SessionStart();
     OA_Upgrade_Login::readSession($panDetected);
     $oPlugin = new Plugins_Authentication();
     if ($oPlugin->suppliedCredentials()) {
         // The new Users, Account, Permissions & Preference feature was introduced in OpenX 2.5.46-dev
         $newLogin = $openadsDetected && version_compare($oUpgrader->versionInitialApplication, '2.5.46-dev', '>=') == -1;
         if ($newLogin) {
             OA_Upgrade_Login::_checkLoginNew();
         } else {
             if ($openadsDetected || $maxDetected) {
                 OA_Upgrade_Login::_checkLoginOld('preference', true);
             } elseif ($max01Detected) {
                 OA_Upgrade_Login::_checkLoginOld('config', true);
             } elseif ($panDetected) {
                 OA_Upgrade_Login::_checkLoginOld('config', false);
             } else {
                 return false;
             }
         }
     }
     return OA_Permission::isAccount(OA_ACCOUNT_ADMIN) || OA_Permission::isUserLinkedToAdmin();
 }
 function execute($aParams)
 {
     $this->oUpgrade =& $aParams[0];
     // Recompile the delivery limitations to update the compiled limitations as well
     $this->oUpgrade->addPostUpgradeTask('Recompile_Acls');
     $this->oDbh =& OA_DB::singleton();
     $aConf = $GLOBALS['_MAX']['CONF']['table'];
     $this->prefix = $aConf['prefix'];
     $this->tblPreferences = $aConf['prefix'] . ($aConf['preferences'] ? $aConf['preferences'] : 'preferences');
     $this->tblAccountPreferenceAssoc = $aConf['prefix'] . ($aConf['account_preference_assoc'] ? $aConf['account_preference_assoc'] : 'account_preference_assoc');
     $query = "SELECT preference_id\n                  FROM " . $this->oDbh->quoteIdentifier($this->tblPreferences, true) . "\n                  WHERE preference_name = 'auto_alter_html_banners_for_click_tracking'";
     $rs = $this->oDbh->query($query);
     //check for error
     if (PEAR::isError($rs)) {
         $this->logError($rs->getUserInfo());
         return false;
     }
     $preferenceId = $rs->fetchRow(MDB2_FETCHMODE_ASSOC);
     $preferenceId = $preferenceId['preference_id'];
     if (!empty($preferenceId)) {
         $sql = "DELETE FROM " . $this->oDbh->quoteIdentifier($this->tblAccountPreferenceAssoc, true) . " WHERE preference_id = {$preferenceId}";
         $rs = $this->oDbh->exec($sql);
         //check for error
         if (PEAR::isError($rs)) {
             $this->logError($rs->getUserInfo());
             return false;
         }
         $this->logOnly("Removed entries in account_preferences_assoc table related to auto_alter_html_banners_for_click_tracking");
         $sql = "DELETE FROM " . $this->oDbh->quoteIdentifier($this->tblPreferences, true) . " WHERE preference_id = {$preferenceId}";
         $rs = $this->oDbh->exec($sql);
         //check for error
         if (PEAR::isError($rs)) {
             $this->logError($rs->getUserInfo());
             return false;
         }
         $this->logOnly("Removed auto_alter_html_banners_for_click_tracking preference in preferences table");
     }
     return true;
 }
 function testUpdate()
 {
     $oUpgrade = new OA_Upgrade();
     $this->oConfiguration = $oUpgrade->oConfiguration;
     $oUpgrade->initDatabaseConnection();
     // run the upgrade
     Mock::generatePartial('OA_UpgradePostscript_2_5_67', $mockName = 'OA_UpgradePostscript_2_5_67_' . rand(), array('logOnly', 'logError'));
     $oMockPostUpgrade = new $mockName($this);
     $oMockPostUpgrade->oUpgrade =& $oUpgrade;
     $aContexts = array_keys($oMockPostUpgrade->aContexts);
     $aTables = array_values($oMockPostUpgrade->aContexts);
     array_push($aTables, 'audit');
     $this->initDatabase(581, $aTables);
     array_pop($aTables);
     // prepare data
     $tblAudit = $this->oDbh->quoteIdentifier($this->getPrefix() . 'audit', true);
     foreach ($aContexts as $i => $context) {
         $query = "INSERT INTO {$tblAudit} (actionid, context, details, userid, usertype, account_id) VALUES ({$i}, '{$context}', 'details', 1, 0, 1)";
         $this->oDbh->exec($query);
     }
     $query = "SELECT actionid, context FROM {$tblAudit}";
     $result = $this->oDbh->queryAll($query);
     $this->assertIsA($result, 'array');
     foreach ($result as $i => $row) {
         $this->assertEqual($row['context'], $aContexts[$row['actionid']]);
         //$aData[$row['actionid']]['original']);
     }
     $oMockPostUpgrade->updateAuditContext();
     // test results
     $query = "SELECT actionid, context FROM {$tblAudit}";
     $result = $this->oDbh->queryAll($query);
     $this->assertIsA($result, 'array');
     foreach ($result as $i => $row) {
         $this->assertEqual($row['context'], $aTables[$row['actionid']]);
         //$aData[$row['actionid']]['expected']);
     }
 }
 function __construct($aComponentGroup, $oComponentGroupManager)
 {
     parent::__construct();
     $this->aComponentGroup = $aComponentGroup;
     $this->oComponentGroupManager = $oComponentGroupManager;
     $pluginPath = $this->oComponentGroupManager->getPathToComponentGroup($this->aComponentGroup['name']);
     $this->upgradePath = $pluginPath . 'etc/changes/';
     $this->oDBUpgrader->path_changes = $this->upgradePath;
     $this->recoveryFile = MAX_PATH . '/var/plugins/recover/' . strtoupper($this->aComponentGroup['name']);
     /*$this->nobackupsFile    = MAX_PATH.$pluginPath.'NOBACKUPS';
       $this->postTaskFile     = MAX_PATH.$pluginPath.'TASKS.php';*/
     $this->initDatabaseConnection();
     if (!file_exists(MAX_PATH . '/var/plugins/log')) {
         @mkdir(MAX_PATH . '/var/plugins/log');
     }
     $this->oLogger->setLogFile('plugins/log/' . $this->aComponentGroup['name'] . '_upgrade.log');
 }
Example #13
0
    if (!empty($_POST['signup_opt'])) {
        if (!empty($_POST['signup_email'])) {
            phpAds_registerGlobalUnslashed('signup_email');
            OA_Dal_ApplicationVariables::set('sync_registered_email', $signup_email);
            $oSync = new OA_Sync();
            $res = $oSync->checkForUpdates();
        }
    } else {
        // The opt button is unticked, clear any existing sync_registered_email
        OA_Dal_ApplicationVariables::delete('sync_registered_email');
    }
    require_once LIB_PATH . '/Admin/Redirect.php';
    OX_Admin_Redirect::redirect('advertiser-index.php');
}
// Setup oUpgrader
$oUpgrader = new OA_Upgrade();
@set_time_limit(600);
// required files for header & nav
require_once MAX_PATH . '/lib/max/Admin/Languages.php';
require_once MAX_PATH . '/lib/OA/Permission.php';
require_once MAX_PATH . '/www/admin/lib-gui.inc.php';
require_once MAX_PATH . '/lib/OA/Admin/Template.php';
require_once MAX_PATH . '/lib/OA/Admin/Option.php';
require_once MAX_PATH . '/lib/max/language/Loader.php';
require_once MAX_PATH . '/lib/OA/Upgrade/UpgradePluginImport.php';
//  load translations for installer
Language_Loader::load('installer');
$options = new OA_Admin_Option('settings');
// clear the $session variable to prevent users pretending to be logged in.
unset($session);
define('phpAds_installing', true);
 function testCanUpgradeOrInstall()
 {
     // run once upgrade or install
     $oUpgrade = new OA_Upgrade();
     $firstResult = $oUpgrade->canUpgradeOrInstall();
     $existing_installation_status = $oUpgrade->existing_installation_status;
     $aPackageList = $oUpgrade->aPackageList;
     $aMessages = $oUpgrade->getMessages();
     $oUpgrade->oLogger->logClear();
     $oUpgrade->aPackageList = array();
     $oUpgrade->existing_installation_status = 235234;
     // run another one and check values
     $this->assertEqual($oUpgrade->canUpgradeOrInstall(), $firstResult);
     $this->assertEqual($oUpgrade->existing_installation_status, $existing_installation_status);
     $this->assertEqual($oUpgrade->aPackageList, $aPackageList);
     $this->assertEqual($oUpgrade->getMessages(), $aMessages);
 }
    require_once MAX_PATH . '/www/admin/lib-sessions.inc.php';
    require_once MAX_PATH . '/lib/OA/Permission.php';
    unset($session);
    phpAds_SessionDataFetch();
    if (!OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
        $_POST['xajax'] = $_GET['xajax'] = $_REQUEST['xajax'] = 'sessionExpired';
        $_POST['xajaxargs'] = $_GET['xajaxargs'] = $_REQUEST['xajaxargs'] = array();
        require_once MAX_PATH . '/lib/xajax.inc.php';
    }
}
// Required files
require_once MAX_PATH . '/www/admin/config.php';
require_once MAX_PATH . '/www/admin/lib-maintenance.inc.php';
require_once MAX_PATH . '/lib/OA/Sync.php';
require_once MAX_PATH . '/lib/OA/Upgrade/Upgrade.php';
$oUpgrader = new OA_Upgrade();
require_once MAX_PATH . '/lib/xajax.inc.php';
// Security check
OA_Permission::enforceAccount(OA_ACCOUNT_ADMIN);
/*-------------------------------------------------------*/
/* HTML framework                                        */
/*-------------------------------------------------------*/
phpAds_PageHeader("updates-index");
phpAds_MaintenanceSelection("history", "updates");
/*-------------------------------------------------------*/
/* Main code                                             */
/*-------------------------------------------------------*/
function getDBAuditTable($aAudit)
{
    $td = "<td class=\"tablebody\">%s</td>";
    $th = "<th align=\"left\" style='background-color: #ddd; border-bottom: 1px solid #ccc;'><b>%s</b></th>";
Example #16
0
 /**
  * rollback the upgrade executed during the previous test
  * copy the *fake* RECOVER file to the var folder
  * check the audit trail
  * delete the RECOVER file after
  *
  */
 function test_recoverUpgrade()
 {
     $host = OX_getHostName();
     $confFile = $host . '.conf.php';
     if (file_exists(MAX_PATH . '/var/test_' . $confFile)) {
         if (!@unlink(MAX_PATH . '/var/test_' . $confFile)) {
             $this->oLogger->logError('failed to remove the backup configuration file');
             return false;
         }
     }
     if (file_exists(MAX_PATH . '/var/' . $confFile)) {
         if (!copy(MAX_PATH . '/var/' . $confFile, MAX_PATH . '/var/test_' . $confFile)) {
             $this->assertTrue(false, 'test failed to backup conf file before upgrade recovery');
             return false;
         }
     }
     $oUpgrade = new OA_Upgrade();
     $oUpgrade->_pickupRecoveryFile();
     $this->_writeTestRecoveryFile();
     $oUpgrade->recoverUpgrade();
     if (file_exists(MAX_PATH . '/var/' . $confFile)) {
         if (!@unlink(MAX_PATH . '/var/' . $confFile)) {
             $this->oLogger->logError('failed to remove the backup configuration file');
             return false;
         }
     }
     if (file_exists(MAX_PATH . '/var/test_' . $confFile)) {
         if (!copy(MAX_PATH . '/var/test_' . $confFile, MAX_PATH . '/var/' . $confFile)) {
             $this->assertTrue(false, 'test failed to restore the test conf file after upgrade recovery');
             return false;
         }
         @unlink(MAX_PATH . '/var/test_' . $confFile);
     }
     $aAudit = $oUpgrade->oAuditor->queryAuditAllDescending();
     // we should have another 13 records in the upgrade_action audit table
     // we should have another 13 logfiles in the var folder
     // we should have 13 backup conf files in the var folder
     // one for each of the 12 packages plus a version stamp *package*
     $this->assertEqual(count($aAudit), 26, 'wrong number of audit records');
     foreach ($aAudit as $k => $aRec) {
         $idx = 25 - $k;
         if ($idx > 12) {
             $this->assertEqual($aRec['upgrade_action_id'], $idx + 1, '');
             $this->assertEqual($aRec['action'], UPGRADE_ACTION_ROLLBACK_SUCCEEDED, 'wrong action definition');
             $result = $oUpgrade->oAuditor->queryAuditByUpgradeId($k + 1);
             $this->assertIsA($result, 'array', 'failed to retrieve the original audit record array');
             $this->assertTrue(isset($result[0]), 'failed to retrieve the original audit record');
             $aOriginalAuditRec = $result[0];
             $this->assertEqual($aOriginalAuditRec['confbackup'], 'dropped during recovery', 'failure to audit that conf was dropped');
             //$aOriginalAuditRec['confbackup']);
             // recovery should restore then drop the backup tables
             if (file_exists(MAX_PATH . '/var/' . ($k + 11) . '_old.www.mysite.net.conf.php')) {
                 $this->assertFalse(true, 'conf backup was not deleted');
                 @unlink(MAX_PATH . '/var/' . ($k + 11) . '_old.www.mysite.net.conf.php');
             }
             $this->assertTrue(file_exists(MAX_PATH . '/var/' . $aRec['logfile']), 'logfile does not exist');
             $this->assertEqual($aRec['logfile'], $aOriginalAuditRec['logfile'] . '.rollback', 'wrong log file');
             @unlink(MAX_PATH . '/var/' . $aRec['logfile']);
             $this->assertEqual($aRec['upgrade_name'], $aOriginalAuditRec['upgrade_name'], 'package mismatch: ' . $aRec['upgrade_name'] . ' and ' . $aOriginalAuditRec['upgrade_name']);
         }
     }
     // the application variable should match the initial version given in the previous test
     $this->assertEqual($oUpgrade->oVersioner->getApplicationVersion(), '2.3.32-beta-rc1', 'wrong initial application version: ' . $oUpgrade->versionInitialApplication);
     $this->assertFalse(file_exists($oUpgrade->recoveryFile), 'recovery file was not deleted after recovery');
     // just in case of error, lose the recovery file so we can continue afresh
     // and not screw up someone's installation next time they run
     $oUpgrade->_pickupRecoveryFile();
     // delete the *restored* dummy conf file
     @unlink(MAX_PATH . '/var/www.mysite.net.conf.php');
 }
global $installing;
$installing = true;
require_once '../../init.php';
require_once MAX_PATH . '/lib/OA/Upgrade/Upgrade.php';
require_once MAX_PATH . '/lib/OA/Upgrade/Login.php';
require_once MAX_PATH . '/lib/OX/Upgrade/Util/Job.php';
// No upgrade file? No installer!
if (!file_exists(MAX_PATH . '/var/UPGRADE')) {
    header("Location: index.php");
    exit;
}
$aErrors = array();
$result = array('name' => @$_REQUEST['task'], 'status' => 'Invalid Request', 'errors' => &$aErrors, 'type' => 'task');
if (OA_Upgrade_Login::checkLogin(false)) {
    if (validRequest($result)) {
        $oUpgrader = new OA_Upgrade();
        $aResponse = $oUpgrader->runPostUpgradeTask($_REQUEST['task']);
        $result['errors'] = $aResponse['errors'];
        if (count($result['errors']) > 0) {
            $result['status'] = 'Failed';
        } else {
            $result['status'] = 'OK';
        }
    }
} else {
    OX_Upgrade_Util_Job::logError($result, 'Permissions error');
    $result['status'] = 'Permissions error';
}
// Save job results in session
OX_Upgrade_Util_Job::saveJobResult($result);
require_once MAX_PATH . '/lib/JSON/JSON.php';
Example #18
0
 /**
  * Checks if upgrader discovered schema which is old and stores stats
  * in server time rather than UTC.
  *
  * @param OA_Upgrade $oUpgrader
  */
 public static function hasZoneError($oUpgrader)
 {
     $tzoneErr = false;
     if ($oUpgrader->canUpgradeOrInstall()) {
         // Timezone support check
         if ($oUpgrader->existing_installation_status != OA_STATUS_NOT_INSTALLED) {
             if ($oUpgrader->versionInitialSchema['tables_core'] < 538) {
                 // Non TZ-enabled database
                 $tzoneErr = true;
             }
         }
     }
     return $tzoneErr;
 }
Example #19
0
 /**
  * Look for existing installations (phpAdsNew, MMM, Openads)
  * retrieve details and check for errors
  * Allows to limit calls to canUpgradeInit in one thread by storing it's results
  *
  * @param boolean $forceCheck should canUpgradeInit be called anyway
  * @return boolean true if can install or upgrade application, false if can't upgrade or it's current installation
  */
 public function canUpgradeOrInstall($forceCheck = false)
 {
     if ($forceCheck || !isset(self::$canUpgradeOrInstall)) {
         $result = $this->canUpgradeInit();
         self::$canUpgradeOrInstall = array('result' => $result, 'existing_installation_status' => $this->existing_installation_status, 'versionInitialApplication' => isset($this->versionInitialApplication) ? $this->versionInitialApplication : null, 'tables_core' => isset($this->versionInitialSchema['tables_core']) ? $this->versionInitialSchema['tables_core'] : null, 'package0' => isset($this->aPackageList[0]) ? $this->aPackageList[0] : null, 'aDsn-database' => $this->aDsn['database'], 'aDsn-table' => $this->aDsn['table'], 'upgrading_from_milestone_version' => $this->upgrading_from_milestone_version, 'globals-database' => $GLOBALS['_MAX']['CONF']['database'], 'globals-table' => $GLOBALS['_MAX']['CONF']['table'], 'oLogger' => clone $this->oLogger);
     } else {
         // restore results from self::$canUpgradeOrInstall
         $aResult = self::$canUpgradeOrInstall;
         $this->existing_installation_status = $aResult['existing_installation_status'];
         if (isset($aResult['versionInitialApplication'])) {
             $this->versionInitialApplication = $aResult['versionInitialApplication'];
         }
         if (isset($aResult['tables_core'])) {
             $this->versionInitialSchema['tables_core'] = $aResult['tables_core'];
         }
         if (isset($aResult['package0'])) {
             $this->aPackageList[0] = $aResult['package0'];
         }
         $this->aDsn['database'] = $aResult['aDsn-database'];
         $this->aDsn['table'] = $aResult['aDsn-table'];
         $this->upgrading_from_milestone_version = $aResult['upgrading_from_milestone_version'];
         $GLOBALS['_MAX']['CONF']['database'] = $aResult['globals-database'];
         $GLOBALS['_MAX']['CONF']['table'] = $aResult['globals-table'];
         $this->oLogger = $aResult['oLogger'];
     }
     return self::$canUpgradeOrInstall['result'];
 }
 function getOriginalApplicationVersion()
 {
     $oUpgrader = new OA_Upgrade();
     $oUpgrader->oAuditor->init($this->oDBH);
     $aResult = $oUpgrader->seekRecoveryFile();
     if (is_array($aResult) && isset($aResult[0]['auditId'])) {
         $auditId = $aResult[0]['auditId'];
         $aAudit = $oUpgrader->oAuditor->queryAuditByUpgradeId($auditId);
         if (is_array($aAudit[0]) && isset($aAudit[0]['version_from'])) {
             return $aAudit[0]['version_from'];
         }
     }
     return false;
 }