tyler_r
New Member


Joined: Dec 16, 2005
Posts: 1
|
Posted:
Fri Dec 16, 2005 7:36 pm |
|
I think they believe it has been fixed but it hasn't I am having the same problem. It's very trying looking for a solution, but if I find one I will post it all the same.
I have found a solution and it worked for me. I used the nuke 7.5 admin file that is in surveys/admin/
index.php file:
Code:
<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/* */
/************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* http://www.nukefixes.com -- http://www.nukeresources.com */
/************************************************************************/
if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
global $prefix, $db;
$aid = substr("$aid", 0,25);
$row = $db->sql_fetchrow($db->sql_query("SELECT title, admins FROM ".$prefix."_modules WHERE title='Surveys'"));
$row2 = $db->sql_fetchrow($db->sql_query("SELECT name, radminsuper FROM ".$prefix."_authors WHERE aid='$aid'"));
$admins = explode(",", $row['admins']);
$auth_user = 0;
for ($i=0; $i < sizeof($admins); $i++) {
if ($row2['name'] == "$admins[$i]" AND $row['admins'] != "") {
$auth_user = 1;
}
}
if ($row2['radminsuper'] == 1 || $auth_user == 1) {
/*********************************************************/
/* Poll/Surveys Functions */
/*********************************************************/
function puthome($ihome, $acomm) {
echo "<br><b>" . _PUBLISHINHOME . "</b> ";
if (($ihome == 0) OR ($ihome == "")) {
$sel1 = "checked";
$sel2 = "";
}
if ($ihome == 1) {
$sel1 = "";
$sel2 = "checked";
}
echo "<input type=\"radio\" name=\"ihome\" value=\"0\" $sel1>" . _YES . " "
."<input type=\"radio\" name=\"ihome\" value=\"1\" $sel2>" . _NO . ""
." <font class=\"content\">[ " . _ONLYIFCATSELECTED . " ]</font><br>";
echo "<br><b>" . _ACTIVATECOMMENTS . "</b> ";
if (($acomm == 0) OR ($acomm == "")) {
$sel1 = "checked";
$sel2 = "";
}
if ($acomm == 1) {
$sel1 = "";
$sel2 = "checked";
}
echo "<input type=\"radio\" name=\"acomm\" value=\"0\" $sel1>" . _YES . " "
."<input type=\"radio\" name=\"acomm\" value=\"1\" $sel2>" . _NO . "</font><br><br>";
}
function SelectCategory($cat) {
global $prefix, $db;
$selcat = $db->sql_query("SELECT catid, title from " . $prefix . "_stories_cat order by title");
$a = 1;
echo "<b>" . _CATEGORY . "</b> ";
echo "<select name=\"catid\">";
if ($cat == 0) {
$sel = "selected";
} else {
$sel = "";
}
echo "<option name=\"catid\" value=\"0\" $sel>" . _ARTICLES . "</option>";
while ($row = $db->sql_fetchrow($selcat)) {
$catid = intval($row['catid']);
$title = stripslashes($row['title']);
if ($catid == $cat) {
$sel = "selected";
} else {
$sel = "";
}
echo "<option name=\"catid\" value=\"$catid\" $sel>$title</option>";
$a++;
}
echo "</select> [ <a href=\"admin.php?op=AddCategory\">" . _ADD . "</a> | <a href=\"admin.php?op=EditCategory\">" . _EDIT . "</a> | <a href=\"admin.php?op=DelCategory\">" . _DELETE . "</a> ]";
}
function poll_createPoll() {
global $language, $admin, $multilingual, $prefix, $db;
include ('header.php');
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>" . _POLLSADMIN . "</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
echo "<center><font class=\"option\"><b>" . _CREATEPOLL . "</b></font><br><br>"
."[ <a href=\"admin.php?op=remove\">" . _DELETEPOLLS . "</a> | <a href=\"admin.php?op=polledit_select\">" . _EDITPOLL . "</a> ]</center><br><br>"
."<form action=\"admin.php\" method=\"post\">"
."" . _POLLTITLE . ": <input type=\"text\" name=\"pollTitle\" size=\"50\" maxlength=\"100\"><br><br>";
if ($multilingual == 1) {
echo "<br>" . _LANGUAGE . ": "
."<select name=\"planguage\">";
$handle=opendir('language');
while ($file = readdir($handle)) {
if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
$langFound = $matches[1];
$languageslist .= "$langFound ";
}
}
closedir($handle);
$languageslist = explode(" ", $languageslist);
sort($languageslist);
for ($h=0; $h < sizeof($languageslist); $h++) {
if($languageslist[$h]!="") {
echo "<option value=\"$languageslist[$h]\" ";
if($languageslist[$h]==$language) echo "selected";
echo ">" . ucfirst($languageslist[$h]) . "</option>\n";
}
}
echo "</select><br><br>";
} else {
echo "<input type=\"hidden\" name=\"planguage\" value=\"$language\"><br><br>";
}
echo "<font class=\"content\">" . _POLLEACHFIELD . "</font><br>"
."<table border=\"0\">";
for($i = 1; $i <= 12; $i++) {
echo "<tr>"
."<td>" . _OPTION . " $i:</td><td><input type=\"text\" name=\"optionText[$i]\" size=\"50\" maxlength=\"50\"></td>"
."</tr>";
}
echo "</table>"
."<br><br><center><hr size=\"1\" noshade><font class=\"option\"><b>" . _ANNOUNCEPOLL . "</b></font><br>"
."<font class=\"tiny\">" . _LEAVEBLANK . "</font></center>"
."<br><br><b>" . _TITLE . ":</b><br>"
."<input type=\"text\" name=\"title\" size=\"40\"><br><br>";
$cat = 0;
$ihome = 0;
$acomm = 0;
SelectCategory($cat);
echo "<br>";
puthome($ihome, $acomm);
echo "<b>" . _TOPIC . "</b> <select name=\"topic\">";
$toplist = $db->sql_query("SELECT topicid, topictext from " . $prefix . "_topics order by topictext");
echo "<option value=\"\">" . _SELECTTOPIC . "</option>\n";
while ($row = $db->sql_fetchrow($toplist)) {
$topicid = intval($row['topicid']);
$topics = $row['topictext'];
echo "<option value=\"$topicid\">$topics</option>\n";
}
echo "</select>";
echo "<br><br><b>" . _STORYTEXT . "</b><br>"
."<textarea wrap=\"virtual\" cols=\"50\" rows=\"7\" name=\"hometext\">$story</textarea><br><br>"
."<b>" . _EXTENDEDTEXT . "</b><br>"
."<textarea wrap=\"virtual\" cols=\"50\" rows=\"8\" name=\"bodytext\"></textarea><BR>"
."<br><br>"
."<input type=\"hidden\" name=\"op\" value=\"createPosted\">"
."<input type=\"submit\" value=\"" . _CREATEPOLLBUT . "\">"
."</form>";
CloseTable();
include ('footer.php');
}
function old_poll_createPosted() {
global $pollTitle, $optionText, $prefix, $db, $planguage;
$timeStamp = time();
$res = $db->sql_query("INSERT INTO " . $prefix . "_poll_desc VALUES (NULL, '$pollTitle', '$timeStamp', '$planguage', '0')");
if (!$res) {
return;
}
/* create option records in data table */
for($i = 1; $i <= 12; $i++) {
if($optionText[$i] != "") {
$result = $db->sql_query("INSERT INTO " . $prefix . "_poll_data VALUES ('$id', '$optionText[$i]', '0', '$i')");
}
if (!result) {
return;
}
}
Header("Location: admin.php?op=adminMain");
}
function poll_createPosted($pollTitle, $optionText, $planguage, $title, $hometext, $topic, $bodytext, $catid, $ihome, $acomm) {
global $prefix, $db, $aid;
$timeStamp = time();
$pollTitle = FixQuotes($pollTitle);
if(!$db->sql_query("INSERT INTO " . $prefix . "_poll_desc VALUES (NULL, '$pollTitle', '$timeStamp', '0', '$planguage', '0')")) {
return;
}
$object = $db->sql_fetchrow($db->sql_query("SELECT pollID FROM ".$prefix."_poll_desc WHERE pollTitle='$pollTitle'"));
$id = $object['pollID'];
$id = intval($id);
for($i = 1; $i <= sizeof($optionText); $i++) {
if($optionText[$i] != "") {
$optionText[$i] = FixQuotes($optionText[$i]);
}
if(!$db->sql_query("INSERT INTO " . $prefix . "_poll_data (pollID, optionText, optionCount, voteID) VALUES ('$id', '$optionText[$i]', '0', '$i')")) {
return;
}
}
if (($title != "") AND ($hometext != "")) {
$title = stripslashes(FixQuotes($title));
$hometext = stripslashes(FixQuotes($hometext));
$bodytext = stripslashes(FixQuotes($bodytext));
$result = $db->sql_query("insert into ".$prefix."_stories values (NULL, '$catid', '$aid', '$title', now(), '$hometext', '$bodytext', '0', '0', '$topic', '$aid', '', '$ihome', '$planguage', '$acomm', '0', '0', '0', '0', '')");
}
Header("Location: admin.php?op=adminMain");
}
function poll_removePoll() {
global $prefix, $db;
include ('header.php');
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>" . _POLLSADMIN . "</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
echo "<center><font class=\"option\"><b>" . _REMOVEEXISTING . "</b></font><br><br>"
."" . _POLLDELWARNING . "</center><br><br>"
."" . _CHOOSEPOLL . "<br>"
."<form action=\"admin.php\" method=\"post\">"
."<input type=\"hidden\" name=\"op\" value=\"removePosted\">"
."<table border=\"0\">";
$result = $db->sql_query("SELECT pollID, pollTitle, timeStamp, planguage FROM ".$prefix."_poll_desc ORDER BY timeStamp");
if(!$result) {
return;
}
/* cycle through the descriptions until everyone has been fetched */
while($object = $db->sql_fetchrow($result)) {
$pollID = $object['pollID'];
$pollID = intval($pollID);
echo "<tr><td><input type=\"radio\" name=\"id\" value=\"".$object['pollID']."\">".$object['pollTitle']." - (".$object['planguage'].")</td></tr>";
}
echo "</table>";
echo "<input type=\"submit\" value=\"" . _DELETE . "\">";
echo "</form>";
CloseTable();
include ('footer.php');
}
function poll_removePosted() {
global $id, $prefix, $db;
$id = intval($id);
$db->sql_query("DELETE FROM " . $prefix . "_poll_desc WHERE pollID='$id'");
$db->sql_query("DELETE FROM " . $prefix . "_poll_data WHERE pollID='$id'");
Header("Location: admin.php?op=adminMain");
}
function polledit_select() {
global $prefix, $db;
include ('header.php');
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>" . _POLLSADMIN . "</b></font></center>";
CloseTable();
echo "<br>";
OpenTable();
echo "<center><font class=\"option\"><b>" . _EDITPOLL . "</b></font></center><br><br>"
."" . _CHOOSEPOLLEDIT . "<br>"
."<form action=\"admin.php\" method=\"post\">"
."<input type=\"hidden\" name=\"op\" value=\"polledit\">"
."<table border=\"0\">";
$result = $db->sql_query("SELECT pollID, pollTitle, timeStamp, planguage FROM ".$prefix."_poll_desc ORDER BY timeStamp");
if(!$result) {
return;
}
/* cycle through the descriptions until everyone has been fetched */
while($object = $db->sql_fetchrow($result)) {
$pollID = $object['pollID'];
$pollID = intval($pollID);
echo "<tr><td><input type=\"radio\" name=\"pollID\" value=\"".$object['pollID']."\">".$object['pollTitle']." - (".$object['planguage'].")</td></tr>";
}
echo "</table>";
echo "<input type=\"submit\" value=\"" . _EDIT . "\">";
echo "</form>";
CloseTable();
include ('footer.php');
}
function polledit($pollID) {
global $prefix, $db, $multilingual;
include ('header.php');
GraphicAdmin();
OpenTable();
echo "<center><font class=\"title\"><b>" . _POLLSADMIN . "</b></font></center>";
$pollID = intval($pollID);
$row = $db->sql_fetchrow($db->sql_query("SELECT pollTitle, planguage from " . $prefix . "_poll_desc where pollID='$pollID'"));
$pollTitle = $row['pollTitle'];
$planguage = $row['planguage'];
CloseTable();
echo "<br>";
OpenTable();
echo "<center><b>"._POLLEDIT." $pollTitle</b></center><br><br>";
echo "<form action=\"admin.php\" method=\"post\">";
echo "<table border=\"0\" align=\"center\"><tr><td align=\"right\">";
echo "<b>" . _TITLE . ":</b></td><td colspan=\"2\"><input type=\"text\" name=\"pollTitle\" value=\"$pollTitle\" size=\"40\" maxlength=\"100\"></td></tr>";
if ($multilingual == 1) {
echo "<tr><td><b>" . _LANGUAGE . ":</b></td><td>"
."<select name=\"planguage\">";
$handle=opendir('language');
while ($file = readdir($handle)) {
if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
$langFound = $matches[1];
$languageslist .= "$langFound ";
}
}
closedir($handle);
$languageslist = explode(" ", $languageslist);
sort($languageslist);
for ($h=0; $h < sizeof($languageslist); $h++) {
if($languageslist[$h]!="") {
echo "<option value=\"$languageslist[$h]\" ";
if($languageslist[$h]==$planguage) echo "selected";
echo ">".ucfirst($languageslist[$h])."</option>\n";
}
}
echo "</select><br><br>";
echo "</td></tr>";
} else {
echo "<input type=\"hidden\" name=\"planguage\" value=\"$planguage\"><br><br>";
}
$result2 = $db->sql_query("SELECT optionText, optionCount, voteID from ".$prefix."_poll_data where pollID='$pollID' order by voteID");
while ($row2 = $db->sql_fetchrow($result2)) {
$optionText = $row2['optionText'];
$optionCount = intval($row2['optionCount']);
$voteID = intval($row2['voteID']);
echo "<tr><td align=\"right\"><b>" . _OPTION . " $voteID:</b></td><td><input type=\"text\" name=\"optiontext$voteID\" value=\"$optionText\" size=\"40\" maxlength=\"50\"></td><td align=\"right\">$optionCount "._VOTES."</td></tr>";
}
echo "</table><input type=\"hidden\" name=\"pollID\" value=\"$pollID\"><input type=\"hidden\" name=\"op\" value=\"savepoll\">"
."<br><br><center><input type=\"submit\" value=\"" . _SAVECHANGES . "\"><br>" . _GOBACK . "</center><br><br></form>";
CloseTable();
include("footer.php");
}
function savepoll($pollID, $pollTitle, $planguage, $optiontext1, $optiontext2, $optiontext3, $optiontext4, $optiontext5, $optiontext6, $optiontext7, $optiontext8, $optiontext9, $optiontext10, $optiontext11, $optiontext12) {
global $prefix, $db;
$pollID = intval($pollID);
$result = $db->sql_query("update " . $prefix . "_poll_desc set pollTitle='$pollTitle', planguage='$planguage' where pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext1' where voteID='1' AND pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext2' where voteID='2' AND pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext3' where voteID='3' AND pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext4' where voteID='4' AND pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext5' where voteID='5' AND pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext6' where voteID='6' AND pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext7' where voteID='7' AND pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext8' where voteID='8' AND pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext9' where voteID='9' AND pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext10' where voteID='10' AND pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext11' where voteID='11' AND pollID='$pollID'");
$result = $db->sql_query("update " . $prefix . "_poll_data set optionText='$optiontext12' where voteID='12' AND pollID='$pollID'");
Header("Location: admin.php");
}
switch($op) {
case "create":
poll_createPoll();
break;
case "createPosted":
poll_createPosted($pollTitle, $optionText, $planguage, $title, $hometext, $topic, $bodytext, $catid, $ihome, $acomm);
break;
case "ChangePoll":
ChangePoll($pollID, $pollTitle, $optionText, $voteID);
break;
case "remove":
poll_removePoll();
break;
case "removePosted":
poll_removePosted();
break;
case "polledit":
polledit($pollID);
break;
case "savepoll":
savepoll($pollID, $pollTitle, $planguage, $optiontext1, $optiontext2, $optiontext3, $optiontext4, $optiontext5, $optiontext6, $optiontext7, $optiontext8, $optiontext9, $optiontext10, $optiontext11, $optiontext12);
break;
case "polledit_select":
polledit_select();
break;
}
} else {
include("header.php");
GraphicAdmin();
OpenTable();
echo "<center><b>"._ERROR."</b><br><br>You do not have administration permission for module \"$module_name\"</center>";
CloseTable();
include("footer.php");
}
?>
|
And I also used the index.php code that is located in surveys/
Code:
<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2002 by Francisco Burzi */
/* http://phpnuke.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/
/* Additional security & Abstraction layer conversion */
/* 2003 chatserv */
/* http://www.nukefixes.com -- http://www.nukeresources.com */
/************************************************************************/
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$pagetitle = "- "._SURVEYS."";
if (isset($pollID)) {
$pollID = intval($pollID);
}
if(!isset($pollID)) {
include ('header.php');
pollList();
include ('footer.php');
} elseif(isset($forwarder)) {
pollCollector($pollID, $voteID, $forwarder);
} elseif($op == "results" && $pollID > 0) {
include ("header.php");
OpenTable();
echo "<center><font class=\"title\"><b>"._CURRENTPOLLRESULTS."</b></font></center>";
CloseTable();
echo "<br>";
echo "<table border='0' width='100%'><tr><td width='70%' valign='top'>";
OpenTable();
pollResults($pollID);
CloseTable();
echo "</td><td> </td><td width='30%' valign='top'>";
OpenTable();
echo "<b>"._LAST5POLLS." $sitename</b><br><br>";
if (isset($cookie[4])) { $r_options .= "&mode=$cookie[4]"; }
if (isset($cookie[5])) { $r_options .= "&order=$cookie[5]"; }
if (isset($cookie[6])) { $r_options .= "&thold=$cookie[6]"; }
$result = $db->sql_query("SELECT pollID, pollTitle, voters FROM ".$prefix."_poll_desc where artid='0' order by timeStamp DESC limit 1,5");
while ($row = $db->sql_fetchrow($result)) {
$plid = intval($row['pollID']);
$pltitle = stripslashes(check_html($row['pollTitle'], "nohtml"));
$plvoters = intval($row['voters']);
if ($pollID == $plid) {
echo "<img src='images/arrow.gif' border='0'> $pltitle ($plvoters "._LVOTES.")<br><br>";
} else {
echo "<img src='images/arrow.gif' border='0'> <a href='modules.php?name=$module_name&op=results&pollID=$plid$r_options'>$pltitle</a> ($plvoters "._LVOTES.")<br><br>";
}
}
echo "<a href='modules.php?name=$module_name'><b>"._MOREPOLLS."</b></a>";
CloseTable();
echo "</td></tr></table>";
cookiedecode($user);
if (($pollcomm) AND ($mode != "nocomments")) {
echo "<br><br>";
include("modules/Surveys/comments.php");
}
include ("footer.php");
} elseif($voteID > 0) {
pollCollector($pollID, $voteID);
} elseif($pollID != pollLatest()) {
include ('header.php');
OpenTable();
echo "<center><font class=\"option\"><b>"._SURVEY."</b></font></center>";
CloseTable();
echo "<br><br>";
echo "<table border=\"0\" align=\"center\"><tr><td>";
pollMain($pollID);
echo "</td></tr></table>";
include ('footer.php');
} else {
include ('header.php');
OpenTable();
echo "<center><font class=\"option\"><b>"._CURRENTSURVEY."</b></font></center>";
CloseTable();
echo "<br><br><table border=\"0\" align=\"center\"><tr><td>";
pollNewest();
echo "</td></tr></table>";
include ('footer.php');
}
/*********************************************************/
/* Functions */
/*********************************************************/
function pollMain($pollID) {
global $boxTitle, $boxContent, $pollcomm, $user, $cookie, $prefix, $dbi, $module_name, $db;
$pollID = intval($pollID);
if(!isset($pollID))
$pollID = 1;
if(!isset($url))
$url = sprintf("modules.php?name=$module_name&op=results&pollID=%d", $pollID);
$boxContent .= "<form action=\"modules.php?name=$module_name\" method=\"post\">";
$boxContent .= "<input type=\"hidden\" name=\"pollID\" value=\"".$pollID."\">";
$boxContent .= "<input type=\"hidden\" name=\"forwarder\" value=\"".$url."\">";
$result_a = $db->sql_query("SELECT pollTitle, voters FROM ".$prefix."_poll_desc WHERE pollID='$pollID'");
list($pollTitle, $voters) = $db->sql_fetchrow($result_a);
$boxTitle = _SURVEY;
$boxContent .= "<font class=\"content\"><b>$pollTitle</b></font><br><br>\n";
$boxContent .= "<table border=\"0\" width=\"100%\">";
for($i = 1; $i <= 12; $i++) {
$result = sql_query("SELECT pollID, optionText, optionCount, voteID FROM ".$prefix."_poll_data WHERE pollID='$pollID' AND voteID='$i'", $dbi);
$object = sql_fetch_object($result, $dbi);
if(is_object($object)) {
$optionText = $object->optionText;
if($optionText != "") {
$boxContent .= "<tr><td valign=\"top\"><input type=\"radio\" name=\"voteID\" value=\"".$i."\"></td><td width=\"100%\"><font class=\"content\">$optionText</font></td></tr>\n";
}
}
}
$boxContent .= "</table><br><center><font class=\"content\"><input type=\"submit\" value=\""._VOTE."\"></font><br>";
if (is_user($user)) {
cookiedecode($user);
}
for($i = 0; $i < 12; $i++) {
$result2 = sql_query("SELECT optionCount FROM ".$prefix."_poll_data WHERE pollID='$pollID' AND voteID='$i'", $dbi);
$object = sql_fetch_object($result2, $dbi);
$optionCount = $object->optionCount;
$sum = (int)$sum+$optionCount;
}
$boxContent .= "<br><font class=\"content\"><a href=\"modules.php?name=$module_name&op=results&pollID=$pollID&mode=$cookie[4]&order=$cookie[5]&thold=$cookie[6]\"><b>"._RESULTS."</b></a><br><a href=\"modules.php?name=$module_name\"><b>"._POLLS."</b></a><br>";
if ($pollcomm) {
list($numcom) = $db->sql_fetchrow($db->sql_query("select count(*) from ".$prefix."_pollcomments where pollID='$pollID'"));
$boxContent .= "<br>"._VOTES.": <b>$sum</b> <br> "._PCOMMENTS." <b>$numcom</b>\n\n";
} else {
$boxContent .= "<br>"._VOTES." <b>$sum</b>\n\n";
}
$boxContent .= "</font></center></form>\n\n";
themesidebox($boxTitle, $boxContent);
}
function pollLatest() {
global $prefix, $multilingual, $currentlang, $db;
if ($multilingual == 1) {
$querylang = "WHERE planguage='$currentlang' AND artid='0'";
} else {
$querylang = "WHERE artid='0'";
}
$pollID = $db->sql_fetchrow($db->sql_query("SELECT pollID FROM ".$prefix."_poll_desc $querylang ORDER BY pollID DESC LIMIT 1"));
return($pollID[0]);
}
function pollNewest() {
$pollID = pollLatest();
pollMain($pollID);
}
function pollCollector($pollID, $voteID, $forwarder) {
global $HTTP_COOKIE_VARS, $prefix, $db;
/* Fix for lamers that like to cheat on polls */
if (empty($ip)) {
$ip = $_SERVER["REMOTE_ADDR"];
}
$pollID = intval($pollID);
$voteID = intval($voteID);
$past = time()-1800;
$db->sql_query("DELETE FROM ".$prefix."_poll_check WHERE time < '$past'");
$row = $db->sql_fetchrow($db->sql_query("SELECT ip FROM ".$prefix."_poll_check WHERE (ip='$ip') AND (pollID='$pollID')"));
$ips = $row['ip'];
$ctime = time();
if ($ip == $ips) {
$voteValid = 0;
} else {
$db->sql_query("INSERT INTO ".$prefix."_poll_check (ip, time, pollID) VALUES ('$ip', '$ctime', '$pollID')");
$voteValid = "1";
}
/* Fix end */
/* update database if the vote is valid */
if($voteValid>0) {
$db->sql_query("UPDATE ".$prefix."_poll_data SET optionCount=optionCount+1 WHERE pollID='$pollID' AND voteID='$voteID'");
if ($voteID != "") {
$db->sql_query("UPDATE ".$prefix."_poll_desc SET voters=voters+1 WHERE pollID='$pollID'");
update_points(8);
}
Header("Location: $forwarder");
} else {
Header("Location: $forwarder");
}
/* a lot of browsers can't handle it if there's an empty page */
echo "<html><head></head><body></body></html>";
}
function pollList() {
global $user, $cookie, $prefix, $multilingual, $currentlang, $admin, $dbi, $module_name, $db;
if (isset($cookie[4])) { $r_options .= "&mode=$cookie[4]"; }
if (isset($cookie[5])) { $r_options .= "&order=$cookie[5]"; }
if (isset($cookie[6])) { $r_options .= "&thold=$cookie[6]"; }
if ($multilingual == 1) {
$querylang = "WHERE planguage='$currentlang' AND artid='0'";
} else {
$querylang = "WHERE artid='0'";
}
$result = sql_query("SELECT pollID, pollTitle, timeStamp, voters FROM ".$prefix."_poll_desc $querylang ORDER BY timeStamp DESC", $dbi);
$counter = 0;
OpenTable();
OpenTable();
echo "<center><font class=\"title\"><b>"._PASTSURVEYS."</b></font></center>";
CloseTable();
echo "<table border=\"0\" cellpadding=\"8\"><tr><td>";
while($object = sql_fetch_object($result, $dbi)) {
$resultArray[$counter] = array($object->pollID, $object->pollTitle, $object->timeStamp, $object->voters);
$counter++;
}
for ($count = 0; $count < count($resultArray); $count++) {
$id = $resultArray[$count][0];
$id = intval($id);
$i = intval($i);
$pollTitle = $resultArray[$count][1];
$voters = $resultArray[$count][3];
for($i = 0; $i < 12; $i++) {
$result2 = sql_query("SELECT optionCount FROM ".$prefix."_poll_data WHERE pollID='$id' AND voteID='$i'", $dbi);
$object = sql_fetch_object($result2, $dbi);
$optionCount = $object->optionCount;
$sum = (int)$sum+$optionCount;
}
echo "<strong><big>·</big></strong> <a href=\"modules.php?name=$module_name&pollID=$id\">$pollTitle</a> ";
if (is_admin($admin)) {
$editing = " - <a href=\"admin.php?op=polledit&pollID=$id\">Edit</a>";
} else {
$editing = "";
}
echo "(<a href=\"modules.php?name=$module_name&op=results&pollID=$id$r_options\">"._RESULTS."</a> - $sum "._LVOTES."$editing)<br>\n";
$sum = 0;
}
echo "</td></tr></table>"
."<br>";
OpenTable();
echo "<center><font class=\"title\"><b>"._SURVEYSATTACHED."</b></font></center>";
CloseTable();
echo "<table border=\"0\" cellpadding=\"8\"><tr><td>";
if ($multilingual == 1) {
$querylang = "WHERE planguage='$currentlang' AND artid!='0'";
} else {
$querylang = "WHERE artid!='0'";
}
$counter = 0;
$result3 = sql_query("SELECT pollID, pollTitle, timeStamp, voters FROM ".$prefix."_poll_desc $querylang ORDER BY timeStamp DESC", $dbi);
while($object = sql_fetch_object($result3, $dbi)) {
$resultArray2[$counter] = array($object->pollID, $object->pollTitle, $object->timeStamp, $object->voters);
$counter++;
}
for ($count = 0; $count < count($resultArray2); $count++) {
$id = $resultArray2[$count][0];
$id = intval($id);
$i = intval($i);
$pollTitle = $resultArray2[$count][1];
$voters = $resultArray2[$count][3];
for($i = 0; $i < 12; $i++) {
$result4 = sql_query("SELECT optionCount FROM ".$prefix."_poll_data WHERE pollID='$id' AND voteID='$i'", $dbi);
$object = sql_fetch_object($result4, $dbi);
$optionCount = $object->optionCount;
$sum = (int)$sum+$optionCount;
}
echo "<strong><big>·</big></strong> <a href=\"modules.php?name=$module_name&pollID=$id\">$pollTitle</a> ";
if (is_admin($admin)) {
$editing = " - <a href=\"admin.php?op=polledit&pollID=$id\">Edit</a>";
} else {
$editing = "";
}
$res = $db->sql_query("select sid, title from ".$prefix."_stories where pollID='$id'");
list($sid, $title) = $db->sql_fetchrow($res);
$sid = intval($sid);
$title = stripslashes(check_html($title, "nohtml"));
echo "(<a href=\"modules.php?name=$module_name&op=results&pollID=$id$r_options\">"._RESULTS."</a> - $sum "._LVOTES."$editing)<br>\n"
.""._ATTACHEDTOARTICLE." <a href=\"modules.php?name=News&file=article&sid=$sid$r_options\">$title</a><br><br>\n";
$sum = "";
}
echo "</td></tr></table>";
CloseTable();
}
function pollResults($pollID) {
global $resultTableBgColor, $resultBarFile, $Default_Theme, $user, $cookie, $prefix, $dbi, $admin, $module_name, $db;
if(!isset($pollID)) $pollID = 1;
$pollID = intval($pollID);
$result = $db->sql_query("SELECT pollID, pollTitle, timeStamp, artid FROM ".$prefix."_poll_desc WHERE pollID='$pollID'");
$holdtitle = $db->sql_fetchrow($result);
echo "<b>$holdtitle[1]</b><br><br>";
$i = intval($i);
for($i = 0; $i < 12; $i++) {
$result2 = sql_query("SELECT optionCount FROM ".$prefix."_poll_data WHERE pollID='$pollID' AND voteID='$i'", $dbi);
$object = sql_fetch_object($result2, $dbi);
$optionCount = $object->optionCount;
$sum = (int)$sum+$optionCount;
}
echo "<table border=\"0\">";
/* cycle through all options */
for($i = 1; $i <= 12; $i++) {
/* select next vote option */
$result3 = sql_query("SELECT pollID, optionText, optionCount, voteID FROM ".$prefix."_poll_data WHERE pollID='$pollID' AND voteID='$i'", $dbi);
$object = sql_fetch_object($result3, $dbi);
if(is_object($object)) {
$optionText = $object->optionText;
$optionCount = $object->optionCount;
if($optionText != "") {
echo "<tr><td>";
echo "$optionText";
echo "</td>";
if($sum) {
$percent = 100 * $optionCount / $sum;
} else {
$percent = 0;
}
echo "<td>";
$percentInt = (int)$percent * 4 * 1;
$percent2 = (int)$percent;
if(is_user($user)) {
if($cookie[9]=="") $cookie[9]=$Default_Theme;
if(!$file=@opendir("themes/$cookie[9]")) {
$ThemeSel = $Default_Theme;
} else {
$ThemeSel = $cookie[9];
}
} else {
$ThemeSel = $Default_Theme;
}
if (file_exists("themes/$ThemeSel/images/survey_leftbar.gif") AND file_exists("themes/$ThemeSel/images/survey_mainbar.gif") AND file_exists("themes/$ThemeSel/images/survey_rightbar.gif")) {
$l_size = getimagesize("themes/$ThemeSel/images/survey_leftbar.gif");
$m_size = getimagesize("themes/$ThemeSel/images/survey_mainbar.gif");
$r_size = getimagesize("themes/$ThemeSel/images/survey_rightbar.gif");
$leftbar = "survey_leftbar.gif";
$mainbar = "survey_mainbar.gif";
$rightbar = "survey_rightbar.gif";
} else {
$l_size = getimagesize("themes/$ThemeSel/images/leftbar.gif");
$m_size = getimagesize("themes/$ThemeSel/images/mainbar.gif");
$r_size = getimagesize("themes/$ThemeSel/images/rightbar.gif");
$leftbar = "leftbar.gif";
$mainbar = "mainbar.gif";
$rightbar = "rightbar.gif";
}
if (file_exists("themes/$ThemeSel/images/survey_mainbar_d.gif")) {
$m1_size = getimagesize("themes/$ThemeSel/images/survey_mainbar_d.gif");
$mainbar_d = "survey_mainbar_d.gif";
if ($percent2 > 0 AND $percent2 <= 23) {
$salto = "<img src=\"themes/$ThemeSel/images/$mainbar\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m_size[1]\" width=\"$percentInt\">";
} elseif ($percent2 > 24 AND $percent2 < 50) {
$a = $percentInt - 100;
$salto = "<img src=\"themes/$ThemeSel/images/$mainbar\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m_size[1]\" width=\"70\">"
."<img src=\"themes/$ThemeSel/images/$mainbar_d\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m1_size[1]\" width=\"30\">"
."<img src=\"themes/$ThemeSel/images/$mainbar\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m_size[1]\" width=\"$a\">";
} elseif ($percent2 > 49 AND $percent2 < 75) {
$a = $percentInt - 200;
$salto = "<img src=\"themes/$ThemeSel/images/$mainbar\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m_size[1]\" width=\"70\">"
."<img src=\"themes/$ThemeSel/images/$mainbar_d\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m1_size[1]\" width=\"30\">"
."<img src=\"themes/$ThemeSel/images/$mainbar\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m_size[1]\" width=\"70\">"
."<img src=\"themes/$ThemeSel/images/$mainbar_d\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m1_size[1]\" width=\"30\">"
."<img src=\"themes/$ThemeSel/images/$mainbar\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m_size[1]\" width=\"$a\">";
} elseif ($percent2 > 74 AND $percent2 <= 100) {
$a = $percentInt - 300;
$salto = "<img src=\"themes/$ThemeSel/images/$mainbar\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m_size[1]\" width=\"70\">"
."<img src=\"themes/$ThemeSel/images/$mainbar_d\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m1_size[1]\" width=\"30\">"
."<img src=\"themes/$ThemeSel/images/$mainbar\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m_size[1]\" width=\"70\">"
."<img src=\"themes/$ThemeSel/images/$mainbar_d\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m1_size[1]\" width=\"30\">"
."<img src=\"themes/$ThemeSel/images/$mainbar\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m_size[1]\" width=\"70\">"
."<img src=\"themes/$ThemeSel/images/$mainbar_d\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m1_size[1]\" width=\"30\">"
."<img src=\"themes/$ThemeSel/images/$mainbar\" alt=\"$percent2 %\" title=\"$percent2 %\" height=\"$m_size[1]\" width=\"$a\">";
}
}
if ($percent > 0) {
echo "<img src=\"themes/$ThemeSel/images/$leftbar\" height=\"$l_size[1]\" width=\"$l_size[0]\" alt=\"$percent2 %\" title=\"$percent2 %\">";
if (file_exists("themes/$ThemeSel/images/survey_mainbar_d.gif")) {
echo "$salto";
} else {
echo "<img src=\"themes/$ThemeSel/images/$mainbar\" height=\"$m_size[1]\" width=\"$percentInt\" alt=\"$percent2 %\" title=\"$percent2 %\">";
}
echo "<img src=\"themes/$ThemeSel/images/$rightbar\" height=\"$r_size[1]\" width=\"$r_size[0]\" alt=\"$percent2 %\" title=\"$percent2 %\">";
} else {
echo "<img src=\"themes/$ThemeSel/images/$leftbar\" height=\"$l_size[1]\" width=\"$l_size[0]\" alt=\"$percent2 %\" title=\"$percent2 %\">";
if (!file_exists("themes/$ThemeSel/images/survey_mainbar_d.gif")) {
echo "<img src=\"themes/$ThemeSel/images/$mainbar\" height=\"$m_size[1]\" width=\"$m_size[0]\" alt=\"$percent2 %\" title=\"$percent2 %\">";
}
echo "<img src=\"themes/$ThemeSel/images/$rightbar\" height=\"$r_size[1]\" width=\"$r_size[0]\" alt=\"$percent2 %\" title=\"$percent2 %\">";
}
printf(" %.2f%% (%s)", $percent, $optionCount);
echo "</td></tr>";
}
}
}
echo "</table><br>";
echo "<center><font class=\"content\">";
echo "<b>"._TOTALVOTES." $sum</b><br>";
echo "<br><br>";
$booth = $pollID;
$booth = intval($booth);
if ($holdtitle[3] > 0) {
$article = "<br><br>"._GOBACK."</font></center>";
} else {
$article = "</font></center>";
}
echo "[ <a href=\"modules.php?name=$module_name&pollID=$booth\">"._VOTING."</a> | "
."<a href=\"modules.php?name=$module_name\">"._OTHERPOLLS."</a> ] $article";
if (is_admin($admin)) {
echo "<br><center>[ <a href=\"admin.php?op=create\">"._ADD."</a> | <a href=\"admin.php?op=polledit&pollID=$pollID\">"._EDIT."</a> ]</center>";
}
return(1);
}
?>
|
I am using chatserv's survey block to display the surveys.
I know it's probably a security risk to mix and match codes from different versions, but I was tired of not being able to find a solution to this. |
|
|