예제 #1
0
 public function actionOpenID()
 {
     Session::destroy(true);
     $secure = get_param($this->arguments, 0);
     $message = '';
     $this->render('', false);
     var_dump($secure);
     if (!$secure) {
         $message = 'Отсутствуют авторизационные данные';
     } else {
         // иначе - расшифровываем
         $plain = Cipher::decode($secure, PASSKEY);
         var_dump($plain);
         if (!$plain) {
             $message = 'Ошибка при расшифровке данных.';
         } else {
             // Проверка срока годности
             $dt = new DateTime();
             $dt->add(DateInterval::createFromDateString('5 minutes'));
             $expire = get_param($plain, 1) > $dt->format('Y-m-d H:i');
             $uid = get_param($plain, 0);
             //if ($expire) $message = 'Срок авторизации истек. Попробуйте еще раз.';
             $this->authdata = $this->model->openAuth($uid);
             if (!$this->authdata) {
                 $this->preparePopup("Ошибка авторизации.\nНет информации о данном пользователе.\nОбратитесь в отдел АСУ");
             } elseif (!get_param($this->authdata, 'rolename')) {
                 $this->preparePopup("Роль пользователя не определена.\nОбратитесь в отдел АСУ.", 'alert-warning');
             } else {
                 Session::set('auth', $this->authdata);
             }
         }
     }
     $this->data['error'] = $message;
     $this->render('info', false);
     $this->redirect(['location' => '/', 'soft' => intval(!empty($message)), 'delay' => 100]);
     $this->render('');
 }
예제 #2
0
파일: run.php 프로젝트: nickmartin90/cs_465
<?php

/**
 * Created by PhpStorm.
 * User: nickmartin
 * Date: 9/8/15
 * Time: 5:12 PM
 */
include_once 'cipher.php';
include_once 'aes.php';
$cipher = new Cipher();
$cipher->encode();
$cipher->decode();
//print_r($cipher->decode());