Beispiel #1
0
 function autoLogin()
 {
     $oPlugin =& OA_Auth::staticGetAuthPlugin();
     phpAds_SessionStart();
     // No auto-login if auth is external
     if (empty($oPlugin) || get_class($oPlugin) != 'Plugins_Authentication') {
         phpAds_SessionDataDestroy();
         return;
     }
     $doUser = OA_Dal::factoryDO('users');
     if (!empty($_COOKIE['oat']) && $_COOKIE['oat'] == OA_UPGRADE_UPGRADE) {
         // Upgrading, fetch the record using the username of the logged in user
         $doUser->username = OA_Permission::getUsername();
     } else {
         // Installing, fetch the user linked to the admin account
         $doAUA = OA_Dal::factoryDO('account_user_assoc');
         $doAUA->account_id = OA_Dal_ApplicationVariables::get('admin_account_id');
         $doUser->joinAdd($doAUA);
     }
     $doUser->find();
     if ($doUser->fetch()) {
         phpAds_SessionDataRegister(OA_Auth::getSessionData($doUser));
         phpAds_SessionDataStore();
     }
 }
function phpAds_SessionDataRegister($key, $value = '')
{
    global $Session;
    if (!defined('phpAds_installing')) {
        phpAds_SessionStart();
    }
    if (is_array($key) && $value == '') {
        foreach (array_keys($key) as $name) {
            $Session[$name] = $key[$name];
        }
    } else {
        $Session[$key] = $value;
    }
    phpAds_SessionDataStore();
    // This function has been disabled because of incompatibility
    // problem with ZendOptimizer 1.00. Call sessionDataStore
    // manually if have modified the session array.
    // register_shutdown_function("phpAds_SessionDataStore");
}
 function autoLogin()
 {
     $oPlugin =& OA_Auth::staticGetAuthPlugin();
     phpAds_SessionStart();
     // No auto-login if auth is external
     if (empty($oPlugin) || get_class($oPlugin) != 'Plugins_Authentication') {
         phpAds_SessionDataDestroy();
         return;
     }
     $adminAccountId = OA_Dal_ApplicationVariables::get('admin_account_id');
     if (isset($adminAccountId)) {
         // Fetch the user linked to the admin account
         $doUser = OA_Dal::factoryDO('users');
         $doAUA = OA_Dal::factoryDO('account_user_assoc');
         $doAUA->account_id = $adminAccountId;
         $doUser->joinAdd($doAUA);
         $doUser->find();
         if ($doUser->fetch()) {
             phpAds_SessionDataRegister(OA_Auth::getSessionData($doUser));
             phpAds_SessionDataStore();
         }
     }
 }
Beispiel #4
0
function phpAds_SessionDataRegister($key, $value = '')
{
    $conf = $GLOBALS['_MAX']['CONF'];
    global $session;
    //if ($conf['openads']['installed'])
    if (OA_INSTALLATION_STATUS == OA_INSTALLATION_STATUS_INSTALLED) {
        phpAds_SessionStart();
    }
    if (is_array($key) && $value == '') {
        foreach (array_keys($key) as $name) {
            $session[$name] = $key[$name];
        }
    } else {
        $session[$key] = $value;
    }
    //if ($conf['openads']['installed'])
    if (OA_INSTALLATION_STATUS == OA_INSTALLATION_STATUS_INSTALLED) {
        phpAds_SessionDataStore();
    }
}
Beispiel #5
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;
 }
