示例#1
0
 public static function check($token)
 {
     $tokenName = config::get('session/token_name');
     if (session::exists($tokenName) && $token === session::get($tokenName)) {
         session::delete($tokenName);
         return true;
     }
     return false;
 }
示例#2
0
 public function __construct($user = null)
 {
     $this->_db = DB::getInstance();
     $this->_sessionName = config::get('session/session_name');
     $this->_cookieName = config::get('remember/cookie_name');
     if (!$user) {
         if (session::exists($this->_sessionName)) {
             $user = session::get($this->_sessionName);
             if ($this->find($user)) {
                 $this->_isLoggedIn = true;
             } else {
             }
         }
     } else {
         $this->find($user);
     }
 }
示例#3
0
 public function __construct($user = null)
 {
     $this->_db = db::getInstance();
     $this->_session_name = config::get('session/session_name');
     $this->_cookie_name = config::get('remember/cookie_name');
     if (!$user) {
         if (session::exists($this->_session_name)) {
             $user = session::get($this->_session_name);
             if ($this->find($user)) {
                 $this->_is_logged_in = true;
             } else {
                 //process logout
             }
         }
     } else {
         $this->find($user);
     }
 }
示例#4
0
 public function __construct($UserID = null)
 {
     $this->_database = database::getInstance();
     $this->_sessionName = config::get('session/session_name');
     $this->_cookieName = config::get('remember/cookie_name');
     if (!$UserID) {
         if (session::exists($this->_sessionName)) {
             $UserID = session::get($this->_sessionName);
             if ($this->find($UserID)) {
                 $this->_isLoggedIn = true;
             } else {
                 // proceed to logout
                 $this->logout();
             }
         }
     } else {
         $this->find($UserID);
     }
 }
示例#5
0
 public function __construct($user = null, $log)
 {
     $this->_db = db::getInstance();
     $this->_sessionName = config::get('session/session_name');
     $this->_cookieName = config::get('remember/cookie_name');
     $this->_log = $log;
     if (!$user) {
         if (session::exists($this->_sessionName)) {
             //if remember cookie is used for login attempt
             $user = session::get($this->_sessionName);
             if ($this->find($user)) {
                 $this->_isLoggedIn = true;
             } else {
                 //logout
             }
         }
     } else {
         $this->find($user);
     }
 }
示例#6
0
<?php

session_start();
$GLOBALS['config'] = array('mysql' => array('host' => '127.0.0.1', 'username' => 'root', 'password' => 'Linode@11334455', 'db' => 'Booking'), 'remember' => array('cookie_name' => 'hash', 'cookie_expiry' => 604800), 'session' => array('session_name' => 'user', 'token_name' => 'token'));
//auto include classes
spl_autoload_register(function ($class) {
    require_once '../Classes/' . $class . '.php';
});
//include functions
require_once '../Functions/sanitize.php';
require_once '../vendor/autoload.php';
//$logger = new Katzgrau\KLogger\Logger('../Log',Psr\Log\LogLevel::DEBUG);
$_log = new Logger('../Log', Psr\Log\LogLevel::DEBUG);
//check whether cookie is stored and user logged in
if (cookie::exists(config::get('remember/cookie_name')) && !session::exists(config::get('session/session_name'))) {
    $hash = cookie::get(config::get('remember/cookie_name'));
    $hashCheck = db::getInstance();
    $hashCheck->get('User_Sessions', array('Hash', '=', $hash));
    if ($hashCheck->counts()) {
        $user = new user($hashCheck->first()->User_Id, $_log);
        $user->login();
    }
}
示例#7
0
 * $userUpdate=database::getInstance()->update('Users','Sreeks',array(
 * 'Password'=>'newpassword',
 * 'CurrentTown'=>'Arlington'
 * ));
 * if($userUpdate){
 * echo 'Updated';
 * }else{
 * echo 'error';
 * }
 */
/*
 * if(session::exists('Sucess!')){
 * echo session::flash('Sucess!');
 * }
 */
if (session::exists('home')) {
    echo '<p>' . session::flash('home') . '</p>';
}
$user = new user();
if ($user->isLoggedIn()) {
    ?>
<link href="<?php 
    echo 'style.css';
    ?>
" rel='stylesheet' type='text/css'>
<p>
	Hello <a
		href="profile.php?User=<?php 
    echo escape($user->data()->UserID);
    ?>
"><?php 
示例#8
0
     $hDB1->query($_CFG['SQL']['autocomplete_firm'],$_);
     $PageElement=$hDB1->fetch_field('value');}}

