나는 특정 링크의 클릭 수를 추적하는 PHP 추적 웹 사이트를 만들었습니다. 내가하고있는 일은 다음과 같습니다.링크의 클릭 수 추적 - php
사용자가 내 웹 사이트에서 제공하는 링크를 클릭하면 사용자가 내 웹 사이트로 이동하여 IP 주소를 기록한 후 클릭 한 링크 사용자에 매핑 된 다른 주소로 사용자를 리디렉션합니다. 카운터는 ip 확인 후 클릭 수를 증가시킵니다.
내가 직면 한 문제는 내 웹 사이트의 클릭 수와 페이스 북 결과의 클릭 수를 비교할 때 내 결과가 여러 번 더 많다는 것입니다. 나는 그 원인이 무엇인지 모른다.
내 결과 :
페이스 북 결과 :
내 질문은 왜 차이가 있다는 것입니다? 페이스 북에 추가 점검 사항이 있다면 누군가가 그 내용을 알고 있습니까? 아니면 비공개입니까? 또는 페이스 북은 단지 클릭 수를 줄이는가?
도움말 정말 감사하겠습니다. 나는 여기 붙어있다.
다음은 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")));
}
}
}
}
?>
질문을 편집하여 스크립트를 표시 할 수 있습니까? thnx : – hamza
@hamza 당신은 당신의 질문에 그것을 추가 할 수 있고 누군가 당신이 그것을 향상시키는 데 도움이 될만한 것을 발견 할 수 있습니다. – BeetleJuice
나는 반드시 ... thnx ....... – hamza