index.php (1425B)
1 <?php 2 /* 3 * 4 * Just a Blog 5 * http://qualityretro.net 6 * 7 * A simple blogging software that leaves presentation up to the user. 8 * 9 * (c) 2016 Robert D Herb 10 * All rights reserved. 11 * 12 * For more information see LICENSE 13 * 14 */ 15 16 $documentRoot = $_SERVER["DOCUMENT_ROOT"]; 17 require_once( "functions.php" ); 18 require_once( "lib/parsedown/Parsedown.php" ); 19 require_once( "config.php" ); 20 21 $title = TITLE; // Change the defined title to a var to let me change it later. 22 23 //BLOGDIR = $documentRoot . "/" . 24 preg_match( "([0-9A-Za-z_\-]+)", BLOGDIR ) . "/"; 25 26 define( "BLOG_DIR", BLOGDIR ); 27 28 $pages = preg_grep( '~\.md$~', scandir( "pages/" ) ); 29 30 /* Make sure a home page exists. One should be supplied for you. */ 31 if( !file_exists( "pages/home.md" ) ) { 32 trigger_error( "No home page. Make sure there is a file named home.md in 33 the pages directory.", E_USER_ERROR ); 34 } 35 36 sort( $pages ); 37 38 // Build the header 39 write_html( file_get_contents( "html/header.html" ), set_title(), BLOGDIR, build_nav( $pages ) ); 40 $parsedown = new Parsedown(); 41 42 if( isset( $_GET['page'] ) ) { 43 $content = file_get_contents( "pages/" . $_GET['page'] . ".md" ); 44 } 45 else if( isset( $_GET['post'] ) ) { 46 $content = file_get_contents( "posts/" . $_GET['post'] . ".md" ); 47 48 } 49 else { 50 $content = file_get_contents( "pages/home.md" ); 51 } 52 53 print( write_html( $parsedown->text( $content ) ) ); 54 55 write_html( file_get_contents( "html/footer.html" ) ); 56 57 58 ?>