/dead/news.php
PHP | 137 lines | 111 code | 14 blank | 12 comment | 14 complexity | 36695f953b129135bcbee1da8e3a414f MD5 | raw file
Possible License(s): GPL-2.0
- <?php
-
- require "include/bittorrent.php";
-
- dbconn();
- $action = $_GET["action"];
-
- // View News Item /////////////////////////////////////////////////////////
- stdhead("Site news");
- if ($action == 'view')
- {
- $newsid = $_GET["newsid"];
- if (!is_valid_id($newsid))
- stderr("Error","Invalid news item ID - Code 1.");
-
- if(!is_numeric($newsid))
- die("News ID is not an integer<i>".$newsid."</i>");
- $sql = "SELECT * FROM `news` WHERE `id` = '$newsid'";
- $viewNews = mysql_query($sql) or mysql_error();
- if(mysql_num_rows($viewNews) < 1)
- {
- die("There is no news with that ID.");
- }
- elseif(mysql_num_rows($viewNews) > 1)
- {
- die('wtf');
- }
- else
- {
- while($arr = mysql_fetch_array($viewNews)){
-
- $newsid = $arr["id"];
- $body = $arr["body"];
- $userid = $arr["userid"];
- $added = $arr["added"] . " GMT (" . (get_elapsed_time(sql_timestamp_to_unix_timestamp($arr["added"]))) . " ago)";
- $res2 = mysql_query("SELECT username, donor FROM users WHERE id = $userid") or mysql_error();
- $arr2 = mysql_fetch_array($res2);
-
- $postername = $arr2["username"];
-
- if ($postername == "")
- $by = "unknown[$userid]";
- else
- $by = "<a href=\"userdetails.php?id=$userid\"><b>$postername</b></a>" .
- ($arr2["donor"] == "yes" ? "<img src=\"images/star.gif\" alt=\"Donor\">" : "");
- /*
- print("<p class=\"sub\"><table border=\"0 cellspacing=0 cellpadding=0><tr><td class=embedded>");
- print("$added --- by $by");
- print(" - [<a href=?action=edit&newsid=$newsid><b>Edit</b></a>]");
- print(" - [<a href=?action=delete&newsid=$newsid><b>Delete</b></a>]");
- print("</td></tr></table></p>\n");
-
- begin_table(true);
- print("<tr valign=top><td class=comment>$body</td></tr>\n");
- end_table();
- */
- ?>
-
- <h2 class="thought-title first">
- <a href="#"><?=$arr['title']?></a>
- </h2>
- <?php
- if (get_user_class() >= UC_ADMINISTRATOR)
- {
- print(" <font size=\"-2\">[<a class=\"altlink\" href=\"adminnews?action=edit&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "\"><b>E</b></a>]</font>");
- print(" <font size=\"-2\">[<a class=\"altlink\" href=\"adminnews?action=delete&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "\"><b>D</b></a>]</font>");
- }
- ?>
- <div class="time-ago">Posted <?=$added ?></div>
- <div class="thought-text">
- <?=$body?>
- <p><a href="#">continue reading...</a></p>
- </div>
- <div class="thought-info">
- <span class="label-tags"><strong>Tags:</strong></span>
- <ul class="row-tags">
- <?php
- $tagsList = $arr['tags'];
- foreach(explode(',',$tagsList) as $sendIt){
- $cleanTags = str_replace( ' ', '', $sendIt);
- ?><li><a title="array_tags" href="/tags?tag=<?=$cleanTags?>"><?=$sendIt?></a></li>
- <?php }?> </ul>
- <p><strong>Comments:</strong>
- <a href="#"># of comments</a>
- </p>
- </div>
- <?php
- }
- }
-
- }
- else
- {
- $res = mysql_query("SELECT * FROM news ORDER BY added DESC") or mysql_error();
-
- if (mysql_num_rows($res) > 0)
- {
- begin_main_frame();
- begin_frame();
- while ($arr = mysql_fetch_array($res))
- {
- $newsid = $arr["id"];
- $body = $arr["body"];
- $userid = $arr["userid"];
- $added = $arr["added"] . " GMT (" . (get_elapsed_time(sql_timestamp_to_unix_timestamp($arr["added"]))) . " ago)";
- $res2 = mysql_query("SELECT username, donor FROM users WHERE id = $userid") or mysql_error();
- $arr2 = mysql_fetch_array($res2);
-
- $postername = $arr2["username"];
-
- if ($postername == "")
- $by = "unknown[$userid]";
- else
- $by = "<a href=userdetails.php?id=$userid><b>$postername</b></a>" .
- ($arr2["donor"] == "yes" ? "<img src=images/star.gif alt='Donor'>" : "");
-
- print("<p class=sub><table border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>");
- print("$added --- by $by");
- print(" - [<a href=?action=edit&newsid=$newsid><b>Edit</b></a>]");
- print(" - [<a href=?action=delete&newsid=$newsid><b>Delete</b></a>]");
- print("</td></tr></table></p>\n");
-
- begin_table(true);
- print("<tr valign=top><td class=comment>$body</td></tr>\n");
- end_table();
- }
- end_frame();
- end_main_frame();
- }
- else
- {
- stdmsg("Sorry", "No news available!");
- }
- }
- stdfoot();
- die;
- ?>