summaryrefslogtreecommitdiff
path: root/index.php
blob: 73582ea7dfb4aa91591bf189b7bd80651d486492 (plain)
    1 <?php
    2 //print(file_get_contents('res/header.html'));
    3 include('res/header.php');
    4 
    5 // Support multiple page query styles (this implements partial support for
    6 // links used by other sofwares)
    7 if($_GET['p'] != '') {
    8   $post = $_GET['p'];
    9 } else if($_GET['title'] != '') {
   10   $post = $_GET['title'];
   11 } else if($_GET['q'] != '') {
   12   $post = $_GET['q'];
   13 }
   14 
   15 // For security, strip all leading characters off the filename (things like ./
   16 // and ../) to prevent people from abusing the query string.
   17 $post = basename($post);
   18 
   19 if($post == "" && file_exists('html/index.html')) {
   20   // if a post isn't specified
   21   print(file_get_contents('html/index.html'));
   22 } elseif(file_exists('html/' . $post . '.html')) {
   23   // Get the first line
   24   $f = fopen('posts/' . $post . '.adoc', 'r');
   25   $firstline = fgets($f);
   26   fclose($f);
   27   // Print the first line (title)
   28   print('<h1>' . $firstline . '</h1>');
   29 
   30   // Get and print post body
   31   print(file_get_contents('html/' . $post . '.html'));
   32 } else {
   33   print("Error: the page you have requested does not exist.");
   34 }
   35 
   36 print(file_get_contents('res/footer.html'));
   37 ?>

Generated by cgit