controller ? $this->controller : strtolower($this->getId()); } private function _getAction() { return $this->action ? $this->action : strtolower($this->getAction()->getId()); } // 初始化 public function init() { parent::init(); $presentRequestUrl = Yii::app()->request->getPathInfo(); if (isset($_GET['user_id']) && $_GET['sig']) { $UserId = safe_replace($_GET['user_id']); // 登录名 $loginSig = safe_replace($_GET['sig']); // 加密值 if (empty($UserId) || empty($loginSig) ) { echo ''; exit(); } // 获取助教信息 $appFindUser = AssistUser::model()->findByPk($UserId)->attributes; if (empty($appFindUser)) { echo ''; exit(); } //读取session $sessionData=Yii::app()->cache->getValue($loginSig); if(!$sessionData){ echo ''; exit(); } $sessionData=json_decode($sessionData,true); if($sessionData['user_id']!=$UserId){ echo ''; exit(); } Yii::app()->session['user'] = $appFindUser; return true; } else { if (!isset(Yii::app()->session['user'])) { if (!in_array($presentRequestUrl, self::$guestAcl)) { echo ''; exit(); } } } } // 相关动作执行前操作 protected function beforeAction($action) { //读取基础学科 $basicSubject=ASubject::model()->findAll(); $subjectIdArr=array(); if($basicSubject){ foreach ($basicSubject as $item){ $subjectIdArr[$item->subject_id]=$item->subject_name; } } if(!$subjectIdArr){ Yii::app()->jump->error('无法获取科目信息'); } Yii::app()->params['subjectId']=$subjectIdArr; return true; //} } public function output($code, $msg, $rs = null) { $arr = array("success" => $code, "message" => $msg); if ($rs) { $rs = Arr::pack($arr, $rs); } else { $rs = $arr; } echo json_encode($rs); exit(); } /** * 生成密码 * @param $password * @param string $saltOne * @param string $saltTwo * @return string */ public static function producePassword($password, $saltOne = 'ywy', $saltTwo = 'zxhx') { $password = empty($password) ? '123456' : $password; return md5(sha1($password . $saltOne) . $saltTwo); } }