2021-02-08 11:57:32 +00:00
|
|
|
<?php
|
|
|
|
if (strpos($_SERVER['PHP_SELF'], "inc.php") !== false)
|
|
|
|
exit("This file is meant to be included.");
|
|
|
|
|
2021-02-16 18:20:19 +00:00
|
|
|
function addNiverLog($message, $outputLines) {
|
|
|
|
$logs = "\n" . date("Y-m-d H:i:s") . " " . $message . "\n";
|
|
|
|
foreach ($outputLines as $outputLine) {
|
|
|
|
$logs = $logs . " " . $outputLine . "\n";
|
|
|
|
}
|
|
|
|
file_put_contents(ROOT_PATH . "/niver.log", $logs, FILE_APPEND);
|
|
|
|
}
|
|
|
|
|
2021-03-02 21:56:38 +00:00
|
|
|
function checkAction($action) {
|
|
|
|
if ($action === "delete")
|
|
|
|
return "un";
|
|
|
|
else if ($action === "add")
|
|
|
|
return "";
|
|
|
|
else
|
|
|
|
exit("ERROR: wrong value for action");
|
|
|
|
}
|
|
|
|
|
2021-02-12 14:32:48 +00:00
|
|
|
function userExist($username) {
|
2021-05-14 19:10:56 +00:00
|
|
|
$usernameArray[0] = $username;
|
2021-02-12 14:32:48 +00:00
|
|
|
|
|
|
|
$db = new PDO('sqlite:' . DB_PATH);
|
|
|
|
|
2021-02-16 18:20:19 +00:00
|
|
|
$op = $db->prepare('SELECT username FROM users WHERE username = ?');
|
2021-05-14 19:10:56 +00:00
|
|
|
$op->execute($usernameArray);
|
2021-02-12 14:32:48 +00:00
|
|
|
|
2021-05-14 19:10:56 +00:00
|
|
|
$data = $op->fetch();
|
|
|
|
if (isset($data['username']))
|
|
|
|
$dbUsername = $data['username'];
|
|
|
|
else
|
|
|
|
$dbUsername = NULL;
|
2021-02-12 14:32:48 +00:00
|
|
|
|
2021-05-14 19:10:56 +00:00
|
|
|
if (isset($dbUsername)) {
|
2021-02-12 14:32:48 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|