Exemplo n.º 1
0
 public function index($data = '')
 {
     $this->init();
     //if(true){
     //$json['auth'] = "53eeaa3c42106e0ba802d8cbde17b8f6";
     //$data = $this->encode($json);
     //}
     if ($data = $this->decode($data)) {
         $auth = trim(get_std($data, 'auth', ''));
         if (is_alpha_numeric($auth)) {
             $where['auth'] = $auth;
             if (!($rows = $this->User_model->get_where_case_sensitivity($where))) {
                 $response['status'] = 3;
                 $response['alert'] = 'auth不存在.';
                 echo $this->encode($response);
             } else {
                 if (!$rows[0]['vip']) {
                     $response['status'] = 4;
                     $response['alert'] = '帳號未升級.';
                     echo $this->encode($response);
                 } else {
                     $date = date('Y-m-d', time());
                     $sql = "SELECT * FROM `knowledge` WHERE `switch` = 1 AND `date` <= '{$date}' ORDER BY `date` DESC";
                     if ($rows = $this->Knowledge_model->query($sql)) {
                         $response['status'] = 1;
                         $response['knowledge'] = $rows;
                         $response['alert'] = '查詢成功.';
                         echo $this->encode($response);
                     } else {
                         $response['status'] = 5;
                         $response['alert'] = '沒有資料.';
                         echo $this->encode($response);
                     }
                 }
             }
         } else {
             $response['status'] = 2;
             $response['alert'] = 'auth的格式不正確.';
             echo $this->encode($response);
         }
     } else {
         $response['status'] = 0;
         $response['alert'] = '資料傳輸錯誤, 請稍後再試.';
         echo $this->encode($response);
     }
 }
Exemplo n.º 2
0
 public function index($data = '')
 {
     $this->init();
     if (true) {
         //$json['auth'] = "85ace4027df3c500fd9a6099a625f111";
         //$data = $this->encode($json);
     }
     if ($data = $this->decode($data)) {
         $auth = trim(get_std($data, 'auth', ''));
         if (is_alpha_numeric($auth)) {
             $where['auth'] = $auth;
             if (!($rows = $this->User_model->get_where_case_sensitivity($where))) {
             } else {
                 if ($rows[0]['vip']) {
                     $date = date('Y-m-d', time());
                 } else {
                     $N = date('N', time());
                     if ($N >= 4) {
                         $date = date('Y-m-d', time() - ($N - 4) * 86400);
                     } else {
                         $date = date('Y-m-d', time() - ($N - 1) * 86400);
                     }
                 }
                 if ($rows = $this->Knowledge_model->get_where_order(array('date' => $date, 'switch' => 1))) {
                     //前端.
                     $js[] = site_url('config');
                     $js[] = base_url('js/jquery-2.1.0.min.js');
                     $this->layout['js'] = js_links($js);
                     $this->layout['js'] .= js_link(base_url('js/jquery.mobile-1.4.2/jquery.mobile-1.4.2.min.js'));
                     $this->layout['css'] = css_link(base_url('js/jquery.mobile-1.4.2/jquery.mobile-1.4.2.min.css'));
                     $this->layout['title'] = $rows[0]['title'];
                     $this->layout['content'] = $this->load->view('main_index', array('title' => $rows[0]['title'], 'content' => $rows[0]['knowledge']), true);
                     $this->load->view('layout/mobile', $this->layout);
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public function edit_password($data = '')
 {
     $this->init();
     if ($data = $this->decode($data)) {
         $auth = trim(get_std($data, 'auth', ''));
         $password = get_std($data, 'password', false);
         $next_password = get_std($data, 'next_password', false);
         if (is_alpha_numeric($auth)) {
             if (is_alpha_dash($password) and is_alpha_dash($next_password)) {
                 $where['auth'] = $auth;
                 if (!($rows = $this->User_model->get_where_case_sensitivity($where))) {
                     $response['status'] = 4;
                     $response['alert'] = 'auth不存在.';
                     echo $this->encode($response);
                 } else {
                     if ($rows[0]['password'] != md5($password)) {
                         $response['status'] = 5;
                         $response['alert'] = '原密碼不正確.';
                         echo $this->encode($response);
                     } else {
                         $this->User_model->update_where($where, array('password' => md5($next_password)));
                         //回應.
                         $response['status'] = 1;
                         $response['alert'] = '修改完成.';
                         echo $this->encode($response);
                     }
                 }
             } else {
                 $response['status'] = 3;
                 $response['alert'] = '密碼的格式不正確.';
                 echo $this->encode($response);
             }
         } else {
             $response['status'] = 2;
             $response['alert'] = 'auth的格式不正確.';
             echo $this->encode($response);
         }
     } else {
         $response['status'] = 0;
         $response['alert'] = '資料傳輸錯誤, 請稍後再試.';
         echo $this->encode($response);
     }
 }