load->library('session'); } public function login_get() { if ($login = $this->get('login')) { parse_str(base64_decode($login), $user); $this->session->set_userdata($user); if($this->session->userdata('username')) { header('location:'. ($this->get('redirect') ? $this->get('redirect') : '/')); } } } private function loginCheck() { return $this->session->userdata('username'); } public function station_schedule_get() { if ($this->loginCheck()) { $this->load->model('station_schedule_model'); if(!$this->get('categoryId') || !$this->get('dayName')) { $this->res(402, 'Preconfigure required'); }else { $schedules = $this->station_schedule_model->findSchedulesByCategoryIdAndDayName($this->get('categoryId'), $this->get('dayName'))->result(); $this->res(200, 'Success', $schedules); } } else { $this->res(401, 'Not authorized'); } } public function station_schedule_post() { if ($this->loginCheck()) { $this->load->model('station_schedule_model'); if(!$this->post('categoryId') || !$this->post('dayName') || !$this->post('data')) { $this->res(402, 'Preconfigure required'); }else { $schedules = $this->station_schedule_model ->insertSchedules($this->post('categoryId'), $this->post('dayName'), json_decode($this->post('data'), true)); $this->res(200, 'Success', $schedules); } } else { $this->res(401, 'Not authorized'); } } }