2016-08-03 19 views
1

我在php中製作了追蹤網站,追蹤特定鏈接上的點擊次數 - 用於鏈接鏈接追蹤。我正在做的是:追蹤鏈接上的點擊次數 - php

當用戶點擊我的網站提供的鏈接時,他去我的網站,記錄其IP地址後,用戶重定向到映射到鏈接用戶單擊的另一個地址。驗證ip後,計數器遞增點擊次數。

我面臨的問題是,當我比較我的網站和Facebook結果的點擊次數時,我的結果多了很多倍。我不知道那是什麼原因。

我的結果:

enter image description here

Facebook的結果:

enter image description here

enter image description here

我的問題是,爲什麼有區別嗎?如果Facebook有一些額外的檢查,有人知道他們是什麼?或者他們是私人的?或Facebook只是減少點擊次數?

幫助將非常感激。我被困在這裏。

這裏是我的代碼,IP檢查訪客和增加點擊計數器:

<?php 
require_once "dbdata.php"; 

if(isset($_GET['linkid']) && !empty($_GET['linkid'])){ 


$id = $_GET['linkid'];   //getting link id to fetch data from database 
$ip = $_SERVER['REMOTE_ADDR']; // getting visitors ip address 

//database connection 
@$db = new mysqli(hostname,username,password,dbname) or die(json_encode(array("status"=>"Can not connect (Database Connection Error)"))); 


    //getting data from table 
    $query = "select * from links_shared where id = $id ;"; 
    $result_link = $db -> query($query) or die(json_encode(array("status"=>"Error Fetching previous income data"))); 
    $row_link = $result_link-> fetch_assoc(); 

    $link = $row_link['orignal']; //the link to be redirect the user to 

    header("Location:".$link); //redirected 

    if($row_link['status'] == "live"){ //status of link should be live 


    $array_ip = explode(",", $row_link['ip']); //comma sepearted string of ips to array 

    if(!in_array($ip, $array_ip)){ //check if ip is not already present 

     $query = "select * from links_deleted where url = '$link' ;"; //getting block list 
     $result_del = $db -> query($query) or die(json_encode(array("status"=>"Can not select deleted"))); 

     if($result_del -> num_rows <1){ //check if link not in block list 

      $concat = ",".$ip; 
      echo $query = "update links_shared set clicks = (clicks + 1), ip = concat(ip,'$concat') where id= $id; "; 
      $result_update = $db -> query($query) or die(json_encode(array("status"=>"can not update clicks"))); 
     } 

    } 

    } 

} 
?> 

回答

2

無論是Facebook是無效,你的腳本接受點擊(如:不可靠的IP,重複的IP,自動機器人探測... )或更簡單的Facebook只會看到來自其平臺的點擊,但您的腳本會收到來自任何地方的所有點擊。

當然,您的腳本本身也可能存在問題,但由於您沒有顯示,所以無法解決該問題。

+0

我可以通過編輯問題向您展示腳本嗎? thnx的回覆:) – hamza

+0

@hamza你可以將它添加到你的問題,有人可能會發現的東西,可以幫助你改善它。 – BeetleJuice

+0

我當然會...... thnx ....... – hamza