home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / blocks / block-survey.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  3.6 KB  |  75 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", $PHP_SELF)) {
  16.     Header("Location: index.php");
  17.     die();
  18. }
  19.  
  20. global $prefix, $multilingual, $currentlang, $dbi, $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. $result = sql_query("SELECT pollID FROM ".$prefix."_poll_desc $querylang ORDER BY pollID DESC LIMIT 1", $dbi);
  29. $pollID = sql_fetch_row($result, $dbi);
  30. $pollID = $pollID[0];
  31. if ($pollID == 0 || $pollID == "") {
  32.     $content = "";
  33. } else {
  34.     if(!isset($url))
  35.     $url = sprintf("modules.php?name=Surveys&op=results&pollID=%d", $pollID);
  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.     $result = sql_query("SELECT pollTitle, voters FROM ".$prefix."_poll_desc WHERE pollID=$pollID", $dbi);
  40.     list($pollTitle, $voters) = sql_fetch_row($result, $dbi);
  41.     $boxTitle = _SURVEY;
  42.     $content .= "<font class=\"content\"><b>$pollTitle</b></font><br><br>\n";
  43.     $content .= "<table border=\"0\" width=\"100%\">";
  44.     for($i = 1; $i <= 12; $i++) {
  45.     $result = sql_query("SELECT pollID, optionText, optionCount, voteID FROM ".$prefix."_poll_data WHERE (pollID=$pollID) AND (voteID=$i)", $dbi);
  46.     $object = sql_fetch_object($result, $dbi);
  47.     if(is_object($object)) {
  48.         $optionText = $object->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.     $result = sql_query("SELECT optionCount FROM ".$prefix."_poll_data WHERE (pollID=$pollID) AND (voteID=$i)", $dbi);
  60.     $object = sql_fetch_object($result, $dbi);
  61.     $optionCount = $object->optionCount;
  62.     $sum = (int)$sum+$optionCount;
  63.     }
  64.     $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>"._POLLS."</b></a><br>";
  65.  
  66.     if ($pollcomm) {
  67.     list($numcom) = sql_fetch_row(sql_query("select count(*) from ".$prefix."_pollcomments where pollID=$pollID", $dbi), $dbi);
  68.     $content .= "<br>"._VOTES.": <b>$sum</b> <br> "._PCOMMENTS." <b>$numcom</b>\n\n";
  69.     } else {
  70.     $content .= "<br>"._VOTES." <b>$sum</b>\n\n";
  71.     }
  72.     $content .= "</font></center></form>\n\n";
  73. }
  74.  
  75. ?>