Commit 2ac1299f authored by Nico Schallehn's avatar Nico Schallehn

SQlite hinzugefügt für API-Key verwaltung zusätzlich Key Überprüfung

usw.
parent f51d1802
......@@ -6,11 +6,33 @@
class MediaDBViewerAPI{
private $API_KEY;
private $DB_Server;
private $DB_Username;
private $DB_Passwort;
function APIinit($KEY) {
if(isset($KEY) AND strlen($KEY) == API_KEY_LEN){
$this->API_KEY = $KEY;
$ret = true;
if ($db = sqlite_open(API_KEY_DB, 0666, $sqliteerror)) {
$result = sqlite_query($db, 'select * from Keys WHERE Key = '.$KEY);
if(sqlite_num_rows($result) == 1){
$entry = sqlite_fetch_array($query, SQLITE_ASSOC);
$this->DB_Server = $entry['Server'];
$this->DB_Username = $entry['Username'];
$this->DB_Passwort = $entry['Passwort'];
$this->API_KEY = $KEY;
$ret = true;
}
else{
$ret = false;
}
}
else{
$ret = false;
}
}
else {
$ret = false;
......@@ -20,6 +42,7 @@ class MediaDBViewerAPI{
function API_serverinfo(){
return array( "time" => time(),
"time_h" => date(time()),
"HTTP_USER_AGENT" => $_SERVER['HTTP_USER_AGENT'],
"REMOTE_ADDR" => $_SERVER['REMOTE_ADDR']
);
......
......@@ -13,6 +13,7 @@ include 'api.class.php';
*/
define(API_KEY_LEN, 10);
define(API_VERSION, 0.001);
define(API_KEY_DB, "Key.sqlite");
$API = new MediaDBViewerAPI();
......
<?php include 'api.class.php';
$arr = get_defined_functions();
API_KEY_DB
print_r($arr);
\ No newline at end of file
if ($db = sqlite_open(API_KEY_DB, 0666, $sqliteerror)) {
sqlite_query($db, 'CREATE TABLE Keys (Key PRIMARY KEY varchar(10), Server varchar(20), Username varchar(20), Passwort varchar(20))');
sqlite_query($db, "INSERT INTO Keys VALUES ('0123456789', 'localhost', 'MediaDB', 'MediaDB')");
$result = sqlite_query($db, 'select * from Keys');
var_dump(sqlite_fetch_array($result));
} else {
die($sqliteerror);
}
\ No newline at end of file
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