Ejemplo n.º 1
0
 protected static function read()
 {
     if (self::$readed) {
         return;
     }
     $data = Cookies::get('DATA');
     if ($data) {
         $data = unserialize(base64_decode($data));
         self::$readed = true;
         self::$usuario = $data['usuario'];
         self::$contrasena = $data['contrasena'];
     }
 }
Ejemplo n.º 2
0
 public function __construct()
 {
     global $config;
     if (substr(Web::getIP(), 0, strlen($config['internal'])) == $config['internal']) {
         $this->viewOnly = false;
     }
     $this->userId = Cookies::get('uid');
     $this->logId = $this->log();
     switch ($_GET['w']) {
         case 'time':
             $this->return = $this->time;
             break;
         case 'resume':
             $this->return = $this->work();
             break;
         default:
             $this->return = $this->logId;
             break;
     }
 }
Ejemplo n.º 3
0
<?php

/**
 * @Author: lipeng
 * @Date:   2015-12-09 21:56:18
 * @Last Modified by:   lipeng
 * @Last Modified time: 2015-12-09 21:58:35
 */
date_default_timezone_set("PRC");
require './Cookies.class.php';
// 把用户名保存在cookie中
$username = $_GET['username'];
$Cookies = new Cookies();
$Cookies->set('username', $username);
echo $Cookies->get('username');
var_dump($_REQUEST);
var_dump($_COOKIE);
Ejemplo n.º 4
0
<?php

session_start();
if (!file_exists('/pages/install/install.php')) {
    spl_autoload_register(function ($class) {
        require 'inc/classes/' . $class . '.class.php';
    });
}
require_once 'sanitize.php';
if (!file_exists('pages/install/install.php')) {
    $db = DB::getInstance();
    if (Cookies::exists(Config::get('session/cookie_name')) && !Session::exists(Config::get('session/session_name'))) {
        $hash = Cookies::get(Config::get('session/cookie_name'));
        $hashCheck = $db->get('user_session', array('hash', '=', $hash));
        if ($hashCheck->count()) {
            $user = new User($hashCheck->first()->user_id);
            $user->login();
        }
    }
    ini_set('diplay_errors', Setting::get('debug'));
    $error_reporting = Setting::get('debug') == 'Off' ? '0' : '-1';
    error_reporting($error_reporting);
} else {
    error_reporting(-1);
}
Ejemplo n.º 5
0
$type = isset($_GET['type']) ? strtolower($_GET['type']) : '';
if (!in_array($type, array('set', 'get', 'update', 'clear'))) {
    exit('type not exists');
}
$obj = new Cookies('member', 10);
// obj
switch ($type) {
    case 'set':
        // 设置
        $data = array('name' => 'fdipzone', 'gender' => 'male');
        $obj->set('me', $data, 5);
        echo 'set cookies';
        break;
    case 'get':
        // 读取
        $result = $obj->get('me');
        echo '<pre>';
        print_r($result);
        echo '</pre>';
        echo 'get cookies';
        break;
    case 'update':
        // 更新
        $data = array('name' => 'angelababy', 'gender' => 'female');
        $flag = $obj->update('me', $data);
        if ($flag) {
            echo 'update cookies success';
        } else {
            echo 'update cookies false';
        }
        break;