-
Notifications
You must be signed in to change notification settings - Fork 0
/
404.php
76 lines (67 loc) · 2.63 KB
/
404.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
<?php
/* Page is used for posts of type page */
get_header();
?>
<div class="content-column"><?php
debug_location("404");?>
<article class="post page">
<?php
$the_slug = 'error-404';
$args = array(
'name' => $the_slug,
'post_type' => 'page',
'post_status' => 'publish',
'numberposts' => 1
);
$my_posts = get_posts($args);
if( $my_posts ) {
// echo 'ID on the first post found ' . $my_posts[0]->ID;
// var_dump( $my_posts[0] );
// echo "ID: " . $my_posts[0]->ID . "<br>";
echo "<h2>" . $my_posts[0]->post_title . "</h2>"; ?>
<div id="content-container align-center" style="width: 75%; margin:auto;"><?php
echo $my_posts[0]->post_content;
} else { ?>
<h2>404-default</h2>
<div id="content-container align-center" style="width: 75%;"> <?php
}?>
<br/>
<p>You <?php
#some variables for the script to use
#if you have some reason to change these, do. but wordpress can handle it
$adminemail = get_option('admin_email'); #the administrator email address, according to wordpress
$website = get_bloginfo('url'); #gets your blog's url from wordpress
$websitename = get_bloginfo('name'); #sets the blog's name, according to wordpress
if (!isset($_SERVER['HTTP_REFERER'])) {
#politely blames the user for all the problems they caused
echo "tried going to "; #starts assembling an output paragraph
$casemessage = "All is not lost!";
} elseif (isset($_SERVER['HTTP_REFERER'])) {
#this will help the user find what they want, and email me of a bad link
echo "clicked a link to"; #now the message says You clicked a link to...
#setup a message to be sent to me
$failuremess = "A user tried to go to $website<b><em>"
.$_SERVER['REQUEST_URI']."</em></b> and received a 404 (page not found) error. ";
$failuremess .= "It wasn't their fault, so try fixing it.
They came from ".$_SERVER['HTTP_REFERER'];
mail($adminemail, "Bad Link To ".$_SERVER['REQUEST_URI'],
$failuremess, "From: $websitename <noreply@$website>"); #email you about problem
$casemessage = "An administrator has been emailed
about this problem, too.";#set a friendly message
}
echo " '<b><em>".$website.$_SERVER['REQUEST_URI']."'</em></b> "; ?>
and it doesn't exist. <?php echo $casemessage; ?> You can search for what you're looking for:
<br/>
<div id="content-container align-center" style="width: 50%; margin:auto;">
<br/>
<?php include(TEMPLATEPATH . "/searchform.php"); ?>
<br/>
</div>
</p>
</div>
</article>
</div>
<?php
get_sidebar();
get_footer();
?>