Ejemplo n.º 1
0
function vote()
{
    if (isset($_GET['dir']) && isset($_GET['did'])) {
        $d = new Diff();
        if ($d->populateDiff($_GET['did'])) {
            if ($_GET['dir'] == 1 || $_GET['dir'] == -1) {
                $db = new DB();
                $db->query("SELECT * FROM `rating` WHERE `did` = '{$_GET['did']}' AND `uid` = '{$_SESSION['uid']}';");
                if ($db->numRows() == 0) {
                    $db->query("INSERT INTO `rating` (`did`, `uid`, `rating`) VALUES ('{$_GET['did']}', '{$_SESSION['uid']}', '{$_GET['dir']}');");
                } else {
                    $db->query("UPDATE `rating` SET `rating` = '{$_GET['dir']}' WHERE `did` = '{$_GET['did']}' AND `uid` = '{$_SESSION['uid']}';");
                }
                $db->close();
            }
        }
    }
}