Adds check for API-key
This commit is contained in:
1 parent
14a3513237
commit
79af6bfea5
2 files changed
+10
No files matched your search
@@ -33,6 +33,13 @@ if(DB :: isError($conn)) {
|
|||||||
}
|
}
|
||||||
$conn->setFetchMode(DB_FETCHMODE_ORDERED);
|
$conn->setFetchMode(DB_FETCHMODE_ORDERED);
|
||||||
|
|
||||||
|
/* Valid API KEY (defined in credentials.php) ? */
|
||||||
|
if(!isset($_GET['apikey']) || $_GET['apikey'] !== USER_API_KEY) {
|
||||||
|
set_response_code(400);
|
||||||
|
echo json_encode(array('error' => "Invalid apikey."));
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
/* Validate params */
|
/* Validate params */
|
||||||
if(!isset($_GET['q'])) {
|
if(!isset($_GET['q'])) {
|
||||||
set_response_code(400);
|
set_response_code(400);
|
||||||
|
|||||||
@@ -24,4 +24,7 @@ function getDSN($host = "default") {
|
|||||||
|
|
||||||
return "$driver://$user_name:$password@$host_name/$db_name";
|
return "$driver://$user_name:$password@$host_name/$db_name";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define("USER_API_KEY", "");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
Reference in new issue
Block a user