Exemplo n.º 1
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();
 }
 /**
  * Attempts to set the given step as current. Before doing that, checks
  * if current step  can be reached, ie.
  * - if it is a valid wizard step
  * - if all previous steps have been marked as reached.
  *
  * If step is not a valid step it will redirect to first wizard step.
  *
  * If step is valid, but is not reachable yet, it will redirect to
  * first unreached step.
  *
  * @param OX_Admin_UI_Install_Wizard $oWizard
  */
 protected function setCurrentStepIfReachable($oWizard, $stepId)
 {
     //check if given step is valid, if not, direct user to index
     if (!$oWizard->isStep($stepId)) {
         $this->redirect($oWizard->getFirstStep());
     }
     $oWizard->setCurrentStep($stepId);
     $reachable = $oWizard->checkStepReachable();
     //reachable is fine, check if not secured
     if ($reachable) {
         $aMeta = $oWizard->getStepMeta();
         if ($aMeta['secured'] == true && !OA_Upgrade_Login::checkLogin()) {
             $this->redirect('login');
         }
         return true;
     } else {
         //if step is not reachable check the last one marked as completed
         //and redirect user to the next one
         $lastCompleted = $oWizard->getLastCompletedStep();
         if ($lastCompleted != null) {
             $forwardStep = $oWizard->getNextStep($lastCompleted);
         }
         if ($forwardStep == null) {
             $forwardStep = $oWizard->getFirstStep();
         }
         $this->redirect($forwardStep);
     }
 }
 *
 */
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
Exemplo n.º 4
0
function checkLogin()
{
    require_once MAX_PATH . '/lib/OA/Permission.php';
    require_once MAX_PATH . '/lib/OA/Upgrade/Login.php';
    OA_Upgrade_Login::autoLogin();
    return OA_Permission::isAccount(OA_ACCOUNT_ADMIN) || OA_Permission::isUserLinkedToAdmin();
}
Exemplo n.º 5
0
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
if ($action == OA_UPGRADE_FINISH) {
    OA_Upgrade_Login::autoLogin();
    // Execute any components which have registered at the afterLogin hook
    $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterLogin');
    foreach ($aPlugins as $i => $id) {
        if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
            $obj->afterLogin();
        }
    }
    // Delete the cookie
    setcookie('oat', '');
    $oUpgrader->setOpenadsInstalledOn();
    if (!$oUpgrader->removeUpgradeTriggerFile()) {
        $message .= '. ' . $strRemoveUpgradeFile;
        $strInstallSuccess = '<div class="sysinfoerror">' . $strOaUpToDateCantRemove . '</div>' . $strInstallSuccess;
    }
}