当前位置: 首页>>代码示例>>PHP>>正文


PHP setLoginCookie函数代码示例

本文整理汇总了PHP中setLoginCookie函数的典型用法代码示例。如果您正苦于以下问题:PHP setLoginCookie函数的具体用法?PHP setLoginCookie怎么用?PHP setLoginCookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setLoginCookie函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticate

function authenticate($username, $password, $givenname)
{
    // Authenticates user's password by binding to LDAP server using the password
    // If successful, password is correct
    global $ldap_host;
    // Connects to LDAP server
    $ds = ldap_connect($ldap_host);
    // Performs bind to LDAP server with user's paasword
    // Error messages are supressed if wrong password is entered
    if (@ldap_bind($ds, $username, $password)) {
        // Bind is successful - password is correct
        // Sets cookie with user's givenname
        setLoginCookie($givenname);
    } else {
        // Bind is unsuccessful - password is incorrect
        echo "Log in failed. Details incorrect.";
        echo "<p>Click <a href='../../login.php'>here</a> to go back.</p>";
    }
}
开发者ID:40thieves,项目名称:WikiVLE,代码行数:19,代码来源:ldapLogin.php

示例2: action_register2

 public function action_register2()
 {
     global $txt, $modSettings, $context, $user_info;
     // Start collecting together any errors.
     $reg_errors = Error_Context::context('register', 0);
     // Check they are who they should be
     checkSession();
     if (!validateToken('register', 'post', true, false)) {
         $reg_errors->addError('token_verification');
     }
     // You can't register if it's disabled.
     if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) {
         fatal_lang_error('registration_disabled', false);
     }
     // Well, if you don't agree, you can't register.
     if (!empty($modSettings['requireAgreement']) && !isset($_POST['checkbox_agreement'])) {
         $reg_errors->addError('agreement_unchecked');
     }
     // Make sure they came from *somewhere*, have a session.
     if (!isset($_SESSION['old_url'])) {
         redirectexit('action=register');
     }
     // Check their provider deatils match up correctly in case they're pulling something funny
     if ($_POST['provider'] != $_SESSION['extauth_info']['provider']) {
         redirectexit('action=register');
     }
     // Clean up
     foreach ($_POST as $key => $value) {
         if (!is_array($_POST[$key])) {
             $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
         }
     }
     // Needed for isReservedName() and registerMember()
     require_once SUBSDIR . '/Members.subs.php';
     // Needed for generateValidationCode()
     require_once SUBSDIR . '/Auth.subs.php';
     // Set the options needed for registration.
     $regOptions = array('interface' => 'guest', 'username' => !empty($_POST['user']) ? $_POST['user'] : '', 'email' => !empty($_POST['email']) ? $_POST['email'] : '', 'check_reserved_name' => true, 'check_password_strength' => true, 'check_email_ban' => true, 'send_welcome_email' => !empty($modSettings['send_welcomeEmail']), 'require' => empty($modSettings['registration_method']) ? 'nothing' : ($modSettings['registration_method'] == 1 ? 'activation' : 'approval'));
     // Lets check for other errors before trying to register the member.
     if ($reg_errors->hasErrors()) {
         return $this->action_register();
     }
     mt_srand(time() + 1277);
     $regOptions['password'] = generateValidationCode();
     $regOptions['password_check'] = $regOptions['password'];
     // Registration needs to know your IP
     $req = request();
     $regOptions['ip'] = $user_info['ip'];
     $regOptions['ip2'] = $req->ban_ip();
     $memberID = registerMember($regOptions, 'register');
     // If there are "important" errors and you are not an admin: log the first error
     // Otherwise grab all of them and don't log anything
     if ($reg_errors->hasErrors(1) && !$user_info['is_admin']) {
         foreach ($reg_errors->prepareErrors(1) as $error) {
             fatal_error($error, 'general');
         }
     }
     // One last error check
     if ($reg_errors->hasErrors()) {
         return $this->action_register();
     }
     // Do our spam protection now.
     spamProtection('register');
     // Since all is well, we'll go ahead and associate the member's external account
     addAuth($memberID, $_SESSION['extauth_info']['provider'], $_SESSION['extauth_info']['uid'], $_SESSION['extauth_info']['name']);
     // Basic template variable setup.
     if (!empty($modSettings['registration_method'])) {
         loadTemplate('Register');
         $context += array('page_title' => $txt['register'], 'title' => $txt['registration_successful'], 'sub_template' => 'after', 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration']);
     } else {
         call_integration_hook('integrate_activate', array($regOptions['username']));
         setLoginCookie(60 * $modSettings['cookieTime'], $memberID, hash('sha256', Util::strtolower($regOptions['username']) . $regOptions['password'] . $regOptions['register_vars']['password_salt']));
         redirectexit('action=auth;sa=check;member=' . $memberID, $context['server']['needs_login_fix']);
     }
 }
