home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / blocks / block-Survey.php < prev    next >
PHP Script  |  2004-01-10  |  4KB  |  74 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Web Portal System                                          */
  5. /* ===========================                                          */
  6. /*                                                                      */
  7. /* Copyright (c) 2002 by Francisco Burzi                                */
  8. /* http://phpnuke.org                                                   */
  9. /*                                                                      */
  10. /* This program is free software. You can redistribute it and/or modify */
  11. /* it under the terms of the GNU General Public License as published by */
  12. /* the Free Software Foundation; either version 2 of the License.       */
  13. /************************************************************************/
  14.  
  15. if (eregi("block-Survey.php", $_SERVER['PHP_SELF'])) {
  16.     Header("Location: index.php");
  17.     die();
  18. }
  19.  
  20. global $prefix, $multilingual, $currentlang, $db, $boxTitle, $content, $pollcomm, $user, $cookie;
  21.  
  22. if ($multilingual == 1) {
  23.     $querylang = "WHERE planguage='$currentlang' AND artid='0'";
  24. } else {
  25.     $querylang = "WHERE artid='0'";
  26. }
  27.  
  28. $row = $db->sql_fetchrow($db->sql_query("SELECT pollID FROM ".$prefix."_poll_desc $querylang ORDER BY pollID DESC LIMIT 1"));
  29. $pollID = intval($row['pollID']);
  30. if ($pollID == 0 || $pollID == "") {
  31.     $content = "";
  32. } else {
  33.     if (!isset($url)) {
  34.     $url = sprintf("modules.php?name=Surveys&op=results&pollID=%d", $pollID);
  35.     }
  36.     $content .= "<form action=\"modules.php?name=Surveys\" method=\"post\">";
  37.     $content .= "<input type=\"hidden\" name=\"pollID\" value=\"".$pollID."\">";
  38.     $content .= "<input type=\"hidden\" name=\"forwarder\" value=\"".$url."\">";
  39.     $row2 = $db->sql_fetchrow($db->sql_query("SELECT pollTitle, voters FROM ".$prefix."_poll_desc WHERE pollID='$pollID'"));
  40.     $pollTitle = $row2['pollTitle'];
  41.     $voters = intval($row2['voters']);
  42.     $boxTitle = _SURVEY;
  43.     $content .= "<font class=\"content\"><b>$pollTitle</b></font><br><br>\n";
  44.     $content .= "<table border=\"0\" width=\"100%\">";
  45.     for($i = 1; $i <= 12; $i++) {
  46.     $row3 = $db->sql_fetchrow($db->sql_query("SELECT pollID, optionText, optionCount, voteID FROM ".$prefix."_poll_data WHERE (pollID='$pollID') AND (voteID='$i')"));
  47.     if(isset($row3)) {
  48.         $optionText = $row3['optionText'];
  49.         if ($optionText != "") {
  50.         $content .= "<tr><td valign=\"top\"><input type=\"radio\" name=\"voteID\" value=\"".$i."\"></td><td width=\"100%\"><font class=\"content\">$optionText</font></td></tr>\n";
  51.         }
  52.     }
  53.     }
  54.     $content .= "</table><br><center><font class=\"content\"><input type=\"submit\" value=\""._VOTE."\"></font><br>";
  55.     if (is_user($user)) {
  56.     cookiedecode($user);
  57.     }
  58.     for($i = 0; $i < 12; $i++) {
  59.     $row4 = $db->sql_fetchrow($db->sql_query("SELECT optionCount FROM ".$prefix."_poll_data WHERE (pollID='$pollID') AND (voteID='$i')"));
  60.     $optionCount = intval($row4['optionCount']);
  61.     $sum = (int)$sum+$optionCount;
  62.     }
  63.     $content .= "<br><font class=\"content\"><a href=\"modules.php?name=Surveys&op=results&pollID=$pollID&mode=$cookie[4]&order=$cookie[5]&thold=$cookie[6]\"><b>"._RESULTS."</b></a><br><a href=\"modules.php?name=Surveys\"><b>"._OTHERPOLLSB."</b></a><br>";
  64.  
  65.     if ($pollcomm) {
  66.     $numcom = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_pollcomments WHERE pollID='$pollID'"));
  67.     $content .= "<br>"._VOTES.": <b>$sum</b> <br> "._PCOMMENTS." <b>$numcom</b>\n\n";
  68.     } else {
  69.     $content .= "<br>"._VOTES." <b>$sum</b>\n\n";
  70.     }
  71.     $content .= "</font></center></form>\n\n";
  72. }
  73.  
  74. ?>