test
This commit is contained in:
@@ -99,4 +99,11 @@ class mcServApi {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function generateSessionID() {
|
||||||
|
$num = rand(1, 999999);
|
||||||
|
$hash = hash("sha256", $num);
|
||||||
|
|
||||||
|
return $hash;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
require "../../main.php";
|
require "../api.php";
|
||||||
|
|
||||||
$mcServ = new mcServ();
|
$api = new mcServApi();
|
||||||
$db = $mcServ->getDB();
|
$db = $api->getDB();
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
if (!isset($_POST["username"]) || !isset($_POST["passwd"])) {
|
if (!isset($_POST["username"]) || !isset($_POST["passwd"])) {
|
||||||
@@ -22,9 +22,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
$config = $mcServ->getConf();
|
$config = $api->getConf();
|
||||||
|
|
||||||
$session["session_id"] = $mcServ->generateSessionID();
|
$session["session_id"] = $api->generateSessionID();
|
||||||
$device_id = rand(1, 999);
|
$device_id = rand(1, 999);
|
||||||
|
|
||||||
$json[$device_id] = $session;
|
$json[$device_id] = $session;
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
require "../../main.php";
|
require "../api.php";
|
||||||
|
|
||||||
$mcServ = new mcServ;
|
$api = new mcServApi;
|
||||||
|
|
||||||
if (!$mcServ->checkApiAuth()) {
|
if (!$api->checkAuth()) {
|
||||||
die('{"status":500, "error":"Unauthrized"}');
|
die('{"status":500, "error":"Unauthrized"}');
|
||||||
}
|
}
|
||||||
|
|
||||||
$db = $mcServ->getDB();
|
$db = $api->getDB();
|
||||||
|
|
||||||
$sql = "SELECT * FROM servers";
|
$sql = "SELECT * FROM servers";
|
||||||
$stmt = $db->query($sql);
|
$stmt = $db->query($sql);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require "../../main.php";
|
require "../api.php";
|
||||||
|
|
||||||
$admin_user = $_POST["admin_user"];
|
$admin_user = $_POST["admin_user"];
|
||||||
$admin_mail = $_POST["admin_mail"];
|
$admin_mail = $_POST["admin_mail"];
|
||||||
@@ -16,8 +16,8 @@ if ($admin_passwd_2 !== $admin_passwd_1) {
|
|||||||
|
|
||||||
$admin_passwd = hash("sha256", $admin_passwd_2);
|
$admin_passwd = hash("sha256", $admin_passwd_2);
|
||||||
|
|
||||||
$mcServ = new mcServ();
|
$api = new mcServApi();
|
||||||
$config = $mcServ->getConf();
|
$config = $api->getConf();
|
||||||
|
|
||||||
$db = new PDO("sqlite:" . $config["DB_PATH"]);
|
$db = new PDO("sqlite:" . $config["DB_PATH"]);
|
||||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
@@ -60,7 +60,7 @@ INSERT INTO users (username, mail, passwd) VALUES (:user, :mail, :passwd)
|
|||||||
$stmt = $db->prepare($sql);
|
$stmt = $db->prepare($sql);
|
||||||
$stmt->execute([':user' => $admin_user, ':mail' => $admin_mail, ':passwd' => $admin_passwd]);
|
$stmt->execute([':user' => $admin_user, ':mail' => $admin_mail, ':passwd' => $admin_passwd]);
|
||||||
|
|
||||||
$session["session_id"] = $mcServ->generateSessionID();
|
$session["session_id"] = $api->generateSessionID();
|
||||||
$device_id = rand(1, 999);
|
$device_id = rand(1, 999);
|
||||||
|
|
||||||
$json[$device_id] = json_encode($session);
|
$json[$device_id] = json_encode($session);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
* By marc-go
|
* By marc-go
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require "../main.php";
|
require "main.php";
|
||||||
|
|
||||||
$mcServ = new mcServ();
|
$mcServ = new mcServ();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
require "../main.php";
|
require "main.php";
|
||||||
|
|
||||||
$mcServ = new mcServ();
|
$mcServ = new mcServ();
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class mcServ {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getConf() {
|
public function getConf() {
|
||||||
$env = parse_ini_file(__DIR__ . "/.env");
|
$env = parse_ini_file(__DIR__ . "/../.env");
|
||||||
return $env;
|
return $env;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
<?php
|
<?php
|
||||||
echo "404";
|
require "";
|
||||||
?>
|
?>
|
||||||
@@ -3,15 +3,16 @@ ini_set("display_errors", 1);
|
|||||||
ini_set("display_startup_errors", 1);
|
ini_set("display_startup_errors", 1);
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
/*foreach ($_SERVER as $key => $value) {
|
foreach ($_SERVER as $key => $value) {
|
||||||
echo $key . " = " . $value . "<br>";
|
echo $key . " = " . $value . "<br>";
|
||||||
}*/
|
}
|
||||||
|
|
||||||
/*require "../main.php";
|
/*
|
||||||
|
require "../main.php";
|
||||||
|
|
||||||
$mcServ = new mcServ();
|
$mcServ = new mcServ();
|
||||||
|
|
||||||
echo $mcServ->checkApiAuth() ? "TRUE" : "FALSE";
|
echo $mcServ->checkApiAuth() ? "TRUE" : "FALSE";
|
||||||
*/
|
*/
|
||||||
|
|
||||||
echo __DIR__;
|
//echo __DIR__;
|
||||||
@@ -1 +1 @@
|
|||||||
{"162":{"session_id":"a46d0e1ef15a9c36ef3cacfbedf8837a24021b31e7997718ef5b22cc3204b78d"}}
|
{"506":"{\"session_id\":\"7f2b74a916c471ccd03b866c991e5b86f8a28cc776b54c6d73f38956a926368d\"}","array":true}
|
||||||
Reference in New Issue
Block a user