/*
Plugin Name: 404 SEO Plugin
Version: 2.1
Plugin URI: http://www.404plugin.com
Description: Give yourself an SEO boost! Replaces 404 error with suggestions of related pages on the site. After installing, go here, and add <?custom404_print404message();?> to your 404 Template where you want the suggestions to appear. Version 2.1 fixes stability issues and gives cleaner, improved search results.
Author: 404 Plugin
Author URI: http://www.404plugin.com
*/
function custom404_print404message()
{
global $custom404_server;
global $custom404_missingpagestr;
$custom404_missingpagestr = custom404_getmissingpagestr();
$custom404_missingpagestr = str_replace(' ', '+', $custom404_missingpagestr);
$custom404_headline = 'Related pages on this site';
$custom404_server[] = "+site%3A$_SERVER[SERVER_NAME]";
//new version
$custom404_googleresults = custom404_getgoogleresults($custom404_missingpagestr, $_SERVER[SERVER_NAME]);
if (!($custom404_googleresults))
{
$custom404_headline = 'No local results found. From the web:';
$custom404_googleresults = custom404_getgoogleresults($custom404_missingpagestr);
$custom404_yahooresults = custom404_getyahooresults($custom404_missingpagestr);
$custom404_yahooresultsarr = explode("\n", $custom404_yahooresults);
$custom404_formattedyahooresults = '';
foreach ($custom404_yahooresultsarr as $custom404_yahooresult)
{
if (strlen(trim($custom404_yahooresult)))
if (strpos($custom404_googleresults, $custom404_yahooresult) === false &&
strpos($custom404_googleresults, str_replace('rel=nofollow', '', $custom404_yahooresult)) === false )
$custom404_formattedyahooresults .= "$custom404_yahooresult\n";
}
if (!($custom404_googleresults) && !($custom404_formattedyahooresults))
{
$custom404_googleresults = '
No results found on the web.';
}
else
{
$custom404_googleresults = ($custom404_googleresults == '0') ? '' : $custom404_googleresults;
$custom404_formattedyahooresults = ($custom404_formattedyahooresults == '0') ? '' : $custom404_formattedyahooresults;
$custom404_googleresults = utf8_encode($custom404_googleresults );
$custom404_formattedyahooresults = utf8_encode($custom404_formattedyahooresults );
}
}
$custom404_googleresults = $custom404_headline . "
" . $custom404_googleresults;
$custom404_formattedquerystring = $_SERVER[REDIRECT_QUERY_STRING] ? "?$_SERVER[REDIRECT_QUERY_STRING]":"";
print "
Suggestions$custom404_googleresults $custom404_formattedyahooresults |