/**
  * Login to OpenX without using the login form in the user interface and
  * receive a session ID.
  *
  * @access private
  *
  * @param string $username
  * @param string $password
  *
  * @return boolean
  */
 function _internalLogin($username, $password)
 {
     // Require the default language file.
     include_once MAX_PATH . '/lib/max/language/Loader.php';
     // Load the required language file.
     Language_Loader::load('default');
     $oPlugin = OA_Auth::staticGetAuthPlugin();
     $doUser = $oPlugin->checkPassword($username, $password);
     if ($doUser) {
         phpAds_SessionDataRegister(OA_Auth::getSessionData($doUser));
         return true;
     } else {
         return false;
     }
 }
function phpAds_Start()
{
    global $phpAds_config;
    global $Session;
    global $phpAds_productname;
    if (!defined('phpAds_installing')) {
        phpAds_SessionDataFetch();
    }
    if (!phpAds_isLoggedIn() || phpAds_SuppliedCredentials()) {
        // Load preliminary language settings
        @(include phpAds_path . '/language/english/default.lang.php');
        if ($phpAds_config['language'] != 'english' && file_exists(phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php')) {
            @(include phpAds_path . '/language/' . $phpAds_config['language'] . '/default.lang.php');
        }
        phpAds_SessionDataRegister(phpAds_Login());
    }
    // Overwrite certain preset preferences
    if (isset($Session['language']) && $Session['language'] != '' && $Session['language'] != $phpAds_config['language']) {
        $phpAds_config['language'] = $Session['language'];
    }
}
if (!isset($session['maint_update'])) {
    if (function_exists('xml_parser_create')) {
        // Show wait please text with rotating logo
        echo "<br />";
        echo "<table border='0' cellspacing='1' cellpadding='2'><tr><td>";
        echo "<img src='" . OX::assetPath() . "/images/install-busy.gif' width='16' height='16'>";
        echo "</td><td class='install'>" . $strSearchingUpdates . "</td></tr></table>";
        // Send the output to the browser
        if (false !== ob_get_contents()) {
            ob_flush();
        }
        flush();
        // Get updates info and store them into a session var
        $oSync = new OA_Sync();
        $res = $oSync->checkForUpdates();
        phpAds_SessionDataRegister('maint_update', $res);
        phpAds_SessionDataStore();
        echo "<script language='JavaScript'>\n";
        echo "<!--\n";
        echo "document.location.replace('updates-product.php');\n";
        echo "//-->\n";
        echo "</script>\n";
        exit;
    } else {
        echo "<br />" . $strNotAbleToCheck . "<br /><br />";
        echo "<br /><br />" . $strForUpdatesLookOnWebsite . "<br /><br />";
        echo "<b><img src='" . OX::assetPath() . "/images/caret-r.gif'>&nbsp;<a href='http://" . $phpAds_producturl . "' target='_blank'>" . $strClickToVisitWebsite . "</a></b>";
    }
} else {
    $maint_update = $session['maint_update'];
    unset($session['maint_update']);
Пример #4
0
 /**
  * Save the new password in the user properties
  *
  * @param string recovery ID
  * @param string new password
  * @return bool Ttrue the new password was correctly saved
  */
 function saveNewPasswordAndLogin($recoveryId, $password)
 {
     $doPwdRecovery = OA_Dal::factoryDO('password_recovery');
     $doPwdRecovery->recovery_id = $recoveryId;
     $doPwdRecoveryClone = clone $doPwdRecovery;
     $doPwdRecovery->find();
     if ($doPwdRecovery->fetch()) {
         $userId = $doPwdRecovery->user_id;
         $doPlugin =& OA_Auth::staticGetAuthPlugin();
         $doPlugin->setNewPassword($userId, $password);
         $doPwdRecoveryClone->delete();
         phpAds_SessionStart();
         $doUser = OA_Dal::staticGetDO('users', $userId);
         phpAds_SessionDataRegister(OA_Auth::getSessionData($doUser));
         phpAds_SessionDataStore();
         return true;
     }
     return false;
 }
Пример #5
0
 /**
  * A method to switch the active account to a different one
  *
  * @static
  * @param int $accountId
  * @param boolean $hasAccess  Can be used for optimization - if we know that user
  *                            has access to the account he is switching to there is
  *                            no need to check it again
  */
 public static function switchAccount($accountId, $hasAccess = false)
 {
     if ($hasAccess || self::hasAccess($accountId)) {
         $oUser =& self::getCurrentUser();
         $oUser->loadAccountData($accountId);
     }
     // Force session save
     phpAds_SessionDataRegister('user', $oUser);
     // If exists previous message related to switchAccount remove it
     OA_Admin_UI::removeOneMessage('switchAccount');
     // Queue confirmation message
     $translation = new OX_Translation();
     $translated_message = $translation->translate($GLOBALS['strYouAreNowWorkingAsX'], array(htmlspecialchars($oUser->aAccount['account_name'])));
     OA_Admin_UI::queueMessage($translated_message, 'global', 'info', null, 'switchAccount');
 }
Пример #6
0
 function _checkLoginOld($tableName, $agencySupport)
 {
     if (!isset($_COOKIE['sessionID'])) {
         return new PEAR_Error($GLOBALS['strEnableCookies']);
     }
     $prefix = $GLOBALS['_MAX']['CONF']['table']['prefix'];
     $oDbh = OA_DB::singleton();
     if (!PEAR::isError($oDbh)) {
         $tblPreferences = $oDbh->quoteIdentifier($prefix . $tableName, true);
         $query = "SELECT admin, admin_pw FROM {$tblPreferences}";
         if ($agencySupport) {
             $query .= " WHERE agencyid = 0";
         }
         $aPref = $oDbh->queryRow($query, null, MDB2_FETCHMODE_ASSOC);
         if (is_array($aPref)) {
             $oPlugin =& OA_Auth::staticGetAuthPlugin('internal');
             $aCredentials = $oPlugin->_getCredentials(false);
             if (!PEAR::isError($aCredentials)) {
                 if (strtolower($aPref['admin']) == strtolower($aCredentials['username']) && $aPref['admin_pw'] == md5($aCredentials['password'])) {
                     $doUser = OA_Dal::factoryDO('users');
                     $doUser->username = $aPref['admin'];
                     $aSession = OA_Auth::getSessionData($doUser, true);
                     $aSession['user']->aAccount['account_type'] = OA_ACCOUNT_ADMIN;
                     phpAds_SessionDataRegister($aSession);
                 }
             }
         }
         // Openads for PostgreSQL 2.0 session.last_used field is a
         // timestamp with timezone, which gives troubles reading back
         // session data if TZ offset is > 0
         if ($tableName == 'config' && $oDbh->dbsyntax == 'pgsql') {
             // Make sure that session time is loaded as UTC
             $oDbh->exec("SET TIMEZONE TO 'UTC'");
             phpAds_SessionDataStore();
             $oDbh->exec("SET TIMEZONE TO DEFAULT");
             return;
         }
         phpAds_SessionDataStore();
     }
 }
    switch ($phpAds_config['updates_frequency']) {
        case -1:
            $update_check = false;
            break;
        case 0:
            $update_check = true;
            break;
        default:
            $update_check = $phpAds_config['updates_timestamp'] + $phpAds_config['updates_frequency'] * 60 * 60 * 24 <= time();
            break;
    }
    if ($update_check) {
        include 'lib-updates.inc.php';
        $update_check = phpAds_checkForUpdates($phpAds_config['updates_last_seen']);
        if ($update_check[0]) {
            $update_check = false;
        }
    }
    phpAds_SessionDataRegister('update_check', $update_check);
    phpAds_SessionDataStore();
    // Add Product Update redirector
    if ($update_check) {
        Header("Content-Type: application/x-javascript");
        if ($Session['update_check'][1]['security_fix']) {
            echo "\t\t\talert('" . $strUpdateAlertSecurity . "');\n";
        } else {
            echo "\t\t\tif (confirm('" . $strUpdateAlert . "'))\n\t";
        }
        echo "\t\tdocument.location.replace('maintenance-updates.php');\n";
    }
}
Пример #8
0
        }
        // If cache timestamp not set or older than 24hrs, re-sync
        if (isset($aVars['sync_timestamp']) && $aVars['sync_timestamp'] + 86400 < time()) {
            $oSync = new OA_Sync();
            $res = $oSync->checkForUpdates();
            if ($res[0] == 0) {
                $update_check = $res[1];
            }
        }
        if (!is_array($update_check) || $update_check['config_version'] <= $aVars['sync_last_seen']) {
            $update_check = false;
        } else {
            // Make sure that the alert doesn't display everytime
            OA_Dal_ApplicationVariables::set('sync_last_seen', $update_check['config_version']);
            // Format like the XML-RPC response
            $update_check = array(0, $update_check);
        }
    }
    phpAds_SessionDataRegister('maint_update_js', true);
    phpAds_SessionDataStore();
    // Add Product Update redirector
    if (isset($update_check[0]) && $update_check[0] == 0) {
        header("Content-Type: application/x-javascript");
        if ($update_check[1]['security_fix']) {
            echo "alert('" . $strUpdateAlertSecurity . "');\n";
        } else {
            echo "if (confirm('" . $strUpdateAlert . "'))\n\t";
        }
        echo "document.location.replace('updates-product.php');\n";
    }
}
Пример #9
0
function phpAds_PageFooter()
{
    global $phpAds_config;
    global $Session, $phpAds_showHelp, $phpAds_helpDefault, $strMaintenanceNotActive;
    global $phpAds_TextDirection, $phpAds_TextAlignLeft, $phpAds_TextAlignRight;
    echo "</td><td width='40'>&nbsp;</td></tr>";
    // Spacer
    echo "<tr><td width='40' height='20'>&nbsp;</td>";
    echo "<td height='20'>&nbsp;</td></tr>";
    // Footer
    if (isset($phpAds_config['my_footer']) && $phpAds_config['my_footer'] != '') {
        echo "<tr><td width='40' height='20'>&nbsp;</td>";
        echo "<td height='20'>";
        include $phpAds_config['my_footer'];
        echo "</td></tr>";
    }
    echo "</table>";
    echo "</td></tr>";
    echo "</table>";
    if ($phpAds_showHelp) {
        echo "<div id='helpLayer' name='helpLayer' style='position:absolute; left:" . ($phpAds_TextDirection != 'ltr' ? '0' : '181') . "; top:-10; width:10px; height:10px; z-index:1; overflow: hidden; visibility: hidden;'>";
        echo "<img id='helpIcon' src='images/help-book.gif' align='absmiddle'>";
        echo "<span id='helpContents' name='helpContents'>" . $phpAds_helpDefault . "</span></div>";
        echo "<br><br><br><br><br><br>";
    }
    echo "\n\n";
    if (!ereg("/(index|maintenance-updates|install|upgrade)\\.php\$", $_SERVER['PHP_SELF'])) {
        // Add Product Update redirector
        if (phpAds_isUser(phpAds_Admin) && function_exists('xml_parser_create') && !isset($Session['maint_update_js'])) {
            echo "\t<script language='JavaScript' src='maintenance-updates-js.php'></script>\n";
        }
        // Check if the maintenance script is running
        if (phpAds_isUser(phpAds_Admin)) {
            if (!isset($Session['maint_not_running_warning']) && $phpAds_config['maintenance_timestamp'] < time() - 60 * 60 * 24) {
                if ($phpAds_config['maintenance_timestamp'] > 0) {
                    phpAds_SessionDataRegister('maint_not_running_warning', true);
                    // The maintenance script hasn't run in the
                    // last 24 hours, warn the user
                    echo "<script language='JavaScript'>\n";
                    echo "<!--//\n";
                    echo "\talert('" . $strMaintenanceNotActive . "');\n";
                    echo "\tlocation.replace('maintenance-maintenance.php');\n";
                    echo "//-->\n";
                    echo "</script>";
                }
            }
        }
    }
    echo "\n</body></html>";
}
Пример #10
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();
    }
}
function phpAds_SessionValidateToken($token)
{
    static $result;
    if (!isset($result)) {
        $result = $token === phpAds_SessionGetToken();
        phpAds_SessionDataRegister('token', null);
    }
    return $result;
}
Пример #12
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();
    }
}