first commit

This commit is contained in:
kicap1992
2021-04-07 03:07:13 +08:00
commit 47ef4f9ec5
470 changed files with 211306 additions and 0 deletions

View File

@ -0,0 +1,68 @@
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, DELETE, PUT');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization');
header('Access-Control-Allow-Credentials: true');
header('Content-Type: application/json');
defined('BASEPATH') or exit('No direct script access allowed');
use chriskacerguis\RestServer\RestController;
class Api extends RestController
{
function __construct()
{
parent::__construct();
// $this->load->model('model');;
// $this->db->query("SET sql_mode = '' ");
}
public function index_get()
{
$this->response(['message' => 'Halo Bosku'], 200);
// redirect(base_url());
}
// -----------------------------------------------------------------------------------------------------------
public function login_post()
{
// if ($this->post("proses") == "login") {
// $data = $this->model->serialize($this->post('data'));
// $username = $this->post("username");
// $password = $this->post("password");
// // // print_r($data);
// // $result = $this->model->tampil_data_where('tb_login',$data)->result();
// $result = $this->model->tampil_data_where('tb_login',array("username" => $username, "password" => $password))->result();
// print_r($result[0]->nik);
// if (count($result) > 0) {
// $this->session->set_userdata('login', array("level" => "admin" , "nik" => $result[0]->nik));
$this->session->set_userdata('login', array("level" => "admin" ));
// // print_r("data ada");
// $this->response(['res' => "ok"], 200);
// }else{
// $this->response(['res'=> "ko"],404);
// }
$this->response(['res' => "ok"], 200);
// }else{
// $this->response(['res' => "ko"], 400);
// }
}
// public function login_delete()
// {
// $nim = $this->get('nim');
// print_r($this->get('nim'));
// print_r($this->post('proses'));
// }
}

View File

@ -0,0 +1,86 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Home extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('model');
}
function index()
{
// $this->load->view('home/login');
// print_r('sini login');
if ($this->input->post('proses') == 'login') {
// print_r('sini login asdasd');
$username = $this->input->post('username');
$password = $this->input->post('password');
$cek_data =$this->model->tampil_data_where('tb_login',['username' =>$username , 'password' =>$password ])->result();
// print_r($cek_data[0]->level);
if (count($cek_data) > 0) {
switch ($cek_data[0]->level) {
case 'admin':
$this->output->set_status_header(200)->set_content_type('application/json')->set_output(json_encode(array("res" => "ok" , 'level' => $cek_data[0]->level, 'nik' => $cek_data[0]->nik_admin)));
break;
case 'user':
$this->output->set_status_header(200)->set_content_type('application/json')->set_output(json_encode(array("res" => "ok" , 'level' => $cek_data[0]->level, 'nik' => $cek_data[0]->nik_user)));
break;
}
}
else
{
$this->output->set_status_header(400)->set_content_type('application/json')->set_output(json_encode(array("res" => "ko" )));
}
}
else if ($this->input->post('proses') == 'cek_data') {
// print_r('cek data');
$nik = $this->input->post('nik');
$level = $this->input->post('level');
// print_r($level);
$cek_data =$this->model->tampil_data_where('tb_login',['nik_'.$level =>$nik ])->result();
// print_r(count($cek_data));
if (count($cek_data) > 0) {
print_r(json_encode(['res' => 'ok' , 'url' => $level.'/']));
}
else
{
print_r(json_encode(['res' => 'ko' ]));
}
}
else if ($this->input->post('proses') == 'cek_data_detail') {
// print_r('cek data');
$nik = $this->input->post('nik');
$level = $this->input->post('level');
// print_r($level);
$cek_data =$this->model->tampil_data_where('tb_'.$level,['nik_'.$level =>$nik ])->result();
// print_r(count($cek_data));
if (count($cek_data) > 0) {
print_r(json_encode(['res' => 'ok' , 'nama' => $cek_data[0]->nama]));
}
else
{
print_r(json_encode(['res' => 'ko' ]));
}
}
}
}
?>

View File

@ -0,0 +1,25 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->view('welcome_message');
}
}

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>