mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-10 22:56:07 +00:00
fix forum surveys
This commit is contained in:
@@ -368,6 +368,22 @@
|
||||
}
|
||||
}
|
||||
/*****************************************
|
||||
Function to vote on forum survey
|
||||
*****************************************/
|
||||
public function Vote($post) {
|
||||
global $database, $session;
|
||||
if($session->access != BANNED){
|
||||
if($database->checkSurvey($post['tid']) && !$database->checkVote($post['tid'], $session->uid)){
|
||||
$survey = $database->getSurvey($post['tid']);
|
||||
$text = ''.$survey['voted'].','.$session->uid.',';
|
||||
$database->Vote($post['tid'], $post['vote'], $text);
|
||||
}
|
||||
header("Location: allianz.php?s=2&fid2=".$post['fid2']."&pid=".$post['pid']."&tid=".$post['tid']);
|
||||
}else{
|
||||
header("Location: banned.php");
|
||||
}
|
||||
}
|
||||
/*****************************************
|
||||
Function to quit from alliance
|
||||
*****************************************/
|
||||
private function quitally($post) {
|
||||
|
||||
@@ -1059,6 +1059,55 @@ class MYSQL_DB {
|
||||
return mysql_insert_id($this->connection);
|
||||
}
|
||||
|
||||
function createSurvey($topic, $title, $option1, $option2, $option3, $option4, $option5, $option6, $option7, $option8, $ends) {
|
||||
$q = "INSERT into " . TB_PREFIX . "forum_survey (topic,title,option1,option2,option3,option4,option5,option6,option7,option8,ends) values ('$topic','$title','$option1','$option2','$option3','$option4','$option5','$option6','$option7','$option8','$ends')";
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
function getSurvey($topic) {
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return mysql_fetch_array($result);
|
||||
}
|
||||
|
||||
function checkSurvey($topic) {
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
if(mysql_num_rows($result)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function Vote($topic, $num, $text) {
|
||||
$q = "UPDATE " . TB_PREFIX . "forum_survey set vote".$num." = vote".$num." + 1, voted = '$text' where topic = ".$topic."";
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
function checkVote($topic, $uid) {
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$array = mysql_fetch_array($result);
|
||||
$text = $array['voted'];
|
||||
if(preg_match('/,'.$uid.',/',$text)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getVoteSum($topic) {
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$array = mysql_fetch_array($result);
|
||||
$sum = 0;
|
||||
for($i=1;$i<=8;$i++){
|
||||
$sum += $array['vote'.$i];
|
||||
}
|
||||
return $sum;
|
||||
}
|
||||
|
||||
function CreatPost($post, $tids, $owner, $alliance, $player, $coor, $report) {
|
||||
$date = time();
|
||||
$q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date','$alliance','$player','$coor','$report')";
|
||||
|
||||
@@ -1062,6 +1062,55 @@ class MYSQLi_DB {
|
||||
return mysqli_insert_id($this->connection);
|
||||
}
|
||||
|
||||
function createSurvey($topic, $title, $option1, $option2, $option3, $option4, $option5, $option6, $option7, $option8, $ends) {
|
||||
$q = "INSERT into " . TB_PREFIX . "forum_survey (topic,title,option1,option2,option3,option4,option5,option6,option7,option8,ends) values ('$topic','$title','$option1','$option2','$option3','$option4','$option5','$option6','$option7','$option8','$ends')";
|
||||
return mysqli_query($this->connection, $q);
|
||||
}
|
||||
|
||||
function getSurvey($topic) {
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
return mysqli_fetch_array($result);
|
||||
}
|
||||
|
||||
function checkSurvey($topic) {
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic";
|
||||
$result = mysqli_query($this->connection, $q);
|
||||
if(mysqli_num_rows($result)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function Vote($topic, $num, $text) {
|
||||
$q = "UPDATE " . TB_PREFIX . "forum_survey set vote".$num." = vote".$num." + 1, voted = '$text' where topic = ".$topic."";
|
||||
return mysqli_query($this->connection, $q);
|
||||
}
|
||||
|
||||
function checkVote($topic, $uid) {
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic";
|
||||
$result = mysqli_query($this->connection, $q);
|
||||
$array = mysqli_fetch_array($result);
|
||||
$text = $array['voted'];
|
||||
if(preg_match('/,'.$uid.',/',$text)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function getVoteSum($topic) {
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "forum_survey where topic = $topic";
|
||||
$result = mysqli_query($this->connection, $q);
|
||||
$array = mysqli_fetch_array($result);
|
||||
$sum = 0;
|
||||
for($i=1;$i<=8;$i++){
|
||||
$sum += $array['vote'.$i];
|
||||
}
|
||||
return $sum;
|
||||
}
|
||||
|
||||
function CreatPost($post, $tids, $owner, $alliance, $player, $coor, $report) {
|
||||
$date = time();
|
||||
$q = "INSERT into " . TB_PREFIX . "forum_post values (0,'$post','$tids','$owner','$date','$alliance','$player','$coor','$report')";
|
||||
|
||||
Reference in New Issue
Block a user