index.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * 默认展示页面
  4. *
  5. * 默认展示页面
  6. *
  7. ***/
  8. defined('InShopNC') or exit('Access Invalid!');
  9. class indexControl extends SystemControl
  10. {
  11. public function __construct(){
  12. parent::__construct();
  13. Language::read('index');
  14. }
  15. public function indexOp()
  16. {
  17. //输出管理员信息
  18. Tpl::output('admin_info',$this->getAdminInfo());
  19. //输出菜单
  20. $this->getNav('',$top_nav,$left_nav,$map_nav);
  21. $this->init_notice($notice);
  22. Tpl::output('top_nav',$top_nav);
  23. Tpl::output('left_nav',$left_nav);
  24. Tpl::output('map_nav',$map_nav);
  25. Tpl::output('notice',$notice);
  26. Tpl::showpage('index','index_layout');
  27. }
  28. private function init_notice(&$notice)
  29. {
  30. $certs = Model('room')->roomCerts(['cstatus'=>0],'cert_id',false);
  31. if(empty($certs)){
  32. $notice['certs_num'] = 0;
  33. }else{
  34. $notice['certs_num'] = count($certs);
  35. }
  36. }
  37. /**
  38. * 退出
  39. */
  40. public function logoutOp(){
  41. setNcCookie('sys_key','',-1,'',null);
  42. @header("Location: index.php");
  43. exit;
  44. }
  45. /**
  46. * 修改密码
  47. */
  48. public function modifypwOp()
  49. {
  50. if (chksubmit())
  51. {
  52. if (trim($_POST['new_pw']) !== trim($_POST['new_pw2'])){
  53. //showMessage('两次输入的密码不一致,请重新输入');
  54. showMessage(Language::get('index_modifypw_repeat_error'));
  55. }
  56. $admininfo = $this->getAdminInfo();
  57. //查询管理员信息
  58. $admin_model = Model('admin');
  59. $admininfo = $admin_model->getOneAdmin($admininfo['id']);
  60. if (!is_array($admininfo) || count($admininfo)<= 0){
  61. showMessage(Language::get('index_modifypw_admin_error'));
  62. }
  63. //旧密码是否正确
  64. if ($admininfo['admin_password'] != md5(trim($_POST['old_pw']))){
  65. showMessage(Language::get('index_modifypw_oldpw_error'));
  66. }
  67. $new_pw = md5(trim($_POST['new_pw']));
  68. $result = $admin_model->updateAdmin(array('admin_password'=>$new_pw,'admin_id'=>$admininfo['admin_id']));
  69. if ($result){
  70. showMessage(Language::get('index_modifypw_success'));
  71. }else{
  72. showMessage(Language::get('index_modifypw_fail'));
  73. }
  74. }
  75. else
  76. {
  77. Language::read('admin');
  78. Tpl::showpage('admin.modifypw');
  79. }
  80. }
  81. }