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"); }
<?php require_once "../lib/hsh-lib.php"; require_once "../lib/tpl-lib.php"; require_once "../config/login.php"; // Template settings HSHTPL::$UTF8 = FALSE; HSHTPL::suffix("title", "DIKULAN"); HSH::get("/", "main:index"); HSH::get("/om-dikulan", "main:om"); HSH::get("/billetter", "billetter:index"); HSH::get("/turneringer-og-events", "turneringer:index"); HSH::get("/nyt/@id", "news:show"); HSH::get(LoginConfig::$loginuri, "login:get"); HSH::post(LoginConfig::$loginuri, "login:post"); HSH::get("/kontrol/taarn", "control:tower"); HSH::get("/kontrol/crash", "control:crash"); HSH::get("/kontrol/ny", "control:create"); HSH::post("/kontrol/ny", "control:create"); HSH::run();
public function index() { print HSHTPL::template("turneringer"); }