PageRenderTime 67ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/nuke/modules/Stories_Archive/index.php

https://github.com/lucasgoicoechea/prolab
PHP | 265 lines | 252 code | 2 blank | 11 comment | 1 complexity | 931df8add144cf7c97f77498df8643bc MD5 | raw file
  1. <?php
  2. /************************************************************************/
  3. /* PHP-NUKE: Web Portal System */
  4. /* =========================== */
  5. /* */
  6. /* Copyright (c) 2005 by Francisco Burzi */
  7. /* http://phpnuke.org */
  8. /* */
  9. /* This program is free software. You can redistribute it and/or modify */
  10. /* it under the terms of the GNU General Public License as published by */
  11. /* the Free Software Foundation; either version 2 of the License. */
  12. /************************************************************************/
  13. if (!defined('MODULE_FILE')) {
  14. die ("You can't access this file directly...");
  15. }
  16. require_once("mainfile.php");
  17. $module_name = basename(dirname(__FILE__));
  18. get_lang($module_name);
  19. function select_month() {
  20. global $prefix, $user_prefix, $db, $module_name;
  21. include("header.php");
  22. title(""._STORIESARCHIVE."");
  23. OpenTable();
  24. echo "<center><font class=\"content\">"._SELECTMONTH2VIEW."</font><br><br></center><br><br>";
  25. $result = $db->sql_query("SELECT time from ".$prefix."_stories order by time DESC");
  26. echo "<ul>";
  27. while($row = $db->sql_fetchrow($result)) {
  28. $time = $row['time'];
  29. ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $getdate);
  30. if ($getdate[2] == "01") { $month = _JANUARY; } elseif ($getdate[2] == "02") { $month = _FEBRUARY; } elseif ($getdate[2] == "03") { $month = _MARCH; } elseif ($getdate[2] == "04") { $month = _APRIL; } elseif ($getdate[2] == "05") { $month = _MAY; } elseif ($getdate[2] == "06") { $month = _JUNE; } elseif ($getdate[2] == "07") { $month = _JULY; } elseif ($getdate[2] == "08") { $month = _AUGUST; } elseif ($getdate[2] == "09") { $month = _SEPTEMBER; } elseif ($getdate[2] == "10") { $month = _OCTOBER; } elseif ($getdate[2] == "11") { $month = _NOVEMBER; } elseif ($getdate[2] == "12") { $month = _DECEMBER; }
  31. if ($month != $thismonth) {
  32. $year = $getdate[1];
  33. echo "<li><a href=\"modules.php?name=$module_name&amp;sa=show_month&amp;year=$year&amp;month=$getdate[2]&amp;month_l=$month\">$month, $year</a>";
  34. $thismonth = $month;
  35. }
  36. }
  37. echo "</ul>"
  38. ."<br><br><br><center>"
  39. ."<form action=\"modules.php?name=Search\" method=\"post\">"
  40. ."<input type=\"text\" name=\"query\" size=\"30\">&nbsp;"
  41. ."<input type=\"submit\" value=\""._SEARCH."\">"
  42. ."</form><br><br>"
  43. ."[ <a href=\"modules.php?name=$module_name&amp;sa=show_all\">"._SHOWALLSTORIES."</a> ]</center>";
  44. CloseTable();
  45. include("footer.php");
  46. }
  47. function show_month($year, $month, $month_l) {
  48. global $prefix, $user_prefix, $db, $bgcolor1, $bgcolor2, $user, $cookie, $sitename, $multilingual, $language, $module_name, $articlecomm;
  49. $year = intval($year);
  50. $month = htmlentities($month);
  51. $month_l = htmlentities($month_l);
  52. include("header.php");
  53. title(""._STORIESARCHIVE."");
  54. title("$sitename: $month_l $year");
  55. $r_options = "";
  56. if (isset($cookie[4])) { $r_options .= "&amp;mode=$cookie[4]"; }
  57. if (isset($cookie[5])) { $r_options .= "&amp;order=$cookie[5]"; }
  58. if (isset($cookie[6])) { $r_options .= "&amp;thold=$cookie[6]"; }
  59. OpenTable();
  60. echo "<table border=\"0\" width=\"100%\"><tr>"
  61. ."<td bgcolor=\"$bgcolor2\" align=\"left\"><b>"._ARTICLES."</b></td>"
  62. ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._COMMENTS."</b></td>"
  63. ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._READS."</b></td>"
  64. ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._USCORE."</b></td>"
  65. ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._DATE."</b></td>"
  66. ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._ACTIONS."</b></td></tr>";
  67. $result = $db->sql_query("SELECT sid, catid, title, time, comments, counter, topic, alanguage, score, ratings from ".$prefix."_stories WHERE time >= '$year-$month-01 00:00:00' AND time <= '$year-$month-31 23:59:59' order by sid DESC");
  68. while ($row = $db->sql_fetchrow($result)) {
  69. $sid = intval($row['sid']);
  70. $catid = intval($row['catid']);
  71. $title = stripslashes(check_html($row['title'], "nohtml"));
  72. $time = $row['time'];
  73. $comments = stripslashes($row['comments']);
  74. $counter = intval($row['counter']);
  75. $topic = intval($row['topic']);
  76. $alanguage = $row['alanguage'];
  77. $score = intval($row['score']);
  78. $ratings = intval($row['ratings']);
  79. $time = explode(" ", $time);
  80. $actions = "<a href=\"modules.php?name=News&amp;file=print&amp;sid=$sid\"><img src=\"images/print.gif\" border=0 alt=\""._PRINTER."\" title=\""._PRINTER."\" width=\"16\" height=\"11\"></a>&nbsp;<a href=\"modules.php?name=News&amp;file=friend&amp;op=FriendSend&amp;sid=$sid\"><img src=\"images/friend.gif\" border=0 alt=\""._FRIEND."\" title=\""._FRIEND."\" width=\"16\" height=\"11\"></a>";
  81. if ($score != 0) {
  82. $rated = substr($score / $ratings, 0, 4);
  83. } else {
  84. $rated = 0;
  85. }
  86. if ($catid == 0) {
  87. $title = "<a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid$r_options\">$title</a>";
  88. } elseif ($catid != 0) {
  89. $row_res = $db->sql_fetchrow($db->sql_query("SELECT title from ".$prefix."_stories_cat where catid='$catid'"));
  90. $cat_title = $row_res['title'];
  91. $title = "<a href=\"modules.php?name=News&amp;file=categories&amp;op=newindex&amp;catid=$catid\"><i>$cat_title</i></a>: <a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid$r_options\">$title</a>";
  92. }
  93. if ($multilingual == 1) {
  94. if ($alanguage == "") {
  95. $alanguage = $language;
  96. }
  97. $alt_language = ucfirst($alanguage);
  98. $lang_img = "<img src=\"images/language/flag-$alanguage.png\" border=\"0\" hspace=\"2\" alt=\"$alt_language\" title=\"$alt_language\">";
  99. } else {
  100. $lang_img = "<strong><big><b>&middot;</b></big></strong>";
  101. }
  102. if ($articlecomm == 0) {
  103. $comments = 0;
  104. }
  105. echo "<tr>"
  106. ."<td bgcolor=\"$bgcolor1\" align=\"left\">$lang_img $title</td>"
  107. ."<td bgcolor=\"$bgcolor1\" align=\"center\">$comments</td>"
  108. ."<td bgcolor=\"$bgcolor1\" align=\"center\">$counter</td>"
  109. ."<td bgcolor=\"$bgcolor1\" align=\"center\">$rated</td>"
  110. ."<td bgcolor=\"$bgcolor1\" align=\"center\">$time[0]</td>"
  111. ."<td bgcolor=\"$bgcolor1\" align=\"center\">$actions</td></tr>";
  112. }
  113. echo "</table>"
  114. ."<br><br><br><hr size=\"1\" noshade>"
  115. ."<font class=\"content\">"._SELECTMONTH2VIEW."</font><br>";
  116. $result2 = $db->sql_query("SELECT time from ".$prefix."_stories order by time DESC");
  117. echo "<ul>";
  118. while($row2 = $db->sql_fetchrow($result2)) {
  119. $time = $row2['time'];
  120. ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $getdate);
  121. if ($getdate[2] == "01") { $month = _JANUARY; } elseif ($getdate[2] == "02") { $month = _FEBRUARY; } elseif ($getdate[2] == "03") { $month = _MARCH; } elseif ($getdate[2] == "04") { $month = _APRIL; } elseif ($getdate[2] == "05") { $month = _MAY; } elseif ($getdate[2] == "06") { $month = _JUNE; } elseif ($getdate[2] == "07") { $month = _JULY; } elseif ($getdate[2] == "08") { $month = _AUGUST; } elseif ($getdate[2] == "09") { $month = _SEPTEMBER; } elseif ($getdate[2] == "10") { $month = _OCTOBER; } elseif ($getdate[2] == "11") { $month = _NOVEMBER; } elseif ($getdate[2] == "12") { $month = _DECEMBER; }
  122. if ($month != $thismonth) {
  123. $year = $getdate[1];
  124. echo "<li><a href=\"modules.php?name=$module_name&amp;sa=show_month&amp;year=$year&amp;month=$getdate[2]&amp;month_l=$month\">$month, $year</a>";
  125. $thismonth = $month;
  126. }
  127. }
  128. echo "</ul><br><br><center>"
  129. ."<form action=\"modules.php?name=Search\" method=\"post\">"
  130. ."<input type=\"text\" name=\"query\" size=\"30\">&nbsp;"
  131. ."<input type=\"submit\" value=\""._SEARCH."\">"
  132. ."</form>"
  133. ."[ <a href=\"modules.php?name=$module_name\">"._ARCHIVESINDEX."</a> | <a href=\"modules.php?name=$module_name&amp;sa=show_all\">"._SHOWALLSTORIES."</a> ]</center>";
  134. CloseTable();
  135. include("footer.php");
  136. }
  137. function show_all($min) {
  138. global $prefix, $user_prefix, $db, $bgcolor1, $bgcolor2, $user, $cookie, $sitename, $multilingual, $language, $module_name;
  139. if (!isset($min)) {
  140. $min = 0;
  141. }
  142. $max = 250;
  143. include("header.php");
  144. title(""._STORIESARCHIVE."");
  145. title("$sitename: "._ALLSTORIESARCH."");
  146. if (isset($cookie[4])) { $r_options .= "&amp;mode=$cookie[4]"; }
  147. if (isset($cookie[5])) { $r_options .= "&amp;order=$cookie[5]"; }
  148. if (isset($cookie[6])) { $r_options .= "&amp;thold=$cookie[6]"; }
  149. OpenTable();
  150. echo "<table border=\"0\" width=\"100%\"><tr>"
  151. ."<td bgcolor=\"$bgcolor2\" align=\"left\"><b>"._ARTICLES."</b></td>"
  152. ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._COMMENTS."</b></td>"
  153. ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._READS."</b></td>"
  154. ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._USCORE."</b></td>"
  155. ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._DATE."</b></td>"
  156. ."<td bgcolor=\"$bgcolor2\" align=\"center\"><b>"._ACTIONS."</b></td></tr>";
  157. $result = $db->sql_query("SELECT sid, catid, title, time, comments, counter, topic, alanguage, score, ratings from ".$prefix."_stories order by sid DESC limit $min,$max");
  158. $numrows = $db->sql_numrows($db->sql_query("select * from ".$prefix."_stories"));
  159. while($row = $db->sql_fetchrow($result)) {
  160. $sid = intval($row['sid']);
  161. $catid = intval($row['catid']);
  162. $title = stripslashes(check_html($row['title'], "nohtml"));
  163. $time = $row['time'];
  164. $comments = stripslashes($row['comments']);
  165. $counter = intval($row['counter']);
  166. $topic = intval($row['topic']);
  167. $alanguage = $row['alanguage'];
  168. $score = intval($row['score']);
  169. $ratings = intval($row['ratings']);
  170. $time = explode(" ", $time);
  171. $actions = "<a href=\"modules.php?name=News&amp;file=print&amp;sid=$sid\"><img src=\"images/print.gif\" border=0 alt=\""._PRINTER."\" title=\""._PRINTER."\" width=\"15\" height=\"11\"></a>&nbsp;<a href=\"modules.php?name=News&amp;file=friend&amp;op=FriendSend&amp;sid=$sid\"><img src=\"images/friend.gif\" border=0 alt=\""._FRIEND."\" title=\""._FRIEND."\" width=\"15\" height=\"11\"></a>";
  172. if ($score != 0) {
  173. $rated = substr($score / $ratings, 0, 4);
  174. } else {
  175. $rated = 0;
  176. }
  177. if ($catid == 0) {
  178. $title = "<a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid$r_options\">$title</a>";
  179. } elseif ($catid != 0) {
  180. $row_res = $db->sql_fetchrow($db->sql_query("SELECT title from ".$prefix."_stories_cat where catid='$catid'"));
  181. $cat_title = stripslashes($row_res['title']);
  182. $title = "<a href=\"modules.php?name=News&amp;file=categories&amp;op=newindex&amp;catid=$catid\"><i>$cat_title</i></a>: <a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid$r_options\">$title</a>";
  183. }
  184. if ($multilingual == 1) {
  185. if ($alanguage == "") {
  186. $alanguage = $language;
  187. }
  188. $alt_language = ucfirst($alanguage);
  189. $lang_img = "<img src=\"images/language/flag-$alanguage.png\" border=\"0\" hspace=\"2\" alt=\"$alt_language\" title=\"$alt_language\">";
  190. } else {
  191. $lang_img = "<strong><big><b>&middot;</b></big></strong>";
  192. }
  193. echo "<tr>"
  194. ."<td bgcolor=\"$bgcolor1\" align=\"left\">$lang_img $title</td>"
  195. ."<td bgcolor=\"$bgcolor1\" align=\"center\">$comments</td>"
  196. ."<td bgcolor=\"$bgcolor1\" align=\"center\">$counter</td>"
  197. ."<td bgcolor=\"$bgcolor1\" align=\"center\">$rated</td>"
  198. ."<td bgcolor=\"$bgcolor1\" align=\"center\">$time[0]</td>"
  199. ."<td bgcolor=\"$bgcolor1\" align=\"center\">$actions</td></tr>";
  200. }
  201. echo "</table>"
  202. ."<br><br><br>";
  203. if (($numrows > 250) AND ($min == 0)) {
  204. $min = $min+250;
  205. $a++;
  206. echo "<center>[ <a href=\"modules.php?name=$module_name&amp;sa=show_all&amp;min=$min\">"._NEXTPAGE."</a> ]</center><br>";
  207. }
  208. if (($numrows > 250) AND ($min >= 250) AND ($a != 1)) {
  209. $pmin = $min-250;
  210. $min = $min+250;
  211. $a++;
  212. echo "<center>[ <a href=\"modules.php?name=$module_name&amp;sa=show_all&amp;min=$pmin\">"._PREVIOUSPAGE."</a> | <a href=\"modules.php?name=$module_name&amp;sa=show_all&amp;min=$min\">"._NEXTPAGE."</a> ]</center><br>";
  213. }
  214. if (($numrows <= 250) AND ($a != 1) AND ($min != 0)) {
  215. $pmin = $min-250;
  216. echo "<center>[ <a href=\"modules.php?name=$module_name&amp;sa=show_all&amp;min=$pmin\">"._PREVIOUSPAGE."</a> ]</center><br>";
  217. }
  218. echo "<hr size=\"1\" noshade>"
  219. ."<font class=\"content\">"._SELECTMONTH2VIEW."</font><br>";
  220. $result2 = $db->sql_query("SELECT time from ".$prefix."_stories order by time DESC");
  221. echo "<ul>";
  222. while($row2 = $db->sql_fetchrow($result2)) {
  223. $time = $row2['time'];
  224. ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $getdate);
  225. if ($getdate[2] == "01") { $month = _JANUARY; } elseif ($getdate[2] == "02") { $month = _FEBRUARY; } elseif ($getdate[2] == "03") { $month = _MARCH; } elseif ($getdate[2] == "04") { $month = _APRIL; } elseif ($getdate[2] == "05") { $month = _MAY; } elseif ($getdate[2] == "06") { $month = _JUNE; } elseif ($getdate[2] == "07") { $month = _JULY; } elseif ($getdate[2] == "08") { $month = _AUGUST; } elseif ($getdate[2] == "09") { $month = _SEPTEMBER; } elseif ($getdate[2] == "10") { $month = _OCTOBER; } elseif ($getdate[2] == "11") { $month = _NOVEMBER; } elseif ($getdate[2] == "12") { $month = _DECEMBER; }
  226. if ($month != $thismonth) {
  227. $year = $getdate[1];
  228. echo "<li><a href=\"modules.php?name=$module_name&amp;sa=show_month&amp;year=$year&amp;month=$getdate[2]&amp;month_l=$month\">$month, $year</a>";
  229. $thismonth = $month;
  230. }
  231. }
  232. echo "</ul><br><br><center>"
  233. ."<form action=\"modules.php?name=Search\" method=\"post\">"
  234. ."<input type=\"text\" name=\"query\" size=\"30\">&nbsp;"
  235. ."<input type=\"submit\" value=\""._SEARCH."\">"
  236. ."</form>"
  237. ."[ <a href=\"modules.php?name=$module_name\">Stories Archive Index</a> ]</center>";
  238. CloseTable();
  239. include("footer.php");
  240. }
  241. switch($sa) {
  242. case "show_all":
  243. show_all($min);
  244. break;
  245. case "show_month":
  246. show_month($year, $month, $month_l);
  247. break;
  248. default:
  249. select_month();
  250. break;
  251. }
  252. ?>