Example #1
2
 /**
  * check_login方法,获取操作员名称.
  *
  * @return bool 返回成功失败
  */
 public function check_login()
 {
     $conf = new Configure();
     $cookie = new CookieComponent();
     $cookie->key = $conf->read('Security.salt');
     $cookie_session = $cookie->read('session');
     $session = isset($cookie_session) && $cookie_session != '' ? $cookie_session : session_id();
     $operator = $this->findBySession($session);
     if (isset($operator['Operator']['id'])) {
         return $operator['Operator'];
     } else {
         return false;
     }
 }
Example #2
0
 /**
  * make OAuth Authenticate URL
  *
  * @param string $callback_url
  * @param bool   $use_cookie
  * @return string authorize_url
  */
 public function getAuthenticateUrl($callback_url = null, $use_cookie = false)
 {
     // -- check Cookie
     $cookie_key = $this->_getAuthenticateUrlCookieName();
     if ($use_cookie && $this->Cookie->read($cookie_key)) {
         return $this->Cookie->read($cookie_key);
     }
     // -- request token
     $token = $this->DataSource->oauth_request_token($callback_url);
     $url = $this->DataSource->oauth_authenticate();
     // -- set cookie
     if ($use_cookie) {
         $this->Cookie->write($cookie_key, $url, true, self::OAUTH_URL_COOKIE_EXPIRE);
     }
     return $url;
 }
 public function log($info, $adminid)
 {
     $conf = new Configure();
     $cookie = new CookieComponent();
     $cookie->key = $conf->read('Security.salt');
     $cookie_session = $cookie->read('session');
     $session = isset($cookie_session) && $cookie_session != '' ? $cookie_session : session_id();
     //echo $session;die;
     $remak = empty($_POST) ? '' : 'post|' . serialize($_POST);
     $remak .= empty($_GET) ? '' : 'get|' . serialize($_GET);
     $loginfo = $this->find('first', array('conditions' => array('OperatorLog.operator_id' => $adminid), 'order' => 'OperatorLog.created desc'));
     //		$now=strtotime(date("Y-m-d H:i:s"));//转换成时间戳和最后修改时间相减除以60s得出分钟
     //		$lasttime=strtotime($loginfo['OperatorLog']['created']);
     //		$time_difference=(int)(($now-$lasttime)/60);//相差多少分钟
     if ($loginfo['OperatorLog']['session_id'] == $session) {
         //session相同,在日志内容中追加日志
         $logdata['OperatorLog']['id'] = $loginfo['OperatorLog']['id'];
         $logdata['OperatorLog']['info'] = $info . '<br>' . $loginfo['OperatorLog']['info'];
         $logdata['OperatorLog']['action_url'] = $this->AbsoluteUrl() . '<br>' . $loginfo['OperatorLog']['action_url'];
         $logdata['OperatorLog']['remark'] = $remak . '<br>' . $loginfo['OperatorLog']['remark'];
         $this->save($logdata);
     } else {
         $OperatorLogs = array('operator_id' => $adminid, 'session_id' => $session, 'ipaddress' => $this->real_ip(), 'action_url' => $this->AbsoluteUrl(), 'info' => $info, 'type' => 1, 'remark' => $remak);
         $this->saveAll(array('OperatorLog' => $OperatorLogs));
     }
     //		if($time_difference<=20){
     //			//在20分钟以内,在日志内容中追加日志
     //			$logdata['OperatorLog']['id']=$loginfo['OperatorLog']['id'];
     //			$logdata['OperatorLog']['info']=$info.'<br>'.$loginfo['OperatorLog']['info'];
     //			$logdata['OperatorLog']['action_url']=$this->AbsoluteUrl().'<br>'.$loginfo['OperatorLog']['action_url'];
     //			$logdata['OperatorLog']['remark']=$remak.'<br>'.$loginfo['OperatorLog']['remark'];
     //			$this->save($logdata);
     //		}else{
     //			//在20分钟以外,添加新日志
     //			/* 增加记录post和get参数 */
     //			$OperatorLogs = array(
     //				"operator_id"=>$adminid,
     //				"ipaddress"=>$this->real_ip(),
     //				"action_url"=>$this->AbsoluteUrl(),
     //				"info"=>$info,
     //				"type"=>1,
     //				"remark"=>$remak
     //			);
     //			$this->saveAll(array("OperatorLog"=>$OperatorLogs));
     //		}
 }