-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.php
More file actions
43 lines (37 loc) · 813 Bytes
/
functions.php
File metadata and controls
43 lines (37 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
function loadJson($database)
{
$json = file_get_contents($database);
return json_decode($json, true);
}
function saveJson($database, $data)
{
$json = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
file_put_contents($database, $json);
}
function statusCode($errorCode = 200)
{
http_response_code($errorCode);
}
//Hittar det högsts id:et
function theHighestId($array)
{
$userID = 0;
foreach ($array as $obj) {
if ($obj["id"] > $userID) {
$userID = $obj["id"];
}
}
$userID = $userID + 1;
return $userID;
}
function checkIfLoggedIn(){
if (isset($_SESSION["IsLoggedIn"])){
if ($_SESSION["IsLoggedIn"] == true){
return $_SESSION["nameTag"];
}
}
else {
return null;
}
}