PHPが実現したブログには、ヒント機能があります。
1、メッセージの訪問者は歓迎の言葉を表示します。2、一般的な訪問者のソース提示3、メッセージを残さない潜水党(リフレッシュは7回以上、メッセージを催促します。)4、IEに対するプッシュアップデートのヒント
使用方法:対応する関数を呼び出して、例えばwelcome_。msg()
<?php
/**
*
* .
* :
* $_SERVER['HTTP_REFERER']
* $_SERVER["HTTP_USER_AGENT"]
* $_COOKIE["comment_author_" . COOKIEHASH]
*
*/
function welcome_msg(){
if($m = apply_filters('welcome_msg',$string)){
echo $m;
return;
}
global $referer;
$referer=$_SERVER['HTTP_REFERER'];
$hostinfo=parse_url($referer);
$host_h=$hostinfo["host"];
$host_p=$hostinfo["path"];
$host=array($host_h,$host_p);
if(substr($host_h, 0, 4) == 'www.')
$host_h = substr($host_h, 4);
$host_h_url='<a href="http://'.$host_h.'/">$host_h</a>';
//
if($referer==""){
echo "<!-- !-->
";
if($_COOKIE["comment_author_" . COOKIEHASH]!=""){
echo 'Howdy, <strong>'.$_COOKIE["comment_author_" . COOKIEHASH].'</strong>, ';
}else{
echo " ! <strong> </strong>. ~ ";
}
//
//baidu
}elseif(preg_match('/baidu.*/i',$host_h)){
echo " <strong> </strong> ! . . ";
//google
}elseif(!preg_match('/www\.google\.com\/reader/i',$referer) && preg_match('/google\./i',$referer)){
echo " <strong>Google</strong> ! . . ";
//yahoo
}elseif(preg_match('/search\.yahoo.*/i',$referer) || preg_match('/yahoo.cn/i',$referer)){
echo " <strong>Yahoo</strong> ! . . ";
//
//google
}elseif(preg_match('/google\.com\/reader/i',$referer)){
echo " <strong>Google</strong> ! . . ^_^";
//xianguo
}elseif(preg_match('/xianguo\.com\/reader/i', $referer)){
echo " <strong> </strong> ! . . ^_^";
//zhuaxia
}elseif(preg_match('/zhuaxia\.com/i', $referer)){
echo " <strong> </strong> ! . . ^_^";
//
}elseif(preg_match('/inezha\.com/i', $referer)){
echo " <strong> </strong> ! . . ^_^";
//
}elseif(preg_match('/reader\.youdao/i', $referer)){
echo " <strong> </strong> ! . . ^_^";
//
}elseif(self()){
echo "<!-- -->"."
";
}elseif($_COOKIE["comment_author_" . COOKIEHASH]!=""){
echo 'Howdy, <strong>'.$_COOKIE["comment_author_" . COOKIEHASH].'</strong> <strong>'.$host_h.'</strong> ';
}else{
echo ' <strong>'. $host_h.'</strong> . ^_^ .';
}
}
//
function self(){
$local_info = parse_url(get_option('siteurl'));
$local_host = $local_info['host'];
//check self
if ( preg_match("/^http:\/\/(\w+\.)?($local_host)/",$_SERVER['HTTP_REFERER']) != 0) return true;
}
/**
* IE
* , cookie
* IE6 ! 20 !
* @see setcookie_for_ie()
*/
function killIE($msg){
if(preg_match('/MSIE\s6/i', $_SERVER['HTTP_USER_AGENT'])){
if(!$_COOKIE['alert_ie_visitor_'.COOKIEHASH]){
$msg .= '<p> ~ , :</p>';
$msg .= '<p> Internet Explorer , W3C , , </p><br/><p> <strong><a rel="nofollow" title="ie8" href="http://www.microsoft.com/windows/internet-explorer/"> Internet Explorer 8</a></strong> <strong> </strong>, . </p>';
//add_action('init', 'setcookie_for_alert_ie_visitor');
}
}elseif(preg_match('/MSIE\s7/i', $_SERVER['HTTP_USER_AGENT'])){
if(!$_COOKIE['alert_ie_visitor_'.COOKIEHASH]){
$msg .= '<p> ~ , :</p>';
$msg .= '<p> Internet Explorer , <strong><a rel="nofollow" title="ie8" href="http://www.microsoft.com/windows/internet-explorer/"> Internet Explorer 8</a></strong> <strong> </strong>, . </p>';
}
}elseif(preg_match('/MSIE\s8/i', $_SERVER['HTTP_USER_AGENT'])){
if(!$_COOKIE['alert_ie_visitor_'.COOKIEHASH]){
$msg .= '<p> ~ , :</p>';
$msg .= '<p> Internet Explorer ! <strong> : </strong><br/> <strong><a rel="nofollow" title="chrome" href="http://www.google.com/chrome/">Chrome</a></strong> <strong><a rel="nofollow" title="firefox" href="http://www.mozilla.com/">Firefox</a></strong> </p>';
}
}else{
return;
}
return $msg;
}
add_filter('welcome_msg','killIE');
/**
*
* cookie
* ajax , -5
*
* @since 2.0.1
* @see welcome_msg, setcookie_for_alert_commentator
* cookies , cookies
*/
function alert_commentator($msg){
global $user_ID;
// . !
if($user_ID){
return;//just return null;
}
if(!isset($_COOKIE['comment_author_visit_times_'.COOKIEHASH]))
return;//
// >=6
// init cookie cookie 7 !
if(((int)$_COOKIE['comment_author_visit_times_'.COOKIEHASH])>=6){
if($comment_author = $_COOKIE['comment_author_'.COOKIEHASH])
$msg = ' ~, '.$comment_author.' ! .';
else
$msg = ' ? ? . .';
}else{
return;//
}
return $msg;
}
add_filter('welcome_msg','alert_commentator');
/**
*
*
* :
* ,
* -5
*
* @since 2.0.2
*/
function setcookie_for_alert_commentator(){
if(is_bot())
return;
global $user_ID;
if($user_ID)
return;
// ,
if(!isset($_COOKIE['comment_author_visit_times_'.COOKIEHASH])){
setcookie('comment_author_visit_times_'. COOKIEHASH, 1, time() + (60*60*24*300), COOKIEPATH, COOKIE_DOMAIN);
}else{
$visit_times = (int)$_COOKIE['comment_author_visit_times_'.COOKIEHASH];
setcookie('comment_author_visit_times_'. COOKIEHASH, ++$visit_times, time() + (60*60*24*300), COOKIEPATH, COOKIE_DOMAIN);
}
// 7 2
if(((int)$_COOKIE['comment_author_visit_times_'.COOKIEHASH])>=7){
// 0
setcookie('comment_author_visit_times_'. COOKIEHASH, -2, time() + (60*60*24*300), COOKIEPATH, COOKIE_DOMAIN);
}
}
add_action('init', 'setcookie_for_alert_commentator');
/**
* ie cookie
*
*
*/
function setcookie_for_ie(){
if(isset($_COOKIE['alert_ie_visitor_'.COOKIEHASH]))
return;
if(preg_match('/MSIE\s6/i', $_SERVER['HTTP_USER_AGENT'])){
// ie (cookies 5 )
setcookie('alert_ie_visitor_'.COOKIEHASH,'ie6',time()+(20),COOKIEPATH,COOKIE_DOMAIN);
}elseif(preg_match('/MSIE\s7/i', $_SERVER['HTTP_USER_AGENT'])){
// ie7 (cookies 3 )
setcookie('alert_ie_visitor_'.COOKIEHASH,'ie7',time()+(60*60*24*3),COOKIEPATH,COOKIE_DOMAIN);
}elseif(preg_match('/MSIE\s8/i', $_SERVER['HTTP_USER_AGENT'])){
// ie8 (cookies 100 )
setcookie('alert_ie_visitor_'.COOKIEHASH,'ie8',time()+(60*60*24*10),COOKIEPATH,COOKIE_DOMAIN);
}
}
add_action('init', 'setcookie_for_ie');