facebook twitter hatena line email

「Php/アクセス解析コード」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(ページの作成:「*index.html <<nowiki />script type="text/javascript"><<nowiki />!-- if (document.referrer.length != 0) { document.write('<<nowiki />img src="/refererimg?ref='+ en...」)
 
(相違点なし)

2015年5月20日 (水) 03:18時点における最新版

  • index.html
<script type="text/javascript"><!--
if (document.referrer.length != 0) {
     document.write('<img src="/refererimg?ref='+ encodeURI(document.referrer) + '" />');
}
// -->
</script>
  • index.php
// jsで渡されたurlをサニタイズしてdbへ
$url = $_GET['ref'];
// 1pxの画像
header("Content-type: image/gif");
echo base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');