home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / unitednuke / unitednuke.exe / html / modules / News / article.php next >
PHP Script  |  2004-05-19  |  11KB  |  233 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("modules.php", $_SERVER['PHP_SELF'])) {
  16.     die ("You can't access this file directly...");
  17. }
  18. require_once("mainfile.php");
  19. $optionbox = '';
  20. $module_name = basename(dirname(__FILE__));
  21. get_lang($module_name);
  22.  
  23. if (stristr($REQUEST_URI,"mainfile")) {
  24.     Header("Location: modules.php?name=$module_name&file=article&sid=$sid");
  25. } elseif (!isset($sid) && !isset($tid)) {
  26.     Header("Location: index.php");
  27. }
  28.  
  29. if ($save AND is_user($user)) {
  30.     cookiedecode($user);
  31.     $db->sql_query("UPDATE ".$user_prefix."_users SET umode='$mode', uorder='$order', thold='$thold' where uid='$cookie[0]'");
  32.     getusrinfo($user);
  33.     $info = base64_encode("$userinfo[user_id]:$userinfo[username]:$userinfo[user_password]:$userinfo[storynum]:$userinfo[umode]:$userinfo[uorder]:$userinfo[thold]:$userinfo[noscore]");
  34.     setcookie("user","$info",time()+$cookieusrtime);
  35. }
  36.  
  37. if ($op == "Reply") {
  38.     Header("Location: modules.php?name=$module_name&file=comments&op=Reply&pid=0&sid=$sid&mode=$mode&order=$order&thold=$thold");
  39. }
  40.  
  41. $result = $db->sql_query("select catid, aid, time, title, hometext, bodytext, topic, informant, notes, acomm, haspoll, pollID, score, ratings FROM ".$prefix."_stories where sid='$sid'");
  42. if ($numrows = $db->sql_numrows($result) != 1) {
  43.     Header("Location: index.php");
  44.     die();
  45. }
  46. $row = $db->sql_fetchrow($result);
  47. $catid = intval($row['catid']);
  48. $aid = $row['aid'];
  49. $time = $row['time'];
  50. $title = $row['title'];
  51. $hometext = $row['hometext'];
  52. $bodytext = $row['bodytext'];
  53. $topic = $row['topic'];
  54. $informant = $row['informant'];
  55. $notes = $row['notes'];
  56. $acomm = intval($row['acomm']);
  57. $haspoll = intval($row['haspoll']);
  58. $pollID = intval($row['pollID']);
  59. $score = intval($row['score']);
  60. $ratings = intval($row['ratings']);
  61.  
  62. if ($aid == "") {
  63.     Header("Location: modules.php?name=$module_name");
  64. }
  65.  
  66. $db->sql_query("UPDATE ".$prefix."_stories SET counter=counter+1 where sid='$sid'");
  67.  
  68. $artpage = 1;
  69. $pagetitle = "- $title";
  70. require("header.php");
  71. $artpage = 0;
  72.  
  73. formatTimestamp($time);
  74. $title = stripslashes($title);
  75. $hometext = stripslashes($hometext);
  76. $bodytext = stripslashes($bodytext);
  77. $notes = stripslashes($notes);
  78.  
  79. if ($notes != "") {
  80.     $notes = "<br><br><b>"._NOTE."</b> <i>$notes</i>";
  81. } else {
  82.     $notes = "";
  83. }
  84.  
  85. if($bodytext == "") {
  86.     $bodytext = "$hometext$notes";
  87. } else {
  88.     $bodytext = "$hometext<br><br>$bodytext$notes";
  89. }
  90.  
  91. if($informant == "") {
  92.     $informant = $anonymous;
  93. }
  94.  
  95. getTopics($sid);
  96.  
  97. if ($catid != 0) {
  98.     $row2 = $db->sql_fetchrow($db->sql_query("select title from ".$prefix."_stories_cat where catid='$catid'"));
  99.     $title1 = $row2['title'];
  100.     $title = "<a href=\"modules.php?name=$module_name&file=categories&op=newindex&catid=$catid\"><font class=\"storycat\">$title1</font></a>: $title";
  101. }
  102.  
  103. echo "<table width=\"100%\" border=\"0\"><tr><td valign=\"top\" width=\"100%\">\n";
  104. themearticle($aid, $informant, $datetime, $title, $bodytext, $topic, $topicname, $topicimage, $topictext);
  105. echo "</td><td> </td><td valign=\"top\">\n";
  106.  
  107. if ($multilingual == 1) {
  108.     $querylang = "AND (blanguage='$currentlang' OR blanguage='')";
  109. } else {
  110.     $querylang = "";
  111. }
  112.  
  113. /* Determine if the article has attached a poll */
  114. if ($haspoll == 1) {
  115.     $url = sprintf("modules.php?name=Surveys&op=results&pollID=%d", $pollID);
  116.     $boxContent = "<form action=\"modules.php?name=Surveys\" method=\"post\">";
  117.     $boxContent .= "<input type=\"hidden\" name=\"pollID\" value=\"".$pollID."\">";
  118.     $boxContent .= "<input type=\"hidden\" name=\"forwarder\" value=\"".$url."\">";
  119.     $row3 = $db->sql_fetchrow($db->sql_query("SELECT pollTitle, voters FROM ".$prefix."_poll_desc WHERE pollID='$pollID'"));
  120.     $pollTitle = $row3['pollTitle'];
  121.     $voters = $row3['voters'];
  122.     $boxTitle = _ARTICLEPOLL;
  123.     $boxContent .= "<font class=\"content\"><b>$pollTitle</b></font><br><br>\n";
  124.     $boxContent .= "<table border=\"0\" width=\"100%\">";
  125.     for($i = 1; $i <= 12; $i++) {
  126.     $result4 = $db->sql_query("SELECT pollID, optionText, optionCount, voteID FROM ".$prefix."_poll_data WHERE (pollID='$pollID') AND (voteID='$i')");
  127.     $row4 = $db->sql_fetchrow($result4);
  128.     $numrows = $db->sql_numrows($result4);
  129.     if($numrows != 0) {
  130.         $optionText = $row4['optionText'];
  131.         if($optionText != "") {
  132.         $boxContent .= "<tr><td valign=\"top\"><input type=\"radio\" name=\"voteID\" value=\"".$i."\"></td><td width=\"100%\"><font class=\"content\">$optionText</font></td></tr>\n";
  133.         }
  134.     }
  135.     }
  136.     $boxContent .= "</table><br><center><font class=\"content\"><input type=\"submit\" value=\""._VOTE."\"></font><br>";
  137.     if (is_user($user)) {
  138.         cookiedecode($user);
  139.     }
  140.     for($i = 0; $i < 12; $i++) {
  141.     $row5 = $db->sql_fetchrow($db->sql_query("SELECT optionCount FROM ".$prefix."_poll_data WHERE (pollID='$pollID') AND (voteID='$i')"));
  142.     $optionCount = $row5['optionCount'];
  143.     $sum = (int)$sum+$optionCount;
  144.     }
  145.     $boxContent .= "<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> | <a href=\"modules.php?name=Surveys\"><b>"._POLLS."</b></a> ]<br>";
  146.  
  147.     if ($pollcomm) {
  148.     $result6 = $db->sql_query("select * from ".$prefix."_pollcomments where pollID='$pollID'");
  149.     $numcom = $db->sql_numrows($result6);
  150.     $boxContent .= "<br>"._VOTES.": <b>$sum</b><br>"._PCOMMENTS." <b>$numcom</b>\n\n";
  151.     } else {
  152.         $boxContent .= "<br>"._VOTES." <b>$sum</b>\n\n";
  153.     }
  154.     $boxContent .= "</font></center></form>\n\n";
  155.     themesidebox($boxTitle, $boxContent);
  156. }
  157.  
  158. $row7 = $db->sql_fetchrow($db->sql_query("select title, content, active, position from ".$prefix."_blocks where blockfile='block-Login.php' $querylang"));
  159. $title = $row7['title'];
  160. $content = $row7['content'];
  161. $active = $row7['active'];
  162. $position = $row7['position'];
  163. if (($active == 1) AND ($position == "r") AND (!is_user($user))) {
  164.     loginbox();
  165. }
  166.  
  167. $boxtitle = ""._RELATED."";
  168. $boxstuff = "<font class=\"content\">";
  169. $result8 = $db->sql_query("select name, url from ".$prefix."_related where tid='$topic'");
  170. while ($row8 = $db->sql_fetchrow($result8)) {
  171.     $name = $row8['name'];
  172.     $url = $row8['url'];
  173.     $boxstuff .= "<strong><big>·</big></strong> <a href=\"$url\" target=\"new\">$name</a><br>\n";
  174. }
  175.  
  176. $boxstuff .= "<strong><big>·</big></strong> <a href=\"modules.php?name=Search&topic=$topic\">"._MOREABOUT." $topictext</a><br>\n";
  177. $boxstuff .= "<strong><big>·</big></strong> <a href=\"modules.php?name=Search&author=$aid\">"._NEWSBY." $aid</a>\n";
  178.  
  179. $boxstuff .= "</font><br><hr noshade width=\"95%\" size=\"1\"><center><font class=\"content\"><b>"._MOSTREAD." $topictext:</b><br>\n";
  180.  
  181. global $multilingual, $currentlang;
  182.     if ($multilingual == 1) {
  183.     $querylang = "AND (alanguage='$currentlang' OR alanguage='')"; /* the OR is needed to display stories who are posted to ALL languages */
  184.     } else {
  185.     $querylang = "";
  186.     }
  187. $row9 = $db->sql_fetchrow($db->sql_query("select sid, title from ".$prefix."_stories where topic='$topic' $querylang order by counter desc limit 0,1"));
  188. $topstory = intval($row9['sid']);
  189. $ttitle = $row9['title'];
  190.  
  191. $boxstuff .= "<a href=\"modules.php?name=$module_name&file=article&sid=$topstory\">$ttitle</a></font></center><br>\n";
  192. themesidebox($boxtitle, $boxstuff);
  193.  
  194. if ($ratings != 0) {
  195.     $rate = substr($score / $ratings, 0, 4);
  196.     $r_image = round($rate);
  197.     $the_image = "<br><br><img src=\"images/articles/stars-$r_image.gif\" border=\"1\"></center><br>";
  198. } else {
  199.     $rate = 0;
  200.     $the_image = "</center><br>";
  201. }
  202. $ratetitle = ""._RATEARTICLE."";
  203. $ratecontent = "<center>"._AVERAGESCORE.": <b>$rate</b><br>"._VOTES.": <b>$ratings</b>$the_image";
  204. $ratecontent .= "<form action=\"modules.php?name=$module_name\" method=\"post\"><center>"._RATETHISARTICLE."</center><br>";
  205. $ratecontent .= "<input type=\"hidden\" name=\"sid\" value=\"$sid\">";
  206. $ratecontent .= "<input type=\"hidden\" name=\"op\" value=\"rate_article\">";
  207. $ratecontent .= "<input type=\"radio\" name=\"score\" value=\"5\"> <img src=\"images/articles/stars-5.gif\" border=\"0\" alt=\""._EXCELLENT."\" title=\""._EXCELLENT."\"><br>";
  208. $ratecontent .= "<input type=\"radio\" name=\"score\" value=\"4\"> <img src=\"images/articles/stars-4.gif\" border=\"0\" alt=\""._VERYGOOD."\" title=\""._VERYGOOD."\"><br>";
  209. $ratecontent .= "<input type=\"radio\" name=\"score\" value=\"3\"> <img src=\"images/articles/stars-3.gif\" border=\"0\" alt=\""._GOOD."\" title=\""._GOOD."\"><br>";
  210. $ratecontent .= "<input type=\"radio\" name=\"score\" value=\"2\"> <img src=\"images/articles/stars-2.gif\" border=\"0\" alt=\""._REGULAR."\" title=\""._REGULAR."\"><br>";
  211. $ratecontent .= "<input type=\"radio\" name=\"score\" value=\"1\"> <img src=\"images/articles/stars-1.gif\" border=\"0\" alt=\""._BAD."\" title=\""._BAD."\"><br><br>";
  212. $ratecontent .= "<center><input type=\"submit\" value=\""._CASTMYVOTE."\"></center></form><br>";
  213. themesidebox($ratetitle, $ratecontent);
  214.  
  215. $optiontitle = ""._OPTIONS."";
  216. $optionbox .= "<br> <img src=\"images/print.gif\" border=\"0\" alt=\""._PRINTER."\" title=\""._PRINTER."\" width=\"16\" height=\"11\">  <a href=\"modules.php?name=$module_name&file=print&sid=$sid\">"._PRINTER."</a><br><br>";
  217. $optionbox .= " <img src=\"images/friend.gif\" border=\"0\" alt=\""._FRIEND."\" title=\""._FRIEND."\" width=\"16\" height=\"11\">  <a href=\"modules.php?name=$module_name&file=friend&op=FriendSend&sid=$sid\">"._FRIEND."</a><br><br>\n";
  218. if (is_admin($admin)) {
  219.     $optionbox .= "<center><b>"._ADMIN."</b><br>[ <a href=\"admin.php?op=adminStory\">"._ADD."</a> | <a href=\"admin.php?op=EditStory&sid=$sid\">"._EDIT."</a> | <a href=\"admin.php?op=RemoveStory&sid=$sid\">"._DELETE."</a> ]</center>";
  220. }
  221. themesidebox($optiontitle, $optionbox);
  222.  
  223. echo "</td></tr></table>\n";
  224. cookiedecode($user);
  225.  
  226. include("modules/$module_name/associates.php");
  227.  
  228. if ((($mode != "nocomments") OR ($acomm == 0)) OR ($articlecomm == 1)) {
  229.     include("modules/News/comments.php");
  230. }
  231. include ("footer.php");
  232.  
  233. ?>