-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·75 lines (72 loc) · 1.41 KB
/
index.php
File metadata and controls
executable file
·75 lines (72 loc) · 1.41 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE head PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="templates/main.css">
</head>
<body>
<?php
include './init.php';
$bTryNotOK = false;
$bLoginNotOK = false;
$bPasswordNotOK = false;
if (isset($_GET['logout']))
{
$_SESSION['loged'] = false;
}
if (isset($_POST['login']) || isset($_POST['password']))
{
if ($_POST['login'] != '' && $_POST['password'] != '')
{
$oUserModel = new User();
$oUser = $oUserModel->getByLogin($_POST['login']);
if ($oUser != null)
{
if ($oUser->getPassword() == $_POST['password'])
{
$_SESSION['loged'] = true;
$_SESSION['loged_id'] = $oUser->getId();
}
else
{
$bPasswordNotOK = true;
}
}
else
{
$bLoginNotOK = true;
}
}
else
{
$bTryNotOK = true;
}
}
if (isset($_SESSION['loged']) && $_SESSION['loged'])
{
if (isset($_POST['tosave']))
{
$db = new DB();
$oToSave = $db->getObject($_POST['tosave']);
$asColumns = explode(',', $oToSave->getColumns());
foreach ($asColumns as $sColumn)
{
if (isset($_POST[$sColumn]))
{
$sFunction = 'set'.$sColumn;
$oToSave->$sFunction($_POST[$sColumn]);
}
}
$db->save($_POST['tosave'], $oToSave);
}
echo '<div class="top_right">
<a href="index.php?logout">Logout</a>
</div>';
include 'templates/home.php';
}
else
{
include 'templates/login.php';
}
?>
</body>
</html>