} else { if ($wikiSubPage == "edit") { if (file_exists($wikiFile)) { $handle = fopen($wikiFile, "r"); $data = fread($handle, filesize($wikiFile)); } // Put in template $wikiData = $data; include getThemeDir() . "/edit.php"; } else { if ($wikiSubPage == "history") { $wikiHistory = getGitHistory($wikiPage); include getThemeDir() . "/history.php"; } else { if (eregi("[0-9A-F]{20,20}", $wikiSubPage)) { $output = array(); if (!git("cat-file -p " . $wikiSubPage . ":{$wikiPage}", $output)) { return; } $wikiContent = wikify(join("\n", $output)); include getThemeDir() . "/view.php"; } else { print "Unknow subpage: " . $wikiSubPage; } } } } } } } }
function getContent($pageTitle) { global $db; $sql = 'SELECT id, page, content FROM page_content WHERE page = :pageTitle LIMIT 1'; $stmt = $db->prepare($sql); $stmt->bindValue(':pageTitle', $pageTitle); $stmt->execute(); if ($stmt->numRows() == 0) { if (Session::hasPriv('CONTENT_EDIT')) { return '<span class = "bad">Content block "' . $pageTitle . '" does not exist in the database - <a href = "updateContent.php?title=' . $pageTitle . '">create it</a>?</span>'; } else { return '<span class = "bad">Content block "' . $pageTitle . '" does not exist in the database.</span>'; } } $content = $stmt->fetchRow(); $stuff = $content['content']; $stuff = stripslashes($stuff); $stuff = wikify($stuff); if (Session::hasPriv('CONTENT_EDIT')) { $stuff .= ' <a href = "updateContent.php?id=' . $content['id'] . '"><img class = "icon" src = "resources/images/icons/edit.png" alt = "edit" /></a>'; } $stuff = parify($stuff); return $stuff; }