function postCreate($topic_id, $author_id, $message, $flags) { global $database_cfg; $errors = array(); if (!userExistsById($author_id)) { $errors[] = "User marked as author (" . $author_id . ") not found"; } if (!topicExistsById($topic_id)) { $errors[] = "Topic marked as parent not found"; } if (postExists($topic_id, $message)) { $errors[] = "This post already exists in this topic"; } if (count($errors) > 0) { return $errors; } databaseQuery("insert into " . $database_cfg["prefix"] . "posts (topic_id, author_id, message, flags, created) values ('" . intval($topic_id) . "', '" . intval($author_id) . "', '" . stringEncode($message) . "', '" . $flags . "', '" . stringEncode(date("H:i, d.m.Y")) . "')"); databaseQuery("update " . $database_cfg["prefix"] . "topics set edited='" . stringEncode(date("H:i, d.m.Y")) . "' where id='" . intval($topic_id) . "'", "Can't update topic"); }
function topicDrop($topic_id) { global $database_cfg; if (topicExistsById($topic_id)) { databaseQuery("delete from " . $database_cfg["prefix"] . "topics where id='" . intval($topic_id) . "'", "Can't delete topic"); } }
if (isset($_GET["regform"])) { echo "<form action=\"index.php?regusr\" method=\"post\">"; echo "Username (used for logging in):<br /> <input type=\"text\" name=\"username\" /><br />"; echo "Password:<br /> <input type=\"password\" name=\"password1\" /><br />"; echo "Password (once more):<br /> <input type=\"password\" name=\"password2\" /><br />"; echo "Nickname (showed in your profile):<br /> <input type=\"text\" name=\"nickname\" /><br />"; echo "Your e-mail address:<br /> <input type=\"text\" name=\"email1\" /><br />"; echo "Repeat your e-mail:<br /> <input type=\"text\" name=\"email2\" /><br />"; echo "<h1><a id=\"foo\" href=\"javascript: void(0);\" onClick=\"javascript: \$('#foo').load('index.php?cap');\">CLICK ME!</a></h1>"; echo "Result (solve problem upper):<br /> <input type=\"text\" name=\"captcha_res\" /><br />"; echo "<input type=\"submit\" value=\"register\" />"; echo "</form>"; } else { if (isset($_GET["topic_id"])) { $user = userGetLoggedIn(); if (topicExistsById(intval($_GET["topic_id"])) && topicCheckReader($_GET["topic_id"], $user["id"])) { $topic = topicGetById(intval($_GET["topic_id"])); $posts = postGetByTopicId(intval($topic["id"])); echo "<h1>" . stringDecode($topic["title"]) . "</h1>"; if (topicCheckModerator($topic["id"], $user["id"]) || userCheckAdministrator($user["id"])) { echo "<a href=\"index.php?edittopic&topic_id=" . $_GET["topic_id"] . "\">Edit topic</a>"; } $topics = topicGetByIdRange($_GET["topic_id"], 0, 5); if (count($topics) > 0) { echo "<br /> <br /> <p class=\"item_top\"> <b> Sub-topics: </b> </p> <br />"; for ($i = 0; $i < count($topics); $i++) { echo "<a href=\"index.php?topic_id=" . intval($topics[$i]["id"]) . "\">" . stringDecode($topics[$i]["title"]) . "</a> <br />"; } } echo "<br /> <br /> <p class=\"item_top\"> <b> Topic posts: </b> </p> <br />"; for ($i = 0; $i < count($posts); $i++) {