Adds some various php files
This commit is contained in:
parent
e73edafc99
commit
f04ad028ae
9 changed files with 112 additions and 0 deletions
32
php/Common.php
Normal file
32
php/Common.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
if(defined("COMMON")) return;
|
||||
define("COMMON", 1);
|
||||
|
||||
function get_DB() {
|
||||
return mysqli_connect(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getJsonizedInput() {
|
||||
$js = file_get_contents("php://input");
|
||||
return json_decode($js,true);
|
||||
}
|
||||
|
||||
|
||||
function rewrite_DB_conf($host, $user, $pass, $db)
|
||||
{
|
||||
$ptl = "<\?php\n"
|
||||
. "define(\"DB_HOST\", \"$host\");\n"
|
||||
. "define(\"DB_USER\", \"$user\");\n"
|
||||
. "define(\"DB_PASS\", \"$pass\");\n"
|
||||
. "define(\"DB_NAME\", \"$db\");\n"
|
||||
. "\?>";
|
||||
|
||||
file_put_contents("Database.php", $ptl);
|
||||
}
|
||||
|
||||
require("Database.php");
|
||||
|
||||
session_start();
|
||||
?>
|
8
php/Database.php
Normal file
8
php/Database.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
define("DB_HOST", "localhost");
|
||||
define("DB_USER", "root");
|
||||
define("DB_PASS", "changeme");
|
||||
define("DB_NAME", "changeme");
|
||||
|
||||
?>
|
16
php/Login.php
Normal file
16
php/Login.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
if(!defined("COMMON"))
|
||||
require("Common.php");
|
||||
|
||||
$js = getJsonizedInput();
|
||||
|
||||
// Read login parameters
|
||||
$username = $js["username"];
|
||||
$password = $js["password"];
|
||||
|
||||
// Password is hashed
|
||||
// Compare against hash in database + : md5(salt)
|
||||
$DB = get_DB();
|
||||
|
||||
?>
|
4
php/README.md
Normal file
4
php/README.md
Normal file
|
@ -0,0 +1,4 @@
|
|||
About
|
||||
======
|
||||
|
||||
These files get copied to the API subdomain by default. This setup is intended to permit for multiple hosts.
|
17
php/SetupCheck.php
Normal file
17
php/SetupCheck.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
if(DB_NAME == "changeme" && DB_PASS == "changeme") {
|
||||
$ret = array (
|
||||
"done" => false
|
||||
);
|
||||
header("X-Zontreck-Setup-Completed", "FALSE");
|
||||
die(json_encode($ret));
|
||||
}else {
|
||||
$ret = array (
|
||||
"done" => true
|
||||
);
|
||||
header("X-Zontreck-Setup-Completed", "TRUE");
|
||||
die(json_encode($ret));
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue