-
Notifications
You must be signed in to change notification settings - Fork 2
/
z-protect.php
46 lines (40 loc) · 992 Bytes
/
z-protect.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
<?php
if (defined('TEMPLATEPATH') || defined('WPUTH_IS_Z_PROTECT')) {
return;
}
define('WPUTH_IS_Z_PROTECT', true);
// Load base WordPress file
$bootfile = 'wp-blog-header.php';
while (!is_file($bootfile)) {
if (is_dir('..')) {
if (!chdir('..')) {
exit();
}
}
else {
exit('Oops');
}
}
include ($bootfile);
// Redirect to home page for some files
if (isset($_SERVER['REQUEST_URI'])) {
$url = parse_url($_SERVER['REQUEST_URI']);
if (isset($url['path'])) {
$current_filename = basename($url['path']);
$invalid_files = array(
'comments.php',
'functions.php',
'header.php',
'footer.php'
);
if (in_array($current_filename, $invalid_files)) {
wp_redirect(home_url());
die;
}
}
}
// Load 404
header($_SERVER["SERVER_PROTOCOL"] . " 404 Not Found");
$GLOBALS['wp_query']->set_404();
include get_404_template();
die;