forked from netharbour/netharbour
/
sessionCheck.php
executable file
·45 lines (43 loc) · 986 Bytes
/
sessionCheck.php
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
44
45
<?
session_start();
include_once "config/opendb.php";
include_once "classes/Dashboard.php";
if (!isset($_SESSION['username']) || !isset($_SESSION['password']))
{
header("Location: login.php");
}
$access = $_SESSION['access'];
if (preg_match("/configurations.php/", $_SERVER['PHP_SELF']))
{
if ($access != 100)
{
header("Location: index.php");
echo "<h1>You have no permission</h1>";
}
}
if ($_SESSION['action'] !="")
{
$allUpdates = Updates::get_updates();
$index = 0;
foreach ($allUpdates as $id => $value)
{
$index++;
if ($index >10)
{
$curUpdate = new Updates($id);
if ($curUpdate->get_archived() == 0)
{
$curUpdate->set_archived(1);
if(!$curUpdate->update())
{echo 'update widget failed. Reason: '.$curUpdate->get_error();}
}
}
}
$update = new Updates();
$update->set_action($_SESSION['action']);
$update->set_username($_SESSION['fullname']);
$update->set_archived(0);
if($update->insert_update())
{$_SESSION['action']="";}
}
?>