예제 #1
0
 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;
     }
 }
예제 #2
0
 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;
         }
     }
 }
예제 #3
0
 function om()
 {
     echo HSHTPL::template("om-os");
 }
예제 #4
0
 public function get()
 {
     echo HSHTPL::template("loginform");
 }
예제 #5
0
 public function index()
 {
     print HSHTPL::template("billetter");
 }
예제 #6
0
 public function index()
 {
     print HSHTPL::template("turneringer");
 }