Skip to content
Snippets Groups Projects
Commit 8a119125 authored by Sibidharan's avatar Sibidharan :speech_balloon:
Browse files

Apr 27 class final code

parent ed516a0b
No related branches found
No related tags found
No related merge requests found
RewriteBase / RewriteBase /
RewriteEngine On RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/?api/([^/]+)?$ api/index.php?rquest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ api/index.php?rquest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d ## For general files, if not above, just remove .php
RewriteRule ^(.*)$ api/index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s # Redirect external .php requests to 404 Error (Pretending that I am not doing PHP)
RewriteRule ^(.*)$ api/index.php [QSA,NC,L] RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
\ No newline at end of file RewriteRule ^(.+)\.php$ "http://%{HTTP_HOST}/$1" [R=404,L]
# Resolve .php file for extensionless php urls
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/.]+)$ $1.php [L]
RewriteBase / #RewriteBase /
RewriteEngine On #RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d #RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-s #RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)$ index.php?rquest=$1 [QSA,NC,L] #RewriteRule ^(.*)$ index.php?rquest=$1 [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -d #RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ index.php [QSA,NC,L] #RewriteRule ^(.*)$ index.php [QSA,NC,L]
RewriteCond %{REQUEST_FILENAME} -s #RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^(.*)$ index.php [QSA,NC,L] #RewriteRule ^(.*)$ index.php [QSA,NC,L]
...@@ -76,10 +76,11 @@ ...@@ -76,10 +76,11 @@
private function inputs(){ private function inputs(){
switch($this->get_request_method()){ switch($this->get_request_method()){
case "POST": case "POST":
$this->_request = $this->cleanInputs($_POST); //$this->_request = $this->cleanInputs($_POST);
$this->_request = $this->cleanInputs(array_merge($_GET,$_POST));
break; break;
case "GET": case "GET":
//break; $this->_request = $this->cleanInputs($_GET);
case "DELETE": case "DELETE":
$this->_request = $this->cleanInputs($_GET); $this->_request = $this->cleanInputs($_GET);
break; break;
......
...@@ -56,35 +56,43 @@ ...@@ -56,35 +56,43 @@
$error = $this->json($error); $error = $this->json($error);
$this->response($error,406); $this->response($error,406);
} }
$data = array('version' => '0.1', 'desc' => 'This API is created by Blovia Technologies Pvt. Ltd., for the public usage for accessing data about vehicles.'); $data = array('version' => $this->_request['version'], 'desc' => 'This API is created by Blovia Technologies Pvt. Ltd., for the public usage for accessing data about vehicles.');
$data = $this->json($data); $data = $this->json($data);
$this->response($data,200); $this->response($data,200);
} }
private function verify(){ private function verify(){
$user = $this->_request['user']; if($this->get_request_method() == "POST" and isset($this->_request['user']) and isset($this->_request['pass'])){
$password = $this->_request['pass']; $user = $this->_request['user'];
$password = $this->_request['pass'];
$flag = 0;
if($user == "admin"){ $flag = 0;
if($password == "adminpass123"){ if($user == "admin"){
$flag = 1; if($password == "adminpass123"){
$flag = 1;
}
} }
}
if($flag == 1){ if($flag == 1){
$data = [ $data = [
"status" => "verified" "status" => "verified"
]; ];
$data = $this->json($data); $data = $this->json($data);
$this->response($data,200); $this->response($data,200);
} else {
$data = [
"status" => "unauthorized"
];
$data = $this->json($data);
$this->response($data,401);
}
} else { } else {
$data = [ $data = [
"status" => "unauthorized" "status" => "bad_request"
]; ];
$data = $this->json($data); $data = $this->json($data);
$this->response($data,403); $this->response($data,400);
} }
} }
...@@ -93,6 +101,10 @@ ...@@ -93,6 +101,10 @@
$this->response($data,200); $this->response($data,200);
} }
private function request_info(){
$data = $this->json($_SERVER);
}
function generate_hash(){ function generate_hash(){
$bytes = random_bytes(16); $bytes = random_bytes(16);
return bin2hex($bytes); return bin2hex($bytes);
......
sg.php 0 → 100644
<pre>
<?php
print_r($GLOBALS);
print_r($_SERVER);
print_r($_REQUEST);
print_r($_POST);
print_r($_GET);
print_r($_FILES);
print_r($_ENV);
print_r($_COOKIE);
?>
</pre>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment