-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.php
67 lines (53 loc) · 1.46 KB
/
main.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
@session_start();
ini_set('error_reporting', E_ERROR);
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
require 'pdo.php';
$site = "https://amazing-projects.ru/projectx/";
if(isset($_GET['out'])) {
$_SESSION = [];
header('Location: '.$site);
}
if(isset($_GET['l'])) {
$user = DB::getRow('SELECT * FROM `users` WHERE `link` = ?',array(trim((int)$_GET['l'])));
if(!empty($user['id'])) {
$_SESSION['user_id'] = $user['id'];
header('Location: '.$site .'/personal/');
}
}
if(!empty($_POST) && !empty($_POST['login'])) {
if($_POST['login'] == '122' && $_POST['password'] == '123456') {
$_SESSION['login'] = '122';
}
}
if(!empty($_POST['action'])) {
if($_POST['action'] == 'add_user') {
$link = time('siHdny');
$lastName = trim($_POST['lastname']);
$name = trim($_POST['firstname']);
$patronymic = trim($_POST['patronymic']);
$id = DB::add('INSERT INTO `users` SET `position_id` = ?, `link` = ?, `name` = ?, `lastName` = ?,
`patronymic` = ?', array($_POST['positions'], $link, $name, $lastName, $patronymic));
}
}
if(!empty($_GET['action'])) {
$action = trim($_GET['action']);
}
if(empty($_SESSION['login']) && empty($_SESSION['user_id'])) {
$page = 'auth';
} else {
if(!empty($_SESSION['user_id'])) {
$page = 'personal';
} else {
if(empty($_GET['page'])) {
$page = 'admin';
@header('Location: '.$site .'/admin/');
} else {
$page = $_GET['page'];
}
}
if(!empty($page)) {
include_once './pages/'.$page.'.php';
}
}