test
This commit is contained in:
@@ -99,4 +99,11 @@ class mcServApi {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function generateSessionID() {
|
||||
$num = rand(1, 999999);
|
||||
$hash = hash("sha256", $num);
|
||||
|
||||
return $hash;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
require "../../main.php";
|
||||
require "../api.php";
|
||||
|
||||
$mcServ = new mcServ();
|
||||
$db = $mcServ->getDB();
|
||||
$api = new mcServApi();
|
||||
$db = $api->getDB();
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
if (!isset($_POST["username"]) || !isset($_POST["passwd"])) {
|
||||
@@ -22,9 +22,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($result) {
|
||||
$config = $mcServ->getConf();
|
||||
$config = $api->getConf();
|
||||
|
||||
$session["session_id"] = $mcServ->generateSessionID();
|
||||
$session["session_id"] = $api->generateSessionID();
|
||||
$device_id = rand(1, 999);
|
||||
|
||||
$json[$device_id] = $session;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?php
|
||||
require "../../main.php";
|
||||
require "../api.php";
|
||||
|
||||
$mcServ = new mcServ;
|
||||
$api = new mcServApi;
|
||||
|
||||
if (!$mcServ->checkApiAuth()) {
|
||||
if (!$api->checkAuth()) {
|
||||
die('{"status":500, "error":"Unauthrized"}');
|
||||
}
|
||||
|
||||
$db = $mcServ->getDB();
|
||||
$db = $api->getDB();
|
||||
|
||||
$sql = "SELECT * FROM servers";
|
||||
$stmt = $db->query($sql);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require "../../main.php";
|
||||
require "../api.php";
|
||||
|
||||
$admin_user = $_POST["admin_user"];
|
||||
$admin_mail = $_POST["admin_mail"];
|
||||
@@ -16,8 +16,8 @@ if ($admin_passwd_2 !== $admin_passwd_1) {
|
||||
|
||||
$admin_passwd = hash("sha256", $admin_passwd_2);
|
||||
|
||||
$mcServ = new mcServ();
|
||||
$config = $mcServ->getConf();
|
||||
$api = new mcServApi();
|
||||
$config = $api->getConf();
|
||||
|
||||
$db = new PDO("sqlite:" . $config["DB_PATH"]);
|
||||
$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->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);
|
||||
|
||||
$json[$device_id] = json_encode($session);
|
||||
|
||||
Reference in New Issue
Block a user