Example #1
0
<?php

// disable the catch from the client browser
header("Cache-Control: no-cache");
require_once 'database.php';
include '../autoloader.php';
require_once './Model/Ratings.php';
$db = Database::getDB();
$units = Database::unit();
$getRollId = Project\Auth\models\AuthModel::getUser('roleId');
if ($getRollId === false) {
    echo "Please Login First to Rate the movies !! Thank You.";
} else {
    $ip = \Project\Auth\models\AuthModel::getUser('id');
    //getting id of movie-1,2,3 which one is click that id from the rating.js page
    $id_sent = preg_replace("/[^0-9]/", "", $_REQUEST['id']);
    //Take the value of star based on user select Ex-user select 1-5 star take that value
    $vote_sent = preg_replace("/[^0-9]/", "", $_REQUEST['stars']);
    // Get The IP address of the local server host machine.
    //$ip =$_SERVER['REMOTE_ADDR'] ;
    $getIP = new Ratings();
    $getIP->getRating_IP($id_sent);
    // kill the script
    if ($vote_sent > $units) {
        die("Sorry, vote appears to be invalid.");
    }
    $disAll = new Ratings();
    $numbers = $disAll->displayValues($id_sent);
    $checkIP = unserialize($numbers['used_ips']);
    $count = $numbers['total_votes'];
    //Grab total votes from database column