Example #1
0
 public function view()
 {
     $new = new BaseModelEncrypt();
     $x = $new->rsa_public_encode("-----3-----");
     $y = $new->rsa_private_decode($x);
     //echo "\n[ RSA PUB ENCODE ]:".$x."\n";
     echo "\n[ RSA PRI DECODE ]:" . $y . "\n";
     exit;
     $this->setView('hi', 'hello world!!!');
     $this->display('./hi.html');
 }
Example #2
0
 /**
  * load user, read cookie login
  */
 public function loadUser()
 {
     //read cookie
     $userCookie = $this->getUserCookie();
     if (!empty($userCookie)) {
         //decrept cookie
         $encryptModel = new BaseModelEncrypt();
         $userCookieSerialStr = $encryptModel->rsa_private_decode($userCookie);
         $userCookieArr = unserialize($userCookieSerialStr);
         //print_r($userCookieArr);
         if (!empty($userCookieArr['uid'])) {
             $userModelDb = new UserModelDB();
             //fetch db to validate register user
             $user = $userModelDb->getUserByUid($userCookieArr['uid']);
         }
         if (!empty($user)) {
             $this->uid = $user['id'];
             $this->email = $user['email'];
             $this->role = 'member';
         }
     }
     return array('uid' => $this->uid, 'email' => $this->email, 'ip' => $this->ip, 'ua' => $this->ua, 'role' => $this->role);
 }