开发者ID:eurich,项目名称:elkarte-external-authentication,代码行数:75,代码来源:Extauth.controller.php

示例3: DeleteInstall

function DeleteInstall()
{
    global $txt, $HTTP_SESSION_VARS, $incontext;
    global $current_smf_version, $sourcedir, $forum_version, $modSettings, $user_info, $db_type;
    $incontext['page_title'] = $txt['congratulations'];
    $incontext['sub_template'] = 'delete_install';
    $incontext['continue'] = 0;
    require dirname(__FILE__) . '/Settings.php';
    load_database();
    chdir(dirname(__FILE__));
    require_once $sourcedir . '/Errors.php';
    require_once $sourcedir . '/lib/Subs.php';
    require_once $sourcedir . '/CommonAPI.php';
    require_once $sourcedir . '/Load.php';
    require_once $sourcedir . '/Security.php';
    require_once $sourcedir . '/lib/Subs-Auth.php';
    // Bring a warning over.
    if (!empty($incontext['account_existed'])) {
        $incontext['warning'] = $incontext['account_existed'];
    }
    smf_db_query('
		SET NAMES utf8', array());
    // As track stats is by default enabled let's add some activity.
    smf_db_insert('ignore', '{db_prefix}log_activity', array('date' => 'date', 'topics' => 'int', 'posts' => 'int', 'registers' => 'int'), array(strftime('%Y-%m-%d', time()), 1, 1, !empty($incontext['member_id']) ? 1 : 0), array('date'));
    // Automatically log them in ;)
    if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
        setLoginCookie(3153600 * 60, $incontext['member_id'], sha1(sha1(strtolower($_POST['username']) . $_POST['password1']) . $incontext['member_salt']));
    }
    $result = smf_db_query('
		SELECT value
		FROM {db_prefix}settings
		WHERE variable = {string:db_sessions}', array('db_sessions' => 'databaseSession_enable', 'db_error_skip' => true));
    if (mysql_num_rows($result) != 0) {
        list($db_sessions) = mysql_fetch_row($result);
    }
    mysql_free_result($result);
    if (empty($db_sessions)) {
        if (@version_compare(PHP_VERSION, '4.2.0') == -1) {
            $HTTP_SESSION_VARS['php_412_bugfix'] = true;
        }
        $_SESSION['admin_time'] = time();
    } else {
        $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
        smf_db_insert('replace', '{db_prefix}sessions', array('session_id' => 'string', 'last_update' => 'int', 'data' => 'string'), array(session_id(), time(), 'USER_AGENT|s:' . strlen($_SERVER['HTTP_USER_AGENT']) . ':"' . $_SERVER['HTTP_USER_AGENT'] . '";admin_time|i:' . time() . ';'), array('session_id'));
    }
    // We're going to want our lovely $modSettings now.
    $request = smf_db_query('
		SELECT variable, value
		FROM {db_prefix}settings', array('db_error_skip' => true));
    // Only proceed if we can load the data.
    if ($request) {
        while ($row = mysql_fetch_row($request)) {
            $modSettings[$row[0]] = $row[1];
        }
        mysql_free_result($request);
    }
    updateStats('member');
    updateStats('message');
    updateStats('topic');
    $request = smf_db_query('
		SELECT id_msg
		FROM {db_prefix}messages
		WHERE id_msg = 1
			AND modified_time = 0
		LIMIT 1', array('db_error_skip' => true));
    if (mysql_num_rows($request) > 0) {
        updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
    }
    mysql_free_result($request);
    // Now is the perfect time to fetch the SM files.
    require_once $sourcedir . '/ScheduledTasks.php';
    // Sanity check that they loaded earlier!
    if (isset($modSettings['recycle_board'])) {
        $forum_version = $current_smf_version;
        // The variable is usually defined in index.php so lets just use our variable to do it for us.
        scheduled_fetchSMfiles();
        // Now go get those files!
        // We've just installed!
        $user_info['ip'] = $_SERVER['REMOTE_ADDR'];
        $user_info['id'] = isset($incontext['member_id']) ? $incontext['member_id'] : 0;
        logAction('install', array('version' => $forum_version), 'admin');
    }
    // Check if we need some stupid MySQL fix.
    $server_version = smf_db_get_version();
    if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
        updateSettings(array('db_mysql_group_by_fix' => '1'));
    }
    // Some final context for the template.
    $incontext['dir_still_writable'] = is_writable(dirname(__FILE__)) && substr(__FILE__, 1, 2) != ':\\';
    $incontext['probably_delete_install'] = isset($_SESSION['installer_temp_ftp']) || is_writable(dirname(__FILE__)) || is_writable(__FILE__);
    return false;
}
开发者ID:norv,项目名称:EosAlpha,代码行数:92,代码来源:install.php

示例4: set_smf_cookie

function set_smf_cookie($id, $passhash, $salt)
{
    global $THIS_BASEPATH;
    require $THIS_BASEPATH . '/smf/SSI.php';
    if (!function_exists(setLoginCookie)) {
        require $THIS_BASEPATH . '/smf/Sources/Subs-Auth.php';
    }
    setLoginCookie(189216000, $id, sha1($passhash . $salt));
}
开发者ID:Karpec,项目名称:gizd,代码行数:9,代码来源:functions.php

示例5: later

    /*
    NOTE: Following code adapted from http://elbertf.com/2010/01/store-passwords-safely-with-php-and-mysql/
        A random salt is generated and appended to the given password to generate a hash
        This is then hashed 100000 times for extra security
        The salt is then appended to the hash, so that the salt can be retrieved later (i.e. on log in)
    */
    // Create a 256 bit (64 characters) long random salt
    // Add 'something random' and the username to the salt as well for added security
    $salt = hash('sha256', uniqid(mt_rand(), true) . 'something random' . strtolower($username));
    // Prefix the password with the salt
    $hash = $salt . $password;
    // Hash the salted password 100000 times
    for ($i = 0; $i < 100000; $i++) {
        $hash = hash('sha256', $hash);
    }
    // Prefix the hash with the salt so we can get it back later
    $hash = $salt . $hash;
    // Insert the username and hashed password into the DB
    $query = "INSERT INTO Users (username, password) VALUES ('{$username}', '{$hash}')";
    // If the insertion was successful, then set the log in cookie
    if (mysql_query($query)) {
        // Calls the setLoginCookie function, which sets a cookie for the username
        setLoginCookie($username);
    } else {
        // Insertion was unsuccessful
        if (mysql_errno() == 1062) {
            // Insertion failed because the username is already being used
            echo "Oh no! The username '{$username}' is already taken!";
        }
    }
}
开发者ID:40thieves,项目名称:WikiVLE,代码行数:31,代码来源:register.php

示例6: action_register2


//.........这里部分代码省略.........
     if (isset($_POST['default_options'])) {
         $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
     }
     $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array();
     // Make sure they are clean, dammit!
     $regOptions['theme_vars'] = htmlspecialchars__recursive($regOptions['theme_vars']);
     // Check whether we have fields that simply MUST be displayed?
     require_once SUBSDIR . '/Profile.subs.php';
     loadCustomFields(0, 'register');
     foreach ($context['custom_fields'] as $row) {
         // Don't allow overriding of the theme variables.
         if (isset($regOptions['theme_vars'][$row['colname']])) {
             unset($regOptions['theme_vars'][$row['colname']]);
         }
         // Prepare the value!
         $value = isset($_POST['customfield'][$row['colname']]) ? trim($_POST['customfield'][$row['colname']]) : '';
         // We only care for text fields as the others are valid to be empty.
         if (!in_array($row['type'], array('check', 'select', 'radio'))) {
             // Is it too long?
             if ($row['field_length'] && $row['field_length'] < Util::strlen($value)) {
                 $reg_errors->addError(array('custom_field_too_long', array($row['name'], $row['field_length'])));
             }
             // Any masks to apply?
             if ($row['type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') {
                 // @todo We never error on this - just ignore it at the moment...
                 if ($row['mask'] == 'email' && !isValidEmail($value)) {
                     $reg_errors->addError(array('custom_field_invalid_email', array($row['name'])));
                 } elseif ($row['mask'] == 'number' && preg_match('~[^\\d]~', $value)) {
                     $reg_errors->addError(array('custom_field_not_number', array($row['name'])));
                 } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) !== '' && preg_match(substr($row['mask'], 5), $value) === 0) {
                     $reg_errors->addError(array('custom_field_inproper_format', array($row['name'])));
                 }
             }
         }
         // Is this required but not there?
         if (trim($value) == '' && $row['show_reg'] > 1) {
             $reg_errors->addError(array('custom_field_empty', array($row['name'])));
         }
     }
     // Lets check for other errors before trying to register the member.
     if ($reg_errors->hasErrors()) {
         $_REQUEST['step'] = 2;
         // If they've filled in some details but made an error then they need less time to finish
         $_SESSION['register']['limit'] = 4;
         return $this->action_register();
     }
     // If they're wanting to use OpenID we need to validate them first.
     if (empty($_SESSION['openid']['verified']) && !empty($_POST['authenticate']) && $_POST['authenticate'] == 'openid') {
         // What do we need to save?
         $save_variables = array();
         foreach ($_POST as $k => $v) {
             if (!in_array($k, array('sc', 'sesc', $context['session_var'], 'passwrd1', 'passwrd2', 'regSubmit'))) {
                 $save_variables[$k] = $v;
             }
         }
         require_once SUBSDIR . '/OpenID.subs.php';
         $openID = new OpenID();
         $openID->validate($_POST['openid_identifier'], false, $save_variables);
     } elseif ($verifiedOpenID || (!empty($_POST['openid_identifier']) || !empty($_SESSION['openid']['openid_uri'])) && $_POST['authenticate'] == 'openid') {
         $regOptions['username'] = !empty($_POST['user']) && trim($_POST['user']) != '' ? $_POST['user'] : $_SESSION['openid']['nickname'];
         $regOptions['email'] = !empty($_POST['email']) && trim($_POST['email']) != '' ? $_POST['email'] : $_SESSION['openid']['email'];
         $regOptions['auth_method'] = 'openid';
         $regOptions['openid'] = !empty($_SESSION['openid']['openid_uri']) ? $_SESSION['openid']['openid_uri'] : (!empty($_POST['openid_identifier']) ? $_POST['openid_identifier'] : '');
     }
     // Registration needs to know your IP
     $req = request();
     $regOptions['ip'] = $user_info['ip'];
     $regOptions['ip2'] = $req->ban_ip();
     $memberID = registerMember($regOptions, 'register');
     // If there are "important" errors and you are not an admin: log the first error
     // Otherwise grab all of them and don't log anything
     if ($reg_errors->hasErrors(1) && !$user_info['is_admin']) {
         foreach ($reg_errors->prepareErrors(1) as $error) {
             fatal_error($error, 'general');
         }
     }
     // Was there actually an error of some kind dear boy?
     if ($reg_errors->hasErrors()) {
         $_REQUEST['step'] = 2;
         return $this->action_register();
     }
     // Do our spam protection now.
     spamProtection('register');
     // We'll do custom fields after as then we get to use the helper function!
     if (!empty($_POST['customfield'])) {
         require_once SUBSDIR . '/Profile.subs.php';
         makeCustomFieldChanges($memberID, 'register');
     }
     // If COPPA has been selected then things get complicated, setup the template.
     if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) {
         redirectexit('action=coppa;member=' . $memberID);
     } elseif (!empty($modSettings['registration_method'])) {
         loadTemplate('Register');
         $context += array('page_title' => $txt['register'], 'title' => $txt['registration_successful'], 'sub_template' => 'after', 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration']);
     } else {
         call_integration_hook('integrate_activate', array($regOptions['username']));
         setLoginCookie(60 * $modSettings['cookieTime'], $memberID, hash('sha256', Util::strtolower($regOptions['username']) . $regOptions['password'] . $regOptions['register_vars']['password_salt']));
         redirectexit('action=auth;sa=check;member=' . $memberID, $context['server']['needs_login_fix']);
     }
 }
