PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/dead/news.php

https://bitbucket.org/nexea/x00n
PHP | 137 lines | 111 code | 14 blank | 12 comment | 14 complexity | 36695f953b129135bcbee1da8e3a414f MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. require "include/bittorrent.php";
  3. dbconn();
  4. $action = $_GET["action"];
  5. // View News Item /////////////////////////////////////////////////////////
  6. stdhead("Site news");
  7. if ($action == 'view')
  8. {
  9. $newsid = $_GET["newsid"];
  10. if (!is_valid_id($newsid))
  11. stderr("Error","Invalid news item ID - Code 1.");
  12. if(!is_numeric($newsid))
  13. die("News ID is not an integer<i>".$newsid."</i>");
  14. $sql = "SELECT * FROM `news` WHERE `id` = '$newsid'";
  15. $viewNews = mysql_query($sql) or mysql_error();
  16. if(mysql_num_rows($viewNews) < 1)
  17. {
  18. die("There is no news with that ID.");
  19. }
  20. elseif(mysql_num_rows($viewNews) > 1)
  21. {
  22. die('wtf');
  23. }
  24. else
  25. {
  26. while($arr = mysql_fetch_array($viewNews)){
  27. $newsid = $arr["id"];
  28. $body = $arr["body"];
  29. $userid = $arr["userid"];
  30. $added = $arr["added"] . " GMT (" . (get_elapsed_time(sql_timestamp_to_unix_timestamp($arr["added"]))) . " ago)";
  31. $res2 = mysql_query("SELECT username, donor FROM users WHERE id = $userid") or mysql_error();
  32. $arr2 = mysql_fetch_array($res2);
  33. $postername = $arr2["username"];
  34. if ($postername == "")
  35. $by = "unknown[$userid]";
  36. else
  37. $by = "<a href=\"userdetails.php?id=$userid\"><b>$postername</b></a>" .
  38. ($arr2["donor"] == "yes" ? "<img src=\"images/star.gif\" alt=\"Donor\">" : "");
  39. /*
  40. print("<p class=\"sub\"><table border=\"0 cellspacing=0 cellpadding=0><tr><td class=embedded>");
  41. print("$added&nbsp;---&nbsp;by&nbsp$by");
  42. print(" - [<a href=?action=edit&newsid=$newsid><b>Edit</b></a>]");
  43. print(" - [<a href=?action=delete&newsid=$newsid><b>Delete</b></a>]");
  44. print("</td></tr></table></p>\n");
  45. begin_table(true);
  46. print("<tr valign=top><td class=comment>$body</td></tr>\n");
  47. end_table();
  48. */
  49. ?>
  50. <h2 class="thought-title first">
  51. <a href="#"><?=$arr['title']?></a>
  52. </h2>
  53. <?php
  54. if (get_user_class() >= UC_ADMINISTRATOR)
  55. {
  56. print(" <font size=\"-2\">[<a class=\"altlink\" href=\"adminnews?action=edit&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "\"><b>E</b></a>]</font>");
  57. print(" <font size=\"-2\">[<a class=\"altlink\" href=\"adminnews?action=delete&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "\"><b>D</b></a>]</font>");
  58. }
  59. ?>
  60. <div class="time-ago">Posted <?=$added ?></div>
  61. <div class="thought-text">
  62. <?=$body?>
  63. <p><a href="#">continue reading...</a></p>
  64. </div>
  65. <div class="thought-info">
  66. <span class="label-tags"><strong>Tags:</strong></span>
  67. <ul class="row-tags">
  68. <?php
  69. $tagsList = $arr['tags'];
  70. foreach(explode(',',$tagsList) as $sendIt){
  71. $cleanTags = str_replace( ' ', '', $sendIt);
  72. ?><li><a title="array_tags" href="/tags?tag=<?=$cleanTags?>"><?=$sendIt?></a></li>
  73. <?php }?> </ul>
  74. <p><strong>Comments:</strong>
  75. <a href="#"># of comments</a>
  76. </p>
  77. </div>
  78. <?php
  79. }
  80. }
  81. }
  82. else
  83. {
  84. $res = mysql_query("SELECT * FROM news ORDER BY added DESC") or mysql_error();
  85. if (mysql_num_rows($res) > 0)
  86. {
  87. begin_main_frame();
  88. begin_frame();
  89. while ($arr = mysql_fetch_array($res))
  90. {
  91. $newsid = $arr["id"];
  92. $body = $arr["body"];
  93. $userid = $arr["userid"];
  94. $added = $arr["added"] . " GMT (" . (get_elapsed_time(sql_timestamp_to_unix_timestamp($arr["added"]))) . " ago)";
  95. $res2 = mysql_query("SELECT username, donor FROM users WHERE id = $userid") or mysql_error();
  96. $arr2 = mysql_fetch_array($res2);
  97. $postername = $arr2["username"];
  98. if ($postername == "")
  99. $by = "unknown[$userid]";
  100. else
  101. $by = "<a href=userdetails.php?id=$userid><b>$postername</b></a>" .
  102. ($arr2["donor"] == "yes" ? "<img src=images/star.gif alt='Donor'>" : "");
  103. print("<p class=sub><table border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>");
  104. print("$added&nbsp;---&nbsp;by&nbsp$by");
  105. print(" - [<a href=?action=edit&newsid=$newsid><b>Edit</b></a>]");
  106. print(" - [<a href=?action=delete&newsid=$newsid><b>Delete</b></a>]");
  107. print("</td></tr></table></p>\n");
  108. begin_table(true);
  109. print("<tr valign=top><td class=comment>$body</td></tr>\n");
  110. end_table();
  111. }
  112. end_frame();
  113. end_main_frame();
  114. }
  115. else
  116. {
  117. stdmsg("Sorry", "No news available!");
  118. }
  119. }
  120. stdfoot();
  121. die;
  122. ?>