public function actionOwnerUpdate() { try { $model = parent::_dataLoad(new StAdmin(), $this->_admini['userId']); //首先从session中获取登录是的id号(yii框架自带) $data = StAdmin::model()->findByPk($this->_admini['userId']); //查询该用户并对该用户的密码进行更新 if (XUtils::method() == 'POST') { $id = $data['id']; $name = $data['name']; $password = $_POST['password']; $count = StAdmin::model()->updateByPk($id, array('name' => $name, 'password' => $password)); if ($count > 0) { AdminLogger::_create(array('catalog' => 'update', 'intro' => '修改密码:' . CHtml::encode($data['name']))); //日志 XUtils::message('success', '修改完成', $this->createUrl('adminLogin/index')); } else { XUtils::message('fail', '修改失败', $this->createUrl('adminLogin/ownerUpdate')); } } $this->render('ownerUpdate', array('data' => $data)); } catch (Exception $e) { echo var_dump($e); } }
public function actionLogin() { $username = $_REQUEST['username']; $password = $_REQUEST['password']; $temp = StAdmin::model()->findByPk($username); $temp = json_decode(CJSON::encode($temp), TRUE); if ($password == $temp['password']) { $retArr = array('flag' => 1, 'username' => $username); } else { $retArr = array('flag' => 0); } exit(json_encode($retArr)); }