forked from Webspell-RM/Webspell-RM-Base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rewrite.php
78 lines (75 loc) · 3.74 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
<?php
/*¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\
| _ _ ___ ___ ___ ___ ___ __ __ ___ __ __ |
|( \/\/ )( _)( ,)/ __)( ,\( _)( ) ( ) ( ,) ( \/ ) |
| \ / ) _) ) ,\\__ \ ) _/ ) _) )(__ )(__ ) \ ) ( |
| \/\/ (___)(___/(___/(_) (___)(____)(____) (_)\_)(_/\/\_) |
| ___ ___ |
| |__ \ / _ \ |
| ) | | | | | |
| / / | | | | |
| / /_ _ | |_| | |
| |____| (_) \___/ |
\___________________________________________________________________/
/ \
| Copyright 2005-2018 by webspell.org / webspell.info |
| Copyright 2018-2019 by webspell-rm.de |
| |
| - 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 |
| |
| Code based on WebSPELL Clanpackage |
| (Michael Gruber - webspell.at) |
\___________________________________________________________________/
/ \
| WEBSPELL RM Version 2.0 |
| For Support, Mods and the Full Script visit |
| webspell-rm.de |
\__________________________________________________________________*/
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);
}