You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.5 KiB
43 lines
1.5 KiB
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Page_error_handler extends MY_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
//parent::__construct();
|
|
$this->my_parent_controller();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$this->check_route();
|
|
// Whoops, we don't have a page for that!
|
|
//show_404();
|
|
$this->output->set_status_header('404');
|
|
$data['content'] = 'error_404'; // View name
|
|
$data['heading'] = 'Page Not Found'; // View name
|
|
$data['message'] = 'The page you requested was not found on this site.'; // View name
|
|
$this->load->view('error_404',$data);//loading in my template
|
|
}
|
|
|
|
private function check_route() {
|
|
$requestURI = $this->uri->segment_array();
|
|
$requestHeaders = $this->input->request_headers();
|
|
|
|
if( $requestURI && $requestHeaders) {
|
|
if ( (in_array('api', $requestURI) && in_array('v1', $requestURI)) && (isset($requestHeaders['API-KEY']) && isset($requestHeaders['API-ID'])) ) {
|
|
$this->output->set_status_header(404)
|
|
->set_content_type('application/json', 'utf-8')
|
|
->set_output(json_encode([
|
|
"error" => [
|
|
"code" => 404,
|
|
"type" => "not found",
|
|
"message" => 'The link you requested was not found on this site.'
|
|
]
|
|
]))
|
|
->_display();
|
|
exit(0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|