if (isset($_GET["type"]) && isset($_GET["query"])) { $type = $_GET["type"]; $query = strtolower($_GET["query"]); $search = new Search(); switch ($type) { case "blog": $blog = new Blog(); $results = $search->find_articles($query); if ($search->num_results() > 0) { ?> <p>Order By: <a href="#" id="order_relevance">Relevance</a> | <a href="#" id="order_name">Name</a></p><?php $sum = array_sum($results); $q = explode(" ", $query); foreach ($results as $key => $value) { $current = $blog->get($key); $current_meta = $blog->get_sub("meta", $key, array("tags", "author")); echo "<div class=\"search_result\"><h2><a href=\"blog.php?p=read&id={$key}\" rel=\"{$value}\" id=\"r{$key}\">", $current["head"], "</a></h2><h3>", $current["subh"], "</h3><span>Relevance: <strong>", substr($value / $sum * 100, 0, 5), "%</strong> ({$value} pts)</span><div class=\"article_body\" style=\"display: none; margin: 10px;\">"; echo "<p>"; $special_chars = array(".", ",", "-", "[", "]", "\\", "/", "|", "(", ")", "!", "@", "#", "\$", "%", "&", "*", "_", "?"); $body = str_replace(array("\n\n", "\n"), array("</p><p>", " <br /> "), $current["body"]); $body = str_replace($special_chars, "", $body); $body = explode(" ", $body); foreach ($q as $qk => $qv) { $color = "ff" . dechex($qk . "20") . "0f"; foreach ($body as $bk => $bv) { if (ereg($qv, $bv)) { $body[$bk] = str_replace($bv, "<span style=\"color: #{$color}; font-size: 18px; font-family: Tahoma\">" . $bv . "</span>", $body[$bk]); } } } echo implode(" ", $body), "</p><p>Tags: ", $current_meta["tags"], ", Written By: ", $current_meta["author"], "</p></div></div>";
} ?> <?php $p = isset($_GET["p"]) ? $_GET["p"] : "add"; switch ($p) { case "mod": case "add": $blog = new Blog(); $data = array("head" => "", "subh" => "", "body" => ""); $meta = array("allow_comments" => 1, "tags" => "", "published" => 1, "author" => $_SESSION["admin_user"]); $root = get_entities("zombie_roots", $_SESSION["id"], array("groups")); $root = explode(", ", $root["groups"]); $meta["groups"] = array("all"); if (isset($_GET["id"]) && isset($_GET["p"]) && $_GET["p"] == "mod") { $data = $blog->get($_GET["id"], array("head", "subh", "body")); $meta = $blog->get_sub("meta", $_GET["id"], array("allow_comments", "tags", "author", "groups", "published")); $groups = explode(", ", $meta["groups"]); } ?> <form method="post" id="article_form" action="engine.php?action=<?php echo $p == "add" ? "add_article" : "mod_article"; if (isset($_GET["id"])) { echo "&id=" . $_GET["id"]; } ?> " enctype="plain/text"> <p> <label for="head">Header</label> <input type="text" name="head" id="head" value="<?php echo $data["head"]; ?> "/>
?> /> <input type="submit" class="btn" <?php echo $p == "add" ? "value=\"Create a bloody masterpiece\" id=\"add_article\"" : "value=\"Re-animate\" id=\"mod_article\""; ?> /><img src="images/btn_right.png" alt="btn_right" class="btn_right" /> </p> </form> <?php break; case "read": if (isset($_GET['id'])) { $id = $_GET["id"]; $blog = new Blog(); $article = $blog->get($id); $meta = $blog->get_sub("meta", $id, array("author")); echo "<a href=\"blog.php?p=mod&id=", $id, "\">Modify this Article</a> or <a href=\"blog.php?p=del&id=", $id, "\">delete it</a>"; echo "<h2>", $article["head"], "</h2>"; if ($article["subh"] != null) { echo "<h3>", $article["subh"], " - By: ", $meta["author"], "</h3>"; } $body = str_replace(array("\n\n", "\n"), array("</p><p>", "<br />"), $article["body"]); echo "<p>", $body, "</p>"; echo "<a href=\"blog.php?p=mod&id=", $id, "\">Modify this Article</a> or <a href=\"blog.php?p=del&id=", $id, "\">delete it</a>"; } else { echo "No article selected"; } break; case "del": $id = $_GET["id"]; if (!isset($_GET["ERROR_CODE"]) || !isset($_GET["SUCCESS_CODE"])) {