inital template
This commit is contained in:
78
sources/backend/functions.php
Normal file
78
sources/backend/functions.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
#--------------------#
|
||||
#----- by 4nima -----#
|
||||
#----- v. 1.0.0 -----#
|
||||
#-- coding@4nima.de -#
|
||||
#--------------------#
|
||||
|
||||
// session_start();
|
||||
|
||||
|
||||
// Generate Navigation
|
||||
function genNav($nav) {
|
||||
foreach ($nav as $item) {
|
||||
if (is_array($item[1])) {
|
||||
echo '
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="gamedrop" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
'.$item[0].'
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="gamedrop">
|
||||
';
|
||||
|
||||
foreach ($item[1] as $dropdown) {
|
||||
if ($dropdown[0] == "---") {
|
||||
echo '<div class="dropdown-divider"></div>';
|
||||
} else {
|
||||
echo '<a class="dropdown-item" href="'.$dropdown[1].'">'.$dropdown[0].'</a>';
|
||||
}
|
||||
}
|
||||
echo '
|
||||
</div>
|
||||
</li>
|
||||
|
||||
';
|
||||
} else {
|
||||
echo '
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="'.$item[1].'">'.$item[0].'</a>
|
||||
</li>
|
||||
';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Setzt Login Cookie und Session
|
||||
function setLogin($usr, $hash, $lvl, $stay) {
|
||||
if ($stay) {
|
||||
setcookie('usr', $usr, time()+18144000);
|
||||
setcookie('hash', $hash, time()+18144000);
|
||||
}
|
||||
$_SESSION['usr'] = $usr;
|
||||
$_SESSION['hash'] = $hash;
|
||||
$_SESSION['lvl'] = $lvl;
|
||||
}
|
||||
|
||||
// Login Prüfung
|
||||
function checkLogin($usr, $lvl, $hash) {
|
||||
$db = new Database();
|
||||
$db->query('
|
||||
SELECT *
|
||||
FROM user
|
||||
WHERE username = :usr
|
||||
AND lvl = :lvl
|
||||
AND pwdhash = :hash
|
||||
');
|
||||
$db->bind(':usr', $usr);
|
||||
$db->bind(':lvl', $lvl);
|
||||
$db->bind(':hash', $hash);
|
||||
$user = $db->resultset();
|
||||
if ($user[0]['username'] == $usr && $user[0]['lvl'] == $lvl && $user[0]['pwdhash'] == $hash) {
|
||||
$login = TRUE;
|
||||
} else {
|
||||
$_SESSION = array();
|
||||
}
|
||||
return $login;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user