久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      wordpress如何實現(xiàn)訪客統(tǒng)計

      下面由WordPress教程欄目給大家介紹wordpress實現(xiàn)訪客統(tǒng)計的方法,希望對需要的朋友有所幫助!

      wordpress如何實現(xiàn)訪客統(tǒng)計

      wordpress程序修改

      簡單介紹一下用php+mysql實現(xiàn)簡單的訪客統(tǒng)計

      一、php腳本

      <?php  //連接數(shù)據(jù)庫  $conn=mysql_connect("localhost","root","root");  if(!$conn){  die("鏈接失敗".mysql_errno());  }  //設(shè)置數(shù)據(jù)庫編碼方式  mysql_query("set names utf8",$conn) or die(mysql_errno());  //選擇數(shù)據(jù)庫  mysql_select_db("wordpress",$conn) or die(mysql_errno());  $adress=$_SERVER["REMOTE_ADDR"];  //將本次訪客的ip地址添加到數(shù)據(jù)庫中  $sql="select times from wp_count where ip='$adress'";  $res=mysql_query($sql,$conn);  if(!$row=mysql_fetch_row($res)){  $sql="insert into wp_count(ip, times) values('$adress','1')";  }else{  $times = $row['0']+1;  $sql="update wp_count set times='$times' where ip='$adress'";  }  $res=mysql_query($sql,$conn); //發(fā)送語句獲取總數(shù)  $sql="select count(ip) from wp_count";  $res=mysql_query($sql,$conn);  if($row=mysql_fetch_row($res)){  $num=$row['0'];  }  echo"您是第 "."$num"." 位訪客"."您的ip地址是"."$adress";  mysql_close();  ?>

      解釋:當(dāng)數(shù)據(jù)庫中當(dāng)前ip沒有的時候,執(zhí)行insert。否則執(zhí)行update。insert插入ip以及初始值times=1,update更新times+1。

      二、數(shù)據(jù)庫示例

      表wp_count
        wordpress如何實現(xiàn)訪客統(tǒng)計
      ps:上面的表結(jié)構(gòu)滿足我的需求,因為我的站點(diǎn)統(tǒng)計的是ip數(shù),而且我將同一個ip無論訪問多少次都認(rèn)定為他是一個訪客。頁面上顯示的多少位就是總共有多少個ip訪問。

      三、效果
        wordpress如何實現(xiàn)訪客統(tǒng)計
      四、擴(kuò)展

      上面的示例使用的是數(shù)據(jù)庫的方式實現(xiàn)。當(dāng)然,如果使用txt文本的形式也是可以的。

      在簡單的訪客統(tǒng)計的基礎(chǔ)上,大家可以為自己的站點(diǎn)添加一個很精確的站點(diǎn)統(tǒng)計。例如實現(xiàn)訪客上次訪問時間,就可以利用js觸發(fā)當(dāng)訪客關(guān)閉當(dāng)前頁面的時候修改訪問時間就能實現(xiàn)。

      ps:經(jīng)測試,百度統(tǒng)計的數(shù)據(jù)并不是非常準(zhǔn)確。因為百度是用引用的js進(jìn)行數(shù)據(jù)統(tǒng)計,如果站點(diǎn)js加載失敗或者其他原因就可能導(dǎo)致某些數(shù)據(jù)未統(tǒng)計到。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號