-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
210 lines (166 loc) · 5.68 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
//error_reporting(E_ALL);
session_start();
header('Content-Type: text/html; charset=utf-8');
include ('/func.php');
include('/class/Uploader.php');
include('/class/Db.php');
include('/class/Animal.php');
include('/class/User.php');
include('/class/Validation.php');
include('/class/Posters.php');
Db::connect();
$url = $_SERVER['REQUEST_URI'];
$title = '';
$template = '';
$explode = explode('?', $url);
switch ($explode[0]) {
case '/':
$template = 'posters';
$title = 'Головна сторінка';
break;
case '/posters':
$template = 'posters';
$title = 'Головна сторінка';
break;
case '/postersUser':
$template = 'postersUser';
$title = 'Мої оголошення';
break;
case '/map':
$template = 'map';
$title = 'Перегляд тварин';
break;
case '/posterView':
$template = 'posterView';
$title = 'Продукт';
break;
case '/animalsAdd':
$template = 'animalsAdd';
$title = 'Добавлення тварин';
if(isset($_POST['sendForm'])){
$errors = Animal::getInstence()->add($_POST)->errors;
}
break;
case '/login':
$template = 'login';
$title = 'Логування';
if($_POST){
$errors = User::getInstence()->login($_POST['email'], $_POST['password'])->errors;
}
break;
case '/registration':
$template = 'registration';
$title = 'Реєстрація';
if($_POST){
$errors = User::getInstence()->registration($_POST)->errors;
}
break;
case '/logout':
User::getInstence()->logout();
header("location: /login");
break;
default :
preg_match('/(.*?)(\?id=|\?status=)(.*?)$|(.*?)\?status=(.*?)$/', $url, $matche);
if (isset($matche[2])) {
$template = $matche[1];
if($template == "/posters") $title = 'Головна сторінка';
else $title = 'Оголошення';
$errors = Animal::getInstence()->update($_POST)->errors;
}else{
preg_match('/(.*?)\?id=(.*?)&user_id=(.*?)$/', $url, $matche);
if (isset($matche[2])) {
$template = $matche[1];
$title = 'Оголошення';
$errors = Animal::getInstence()->update($_POST)->errors;
}
}
break;
$template = '';
}
?>
<!DOCTYPE html>
<html >
<head>
<title><?= $title?></title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<link rel="stylesheet" href="styles/style.css">
<link rel="stylesheet" href="styles/style_images.css">
<link rel="stylesheet" href="styles/bootstrap.min.css">
<link rel="stylesheet" href="styles/bootstrap-theme.min.css">
<link rel="shortcut icon" href="/image/Search.ico" type="image/x-icon">
<script src="/js/jquery-3.1.1.js"></script>
<script src="/js/JQuery/selects.js"></script>
<script src="/js/JQuery/sendMail.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/JQuery/delete-poster.js"></script>
<script src="/js/JQuery/change-status.js"></script>
</head>
<body>
<div class="container">
<div class="row" id="header">
<div class="col-md-8" id="header-text">
<h2>Сайт пошуку пропавших тварин</h2>
</div>
<?php if(is_login()):?>
<div class="col-md-4" id="registration">
<div class="btn-group" id="output">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<span class="glyphicon glyphicon-user"><span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li><a href="/postersUser">Мої оголошення</a></li>
<li><a href="/animalsAdd">Добавити оголошення</a></li>
</ul>
</div>
|
<a href="/logout" id="output"> Вихід </a>
</div>
<?php else:?>
<div class="col-md-4" id="registration">
<a href="/login" id="input" >Вхід</a>
|
<a href="/registration" id="input" >Реєстрація</a>
</div>
<?php endif;?>
</div>
<div class="row" >
<div class="col-md-12" id="menu">
<nav role="navigation" class="navbar navbar-default navbar-inverse">
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="/posters">Головна</a></li>
<li class="divider-vertical"></li>
<li><a href="/map">Пошук на карті</a></li>
<li class="divider"></li>
<?php if(is_login()):?>
<li><a href="/animalsAdd">Добавити оголошення</a></li>
<?php endif;?>
</ul>
</div>
</nav>
</div>
</div>
<div class="row" >
<?php include ('/templates/' . $template . '.php');?>
</div>
<div class="row" >
<div class="col-md-12" id = "footer">
<script type="text/javascript">(function() {
if (window.pluso)if (typeof window.pluso.start == "function") return;
if (window.ifpluso==undefined) { window.ifpluso = 1;
var d = document, s = d.createElement('script'), g = 'getElementsByTagName';
s.type = 'text/javascript'; s.charset='UTF-8'; s.async = true;
s.src = ('https:' == window.location.protocol ? 'https' : 'http') + '://share.pluso.ru/pluso-like.js';
var h=d[g]('body')[0];
h.appendChild(s);
}})();
</script>
<div class="pluso" data-background="transparent" data-options="big,square,line,horizontal,counter,theme=01" data-services="vkontakte,odnoklassniki,facebook,twitter,google,moimir,email,print"></div>
<center><h2>© Славік Іванюра</h2></center>
</div>
</div>
</div>
</body>
</html>