开发者ID:Ralkage,项目名称:Elkarte,代码行数:101,代码来源:Register.controller.php

示例7: action_deleteInstall

/**
 * Final step, clean up and a complete message!
 */
function action_deleteInstall()
{
    global $txt, $incontext, $db_character_set;
    global $current_version, $databases, $forum_version, $modSettings, $user_info, $db_type;
    // A few items we will load in from settings and make avaialble.
    global $boardurl, $db_prefix, $cookiename, $mbname, $language;
    $incontext['page_title'] = $txt['congratulations'];
    $incontext['sub_template'] = 'delete_install';
    $incontext['continue'] = 0;
    require dirname(__FILE__) . '/Settings.php';
    if (!defined('ELK')) {
        define('ELK', 1);
    }
    definePaths();
    $db = load_database();
    if (!defined('SUBSDIR')) {
        define('SUBSDIR', dirname(__FILE__) . '/sources/subs');
    }
    chdir(dirname(__FILE__));
    require_once SOURCEDIR . '/Errors.php';
    require_once SOURCEDIR . '/Logging.php';
    require_once SOURCEDIR . '/Subs.php';
    require_once SOURCEDIR . '/Load.php';
    require_once SUBSDIR . '/Cache.subs.php';
    require_once SOURCEDIR . '/Security.php';
    require_once SUBSDIR . '/Auth.subs.php';
    require_once SUBSDIR . '/Util.class.php';
    // Bring a warning over.
    if (!empty($incontext['account_existed'])) {
        $incontext['warning'] = $incontext['account_existed'];
    }
    if (!empty($db_character_set) && !empty($databases[$db_type]['utf8_support'])) {
        $db->query('', '
			SET NAMES {raw:db_character_set}', array('db_character_set' => $db_character_set, 'db_error_skip' => true));
    }
    // As track stats is by default enabled let's add some activity.
    $db->insert('ignore', '{db_prefix}log_activity', array('date' => 'date', 'topics' => 'int', 'posts' => 'int', 'registers' => 'int'), array(strftime('%Y-%m-%d', time()), 1, 1, !empty($incontext['member_id']) ? 1 : 0), array('date'));
    // We're going to want our lovely $modSettings now.
    $request = $db->query('', '
		SELECT variable, value
		FROM {db_prefix}settings', array('db_error_skip' => true));
    // Only proceed if we can load the data.
    if ($request) {
        while ($row = $db->fetch_row($request)) {
            $modSettings[$row[0]] = $row[1];
        }
        $db->free_result($request);
    }
    // Automatically log them in ;)
    if (isset($incontext['member_id']) && isset($incontext['member_salt'])) {
        setLoginCookie(3153600 * 60, $incontext['member_id'], hash('sha256', $incontext['passwd'] . $incontext['member_salt']));
    }
    $result = $db->query('', '
		SELECT value
		FROM {db_prefix}settings
		WHERE variable = {string:db_sessions}', array('db_sessions' => 'databaseSession_enable', 'db_error_skip' => true));
    if ($db->num_rows($result) != 0) {
        list($db_sessions) = $db->fetch_row($result);
    }
    $db->free_result($result);
    if (empty($db_sessions)) {
        $_SESSION['admin_time'] = time();
    } else {
        $_SERVER['HTTP_USER_AGENT'] = substr($_SERVER['HTTP_USER_AGENT'], 0, 211);
        $db->insert('replace', '{db_prefix}sessions', array('session_id' => 'string', 'last_update' => 'int', 'data' => 'string'), array(session_id(), time(), 'USER_AGENT|s:' . strlen($_SERVER['HTTP_USER_AGENT']) . ':"' . $_SERVER['HTTP_USER_AGENT'] . '";admin_time|i:' . time() . ';'), array('session_id'));
    }
    updateStats('member');
    updateStats('message');
    updateStats('topic');
    $request = $db->query('', '
		SELECT id_msg
		FROM {db_prefix}messages
		WHERE id_msg = 1
			AND modified_time = 0
		LIMIT 1', array('db_error_skip' => true));
    if ($db->num_rows($request) > 0) {
        updateStats('subject', 1, htmlspecialchars($txt['default_topic_subject']));
    }
    $db->free_result($request);
    // Now is the perfect time to fetch remote files.
    require_once SUBSDIR . '/ScheduledTask.class.php';
    // Sanity check that they loaded earlier!
    if (isset($modSettings['recycle_board'])) {
        // The variable is usually defined in index.php so lets just use our variable to do it for us.
        $forum_version = $current_version;
        // Now go get those files!
        $task = new Scheduled_Task();
        $task->fetchFiles();
        // We've just installed!
        $user_info['ip'] = $_SERVER['REMOTE_ADDR'];
        $user_info['id'] = isset($incontext['member_id']) ? $incontext['member_id'] : 0;
        logAction('install', array('version' => $forum_version), 'admin');
    }
    // Check if we need some stupid MySQL fix.
    $server_version = $db->db_server_info();
    if ($db_type == 'mysql' && in_array(substr($server_version, 0, 6), array('5.0.50', '5.0.51'))) {
        updateSettings(array('db_mysql_group_by_fix' => '1'));
//.........这里部分代码省略.........
开发者ID:joshuaadickerson,项目名称:Elkarte,代码行数:101,代码来源:install.php

示例8: parseCredentials

if (isset($_POST["jumpto"])) {
    $jumpto = $_POST["jumpto"];
} else {
    if (isset($_GET["jumpto"])) {
        $jumpto = $_GET["jumpto"];
    } else {
        $jumpto = "home.php";
    }
}
$msg = "";
if (isset($_POST["un"]) && isset($_POST["pwd"])) {
    $msg = parseCredentials($_POST["un"], $_POST["pwd"], $token, $expires);
    //echo $token;
    //exit;
    if (isset($token) && strlen($token) == 32 && isset($expires)) {
        setLoginCookie($token, $expires->getTimestamp());
        header("Location: {$jumpto}");
    }
}
?>






<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
开发者ID:nordquip,项目名称:sousms,代码行数:31,代码来源:index.php

示例9: Register2


//.........这里部分代码省略.........
            unset($_SESSION['visual_verification_code']);
        }
        fatal_lang_error('visual_verification_failed', false);
    } elseif (isset($_SESSION['visual_errors'])) {
        unset($_SESSION['visual_errors']);
    }
    // Collect all extra registration fields someone might have filled in.
    $possible_strings = array('websiteUrl', 'websiteTitle', 'AIM', 'YIM', 'location', 'birthdate', 'timeFormat', 'buddy_list', 'pm_ignore_list', 'smileySet', 'signature', 'personalText', 'avatar', 'lngfile', 'secretQuestion', 'secretAnswer');
    $possible_ints = array('pm_email_notify', 'notifyTypes', 'ICQ', 'gender', 'ID_THEME');
    $possible_floats = array('timeOffset');
    $possible_bools = array('notifyAnnouncements', 'notifyOnce', 'notifySendBody', 'hideEmail', 'showOnline');
    if (isset($_POST['secretAnswer']) && $_POST['secretAnswer'] != '') {
        $_POST['secretAnswer'] = md5($_POST['secretAnswer']);
    }
    // Needed for isReservedName() and registerMember().
    require_once $sourcedir . '/Subs-Members.php';
    // Validation... even if we're not a mall.
    if (isset($_POST['realName']) && (!empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum'))) {
        $_POST['realName'] = trim(preg_replace('~[\\s]~' . ($context['utf8'] ? 'u' : ''), ' ', $_POST['realName']));
        if (trim($_POST['realName']) != '' && !isReservedName($_POST['realName']) && $func['strlen']($_POST['realName']) <= 60) {
            $possible_strings[] = 'realName';
        }
    }
    if (isset($_POST['MSN']) && preg_match('~^[0-9A-Za-z=_+\\-/][0-9A-Za-z=_\'+\\-/\\.]*@[\\w\\-]+(\\.[\\w\\-]+)*(\\.[\\w]{2,6})$~', $_POST['MSN']) != 0) {
        $profile_strings[] = 'MSN';
    }
    // Handle a string as a birthdate...
    if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') {
        $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
    } elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) {
        $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
    }
    // Validate the passed langauge file.
    if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) {
        $language_directories = array($settings['default_theme_dir'] . '/languages', $settings['actual_theme_dir'] . '/languages');
        if (!empty($settings['base_theme_dir'])) {
            $language_directories[] = $settings['base_theme_dir'] . '/languages';
        }
        $language_directories = array_unique($language_directories);
        foreach ($language_directories as $language_dir) {
            if (!file_exists($language_dir)) {
                continue;
            }
            $dir = dir($language_dir);
            while ($entry = $dir->read()) {
                if (preg_match('~^index\\.(.+)\\.php$~', $entry, $matches) && $matches[1] == $_POST['lngfile']) {
                    // Got it!
                    $found = true;
                    $_SESSION['language'] = $_POST['lngfile'];
                    break 2;
                }
            }
            $dir->close();
        }
        if (empty($found)) {
            unset($_POST['lngfile']);
        }
    } else {
        unset($_POST['lngfile']);
    }
    // Set the options needed for registration.
    $regOptions = array('interface' => 'guest', 'username' => $_POST['user'], 'email' => $_POST['email'], 'password' => $_POST['passwrd1'], 'password_check' => $_POST['passwrd2'], 'check_reserved_name' => true, 'check_password_strength' => true, 'check_email_ban' => true, 'send_welcome_email' => !empty($modSettings['send_welcomeEmail']), 'require' => !empty($modSettings['coppaAge']) && !isset($_POST['skip_coppa']) ? 'coppa' : (empty($modSettings['registration_method']) ? 'nothing' : ($modSettings['registration_method'] == 1 ? 'activation' : 'approval')), 'extra_register_vars' => array(), 'theme_vars' => array());
    // Include the additional options that might have been filled in.
    foreach ($possible_strings as $var) {
        if (isset($_POST[$var])) {
            $regOptions['extra_register_vars'][$var] = '\'' . $func['htmlspecialchars']($_POST[$var]) . '\'';
        }
    }
    foreach ($possible_ints as $var) {
        if (isset($_POST[$var])) {
            $regOptions['extra_register_vars'][$var] = (int) $_POST[$var];
        }
    }
    foreach ($possible_floats as $var) {
        if (isset($_POST[$var])) {
            $regOptions['extra_register_vars'][$var] = (double) $_POST[$var];
        }
    }
    foreach ($possible_bools as $var) {
        if (isset($_POST[$var])) {
            $regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1;
        }
    }
    // Registration options are always default options...
    if (isset($_POST['default_options'])) {
        $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
    }
    $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? htmlspecialchars__recursive($_POST['options']) : array();
    $memberID = registerMember($regOptions);
    // If COPPA has been selected then things get complicated, setup the template.
    if (!empty($modSettings['coppaAge']) && !isset($_POST['skip_coppa'])) {
        redirectexit('action=coppa;member=' . $memberID);
    } elseif (!empty($modSettings['registration_method'])) {
        loadTemplate('Register');
        $context += array('page_title' => &$txt[97], 'sub_template' => 'after', 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration']);
    } else {
        setLoginCookie(60 * $modSettings['cookieTime'], $memberID, sha1(sha1(strtolower($regOptions['username']) . $regOptions['password']) . substr($regOptions['register_vars']['passwordSalt'], 1, -1)));
        redirectexit('action=login2;sa=check;member=' . $memberID, $context['server']['needs_login_fix']);
    }
}
开发者ID:alencarmo,项目名称:OCF,代码行数:101,代码来源:Register.php

示例10: fb_log

 public function fb_log()
 {
     global $fb_hook_object, $smcFunc, $fb_object, $user_info, $scripturl, $modSettings, $sourcedir;
     $face_userid['id_member'] = $fb_hook_object->face_USettings($fb_object->user_info_fbid, 'id_member', 'fbid');
     $face_pass['passwd'] = $fb_hook_object->face_USettings($face_userid['id_member'], 'passwd', 'id_member');
     $face_passsalt['password_salt'] = $fb_hook_object->face_USettings($face_userid['id_member'], 'password_salt', 'id_member');
     $modSettings['cookieTime'] = 3153600;
     require_once $sourcedir . '/Subs-Auth.php';
     include_once $sourcedir . '/LogInOut.php';
     setLoginCookie(60 * $modSettings['cookieTime'], $face_userid['id_member'], sha1($face_pass['passwd'] . $face_passsalt['password_salt']));
     $face_pwp['fbpw'] = $fb_hook_object->face_USettings($face_userid['id_member'], 'fbpw', 'id_member');
     if (!empty($face_pwp['fbpw'])) {
         setcookie("pwdone", 1);
     } else {
         setcookie("pwdone", 0);
     }
     if (empty($_SESSION['login_url'])) {
         $fb_log_url = !empty($fb_hook_object->modSettings['fb_log_url']) ? $fb_hook_object->modSettings['fb_log_url'] : $fb_hook_object->scripturl;
         header('Location: ' . $fb_log_url . '');
     } else {
         $temp = $_SESSION['login_url'];
         $fb_log_url = !empty($fb_hook_object->modSettings['fb_log_url']) ? $fb_hook_object->modSettings['fb_log_url'] : $temp;
         unset($_SESSION['login_url']);
         header('Location: ' . $fb_log_url . '');
     }
 }
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:26,代码来源:FacebookIntergrate.php

示例11: checkLogin

<?php

include_once "db.php";
include_once "dertyn.php";
if ($_POST['checksubmit']) {
    $user = $_POST['user'];
    $pass = $_POST['pass'];
    $logincheck = checkLogin($user, $pass);
    if ($logincheck == 0) {
        setLoginCookie($user);
        header("Location: {$siteurl}");
    }
}
include_once "header.php";
echo "<p>\n";
if (!$_POST['checksubmit']) {
    showLoginform();
} else {
    if ($logincheck == 0) {
        echo "thanks for logging in {$user}!<br /><b>return to <a href='{$siteurl}'>{$sitename}</a></b>.";
    } else {
        $errmsg = $user;
        echo "login failed.  try again.";
        logerr($errmsg, "login");
    }
}
echo "</p>\n";
?>

<?php 
include_once "footer.php";
开发者ID:ultramookie,项目名称:dertyn,代码行数:31,代码来源:login.php

示例12: Logout

function Logout($internal = false)
{
    global $db_prefix, $sourcedir, $ID_MEMBER, $user_info, $user_settings, $context, $modSettings;
    // Make sure they aren't being auto-logged out.
    if (!$internal) {
        checkSession('get');
    }
    require_once $sourcedir . '/Subs-Auth.php';
    if (isset($_SESSION['pack_ftp'])) {
        $_SESSION['pack_ftp'] = null;
    }
    // Just ensure they aren't a guest!
    if (!$user_info['is_guest']) {
        if (isset($modSettings['integrate_logout']) && function_exists($modSettings['integrate_logout'])) {
            call_user_func($modSettings['integrate_logout'], $user_settings['memberName']);
        }
        // If you log out, you aren't online anymore :P.
        db_query("\n\t\t\tDELETE FROM {$db_prefix}log_online\n\t\t\tWHERE ID_MEMBER = {$ID_MEMBER}\n\t\t\tLIMIT 1", __FILE__, __LINE__);
    }
    $_SESSION['log_time'] = 0;
    // Empty the cookie! (set it in the past, and for ID_MEMBER = 0)
    setLoginCookie(-3600, 0);
    // Off to the merry board index we go!
    if (empty($_SESSION['logout_url'])) {
        redirectexit('', $context['server']['needs_login_fix']);
    } else {
        $temp = $_SESSION['logout_url'];
        unset($_SESSION['logout_url']);
        redirectexit($temp, $context['server']['needs_login_fix']);
    }
}
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:31,代码来源:LogInOut.php

示例13: gplus_connectlog

function gplus_connectlog()
{
    global $scripturl, $modSettings, $sourcedir;
    $_SESSION['gplus']['id'] = $_SESSION['gplus']['idm'];
    if (empty($_SESSION['gplus']['id'])) {
        fatal_lang_error('gp__app_error3', false);
    }
    $member_load = gplus_loadUser($_SESSION['gplus']['id'], 'gpid');
    $modSettings['cookieTime'] = 3153600;
    require_once $sourcedir . '/Subs-Auth.php';
    include_once $sourcedir . '/LogInOut.php';
    setLoginCookie(60 * $modSettings['cookieTime'], $member_load['id_member'], sha1($member_load['passwd'] . $member_load['password_salt']));
    unset($_SESSION['gplus']['id']);
    unset($_SESSION['gplus']['name']);
    unset($_SESSION['gplusdata']);
    $gplus_log_url = !empty($modSettings['gp_app_custon_logurl']) ? $modSettings['gp_app_custon_logurl'] : $scripturl;
    redirectexit($gplus_log_url);
}
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:18,代码来源:GPlus.php

示例14: action_cookieSettings_display

    /**
     * Modify cookies settings.
     *
     * This method handles the display, allows to edit, and saves the result
     * for the _cookieSettings form.
     */
    public function action_cookieSettings_display()
    {
        global $context, $scripturl, $txt, $modSettings, $cookiename, $user_settings, $boardurl;
        // Initialize the form
        $this->_initCookieSettingsForm();
        $context['post_url'] = $scripturl . '?action=admin;area=serversettings;sa=cookie;save';
        $context['settings_title'] = $txt['cookies_sessions_settings'];
        // Saving settings?
        if (isset($_REQUEST['save'])) {
            call_integration_hook('integrate_save_cookie_settings');
            // Its either local or global cookies
            if (!empty($_POST['localCookies']) && empty($_POST['globalCookies'])) {
                unset($_POST['globalCookies']);
            }
            if (!empty($_POST['globalCookiesDomain']) && strpos($boardurl, $_POST['globalCookiesDomain']) === false) {
                fatal_lang_error('invalid_cookie_domain', false);
            }
            //Settings_Form::save_db($config_vars);
            $this->_cookieSettingsForm->save();
            // If the cookie name was changed, reset the cookie.
            if ($cookiename != $_POST['cookiename']) {
                require_once SUBSDIR . '/Auth.subs.php';
                $original_session_id = $context['session_id'];
                // Remove the old cookie, nom nom nom
                setLoginCookie(-3600, 0);
                // Set the new one.
                $cookiename = $_POST['cookiename'];
                setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], hash('sha256', $user_settings['passwd'] . $user_settings['password_salt']));
                redirectexit('action=admin;area=serversettings;sa=cookie;' . $context['session_var'] . '=' . $original_session_id, $context['server']['needs_login_fix']);
            }
            redirectexit('action=admin;area=serversettings;sa=cookie;' . $context['session_var'] . '=' . $context['session_id'] . ';msg=' . (!empty($context['settings_message']) ? $context['settings_message'] : 'core_settings_saved'));
        }
        addInlineJavascript('
		// Initial state
		hideGlobalCookies();

		// Update when clicked
		$("#localCookies, #globalCookies").click(function() {
			hideGlobalCookies();
		});', true);
        // Fill the config array.
        $this->_cookieSettingsForm->prepare_file();
    }
开发者ID:KeiroD,项目名称:Elkarte,代码行数:49,代码来源:ManageServer.controller.php

示例15: method_logout_user

function method_logout_user()
{
    global $context, $mobdb, $mobsettings, $modSettings, $user_info, $sourcedir, $ID_MEMBER, $user_settings;
    require_once $sourcedir . '/Subs-Auth.php';
    if (isset($_SESSION['pack_ftp'])) {
        $_SESSION['pack_ftp'] = null;
    }
    // Just ensure they aren't a guest!
    if (!$user_info['is_guest']) {
        if (isset($modSettings['integrate_logout']) && function_exists($modSettings['integrate_logout'])) {
            call_user_func($modSettings['integrate_logout'], $user_settings['memberName']);
        }
        // If you log out, you aren't online anymore :P.
        $mobdb->query("\n            DELETE FROM {db_prefix}log_online\n            WHERE ID_MEMBER = {int:current_member}\n            LIMIT 1", array('current_member' => $ID_MEMBER));
    }
    $_SESSION['log_time'] = 0;
    // Empty the cookie! (set it in the past, and for ID_MEMBER = 0)
    setLoginCookie(-3600, 0);
}
开发者ID:keweiliu6,项目名称:test_smf1,代码行数:19,代码来源:Mobiquo-Functions.php


注:本文中的setLoginCookie函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。