Example #1
0
    $r = mysqli_fetch_assoc($q);
    $comment = isset($_POST['comment']) ? $_POST['comment'] : "";
    $score = isset($_POST['score']) ? $_POST['score'] : 0;
    if ($r['allowDiscussion'] == "no" and $r['allowScoring'] == "no") {
        phpAlert('Posting comments and score for this media is not allowed.');
    } elseif ($r['allowDiscussion'] == "yes" and $r['allowScoring'] == "no") {
        if (!empty($comment)) {
            mysqli_query($connection, "insert into comment (media_id, postedBy, comment)\n                                   values ('{$mediaID}', '{$u_id}', '{$comment}')");
        }
    } elseif ($r['allowDiscussion'] == "no" and $r['allowScoring'] == "yes") {
        postScore($connection, $mediaID, $u_id, $score);
    } elseif ($r['allowDiscussion'] == "yes" and $r['allowScoring'] == "yes") {
        if (!empty($comment)) {
            mysqli_query($connection, "insert into comment (media_id, postedBy, comment)\n                                   values ('{$mediaID}', '{$u_id}', '{$comment}')");
        }
        postScore($connection, $mediaID, $u_id, $score);
    }
    $incrementViews = false;
}
if ($incrementViews) {
    mysqli_query($connection, "update media set views = views+1 where media_id = '{$mediaID}'");
}
$queryOne = mysqli_query($connection, "select * from media where media_id = '{$mediaID}'");
$recordOne = mysqli_fetch_assoc($queryOne);
$recommendKeyword = $recordOne['title'] . $recordOne['description'] . $recordOne['filename'] . $recordOne['keywordOne'] . $recordOne['keywordTwo'] . $recordOne['keywordThree'];
$queryThree = mysqli_query($connection, "select * from media where (instr('{$recommendKeyword}', title) or\n                           instr('{$recommendKeyword}', description) or instr('{$recommendKeyword}', filename) or\n                           instr('{$recommendKeyword}', keywordOne) or instr('{$recommendKeyword}', keywordTwo) or\n                           instr('{$recommendKeyword}', keywordThree)) and user_id != '{$u_id}' and media_id != '{$mediaID}'");
$disabledOne = $recordOne['allowDiscussion'] == "yes" ? "" : "disabled";
$disabledTwo = $recordOne['allowScoring'] == "yes" ? "" : "disabled";
if ($flag == 1) {
    $uname = $_SESSION['username'];
} elseif ($flag == 0) {
<?php

/**
 * Created by PhpStorm.
 * User: Arman Jalalian
 * Date: 12/11/2015
 * Time: 12:56 PM
 */
require "config.php";
postScore();
function postScore()
{
    global $connect;
    $player = $_POST['Player'];
    $score = $_POST['Score'];
    $created = date('Y-m-d H:i:s');
    $postQuery = "INSERT INTO `Highscore`(`Player`, `Score`, `Created`) VALUES ('{$player}', '{$score}', '{$created}')";
    if ($scoreQuery = mysqli_query($connect, $postQuery)) {
        echo "Succes!";
    }
}