logout(); header('Location: /'); } if (isset($_SERVER['HTTP_X_QUERY'])) { // $obj = new Home(); // $obj->logout(); // header('Location: /'); $query_string = $this->getQueryStringVariable($_SERVER['HTTP_X_QUERY']); $sessid = explode('=', $query_string[0]); $sessid = $sessid[1]; $userid = explode('=', $query_string[1]); $userid = $userid[1]; // Check if user login $session = \App\Models\ClientSession::fetch([ 'uid' => $userid, 'id' => $sessid ]); if (is_array($session)) { $token = Token::generate($userid); header("X-Token: $token"); } else { $response = []; $response['status'] = 401; $response['message'] = 'Unauthorized'; echo json_encode($response); die(); // $ip_address = isset($_SERVER['HTTP_X_FORWADED_FOR']) ? $_SERVER['HTTP_X_FORWADED_FOR'] : $_SERVER['REMOTE_ADDR']; // $record = \App\Models\ClientSession::fetch(['ip_address' => $ip_address]); // $obj = 'Home'; // $obj = $this->getNamespace($obj); // if (is_array($record)) { // $obj = new $obj(); // $obj->logout($record['uid']); // } else { // $obj = new $obj(); // $obj->logout($userid); // } // header('Location: /'); die(); } } $object = new Api(); if (isset($this->params['action'])) { $action = $this->params['action']; return $object->$action(); } else { $method = $_SERVER['REQUEST_METHOD']; $model = $this->params['model']; } return (isset($this->params['id'])) ? $object->$method($model, $this->params['id']) : $object->$method($model, "", (Input::exists('get')) ? $_GET : []); } }