网站维护指南
碎碎念   June 6, 2009   引用(0)   
点击在新窗口中浏览此图片
以下代码仅供“技术故障”或“不可抗力因素”影响时使用,代码添加于blog根目录下的index.php最前面即可。
function fromasearchengine(){
  if(preg_match("/(Bot|Crawl|Spider|slurp|sohu-search|lycos|robozilla)/i", $_SERVER['HTTP_USER_AGENT'])) {
  return true;
}
else return false;
}
date_default_timezone_set("Etc/GMT-8");
if( date("Y-m-d") == '2009-06-04' ){
  if( !fromasearchengine() ){
    header("Content-type: text/html; charset=utf8");
    echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
    echo '<body style="text-align:center;background:#3E3E3E;color:#BBBEC2;padding:100px 0 0 0;font-size:16px;">由于 Page not found 直肠梗塞 + 博主鬼火喜欢瞎掺和,本blog今天不工作。<br /><img src="http://www.404cn.net/blog/mm.jpg" style="margin:10px 0;border:5px solid #000;"/></body>';
    die();
  }
}

对于灰常喜欢瞎折腾的同学,还可将维护页存为maintenance.html,与index.php保存于同一目录,然后使用如下代码变体:
function fromasearchengine(){
  if(preg_match("/(Bot|Crawl|Spider|slurp|sohu-search|lycos|robozilla)/i", $_SERVER['HTTP_USER_AGENT'])) {
  return true;
}
else return false;
}
date_default_timezone_set("Etc/GMT-8");
if( date("Y-m-d") == '2009-06-04' ){
  if( !fromasearchengine() ){
    header(”location:maintenance.html”);
    die();
  }
}

以上代码变体于http://docs.google.com/View?id=dfmzrmzj_222cm4sx7fc,链接页有详细注释
This entry comes from 本站原创 and has been read for 1094 times. It is tagged with , .
0cai Email Homepage says: at June 13, 2009 23:50
鬼火总是在技术之中寻求风趣!
鬼火 回复于 June 16, 2009 20:01
跟风而已
博爱老头 Homepage says: at June 10, 2009 17:38
那天,我坚挺了。。。
鬼火 回复于 June 12, 2009 20:05
难道我要说我萎了吗
FORECE Homepage says: at June 6, 2009 22:24
终于维护完了?
鬼火 回复于 June 6, 2009 23:31
那是,就一天
分页: 1/1 第一页 1 最后页
发表评论

昵称

网址

电邮

OpenID登入 高级选项 表情