예제 #1
0
 /**
  * Verify Session
  *
  * @param string $sessionId
  * @return boolean
  */
 function verifySession($sessionId)
 {
     if (!$this->_verifySessionLength($sessionId)) {
         return false;
     }
     $this->_setSessionId($sessionId);
     if (OA_Auth::isLoggedIn()) {
         return true;
     } else {
         $this->raiseError('Session ID is invalid');
         return false;
     }
 }
 /**
  * Check if the user is allowed to see the password recovery tools
  *
  */
 function checkAccess()
 {
     return !OA_Auth::isLoggedIn() && !OA_Auth::suppliedCredentials();
 }
 /**
  * Logoff from the session.
  *
  * @access public
  *
  * @param string $sessionId
  *
  * @return boolean
  */
 function logoff($sessionId)
 {
     if ($this->verifySession($sessionId)) {
         phpAds_SessionDataDestroy();
         unset($GLOBALS['session']);
         return !OA_Auth::isLoggedIn();
     } else {
         return false;
     }
 }
예제 #4
0
 function _assignUserAccountInfo($oCurrentSection)
 {
     global $session;
     // Show currently logged on user and IP
     if (OA_Auth::isLoggedIn() || defined('phpAds_installing')) {
         $this->oTpl->assign('helpLink', OA_Admin_Help::getHelpLink($oCurrentSection));
         if (!defined('phpAds_installing')) {
             $this->oTpl->assign('infoUser', OA_Permission::getUsername());
             $this->oTpl->assign('buttonLogout', true);
             $this->oTpl->assign('buttonReportBugs', true);
             // Account switcher
             OA_Admin_UI_AccountSwitch::assignModel($this->oTpl);
             $this->oTpl->assign('strWorkingAs', $GLOBALS['strWorkingAs_Key']);
             $this->oTpl->assign('keyWorkingAs', $GLOBALS['keyWorkingAs']);
             $this->oTpl->assign('accountId', OA_Permission::getAccountId());
             $this->oTpl->assign('accountName', OA_Permission::getAccountName());
             $this->oTpl->assign('accountSearchUrl', MAX::constructURL(MAX_URL_ADMIN, 'account-switch-search.php'));
             $this->oTpl->assign('productUpdatesCheck', OA_Permission::isAccount(OA_ACCOUNT_ADMIN) && $GLOBALS['_MAX']['CONF']['sync']['checkForUpdates'] && !isset($session['maint_update_js']));
             if (OA_Permission::isUserLinkedToAdmin()) {
                 $this->oTpl->assign('maintenanceAlert', OA_Dal_Maintenance_UI::alertNeeded());
             }
         } else {
             $this->oTpl->assign('buttonStartOver', true);
         }
     }
 }
예제 #5
0
/**
 * Starts or continue existing session
 *
 * @param unknown_type $checkRedirectFunc
 */
