Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/glacials/kure. a flat-file blogging engine
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156<?php
/* NOTES * kure is in BETA. Be aware that there may be BUGS and/or SECURITY HOLES * in the engine, and that you are using it at your own risk. Please be * cautious. * * I graciously accept bug reports and suggestions for kure's engine. Visit * kure's repo at github.com/glacials/kure. My email is qhiiyr@gmail.com * if you wish to reach me directly. * * If you wish to remove the footer's "powered by kure" text, feel free. I * always appreciate recognition somewhere, but I'll let you decide what's fair. * :P */
session_start();
// Tell all files to include relative to THIS FILE's directoryset_include_path(dirname($_SERVER['SCRIPT_FILENAME']));
// Avoid warnings about unset timezones by setting it to the server's timezoneif (function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get")) @date_default_timezone_set(@date_default_timezone_get());
// Autoload any class which is used in this filefunction __autoload($class) { if(file_exists('classes/' . $class . '.php')) include 'classes/' . $class . '.php'; else include_once 'classes/Exceptions.php';}
require_once 'functions.php';require_once 'classes/markdown.php';
set_exception_handler('exception_handler');Engine::init_plugins();
try { $config = Engine::get_config(); $language = Engine::get_language();} catch(CannotFindFileException $e) { Engine::quit($language->cant_find_config, $e->getMessage());} catch(CannotReadFileException $e) { Engine::quit($language->cant_read_config, $e->getMessage());}
try { Template::run('header');} catch(CannotFindFileException $e) { Engine::quit($language->cant_find_template, $e->getMessage());} catch(CannotReadFileException $e) { Engine::quit($language->cant_read_template, $e->getMessage());}
/***** Entry Viewer *****/if(isset($_GET['e'])) { // if a specific entry has been requested
$filename = sanitize($_GET['e']);
try { $entry_handler = new EntryHandler($filename); } catch(CannotFindFileException $e) { Engine::quit($language->cant_find_entry, $e->getMessage()); } catch(CannotReadFileException $e) { Engine::quit($language->cant_read_entry, $e->getMessage()); }
if(!$entry_handler->has_next()) Engine::quit($language->cant_find);
/***** Entry Listing (Home) *****/} elseif(empty($_GET) || isset($_GET['page'])) {
if(!isset($_GET['page'])) $_GET['page'] = 0; // default to page 0
// Avoid injection stuff if(!is_numeric($_GET['page'])) Engine::quit($language->bad_page);
try { $entry_handler = new EntryHandler($_GET['page'], $config->entries_per_page); } catch(CannotFindFileException $e) { Engine::quit($language->cant_find_entry, $e->getMessage()); } catch(CannotReadFileException $e) { Engine::quit($language->cant_read_entry, $e->getMessage()); }
if(!$entry_handler->has_next()) Engine::quit($language->no_entries);
} else {
Engine::quit('');
}
while($entry_handler->has_next()) {
$entry = $entry_handler->next();
$template_vars = array('{ENTRYTITLE}' => $entry->title, '{ENTRYADDRESS}' => '?e=' . $entry->filename, '{ENTRYDAY}' => date('j', $entry->timestamp), '{ENTRYMONTH}' => date('F', $entry->timestamp), '{ENTRYYEAR}' => date('Y', $entry->timestamp), '{ENTRYCONTENT}' => $entry->content );
try { Template::run('entry', $template_vars); } catch(CannotFindFileException $e) { Engine::quit($language->cant_find_template, $e->getMessage()); } catch(CannotReadFileException $e) { Engine::quit($language->cant_read_template, $e->getMessage()); }
}
if(!isset($_GET['page'])) $_GET['page'] = 0; // default to page 0
print "\t\t\t" . '<div class="split">' . "\n";
// Display "previous entries" / "more recent entries" links if necessaryif(($_GET['page'] + 1) * $config->entries_per_page < $entry_handler->total_entries) {
$last = '?page=' . ($_GET['page'] + 1); print "\t\t\t\t" . '<div class="left-split"><a class="navitem" href="' . $last . '">less recent</a></div>' . "\n";
}
if($_GET['page'] != 0) {
if($_GET['page'] == 1) $next = '?'; else $next = '?page=' . ($_GET['page'] - 1);
print "\t\t\t\t" . '<div class="right-split"><a class="navitem" href="' . $next . '"> more recent</a></div>' . "\n";
}
print "\t\t\t" . '</div>' . "\n";
try{ Template::run('footer');} catch(CannotFindFileException $e) { Engine::quit($language->cant_find_template, $e->getMessage());} catch(CannotReadFileException $e) { Engine::quit($language->cant_read_template, $e->getMessage());}?>