public function storeRating($id, CreateRatingRequest $request)
 {
     $input = $request->all();
     if ($input['rating'] == null) {
         flash()->error("You must choose a value in order to rate this series.");
         return \Redirect::back();
     }
     $newrating = new Rating();
     $newrating->rating = $input['rating'];
     $newrating->userId = Auth::id();
     $newrating->seriesId = $input['sId'];
     //we already know that the "requester" hasn't rated this serie yet
     addRating($newrating);
     flash()->success("Your rating has been stored successfully.");
     return \Redirect::back();
 }
Exemplo n.º 2
0
    } else {
        $url = $_SERVER['REQUEST_URI'];
        echo "<meta http-equiv=\"refresh\" content=\"0;url=Login.php?url={$url}\">";
    }
}
if (isset($_POST['playlist'])) {
    if ($_SESSION["username"]) {
        addMediaPlaylist($_POST['ply'], $mid);
    } else {
        $url = $_SERVER['REQUEST_URI'];
        echo "<meta http-equiv=\"refresh\" content=\"0;url=Login.php?url={$url}\">";
    }
}
if (isset($_POST['rate'])) {
    if ($_SESSION["username"]) {
        addRating($id, $mid, $_POST['rating']);
        echo "<meta http-equiv=\"refresh\" content=\"0\">";
    } else {
        $url = $_SERVER['REQUEST_URI'];
        echo "<meta http-equiv=\"refresh\" content=\"0;url=Login.php?url={$url}\">";
    }
}
if (isset($_POST['channel'])) {
    if ($_SESSION["username"]) {
        addMediaChannel($_POST['chl'], $mid);
    } else {
        $url = $_SERVER['REQUEST_URI'];
        echo "<meta http-equiv=\"refresh\" content=\"0;url=Login.php?url={$url}\">";
    }
}
echo "<br/>";
Exemplo n.º 3
0
<?php

require_once "ApiLibrary.php";
session_start();
//Checks if this is running from a request
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'GET') {
    //This checks to see if anything was passed into the parameter userName
    if (!isset($_GET['iid']) || !isset($_GET['rating']) || !isset($_GET['comment'])) {
        //handle error
    } else {
        $_iid = $_GET['iid'];
        if (!isset($_SESSION['username']) || $_SESSION['username'] == null) {
            echo json_encode(array("error" => "must be logged in to buy item."));
            return;
        }
        $_iid = $_GET['iid'];
        $_username = $_SESSION['username'];
        $_rating = $_GET['rating'];
        $_comment = $_GET['comment'];
        echo addRating($_iid, $_username, $_rating, $_comment);
    }
}
Exemplo n.º 4
0
function updateRatings($data, $database)
{
    //get ratings FROM database
    try {
        $sql = 'SELECT * FROM pegiRating';
        $results = $database->query($sql);
    } catch (Expcetion $e) {
        echo $e->getMessage();
        die;
    }
    //gets all ratings in the database and stores in array
    $inDBRate[] = "";
    foreach ($results as $rate) {
        $inDBRating = $rate['rating'];
        if (!in_array($inDBRating, $inDBRate)) {
            $inDBRate[] = $inDBRating;
        }
    }
    //gets all developers in JSON and stores in array
    $inJSONRate[] = "";
    foreach ($data['library'] as $game) {
        $inJSONRating = $game['pegi_rating'];
        if (!in_array($inJSONRating, $inJSONRate)) {
            $inJSONRate[] = $inJSONRating;
        }
    }
    //Returns the array with ratings not in the database but in JSON file
    $updatedRates = array_diff($inJSONRate, $inDBRate);
    //Adds updated developers to database;
    foreach ($updatedRates as $newRate) {
        addRating($newRate, $database);
    }
}
Exemplo n.º 5
0
mysql_select_db($dbn);
@mysql_query("SET NAMES cp1251");
$html = 1;
if (isset($_POST['rating']) && is_array($_POST['rating'])) {
    $rating = $_POST['rating'];
    $id = isset($_POST['id']) && is_numeric($_POST['id']) ? $_POST['id'] : 0;
    $r = 1;
    foreach ($rating as $v) {
        $r = is_numeric($v) ? 1 : 0;
        if (!$r) {
            break;
        }
    }
    if ($r && $id) {
        for ($i = 1; $i <= 3; $i++) {
            addRating($id, $i, $rating[$i]);
        }
        $html = 2;
    } else {
        die('Bad params');
    }
}
function addRating($id, $type, $rating)
{
    $oResult = mysql_query("SELECT * FROM pm_rating WHERE sID = '{$id}' AND type = '{$type}' LIMIT 1");
    if ($oResult && mysql_num_rows($oResult)) {
        mysql_query("UPDATE pm_rating SET grade=grade+'{$rating}', count=count+1 WHERE sID = '{$id}' AND type = '{$type}' LIMIT 1");
    } else {
        mysql_query("INSERT INTO pm_rating (rID, sID, type, grade, count) VALUES ('', '{$id}', '{$type}', '{$rating}', '1')");
    }
}