servnest/inc/all.inc.php

42 lines
969 B
PHP
Raw Normal View History

<?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");
}
function userExist($username) {
2021-05-14 19:10:56 +00:00
$usernameArray[0] = $username;
$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-05-14 19:10:56 +00:00
$data = $op->fetch();
if (isset($data['username']))
$dbUsername = $data['username'];
else
$dbUsername = NULL;
2021-05-14 19:10:56 +00:00
if (isset($dbUsername)) {
return true;
} else {
return false;
}
}