Example #1
0
function page_exists()
{
    global $page_array, $special;
    return !$page_array["isspecial"] && $page_array["isreal"];
}
function page_lastupdate()
{
    global $page_array;
    return $page_array["lastupdate"] ? nicetime(time() - $page_array["lastupdate"]) . " ago" : "";
}
function def($a, $b)
{
    return $a ? $a : $b;
}
$page_link = $pages_dir . $page_array["slug"];
$iseditting = $action == "edit" && login_is();
$page_title = def($page_array["title"], $page_array["slug"]);
?>
<html>
<head>
	<title><?php 
echo $page_title;
?>
 - JakeMadeThis</title>
	<link rel="stylesheet" type="text/css" href="/p/base.css" />
	<script type="text/javascript" src="/p/scripts.js"></script>
<?php 
if ($iseditting || $action == "view" || $action == "delete" || $action == "rename") {
    ?>
	<script type="text/javascript">
	onload = function(){ if(edit=document.getElementById("editform"))window.scrollTo(0,edit.offsetTop); }
Example #2
0
     $page_array["tags"] = array_place('$v[tag]', $db->select_rows("SELECT tag FROM pages_tags WHERE slug='{$page_escape}' ORDER BY tag"));
 }
 // Get all child pages
 $page_array["childs"] = $db->select_rows("SELECT pages.slug, pages.title, pages.excerpt\n\t\t FROM pages, pages_tags\n\t\t WHERE pages.slug = pages_tags.slug AND pages_tags.tag = '{$page_escape}'\n\t\t ORDER BY pages.title");
 if ($page == "home") {
     $page_array["blogposts"] = $db->select_rows("SELECT slug,title,excerpt,created FROM blog ORDER BY created DESC");
 } else {
     // Get any blog posts tagged to this page
     $page_array["blogposts"] = $db->select_rows("SELECT blog.slug, blog.title, blog.excerpt, blog.created\n\t\t\tFROM blog, pages_tags\n\t\t\tWHERE blog.slug = pages_tags.slug AND pages_tags.tag = '{$page_escape}'\n\t\t\tORDER BY blog.created DESC");
 }
 /// Actions to perform on page ///////////////////
 // ACTION : view
 if ($action == "view") {
     // This lets anyone view the source of the page.
     // Handle that in the output PHP, but do nothing here
 } elseif ($action != "" && !login_is()) {
     $messages[] = "You're not <a href=\"/php/login.php?redirect={$pages_dir}{$page}%3Fedit\" rel=\"nofollow\">logged in</a>, silly";
 } elseif ($action == "delete") {
     // We can delete pages. A confirmation button is needed to make it
     // harder to accidently delete pages
     // Error and skip down is the page doesn't even exist
     if (!$page_array["isreal"]) {
         $messages[] = "This page doesn't exist in the database";
     } elseif (isset($_POST["confirm"])) {
         // Do the page deletion
         $result = $db->query("DELETE FROM {$table} WHERE slug='{$page_escape}'");
         if (!$result) {
             $messages[] = "<small>" . mysql_error() . "</small>";
         } elseif (mysql_affected_rows() == 0) {
             $messages[] = "Didn't affect any rows. This is odd behaviour.";
         } else {