if (session::exists('firm_item_edit') and session::set('firm_item_name')){
   if($_REQUEST['term']==$_REQUEST['firm_item_name'] and mb_strlen($_REQUEST['firm_item_name'])>=3){
     $_['query_str']=trim(preg_replace('/( +)+|\+/',' ',$_REQUEST['firm_item_name']));
     $_['query_str']=substr(join('|',explode(' ',' '.$_['query_str'])),1);
     $hDB1->query($_CFG['SQL']['autocomplete_item'],$_);
     $PageElement=$hDB1->fetch_field('label');}}

if (session::exists('firm_address') and session::set('firm_town_id','firm_street_name')){
   if($_REQUEST['term']==$_REQUEST['firm_street_name'] and mb_strlen($_REQUEST['firm_street_name'])>=2){
     $_['town_id']=$_REQUEST['firm_town_id'];
     $_['query_str']=trim(preg_replace('/( +)+|\+/',' ',$_REQUEST['firm_street_name']));
     $_['query_str']=substr(join('|',explode(' ',' '.$_['query_str'])),1);
     $hDB1->query($_CFG['SQL']['autocomplete_street'],$_);
     $PageElement=$hDB1->fetch_field('label');}}

if (session::exists('export') and session::set('export_town_id','export_item_name')){
   if($_REQUEST['term']==$_REQUEST['export_item_name'] and mb_strlen($_REQUEST['export_item_name'])>=1){
     $_['query_str']=trim(preg_replace('/( +)+|\+/',' ',$_REQUEST['export_item_name']));
     $_['query_str']=substr(join('|',explode(' ',' '.$_['query_str'])),1);
     $hDB1->query($_CFG['SQL']['autocomplete_item'],$_);
     $PageElement=$hDB1->fetch_field('label');}}

header('Content-Type: application/json');
echo json_encode($PageElement);
$_hdebug = fopen("debug.html", "w+");
fwrite ($_hdebug,sprintf('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><pre>%s<hr>%s<hr>%s</pre></body><html>',var_export($_FRONT_END,true),var_export($hDB1->querylog,true),var_export($PageElement,true)));
fclose($_hdebug);
?>
示例#9
0
<?php

require_once '/opt/lampp/htdocs/MySpace/src/init.php';
if (session::exists('profile')) {
    echo '<p>' . session::flash('profile') . '</p>';
}
$user = new user();
if ($user->isLoggedIn()) {
    // $Lname=input::get('LastName');
    // echo $Fname." ".$Lname ;
    /*
     * if ($user->hasPermission ( 'admin' )) {
     * echo 'You are an admin';
     * }
     */
    // $currentID=$_SESSION['UserID'];
    // echo $currentID;
    $UserID2 = input::get('User');
    // $user= new user($UserID);
    if (!$UserID2 == input::get('User')) {
        redirect::to('index.php');
    } else {
        $user2 = new user($UserID2);
        if (!$user2->exists()) {
            redirect::to('404');
        } else {
            $data = $user2->data();
            ?>
<link href="<?php 
            echo 'style.css';
            ?>
示例#10
0
文件: xslt.php 项目: nyan-cat/easyweb
function wwwsession($type, $name)
{
    $xml = new xml();
    if (session::exists($name)) {
        switch ($type) {
            case 'value':
                $xml->append($xml->element($name, session::value($name)));
                break;
            case 'vector':
                foreach (session::vector($name) as $value) {
                    $xml->append($xml->element('value', $value));
                }
                break;
            case 'map':
                foreach (session::map($name) as $key => $value) {
                    $xml->append($xml->element($key, $value));
                }
                break;
            case 'xml':
                $xml = session::xml($name);
                break;
            case 'object':
                $xml = xml::json($name, session::value($name));
                break;
            default:
                runtime_error('Unknown session variable type: ' . $type);
        }
    }
    return $xml->get();
}
示例#11
0
<?php

require_once '/opt/lampp/htdocs/MySpace/src/init.php';
if (session::exists('friends')) {
    echo '<p>' . session::flash('friends') . '</p>';
}
$user = new user();
if ($user->isLoggedIn()) {
    if ($user->ShowFriends($user->data()->UserID)) {
        foreach ($user->friends() as $friend) {
            //echo 'hi';
            //echo $friend->FriendsWith;
            ?>
			<a 
			href="profile.php?User=<?php 
            echo escape($friend->FriendsWith);
            ?>
"><?php 
            echo escape($friend->FriendsWith);
            ?>
 </a><br>
		<?php 
        }
    }
}