public function show($id) { $regexp = "/^(?P<id>\\d+)-(?P<slug>.+)/"; $matches = array(); $count = preg_match($regexp, $id, $matches); if ($count == 1) { $dbh = new PDO(DatabaseConfig::$connectionstring); $sql = "SELECT * FROM news WHERE id = :id ORDER BY id DESC LIMIT 1;"; $query = $dbh->prepare($sql); $query->execute(array(":id" => $matches["id"])); $result = $query->fetchAll(); $row = $result[0]; echo HSHTPL::template("newspost", array("id" => $row["id"], "slug" => $row["slug"], "title" => $row["title"], "timestamp" => Time::relative_time($row["timestamp"]), "content" => Markdown($row["content"]))); } else { header("Location: /404"); exit; } }
public function create() { AuthLib::authed(); $method = $_SERVER["REQUEST_METHOD"]; if ($method == "GET") { echo HSHTPL::template("newform"); } else { if ($method == "POST") { $dbh = new PDO(DatabaseConfig::$connectionstring); $sql = "INSERT INTO news (" . " title" . ", slug" . ", content" . ", timestamp" . ") VALUES (" . " :title" . ", :slug" . ", :content" . ", :timestamp" . ");"; $query = $dbh->prepare($sql); $title = $_POST["blogtitle"]; $slug = LIBLIB::slugify($title); $content = $_POST["blogcontent"]; $query->execute(array(":title" => htmlentities($title), ":slug" => $slug, ":content" => htmlentities($content), ":timestamp" => time())); header("Location: /kontrol/taarn"); exit; } } }
function om() { echo HSHTPL::template("om-os"); }
public function get() { echo HSHTPL::template("loginform"); }
public function index() { print HSHTPL::template("billetter"); }
public function index() { print HSHTPL::template("turneringer"); }