| | 973 | //}}}------------------------------------ |
| | 974 | //{{{ show_comments(): show comment items |
| | 975 | //--------------------------------------- |
| | 976 | function show_comments($options) { |
| | 977 | global $db; |
| | 978 | if (!$options["top"]) { $options["top"] = 0; } else { $options["top"] = (int)$options["top"]; } |
| | 979 | if (!$options["limit"]) { $options["limit"] = 15; } else { $options["limit"] = (int)$options["limit"]; } |
| | 980 | /* create an array with the article titles */ |
| | 981 | $sql = "SELECT id,title FROM articles"; |
| | 982 | $res = $db->query($sql); |
| | 983 | $articles[0] = "no article"; |
| | 984 | while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { |
| | 985 | $articles[$row["id"]] = $row["title"]; |
| | 986 | } |
| | 987 | /* loop through the comments */ |
| | 988 | $res_count =& $db->query("SELECT COUNT(*) FROM comments"); |
| | 989 | $res_count->fetchInto($counter_r, DB_FETCHMODE_NUM); |
| | 990 | $counter = $counter_r[0]; |
| | 991 | $res =& $db->limitQuery("SELECT * FROM comments ORDER BY date DESC", (int)$options["top"], $options["limit"]); |
| | 992 | if (PEAR::isError($res)) { |
| | 993 | die($res->getMessage()); |
| | 994 | } |
| | 995 | while ($res->fetchInto($row, DB_FETCHMODE_ASSOC)) { |
| | 996 | if (!trim($row["title"])) { $row["title"] = "no title"; } |
| | 997 | ?> |
| | 998 | <div class="log_post"> |
| | 999 | <div class="log_head"> |
| | 1000 | <span class="log_subject"> |
| | 1001 | <?=$row["title"]?> (<?=$articles[$row["articles_id"]]?>) |
| | 1002 | <span class="log_cat"><br /> |
| | 1003 | name: <?=$row["name"]?> ip: <?=$row["ip"]?><br /> |
| | 1004 | website: <?=$row["website"]?> email: <?=$row["email"]?> |
| | 1005 | </span> |
| | 1006 | </span> |
| | 1007 | </div> |
| | 1008 | <div class="log_contents"> |
| | 1009 | <?=$row["comment"]?> |
| | 1010 | </div> |
| | 1011 | <div class="log_foot"> |
| | 1012 | <!-- not yet implemented |
| | 1013 | <? if (trim($row["ip"])) { ?><a href="index.php?action=blacklist_ip&commentid=<?=$row["id"]?>">blacklist ip</a><? } ?> |
| | 1014 | --> |
| | 1015 | <a href="index.php?action=delete_comment&id=<?=$row["id"]?>">delete</a> |
| | 1016 | </div> |
| | 1017 | </div> |
| | 1018 | <? |
| | 1019 | } |
| | 1020 | if ($options["top"]) { |
| | 1021 | echo "<a href=\"index.php?action=show_comments&options[top]=".($options["top"]-$options["limit"])."\">previous</a> "; |
| | 1022 | } |
| | 1023 | if (($options["top"] + $options["limit"]) > $counter) { |
| | 1024 | $end = $counter; |
| | 1025 | } else { |
| | 1026 | $end = ($options["top"]+$options["limit"]); |
| | 1027 | } |
| | 1028 | if ($counter == 0) { |
| | 1029 | echo "<span class=\"log_cat\">no comments"; |
| | 1030 | } else { |
| | 1031 | echo "<span class=\"log_cat\">showing ".($options["top"]+1)." to ".$end." of ".$counter." total comments"; |
| | 1032 | } |
| | 1033 | if (($options["top"]+$options["limit"]) < $counter) { |
| | 1034 | echo " <a href=\"index.php?action=show_comments&options[top]=".($options["top"]+$options["limit"])."\">next</a>"; |
| | 1035 | } |
| | 1036 | echo "</span>"; |
| | 1037 | } |
| | 1038 | |
| | 1039 | //}}}-------------------------------------------------------- |
| | 1040 | //{{{ delete_comment($id): Delete a comment from the database |
| | 1041 | //----------------------------------------------------------- |
| | 1042 | function delete_comment($id) { |
| | 1043 | global $db; |
| | 1044 | $sql = sprintf("DELETE FROM comments WHERE id = %d", $id); |
| | 1045 | $res = $db->query($sql); |
| | 1046 | header("Location: index.php?action=show_comments"); |
| | 1047 | } |
| | 1048 | |
| 1005 | | <a class="if_menu_item" href="../index.php"> View Site</a> |
| 1006 | | <a class="if_menu_item<? if ($_REQUEST["action"] == "show_cats") { echo "_act"; } ?>" href="./index.php?action=show_cats"> categories</a> |
| 1007 | | <a class="if_menu_item<? if ($_REQUEST["action"] == "show_authors") { echo "_act"; } ?>" href="./index.php?action=show_authors"> authors</a> |
| 1008 | | <!-- <a class="if_menu_item" href="./index.php?action=show_comments"> comments</a> --> |
| 1009 | | <a class="if_menu_item<? if ($_REQUEST["action"] == "show_posts") { echo "_act"; } ?>" href="./index.php?action=show_posts"> posts</a> |
| 1010 | | <a class="if_menu_item<? if ($_REQUEST["action"] == "show_acro") { echo "_act"; } ?>" href="./index.php?action=show_acro"> acronyms</a> |
| 1011 | | <!-- <a class="if_menu_item<? if ($_REQUEST["action"] == "show_pages") { echo "_act"; } ?>" href="./index.php?action=show_pages"> pages</a> |
| | 1081 | <a class="if_menu_item" href="../index.php">Site</a> |
| | 1082 | <a class="if_menu_item<? if ($_REQUEST["action"] == "show_cats") { echo "_act"; } ?>" href="./index.php?action=show_cats">categories</a> |
| | 1083 | <a class="if_menu_item<? if ($_REQUEST["action"] == "show_authors") { echo "_act"; } ?>" href="./index.php?action=show_authors">authors</a> |
| | 1084 | <a class="if_menu_item<? if ($_REQUEST["action"] == "show_comments") { echo "_act"; } ?>" href="./index.php?action=show_comments">comments</a> |
| | 1085 | <a class="if_menu_item<? if ($_REQUEST["action"] == "show_posts") { echo "_act"; } ?>" href="./index.php?action=show_posts">posts</a> |
| | 1086 | <a class="if_menu_item<? if ($_REQUEST["action"] == "show_acro") { echo "_act"; } ?>" href="./index.php?action=show_acro">acronyms</a> |
| | 1087 | <!-- <a class="if_menu_item<? if ($_REQUEST["action"] == "show_pages") { echo "_act"; } ?>" href="./index.php?action=show_pages"> pages</a> |