-
Notifications
You must be signed in to change notification settings - Fork 10
/
rewrite.php
79 lines (75 loc) · 5.11 KB
/
rewrite.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
<?php
/**
*¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*
* Webspell-RM / / / *
* -----------__---/__---__------__----__---/---/-----__---- _ _ - *
* | /| / /___) / ) (_ ` / ) /___) / / __ / / / / *
* _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/_____/_____/__/__/_ *
* Free Content / Management System *
* / *
*¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*
* @version webspell-rm *
* *
* @copyright 2018-2023 by webspell-rm.de *
* @support For Support, Plugins, Templates and the Full Script visit webspell-rm.de *
* @website <https://www.webspell-rm.de> *
* @forum <https://www.webspell-rm.de/forum.html> *
* @wiki <https://www.webspell-rm.de/wiki.html> *
* *
*¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*
* @license Script runs under the GNU GENERAL PUBLIC LICENCE *
* It's NOT allowed to remove this copyright-tag *
* <http://www.fsf.org/licensing/licenses/gpl.html> *
* *
*¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*
* @author Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at) *
* @copyright 2005-2011 by webspell.org / webspell.info *
* *
*¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯*
*/
if (basename($_SERVER[ 'SCRIPT_FILENAME' ]) == basename("rewrite.php")) {
include_once("system/sql.php");
$_database = new mysqli($host, $user, $pwd, $db);
if ($_database->connect_error) {
die('ERROR: Can not connect to MySQL-Server');
}
$_database->query("SET NAMES 'utf8'");
$_site = null;
$start_time = microtime(true);
if (isset($_GET[ 'url' ])) {
$url_parts = preg_split("/[\._\/-]/", $_GET[ 'url' ]);
$first = $url_parts[ 0 ];
$get = mysqli_query(
$_database,
"SELECT * FROM " . PREFIX . "modrewrite WHERE ".
"regex LIKE '%" . mysqli_real_escape_string($_database, $first) . "%' ORDER BY LENGTH(regex) ASC"
);
while ($ds = mysqli_fetch_assoc($get)) {
$replace = $ds[ 'rebuild_result' ];
$regex = $ds[ 'rebuild_regex' ];
$new = preg_replace("/" . $regex . "/i", $replace, $_GET[ 'url' ], -1, $replace_count);
if ($replace_count > 0) {
$url = parse_url($new);
if (isset($url[ 'query' ])) {
$parts = explode("&", $url[ 'query' ]);
foreach ($parts as $part) {
$k = explode("=", $part);
$_GET[ $k[ 0 ] ] = $k[ 1 ];
$_REQUEST[ $k[ 0 ] ] = $k[ 1 ];
}
}
$_site = $url[ 'path' ];
break;
}
}
}
if ($_site === null) {
header("HTTP/1.0 404 Not Found");
$_site = "index.php";
$_GET[ 'site' ] = "./includes/modules/404.php";
$_GET[ 'type' ] = 404;
}
$needed = microtime(true) - $start_time;
header('X-Rebuild-Time: ' . $needed);
require($_site);
}