OpenVPN_Management_GUI/Modules/Forum/include/dislike.php

70 lines
1.9 KiB
PHP
Raw Normal View History

2012-07-16 21:30:19 +02:00
<?php
session_start();
include($_SERVER["DOCUMENT_ROOT"]."/Site/checkuser.php");
$tbl_name="forum_like"; // Table name
// Connect to server and select database.
include ($_SERVER["DOCUMENT_ROOT"]."/Config/_dbconfig_.php");
$moduleurl = $_REQUEST['path'];
@$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
@$x = mysql_select_db($MYSQL_DATABASE);
if (empty($x))
{
die ("Keine Verbindung zur Datenbank! [<b><font color=red>FAIL</b></font>]<br>");
}
// get data that sent from form
$topic=mysql_real_escape_string($_REQUEST['topic']);
$answer=mysql_real_escape_string($_REQUEST['answer']);
$user=mysql_real_escape_string($_REQUEST['user']);
$datetime=date("d/m/y H:i:s"); //create date time
if($user != $_SESSION["user_nickname"])
die("THIS IS NOT ALLOWED!");
if($topic != "")
{
if($answer=="0")
{
$sql = "SELECT `dislike` FROM forum_question WHERE `id` = '".$topic."'";
$result2 = mysql_query ($sql);
$like=mysql_fetch_array ($result2);
if($like[0] == "")
$like[0] = 0;
$sql="UPDATE forum_question SET `dislike`='".($like[0]+1)."' WHERE `id` = '".$topic."'";
mysql_query($sql);
}
else
{
$sql = "SELECT `a_dislike` FROM forum_answer WHERE `question_id` = '".$topic."' AND `a_id` = '".$answer."'";
$result2 = mysql_query ($sql);
$like=mysql_fetch_array ($result2);
if($like[0] == "")
$like[0] = 0;
$sql="UPDATE forum_answer SET `a_dislike`='".($like[0]+1)."' WHERE `question_id`= '".$topic."' AND `a_id` = '".$answer."'";
mysql_query($sql);
}
$sql="INSERT INTO $tbl_name (`question`, `answer`, `nickname`, `datetime`, `like`) VALUES ('$topic', '$answer', '$user', '$datetime', 'dislike');";
//echo $sql;
$result=mysql_query($sql);
if($result)
{
header ("Location: ".$moduleurl."&uebergabe=1&uebergabe2=".$topic);
}
else
{
echo "ERROR: ".$sql;
}
}
else
{
header ("Location: ".$moduleurl."&uebergabe=1&uebergabe2=".$topic);
}
mysql_close();
?>