コード例 #1
0
ファイル: journal.php プロジェクト: ready4god2513/Journal
 /**
  * Decrypt the data when taking it out of the database
  * @Developer brandon
  * @Date May 18, 2010
  */
 public function __get($key)
 {
     $value = parent::__get($key);
     if (in_array($key, array('content', 'title'))) {
         if ($value) {
             $encrypt = new Encrypt();
             $value = $encrypt->decode($value);
         }
     }
     return $value;
 }
コード例 #2
0
ファイル: message.php プロジェクト: jawngee/HeavyMetal
 public static function Next($account, $queue)
 {
     $q = MessageQueue::Get($account);
     try {
         $message = $q->receive(1);
         $c = new Encrypt();
         $message = $c->decode($message);
         return new Message($account, $queue, $message);
     } catch (AWSException $ex) {
         return null;
     }
 }
コード例 #3
0
ファイル: Form.php プロジェクト: gclove/shadowsocks-panel
 public function ChangeSSPwd()
 {
     $result = array('error' => 1, 'message' => '修改失败');
     $uid = trim($_GET['uid']);
     $user_cookie = explode('\\t', Encrypt::decode(base64_decode($_COOKIE['auth']), COOKIE_KEY));
     $sspwd = trim($_GET['sspwd']);
     if ('' == $sspwd || null == $sspwd) {
         $sspwd = Util::GetRandomPwd();
     }
     if ($uid == $user_cookie[0]) {
         $user = UserModel::GetUserByUserId($uid);
         $user->sspwd = $sspwd;
         $user->updateUser();
         $result = array('error' => 1, 'message' => '修改SS连接密码成功');
     }
     echo json_encode($result);
     exit;
 }
コード例 #4
0
ファイル: auth.php プロジェクト: Ryanker/open-eshop
 public function action_unsubscribe()
 {
     $email_encoded = $this->request->param('id');
     $user = new Model_User();
     //mail encoded
     if ($email_encoded !== NULL) {
         //decode emails
         $email_encoded = Base64::fix_from_url($email_encoded);
         $encrypt = new Encrypt(Core::config('auth.hash_key'), MCRYPT_MODE_NOFB, MCRYPT_RIJNDAEL_128);
         $email = $encrypt->decode($email_encoded);
         if (Valid::email($email, TRUE)) {
             //check we have this email in the DB
             $user = new Model_User();
             $user = $user->where('email', '=', $email)->limit(1)->find();
         } else {
             Alert::set(Alert::INFO, __('Not valid email.'));
         }
     } elseif (Auth::instance()->logged_in()) {
         $user = Auth::instance()->get_user();
     }
     //lets unsubscribe the user
     if ($user->loaded()) {
         $user->subscriber = 0;
         $user->last_modified = Date::unix2mysql();
         try {
             $user->save();
             Alert::set(Alert::SUCCESS, __('You have successfuly unsubscribed'));
         } catch (Exception $e) {
             //throw 500
             throw HTTP_Exception::factory(500, $e->getMessage());
         }
     } else {
         Alert::set(Alert::INFO, __('Pleae login to unsubscribe.'));
     }
     //smart redirect
     if (Auth::instance()->logged_in()) {
         $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'edit')));
     } else {
         $this->redirect(Route::url('default'));
     }
 }
コード例 #5
0
 /**
  * Tests for decode when the string is not valid base64,
  * or is too short to contain a valid IV
  *
  * @param type $key
  * @param type $mode
  * @param type $cipher
  * @param type $txt_encoded
  *
  * @dataProvider provider_decode_invalid_data
  */
 public function test_decode_invalid_data($key, $mode, $cipher, $txt_invalid_encoded)
 {
     // initialize
     $e = new Encrypt($key, $mode, $cipher);
     // assert
     $this->AssertFalse($e->decode($txt_invalid_encoded));
 }
コード例 #6
0
ファイル: session.php プロジェクト: jawngee/Thor
	/**
	 * Generates the auth ticket and auto login cookies for a validated user
	 * 
	 * @param bool $remember_login Should the user's login info be remembered for auto-login?
	 */
	protected function load_ticket($ticket=null)
	{
		// get the ticket cookie
		if ($ticket==null)
			$ticket=get_cookie(self::$_config->auth_ticket_cookie);
		
		if ($ticket==false)
			return;

		$encrypter=new Encrypt();
		// decrypt the auth ticket
		
		$ass=$encrypter->decode($ticket);

		$content=explode("|@@!@@|",$ass);
		if (count($content)>1)
			$this->data=unserialize($content[0]);
	}
コード例 #7
0
ファイル: Util.php プロジェクト: dreammes/shadowsocks-panel
 public static function getToken($tokenName = "token")
 {
     $token = time() - Encrypt::decode(base64_decode(@$_COOKIE[$tokenName]), COOKIE_KEY);
     return $token;
 }
コード例 #8
0
ファイル: index.php プロジェクト: dalinhuang/ozgweb
<?php

require "init.php";
$act = isset($_REQUEST["act"]) ? $_REQUEST["act"] : "default";
if ($act == "default") {
    $smarty->assign('web_name', constant("WEB_NAME"));
    if (isset($_COOKIE["curr_user_name"])) {
        //一周内自动登录
        $name = str_filter(urldecode($_COOKIE["curr_user_name"]));
        $name = Encrypt::decode($name);
        $sql = "select * from user where name = '" . $name . "'";
        $user = $db->get_row($sql, ARRAY_A);
        unset($user["pwd"]);
        $_SESSION["curr_user"] = $user;
        $user["err_login"] = 0;
        $id = $user["id"];
        unset($user["id"]);
        $db->query(SqlText::update("user", $user, "id = " . $id));
        header("location:admin_index.php");
        exit;
    } elseif (isset($_SESSION["curr_user"])) {
        header("location:admin_index.php");
        exit;
    }
    $smarty->display(WEBPATH_ADMIN . '/index.html');
} elseif ($act == "login") {
    $name = str_filter($_REQUEST["name"]);
    $pwd = str_filter($_REQUEST["pwd"]);
    $sql = "select * from user where name = '" . $name . "'";
    $user = $db->get_row($sql, ARRAY_A);
    if ($user) {