Esempio n. 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;
     }
 }
Esempio n. 2
0
 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));
     //		}
 }
Esempio n. 3
0
 /**
  * delete Authorize/Authenticate url cookie
  */
 public function deleteAuthorizeCookie()
 {
     $this->Cookie->delete($this->_getAuthorizeUrlCookieName());
     $this->Cookie->delete($this->_getAuthenticateUrlCookieName());
 }