12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- namespace app\admin\controller\general;
- use app\admin\model\Admin;
- use app\common\controller\Backend;
- use fast\Random;
- use think\Session;
- class Profile extends Backend
- {
-
- public function index()
- {
-
- $this->request->filter(['strip_tags']);
- if ($this->request->isAjax())
- {
- $model = model('AdminLog');
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $total = $model
- ->where($where)
- ->where('admin_id', $this->auth->id)
- ->order($sort, $order)
- ->count();
- $list = $model
- ->where($where)
- ->where('admin_id', $this->auth->id)
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
- $result = array("total" => $total, "rows" => $list);
- return json($result);
- }
- return $this->view->fetch();
- }
-
- public function update()
- {
- if ($this->request->isPost())
- {
- $params = $this->request->post("row/a");
- $params = array_filter(array_intersect_key($params, array_flip(array('email', 'nickname', 'password', 'avatar'))));
- unset($v);
- if (isset($params['password']))
- {
- $params['salt'] = Random::alnum();
- $params['password'] = md5(md5($params['password']) . $params['salt']);
- }
- if ($params)
- {
- $admin = Admin::get($this->auth->id);
- $admin->save($params);
-
- Session::set("admin", $admin->toArray());
- $this->success();
- }
- $this->error();
- }
- return;
- }
- }
|