サイト表示を少しでも軽くしようと、アクセス解析用のプラグインを外したので、そのコバンザメであった「足おと」プラグインは停止してました。
元々、意図しない検索エンジン結果に表示されてしまうというので、適切ではないんだけど、後ろ髪ひかれていた状態だったので復活しました。
index.phpで、$_SERVER[‘REFERER’]を取得してテキスト保存。
crondで、リンクHTML生成。
sidebar.phpでそれをインクルード。
それだけです。
◆index.php
1 2 3 4 5 6 7 8 |
if ( ( $_SERVER['HTTP_REFERER'] != "" ) && ( ! strstr( $_SERVER['HTTP_REFERER'], "mydomain" ) ) ) { $fine_output = "/home/hoge/tmp/referer.txt"; $fp = fopen( $fine_output, "a" ); flock( $fp, LOCK_EX ); fputs( $fp, $_SERVER['HTTP_REFERER'] . "\n" ); flock( $fp, LOCK_UN ); fclose( $fp ); } |
◆sidebar.php
1 2 3 4 5 |
<li><h2><?php echo mb_convert_encoding('足おと', 'UTF-8', 'AUTO');?></h2> <ul> <?php include("/home/hoge/tmp/footstep.txt"); ?> </ul> </li> |
◆crond
1 |
7 2 * * * /home/hoge/tmp/footstep4http_referer.sh > /dev/null 2>&1 & |
◆/home/hoge/tmp/footstep4http_referer.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#!/bin/sh TARGET_INPUT=/home/hoge/tmp/referer.txt; RESULT=`cat $TARGET_INPUT | grep "wp-admin" | sort | uniq`; #echo $RESULT; TARGET_OUTPUT=/home/hoge/tmp/footstep.txt; if [ -f $TARGET_OUTPUT ]; then rm $TARGET_OUTPUT; fi for x in $RESULT; do URL=`echo $x | awk '{split($1,targetName,"wp-admin");print targetName[1];}'`; echo '<a href="'$URL'" target="_blank" style="font-size: 8px; line-height: 1em;">'$URL'</a><br />' >> $TARGET_OUTPUT; done |
No comments yet. You should be kind and add one!
By submitting a comment you grant typista a perpetual license to reproduce your words and name/web site in attribution. Inappropriate and irrelevant comments will be removed at an admin’s discretion. Your email is used for verification purposes only, it will never be shared.