IndexController.class.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. namespace Admin\Controller;
  3. use Common\Controller\AdminController;
  4. class IndexController extends AdminController {
  5. public function __construct(){
  6. parent::__construct();
  7. }
  8. public function index() {
  9. $flag = I('flag',1);
  10. $dayType = I('day_type',3);
  11. $startDate = I('start_date');
  12. $endDate = I('end_date');
  13. $dayList = array(
  14. 1=>array('startDate'=>date('Y-m-d'),'endDate'=>date('Y-m-d',strtotime('+1 day'))),
  15. 2=>array('startDate'=>date('Y-m-d',strtotime('-1 day')),'endDate'=>date('Y-m-d')),
  16. 3=>array('startDate'=>date('Y-m-d',strtotime('-7 day')),'endDate'=>date('Y-m-d')),
  17. 4=>array('startDate'=>date('Y-m-d',strtotime('-30 day')),'endDate'=>date('Y-m-d')),
  18. );
  19. if (empty($startDate)||empty($endDate)){
  20. $startDate = $dayList[$dayType]['startDate'];
  21. $endDate = $dayList[$dayType]['endDate'];
  22. }
  23. if ($flag==1){
  24. $startDate = $dayList[$dayType]['startDate'];
  25. $endDate = $dayList[$dayType]['endDate'];
  26. }
  27. $startTime = strtotime($startDate);
  28. $endTime = strtotime($endDate);
  29. if ($endTime<2){
  30. $this->error('结束时间错误');
  31. }
  32. //统计全部
  33. $info = M('Sta')->field('sum(sta_reg) reg,sum(sta_normal) normal,sum(sta_rank) rank,sum(sta_pve) pve')->find();
  34. //分天统计
  35. $condition = array('operate_dt'=>array('BETWEEN',array($startTime,$endTime+1)));
  36. $staRes = M('Sta')->where($condition)->field('sta_reg, sta_normal, sta_rank, sta_pve, operate_dt')->select();
  37. foreach ($staRes as $row){
  38. $staList[$row['operate_dt']] = array('reg'=>$row['sta_reg'], 'normal'=>$row['sta_normal'], 'rank'=>$row['sta_rank'], 'pve'=>$row['sta_pve']);
  39. }
  40. $xAxis = '';
  41. $yAxisReg = '';
  42. $yAxisPve = '';
  43. $yAxisRank = '';
  44. $yAxisNormal = '';
  45. for($i=$startTime;$i<=$endTime;$i=$i+86400){
  46. $xAxis .= "'".date('md',$i)."',";
  47. if (isset($staList[$i])){
  48. $yAxisPve .= $staList[$i]['pve'].',';
  49. $yAxisReg .= $staList[$i]['reg'].',';
  50. $yAxisRank .= $staList[$i]['rank'].',';
  51. $yAxisNormal .= $staList[$i]['normal'].',';
  52. }else{
  53. $yAxisPve .= '0,';
  54. $yAxisReg .= '0,';
  55. $yAxisRank .= '0,';
  56. $yAxisNormal .= '0,';
  57. }
  58. }
  59. $xAxis = substr($xAxis, 0, -1);
  60. $yAxisPve = substr($yAxisPve, 0, -1);
  61. $yAxisReg = substr($yAxisReg, 0, -1);
  62. $yAxisRank = substr($yAxisRank, 0, -1);
  63. $yAxisNormal = substr($yAxisNormal, 0, -1);
  64. $this->assign('info',$info);
  65. $this->assign('xAxis', $xAxis);
  66. $this->assign('yAxisPve',$yAxisPve);
  67. $this->assign('yAxisReg', $yAxisReg);
  68. $this->assign('yAxisRank', $yAxisRank);
  69. $this->assign('yAxisNormal', $yAxisNormal);
  70. $this->assign('dayType', $dayType);
  71. $this->assign('endDate',$endDate);
  72. $this->assign('startDate',$startDate);
  73. $this->display();
  74. }
  75. public function pwd(){
  76. $step = I('step','');
  77. $adminId = session('admin_id');
  78. $info = M('Admin')->where(array('admin_id'=>$adminId))->field('admin_account,admin_pwd')->find();
  79. if (empty($step)){
  80. $this->assign('info',$info);
  81. $this->display();
  82. }else if($step==2){
  83. $oldPwd = I('old_pwd');
  84. $newPwd = I('new_pwd');
  85. $newRepwd = I('new_repwd');
  86. if (mb_strlen($oldPwd,'UTF8')<6 || mb_strlen($oldPwd,'UTF8')>20){
  87. $this->error('旧密码长度6到20之间');
  88. }
  89. if (mb_strlen($newPwd,'UTF8')<6 || mb_strlen($newPwd,'UTF8')>20){
  90. $this->error('新密码长度6到20之间');
  91. }
  92. if ($newPwd!==$newRepwd){
  93. $this->error('两次输入的新密码不一致,请重新输入');
  94. }
  95. if ($info!=NULL && $info['admin_pwd']!=md5($info['admin_pwd'])){
  96. $this->error('输入的原密码有误,请重新输入');
  97. }
  98. M('Admin')->where(array('admin_id'=>$adminId))->save(array('admin_pwd'=>md5($newPwd)));
  99. $this->success('修改密码成功','/admin/index/index');
  100. }
  101. }
  102. }