function OA_Start($checkRedirectFunc = null)
{
    $conf = $GLOBALS['_MAX']['CONF'];
    global $session;
    // XXX: Why not try loading session data when OpenX is not installed?
    //if ($conf['openads']['installed'])
    if (OA_INSTALLATION_STATUS == OA_INSTALLATION_STATUS_INSTALLED) {
        phpAds_SessionDataFetch();
    }
    if (!OA_Auth::isLoggedIn() || OA_Auth::suppliedCredentials()) {
        // Required files
        include_once MAX_PATH . '/lib/max/language/Loader.php';
        // Load the required language files
        Language_Loader::load('default');
        phpAds_SessionDataRegister(OA_Auth::login($checkRedirectFunc));
        $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterLogin');
        foreach ($aPlugins as $i => $id) {
            if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
                $obj->afterLogin();
            }
        }
    }
    // Overwrite certain preset preferences
    if (!empty($session['language']) && $session['language'] != $GLOBALS['pref']['language']) {
        $GLOBALS['_MAX']['CONF']['max']['language'] = $session['language'];
    }
    // Check if manual account switch has happened and migrate to new global variable
    if (isset($session['accountSwitch'])) {
        $GLOBALS['_OX']['accountSwtich'] = $session['accountSwitch'];
        unset($session['accountSwitch']);
        phpAds_SessionDataStore();
    }
}
예제 #6
0
function phpAds_sqlDie()
{
    global $phpAds_last_query;
    $corrupt = false;
    $aConf = $GLOBALS['_MAX']['CONF'];
    if (strcasecmp($aConf['database']['type'], 'mysql') === 0) {
        $error = mysql_error();
        $errornumber = mysql_errno();
        if ($errornumber == 1027 || $errornumber == 1039) {
            $corrupt = true;
        }
        if ($errornumber == 1016 || $errornumber == 1030) {
            // Probably corrupted table, do additional check
            preg_match("/[0-9]+/Di", $error, $matches);
            if ($matches[0] == 126 || $matches[0] == 127 || $matches[0] == 132 || $matches[0] == 134 || $matches[0] == 135 || $matches[0] == 136 || $matches[0] == 141 || $matches[0] == 144 || $matches[0] == 145) {
                $corrupt = true;
            }
        }
        $dbmsName = 'MySQL';
    } elseif (strcasecmp($aConf['database']['type'], 'pgsql') === 0) {
        $error = pg_errormessage();
        $dbmsName = 'PostgreSQL';
    } else {
        $error = '';
        $dbmsName = 'Unknown';
    }
    if ($corrupt) {
        $title = $GLOBALS['strErrorDBSerious'];
        $message = sprintf($GLOBALS['strErrorDBNoDataSerious'], PRODUCT_NAME);
        if (OA_Auth::isLoggedIn() && OA_Permission::isAccount(OA_ACCOUNT_ADMIN)) {
            $message .= " (" . $error . ").<br><br>" . $GLOBALS['strErrorDBCorrupt'];
        } else {
            $message .= ".<br>" . $GLOBALS['strErrorDBContact'];
        }
    } else {
        $title = $GLOBALS['strErrorDBPlain'];
        $message = sprintf($GLOBALS['strErrorDBNoDataPlain'], PRODUCT_NAME);
        if (OA_Auth::isLoggedIn() && (OA_Permission::isAccount(OA_ACCOUNT_ADMIN) || OA_Permission::isAccount(OA_ACCOUNT_MANAGER)) || defined('phpAds_installing')) {
            // Get the DB server version
            $connection = DBC::getCurrentConnection();
            $connectionId = $connection->getConnectionId();
            $aVersion = $connectionId->getServerVersion();
            $dbVersion = $aVersion['major'] . '.' . $aVersion['minor'] . '.' . $aVersion['patch'] . '-' . $aVersion['extra'];
            $message .= sprintf($GLOBALS['strErrorDBSubmitBug'], PRODUCT_NAME);
            $last_query = $phpAds_last_query;
            $message .= "<br><br><table cellpadding='0' cellspacing='0' border='0'>";
            $message .= "<tr><td valign='top' nowrap><b>Version:</b>&nbsp;&nbsp;&nbsp;</td><td>" . htmlspecialchars(PRODUCT_NAME) . " v" . htmlspecialchars(VERSION) . "</td></tr>";
            $message .= "<tr><td valien='top' nowrap><b>PHP/DB:</b></td><td>PHP " . phpversion() . " / " . $dbmsName . " " . $dbVersion . "</td></tr>";
            $message .= "<tr><td valign='top' nowrap><b>Page:</b></td><td>" . htmlspecialchars($_SERVER['PHP_SELF']) . "</td></tr>";
            $message .= "<tr><td valign='top' nowrap><b>Error:</b></td><td>" . htmlspecialchars($error) . "</td></tr>";
            $message .= "<tr><td valign='top' nowrap><b>Query:</b></td><td><pre>" . htmlspecialchars($last_query) . "</pre></td></tr>";
            $message .= "<tr><td valign='top' nowrap><b>\$_POST:</b></td><td><pre>" . (empty($_POST) ? 'Empty' : htmlspecialchars(print_r($_POST, true))) . "</pre></td></tr>";
            $message .= "<tr><td valign='top' nowrap><b>\$_GET:</b></td><td><pre>" . (empty($_GET) ? 'Empty' : htmlspecialchars(print_r($_GET, true))) . "</pre></td></tr>";
            $message .= "</table>";
        }
    }
    phpAds_Die($title, $message);
}
예제 #7
0
/**
 * Starts or continue existing session
 *
 * @param unknown_type $checkRedirectFunc
 */
function OA_Start($checkRedirectFunc = null)
{
    $conf = $GLOBALS['_MAX']['CONF'];
    global $session;
    // Send no cache headers
    MAX_header('Pragma: no-cache');
    MAX_header('Cache-Control: no-cache, no-store, must-revalidate');
    MAX_header('Expires: 0');
    if (RV_INSTALLATION_STATUS == RV_INSTALLATION_STATUS_INSTALLED) {
        phpAds_SessionDataFetch();
    }
    if (!OA_Auth::isLoggedIn() || OA_Auth::suppliedCredentials()) {
        // Required files
        include_once MAX_PATH . '/lib/max/language/Loader.php';
        // Load the required language files
        Language_Loader::load('default');
        phpAds_SessionDataRegister(OA_Auth::login($checkRedirectFunc));
        $aPlugins = OX_Component::getListOfRegisteredComponentsForHook('afterLogin');
        foreach ($aPlugins as $i => $id) {
            if ($obj = OX_Component::factoryByComponentIdentifier($id)) {
                $obj->afterLogin();
            }
        }
    }
    // Overwrite certain preset preferences
    if (!empty($session['language']) && $session['language'] != $GLOBALS['pref']['language']) {
        $GLOBALS['_MAX']['CONF']['max']['language'] = $session['language'];
    }
    // Check if manual account switch has happened and migrate to new global variable
    if (isset($session['accountSwitch'])) {
        $GLOBALS['_OX']['accountSwtich'] = $session['accountSwitch'];
        unset($session['accountSwitch']);
        phpAds_SessionDataStore();
    }
}