function phpAds_Login()
{
    global $phpAds_config;
    global $strPasswordWrong, $strEnableCookies, $strEnterBoth;
    if (phpAds_SuppliedCredentials()) {
        // Trim spaces from input
        $username = trim($_POST['phpAds_username']);
        $password = trim($_POST['phpAds_password']);
        // Add slashes to input if needed
        if (!ini_get('magic_quotes_gpc')) {
            $username = addslashes($username);
            $password = addslashes($password);
        }
        // Convert plain text password to md5 digest
        $md5digest = md5($password);
        // Exit if not both username and password are given
        if ($md5digest == '' || $md5digest == md5('') || $username == '') {
            $_COOKIE['sessionID'] = phpAds_SessionStart();
            phpAds_LoginScreen($strEnterBoth, $_COOKIE['sessionID']);
        }
        // Exit if cookies are disabled
        if ($_COOKIE['sessionID'] != $_POST['phpAds_cookiecheck']) {
            $_COOKIE['sessionID'] = phpAds_SessionStart();
            phpAds_LoginScreen($strEnableCookies, $_COOKIE['sessionID']);
        }
        if (phpAds_isAdmin($username, $md5digest)) {
            // User is Administrator
            return array("usertype" => phpAds_Admin, "loggedin" => "t", "username" => $username);
        } else {
            // Check client table
            $res = phpAds_dbQuery("\n\t\t\t\tSELECT\n\t\t\t\t\tclientid,\n\t\t\t\t\tpermissions,\n\t\t\t\t\tlanguage\n\t\t\t\tFROM\n\t\t\t\t\t" . $phpAds_config['tbl_clients'] . "\n\t\t\t\tWHERE\n\t\t\t\t\tclientusername = '******'\n\t\t\t\t\tAND clientpassword = '******'\n\t\t\t") or phpAds_sqlDie();
            if (phpAds_dbNumRows($res) > 0) {
                // User found with correct password
                $row = phpAds_dbFetchArray($res);
                return array("usertype" => phpAds_Client, "loggedin" => "t", "username" => $username, "userid" => $row['clientid'], "permissions" => $row['permissions'], "language" => $row['language']);
            } else {
                $res = phpAds_dbQuery("\n\t\t\t\t\tSELECT\n\t\t\t\t\t\taffiliateid,\n\t\t\t\t\t\tpermissions,\n\t\t\t\t\t\tlanguage\n\t\t\t\t\tFROM\n\t\t\t\t\t\t" . $phpAds_config['tbl_affiliates'] . "\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tusername = '******'\n\t\t\t\t\t\tAND password = '******'\n\t\t\t\t\t");
                if ($res && phpAds_dbNumRows($res) > 0) {
                    // User found with correct password
                    $row = phpAds_dbFetchArray($res);
                    return array("usertype" => phpAds_Affiliate, "loggedin" => "t", "username" => $username, "userid" => $row['affiliateid'], "permissions" => $row['permissions'], "language" => $row['language']);
                } else {
                    // Password is not correct or user is not known
                    // Set the session ID now, some server do not support setting a cookie during a redirect
                    $_COOKIE['sessionID'] = phpAds_SessionStart();
                    phpAds_LoginScreen($strPasswordWrong, $_COOKIE['sessionID']);
                }
            }
        }
    } else {
        // User has not supplied credentials yet
        if (defined('phpAds_installing')) {
            // We are trying to install, grant access...
            return array("usertype" => phpAds_Admin, "loggedin" => "t", "username" => 'admin');
        }
        // Set the session ID now, some server do not support setting a cookie during a redirect
        $_COOKIE['sessionID'] = phpAds_SessionStart();
        phpAds_LoginScreen('', $_COOKIE['sessionID']);
    }
}
function phpAds_SessionGetToken()
{
    if (OA_INSTALLATION_STATUS != OA_INSTALLATION_STATUS_INSTALLED) {
        return false;
    }
    global $session;
    phpAds_SessionStart();
    if (empty($session['token'])) {
        $session['token'] = md5(uniqid('phpads', 1));
        phpAds_SessionDataStore();
    }
    return $session['token'];
}
Beispiel #8
0
 /**
  * A static method to restart with a login screen, eventually displaying a custom message
  *
  * @static
  *
  * @param string $sMessage Optional message
  */
 function restart($sMessage = '')
 {
     $_COOKIE['sessionID'] = phpAds_SessionStart();
     OA_Auth::displayLogin($sMessage, $_COOKIE['sessionID']);
 }
function phpAds_Die($title = "Error", $message = "Unknown error")
{
    if (defined('OA_WEBSERVICES_API_XMLRPC')) {
        // It's an XML-RPC response
        if (class_exists('XmlRpcUtils')) {
            $oResponse = XmlRpcUtils::generateError($message);
        } else {
            $oResponse = new XML_RPC_Response('', 99999, $message);
        }
        echo $oResponse->serialize();
        exit;
    }
    $conf = $GLOBALS['_MAX']['CONF'];
    global $phpAds_GUIDone, $phpAds_TextDirection;
    $header = $title == $GLOBALS['strAccessDenied'] ? phpAds_Login : phpAds_Error;
    // Header
    if ($phpAds_GUIDone == false) {
        if (!isset($phpAds_TextDirection)) {
            $phpAds_TextDirection = 'ltr';
        }
        phpAds_PageHeader(phpAds_Error);
    }
    echo "<br>";
    echo "<div class='errormessage'><img class='errormessage' src='" . OX::assetPath() . "/images/errormessage.gif' align='absmiddle'> ";
    echo "<span class='tab-r'>" . $title . "</span><br><br>" . $message . "</div><br>";
    // Die
    if ($header == phpAds_Login) {
        $_COOKIE['sessionID'] = phpAds_SessionStart();
        OA_Auth::displayLogin('', $_COOKIE['sessionID'], true);
    }
    phpAds_PageFooter();
    exit;
}