Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
60
application/controllers/api/admin.php
Normal file
60
application/controllers/api/admin.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
require APPPATH . '/libraries/REST_Controller.php';
|
||||
|
||||
class Admin extends REST_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user