Beispiel #1
0
                    if (getenv('HTTP_FORWARDED')) {
                        $ipaddress = getenv('HTTP_FORWARDED');
                    } else {
                        if (getenv('REMOTE_ADDR')) {
                            $ipaddress = getenv('REMOTE_ADDR');
                        } else {
                            $ipaddress = 'UNKNOWN';
                        }
                    }
                }
            }
        }
    }
    return $ipaddress;
}
$rate = $_POST['rate'];
$video_id = $_POST['video_id'];
$ipadresa = get_client_ip_env();
$ratAct = new RatingActions();
$result = $ratAct->checkUser($ipadresa, $video_id);
if ($result !== false) {
    if ($rate === $result['Rate']) {
        echo "You have already liked this video";
    } else {
        $res = $ratAct->updateUser($video_id, $rate, $ipadresa);
        echo "updated";
    }
} else {
    $ratAct->insertUser($video_id, $rate, $ipadresa);
    echo "you successfuly rated this video";
}
Beispiel #2
0
 public function checkUser()
 {
     $rate = $_POST['rate'];
     $video_id = $_POST['video_id'];
     $ipadresa = $this->get_client_ip_env();
     $ratAct = new RatingActions();
     $result = $ratAct->checkUser($ipadresa, $video_id);
     if ($result !== false) {
         if ($rate === $result['Rate']) {
             echo "You have already liked this video";
         } else {
             $res = $ratAct->updateUser($video_id, $rate, $ipadresa);
             echo "updated";
         }
     } else {
         $ratAct->insertUser($video_id, $rate, $ipadresa);
         echo "you successfuly rated this video";
     }
 }