Profile.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace app\admin\controller\general;
  3. use app\common\controller\Backend;
  4. use fast\Random;
  5. /**
  6. * 个人配置
  7. *
  8. * @icon fa fa-user
  9. */
  10. class Profile extends Backend
  11. {
  12. /**
  13. * 查看
  14. */
  15. public function index()
  16. {
  17. if ($this->request->isAjax())
  18. {
  19. $model = model('AdminLog');
  20. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  21. $total = $model
  22. ->where($where)
  23. ->order($sort, $order)
  24. ->count();
  25. $list = $model
  26. ->where($where)
  27. ->order($sort, $order)
  28. ->limit($offset, $limit)
  29. ->select();
  30. $result = array("total" => $total, "rows" => $list);
  31. return json($result);
  32. }
  33. return $this->view->fetch();
  34. }
  35. /**
  36. * 更新个人信息
  37. */
  38. public function update()
  39. {
  40. if ($this->request->isPost())
  41. {
  42. $this->code = -1;
  43. $params = $this->request->post("row/a");
  44. $params = array_filter(array_intersect_key($params, array_flip(array('email', 'nickname', 'password'))));
  45. unset($v);
  46. if (isset($params['password']))
  47. {
  48. $params['salt'] = Random::alnum();
  49. $params['password'] = md5(md5($params['password']) . $params['salt']);
  50. }
  51. if ($params)
  52. {
  53. model('admin')->where('id', $this->auth->id)->update($params);
  54. $this->code = 1;
  55. }
  56. }
  57. return;
  58. }
  59. }