function getProjectsContent($path) { global $title; include 'blog.php'; $action = array_shift($path); if ($action == "") { $title = "Projects" . $title; $content = '<h1>Projects</h1><p>Below is a list of personal (and maybe some group) projects that I thought deserved their own page. Feel free to contact me (see the footer) if you\'de like to know more about a certain project or endeavor.</p>'; $content .= '<p class="subtitle">The following projects are listed in order of their most recent blog post activity.</p>'; foreach (fetchProjects() as $project) { $content .= getProjectSummary($project); } return $content; } else { $project = fetchProject($action); if ($project == null) { return get404(); } else { $title = $project['name'] . " (Project)" . $title; return getProject($project); } } return "<h1>Projects</h1>"; }
function getBlogContent($path) { $action = array_shift($path); if ($action == null) { $action = '1'; } switch ($action) { case "post": global $title; $postId = array_shift($path); if (isValidId($postId, "posts")) { $title = fetchPostTitle($postId) . " (Post)" . $title; return getPost($postId); } else { return get404(); } break; case "tags": global $currentTag; global $title; $currentTag = array_shift($path); if (isValidId($currentTag, "tags")) { $title = fetchTagName($currentTag) . " (Tag)" . $title; return getTag($currentTag); } else { return get404(); } break; default: global $title; $validNumber = preg_match("/^[0-9]+\$/", $action, $matches); if (!$validNumber) { return get404(); } if (getPageCount("posts") < $action) { return get404(); } $title = "Blog" . $title; if ($action == 1) { $content = '<h1>Blog</h1><p>A small collection of thoughts and progress notes I thought the would would possibly what to know about. I try to keep my updates sparse but informative but I can\'t hold that promise.</p>'; } else { $content = getPageLinks("You are viewing blog posts from a past time.<br>", $action, "/blog/", "posts"); } return $content . getRecentPosts($action - 1) . getPageLinks("Page Selection<br>", $action, "/blog/", "posts"); break; } }
case "admin": include "admin.php"; exit; break; case "blog": include 'blog.php'; $pageContent = getBlogContent($URI); break; case "projects": include 'projects.php'; $pageContent = getProjectsContent($URI); break; default: $pageContent = getPageContent($baseResource); if ($pageContent == null) { $pageContent = get404(); } else { $title = getPageTitle($baseResource) . $title; } break; } ?> <!DOCTYPE html> <html> <head> <title><?php echo $title; ?> </title> <meta name="viewport" content="width=device-width, initial-scale=1.0">
function templateify() { global $CANCEL_TEMPLATEIFY; //In case, for example, you want to send an attachment. if (@$CANCEL_TEMPLATEIFY) { return; } global $pagesTitles, $hiddenPagesTitles, $adminPagesTitles; $pagename = basename($_SERVER['REQUEST_URI'], '.php'); //--TODO-- needs to be full relative paths - e.g. "classes/about.php" gets About. //likewise, links in navbar must be absolute or relative to ROOT_PATH if (!val('f', $pagename)) { $pagename = '404'; } //Make this consistent with the _actual_ 404s with htaccess ("foafi/dshiafos.php") if ($pagename == '' || $pagename == 'doeqs_new') { $pagename = 'index'; } //--todo-- hax if (array_key_exists($pagename, $pagesTitles)) { $title = $pagesTitles[$pagename]; $content = ob_get_clean(); } elseif (array_key_exists($pagename, $hiddenPagesTitles)) { $title = $hiddenPagesTitles[$pagename]; $content = ob_get_clean(); } elseif (array_key_exists($pagename, $adminPagesTitles) && userAccess('a')) { $title = $adminPagesTitles[$pagename] . ' <i>[Admin-Only Page]</i>'; $content = ob_get_clean(); } else { $title = 'Error 404 Not Found'; $content = get404(); ob_clean(); } $content = fetch_alerts_html() . $content; $nav = '['; foreach ($pagesTitles as $p => $t) { $nav .= " · <a href='" . ROOT_PATH . "{$p}.php'>{$t}</a>"; } if (userAccess('a')) { $nav .= ' — '; foreach ($adminPagesTitles as $p => $t) { $nav .= "<a href='" . ROOT_PATH . "{$p}.php'>{$t}</a>"; } } $nav .= ' · ]'; if (userAccess('u')) { $nav .= ' <form action="login.php" method="POST" style="display:inline-block;"><input type="hidden" name="ver" value="<?=csrfCode();?>"/><input type="submit" name="logout" value="Log Out" /></form>'; } //tried OB to get file contents which died for some reason... $template = file_get_contents(__DIR__ . '/html_template.html'); //--todo-- don't access files outside of protected object global $VERSION_NUMBER, $TIME_START; echo str_replace(array('%title%', '%content%', '%nav%', '%version%', '%loadtime%', '%root%'), array($title, $content, $nav, $VERSION_NUMBER, substr(1000 * (microtime(true) - $TIME_START), 0, 6), ROOT_PATH), $template); ob_flush(); flush(); }
return $app->render('views/static_content.php with views/layout.php', ['title' => 'Contact', 'description' => "It's easy to connect with Fisher Evans: E-Mail, Twitter, LinkedIn, GitHub, the works!", 'currentPage' => 'contact', 'staticContent' => $staticContent]); }); $app->bind("/credits", function () use($app) { $staticContent = collection('Static Content')->findOne(['name_slug' => 'credits']); return $app->render('views/static_content.php with views/layout.php', ['title' => 'Credits', 'description' => "I wouldn't have been able to make this site without a little help...", 'currentPage' => '', 'staticContent' => $staticContent]); }); $app->bind("/resume", function () use($app) { global $app; $app->response->status = "301"; header('Location: http://resume.fisherevans.com/'); $data = ['title' => '404 Not Found', 'description' => 'This page was not found. Please let me know if you this is in error.', 'message' => 'My resume is now located here: <a href="http://resume.fisherevans.com/">resume.fisherevans.com/</a>.']; return $app->render('views/404.php with views/layout.php', $data); }); $app->bind("/sitemap.xml", function () use($app) { return $app->render('views/indexes/sitemap.php', ['app' => $app]); }); $app->bind("/blog/rss", function () use($app) { return $app->render('views/indexes/rss.php', ['app' => $app]); }); $app->bind("*", function () use($app) { return get404(); }); if (isset($_SERVER['ORIG_PATH_INFO'])) { $app->run($_SERVER['ORIG_PATH_INFO']); } else { if (isset($_SERVER['REQUEST_URI'])) { $app->run($_SERVER['REQUEST_URI']); } else { $app->run('/'); } }