** http://catonmat.net/blog/making-of-picurls-popurls-for-pictures-part-one/ ** */ error_reporting(E_ALL); if (!$included_from_index) { header("Location: {$SITE_URL}"); exit; } require_once 'mysmarty.php'; require_once 'system/db.sqlite.php'; define('PAGE_NAME', 'page-item'); define('CACHE_TIME', 3600); $sane_item_title = $HandlerMatches[1]; $unique_page_name = PAGE_NAME . "{$sane_item_title}"; $smarty = new MySmarty(); if ($smarty->is_cached('index.tpl.html', $unique_page_name)) { $smarty->display('index.tpl.html', $unique_page_name); exit; } $db = new SQLite($SQLITE_DB_PATH); $comment_error = false; $add_comment = 0; if (isset($_POST['sane_title'])) { if (!preg_match("#^[a-z0-9-]+\$#", $_POST['sane_title']) || $_POST['sane_title'] != $sane_item_title) { # Title must be well formatted and must match the requested URL $comment_error = "The item title was invalid. Is there some hackery going on?!"; $smarty->assign('comment_error', $comment_error); $smarty->assign('existing_comment', isset($_POST['comment']) ? $_POST['comment'] : ''); } else { if (!isset($_POST['comment']) || empty($_POST['comment'])) { $comment_error = "No comment was typed. Please type what you wished and submit it again!";