-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvote_thread.php
31 lines (29 loc) · 1.17 KB
/
vote_thread.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
require_once("Plans.php");
require_once("Configuration.php");
require("functions-main.php");//load main functions
$dbh = db_connect();//establish the database handler
$idcookie = User::id();
if ( !User::logged_in())
{
gdisp_begin($dbh);//begin guest display
echo("You are not allowed to edit as a guest.");//tell person they can't log in
gdisp_end();}//end guest display
else //elseallowed to edit
{
if (!isset($_REQUEST['messageid'])) die("messageid must be specified");
$messageid = (int)$_REQUEST['messageid'];
$vote = isset($_REQUEST['vote'])?$_REQUEST['vote']:"";
mysqli_query($dbh,"delete from boardvotes where userid = '$idcookie' and messageid = '$messageid'");
if ($vote == "y") {
mysqli_query($dbh,"insert into boardvotes (userid, threadid, messageid, vote) values ('$idcookie',(select threadid from subboard where messageid = '$messageid'), '$messageid', 1)");
}
if ($vote == "n") {
mysqli_query($dbh,"insert into boardvotes (userid, threadid, messageid, vote) values ('$idcookie',(select threadid from subboard where messageid = '$messageid'), '$messageid', -1)");
}
}
?>
Success
<?php
db_disconnect($dbh);
?>