Commit f87d6881 authored by Gabriel Genois's avatar Gabriel Genois

...

parent 98466817
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -7,7 +7,7 @@
public $search_id = "uniqid";
public $get_param = "query";
public $iKey = 1;
public $arrKeys = json_decode(file_get_contents("./api_keys.json"), true);
public $arrKeys = array();
public function delete($data, &$iFound)
{
$iFound = 1;
......@@ -184,6 +184,7 @@
public function create_database($sName, &$iFound)
{
$sName = str_replace(' ', '_', $sName);
$iFound = 1;
if (!$this->dbexist($sName)) {
......@@ -214,7 +215,6 @@
public function extract_query($query)
{
$iFound = 0;
if (($pos = strpos($query, 'CREATE DATABASE ')) === 0)
$this->create_database(substr($query, 16, strlen($query) - 16), $iFound);
if (($pos = strpos($query, 'CREATE TABLE ')) === 0)
......@@ -227,9 +227,6 @@
$this->update(substr($query, 7, strlen($query) - 7), $iFound);
if (($pos = strpos($query, 'DELETE ')) === 0)
$this->delete(substr($query, 7, strlen($query) - 7), $iFound);
if(!$iFound)
echo json_encode(array("iCode" => 1, "message" => "Error while extrapolating the query."));
}
......@@ -239,14 +236,29 @@
if(!isset($_GET['query']))
echo json_encode(array("iCode" => -1, "message" => "no query recived."));
else
{
$this->arrKeys = json_decode(file_get_contents(dirname( __FILE__ )."/api_keys.json"), true);
if($this->iKey)
{
if(isset($_GET['key']))
{
if(in_array($_GET['key'], $this->arrKeys))
{
$this->extract_query(base64_decode($_GET[$this->get_param]));
}
else
{
echo json_encode(array("iCode" => 1, "message" => "Invalid key"));
}
}
else
{
echo json_encode(array("iCode" => 1, "message" => "No key recived"));
}
}
else
$this->extract_query(base64_decode($_GET[$this->get_param]));
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment