Initial import from local backup (Documents-Playground/pakerpale)
This commit is contained in:
53
homestead/application/core/MY_Controller.php
Normal file
53
homestead/application/core/MY_Controller.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class MY_Controller extends CI_Controller
|
||||
{
|
||||
|
||||
|
||||
const KEY = 'ctnews^L3wvaMt8GLAatZLE';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// if (!$this->validate()) {
|
||||
// die('Invalid Access');
|
||||
// }
|
||||
}
|
||||
|
||||
protected function response($code, $message, $data)
|
||||
{
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode([
|
||||
'code' => $code,
|
||||
'message' => $message,
|
||||
'data' => $data
|
||||
]));
|
||||
}
|
||||
|
||||
public function validate()
|
||||
{
|
||||
$headers = $this->input->request_headers();
|
||||
if (!empty($headers['ctaccesstoken'])) {
|
||||
$this->load->library('encryption');
|
||||
$this->encryption->initialize(
|
||||
array(
|
||||
'cipher' => 'aes-256',
|
||||
'mode' => 'ctr',
|
||||
'key' => '2UFdhHgY5n5Smd5RnD3H8Z6rKJ8j3zra'
|
||||
)
|
||||
);
|
||||
$headers = $this->input->request_headers();
|
||||
$token = $this->encryption->decrypt($headers['ctaccesstoken']);
|
||||
|
||||
$token = explode('.T', $token);
|
||||
|
||||
if ($token[0] == self::KEY) {
|
||||
if (base64_decode($token[1]) > time() - 5) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user