forked from openstreetmap-ru/OpenStreetMap.ru
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
71 lines (62 loc) · 2.49 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
<?
include_once ('include/config.php');
$_URL = preg_replace("/^(.*?)index\.php$/is", "$1", $_SERVER['SCRIPT_NAME']);
$_URL = preg_replace("/^".preg_quote($_URL, "/")."/is", "", urldecode($_SERVER['REQUEST_URI']));
$_URL = preg_replace("/(\/?)(\?.*)?$/is", "", $_URL);
$_URL = preg_replace("/[^0-9A-Za-z._\\-\\/]/is", "", $_URL); // вырезаем ненужные символы (не обязательно это делать)
$_URL = explode("/", $_URL);
if (preg_match("/^index\.(?:html|php)$/is", $_URL[count($_URL) - 1])) unset($_URL[count($_URL) - 1]); // удаляем суффикс
if (empty($_URL[0]))
$_URL[0] = 'map';
if (function_exists("pg_connect")) { // чтобы можно было тестировать не поднимая БД
$result = pg_query("SELECT * FROM \"pagedata\" WHERE \"name\"='".pg_escape_string($_URL[0])."' AND \"activate\"");
if (pg_num_rows($result) <= 0) Err404();
$data = pg_fetch_assoc($result);
if (!file_exists($data['name'].'.php'))
Err404();
}
include_once ('include/external.php');
include_once ($_URL[0].'.php');
?>
<!doctype html>
<html>
<head>
<title>OpenStreetMap Россия — <?=$data['text'] ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/main.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="css/main_small.css" type="text/css" media="handheld, only screen and (max-device-width:800px)" />
<link rel="search" href="/search.xml" type="application/opensearchdescription+xml" title="OpenStreetMap.Ru" />
<script type="text/javascript" src="js/main.js"></script>
<link rel="icon" type="image/png" href="/favicon.png" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<? print($external_head); ?>
<? print($page_head); ?>
</head>
<body>
<div id="menupan">
<div id="menuback"></div>
<table id="tablemenu"><tr>
<td><? show_menu($pages_menu, $_URL[0]); ?></td>
<td width="100%"></td>
<td>
<table id="mainmenupage"><tr>
<? print($page_topmenu); ?>
</tr></table>
</td>
</tr></table>
</div>
<div id="toppan">
<a href="/">
<img src="<? print($page_logo); ?>" alt="OpenStreetMap.ru" id="logo">
</a>
<div id="topbar">
<? print($page_topbar); ?>
</div>
<div id="colorline" style="background:<?=$data['color']?>;"></div>
</div>
<div id="content">
<? print($page_content); ?>
</div>
<? print($external_bodyend); ?>
</body>
</html>