<?php
function ip_get(){
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
//ip from share internet
$new_ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
//ip pass from proxy
$new_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$new_ip = $_SERVER['REMOTE_ADDR'];
}
global $wpdb;
$table_name=$wpdb->prefix.'wbs_user_ips';
$results = $wpdb->get_results( "SELECT * FROM $table_name"); // Query to fetch data from database table and storing in $results
if(empty($results)){
$wpdb->insert($table_name,
array(
'user_ip'=>$new_ip,
'user_count'=>'1',
'user_status'=>'0',
)
);
}
if(!empty($results)) // Checking if $results have some values or not
{
$count=0;
foreach($results as $row){
$ip= $row->user_ip;
$count=$row->user_count;
}
if($ip==$new_ip){
echo $count++;
$wpdb->query($wpdb->prepare("UPDATE $table_name
SET user_count=".$count."
WHERE user_ip = %s",$ip));
}
}
}
?>
when i run the plugin count variables increment 4 times or 5 time can you please help me
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745321025a4622442.html
评论列表(0条)