Profile.php 1.7 KB

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