-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
118 lines (87 loc) · 2.22 KB
/
index.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
session_start();
require 'core/database.class.php';
require 'core/vote.class.php';
require 'core/shield.class.php';
require 'core/template.class.php';
$hack = new Shield();
$do = isset($_POST['do'])? $_POST['do']: null;
switch ($do)
{
case 'update':
$db = new SafeMySQL();
$vote = new Vote($db);
$profiles = $vote->getPhotos();
$vote->setSession($profiles);
unset($profiles['id1']);
unset($profiles['id2']);
echo json_encode($profiles);
die();
case null:
break;
default:
$hack->hackDetect();
}
$top = isset($_GET['do'])? $_GET['do']: null;
switch ($top)
{
case 'top':
$db = new SafeMySQL();
$top10 = $db->getAll('SELECT profile_photo, profile_vk FROM profiles ORDER BY profile_likes DESC LIMIT 10');
for ($i = 0; $i < 10; $i++)
{
$top10[$i]['profile_vk'] = base64_encode($top10[$i]['profile_vk']);
}
$template = new Template('theme/');
$template->set('top10', json_encode($top10));
$template->display('top');
die();
case 'about':
$template = new Template('theme/');
$template->display('about');
die();
case 'start':
if(!isset($_COOKIE['PHPSESSID']))
die('Для корректной работы приложения необходимо включить cookies');
break;
case null:
break;
default:
$hack->hackDetect();
}
$add = isset($_POST['add'])? $_POST['add']: null;
if ($add)
{
$hack->check();
$db = new SafeMySQL();
$vote = new Vote($db);
$vote->like($add);
$profiles = $vote->getPhotos();
$vote->setSession($profiles);
unset($profiles['id1']);
unset($profiles['id2']);
echo json_encode($profiles);
die();
}else
{
if(!isset($_COOKIE['PHPSESSID']))
{
header ("Location: $_SERVER[PHP_SELF]?do=start");
}
if (isset($_SESSION['hash1']))
{
$profiles = Vote::refresh();
}else
{
$db = new SafeMySQL();
$vote = new Vote($db);
$profiles = $vote->getPhotos();
$vote->setSession($profiles);
}
$template = new Template('theme/');
$template->set('photo1', $profiles['photo1']);
$template->set('photo2', $profiles['photo2']);
$template->set('hash1', $profiles['hash1']);
$template->set('hash2', $profiles['hash2']);
$template->display('main');
}