예제 #1
0
파일: util.php 프로젝트: himmelex/NTW
function common_remembered_user()
{
    $user = null;
    $packed = isset($_COOKIE[REMEMBERME]) ? $_COOKIE[REMEMBERME] : null;
    if (!$packed) {
        return null;
    }
    list($id, $code) = explode(':', $packed);
    if (!$id || !$code) {
        common_log(LOG_WARNING, 'Malformed rememberme cookie: ' . $packed);
        common_forgetme();
        return null;
    }
    $rm = Remember_me::staticGet($code);
    if (!$rm) {
        common_log(LOG_WARNING, 'No such remember code: ' . $code);
        common_forgetme();
        return null;
    }
    if ($rm->user_id != $id) {
        common_log(LOG_WARNING, 'Rememberme code for wrong user: '******' != ' . $id);
        common_forgetme();
        return null;
    }
    $user = User::staticGet($rm->user_id);
    if (!$user) {
        common_log(LOG_WARNING, 'No such user for rememberme: ' . $rm->user_id);
        common_forgetme();
        return null;
    }
    // successful!
    $result = $rm->delete();
    if (!$result) {
        common_log_db_error($rm, 'DELETE', __FILE__);
        common_log(LOG_WARNING, 'Could not delete rememberme: ' . $code);
        common_forgetme();
        return null;
    }
    common_log(LOG_INFO, 'logging in ' . $user->nickname . ' using rememberme code ' . $rm->code);
    common_set_user($user);
    common_real_login(false);
    // We issue a new cookie, so they can log in
    // automatically again after this session
    common_rememberme($user);
    return $user;
}
<?php

if (!defined('EXT')) {
    exit('Invalid file request');
}
if (session_id() == '') {
    session_start();
}
$plugin_info = array('pi_name' => 'Remember Me', 'pi_version' => '1.1', 'pi_author' => 'Wouter Vervloet', 'pi_author_url' => 'http://www.baseworks.nl/', 'pi_description' => 'Save entries for a user to do something with them on (another) page.', 'pi_usage' => Remember_me::usage());
/**
* Remember Me Plugin class 
*
* @package		  remember_me.ee2_addon
* @version			1.1
* @author			  Wouter Vervloet <*****@*****.**>
* @license			http://creativecommons.org/licenses/by-sa/3.0/
*/
class Remember_me
{
    /**
     * Plugin return data
     *
     * @var	string
     */
    var $return_data;
    /**
     * Remember me storage
     *
     * @var	array
     */
    var $_storage = array();