/**********************************************************
* DGWiki Project
* Begun: Sunday, August 28, 2005
* Author: David Gardner
*
* Image Upload
* Not yet.
* Method of adding form elements to rendered output.
* Particularly checkboxes.
* Alternate Border Color for public pages while logged in as admin?
* Bolded Text in a Bulleted list (*) works incorrectly.
* Formatting Tips
* Not yet.
*************************************************************
* FEATURES....
*
* Preview Button
* Press this not to save your changes, but to preview them only.
* Saving Pages
* This saves your content and then forwards you to the page itself,
* no longer in "edit" mode.
* EditPage
* Working! I'm going to have to change the render page to NOT read in
* the content file, but to accept a variable. If Editing page, and the
* form was submitted, then the var will be the contents of the form.
* Otherwise, it will be the contents read in from the source file.
* This way, EditPage will work, whether the page exists or not, and whether
* you are currently working on it or not.
* Do not know how page will behave if page does not exist.
* Search Page
* Criteria entered into both boxes will result in two sets of results. Search
* will halt prematurely if max search time is reached. See User Config Vars.
* WikiWord search works fine. it is actually a regex.
* Content search is fine. it is actually a regex.
* Page Configuration Options
* Though it takes hard coding to add attributes, I can modify existing ones
* and remove existing.
* User Login
* users can log in and log out.
* Page Caching
* Pages are cached upon viewing if they are not already cached. The cached page
* is deleted when the page is modified.
* Force Reload From File feature
* Just click the "reload" link at bottom.
* Searching and Page Security
* Folks should not be able to see Names of pages they don't have access to.
* But I'm not evaluating the groupRead attrib for anything more than "public"
* I think it would just be too memory intensive if I was that detailed.
* User Administration/Maintenance Page
* Any existing passwords will not be overwritten unless you check the box.
* It is not currently possible to view a person's password once it's been
* set. I'm just storing the hashed password.
* User-level Page Security
* Currently, if a config property is not set for a particular page (e.g. you
* add a property to the All list and only a few pages have been updated
* with it), the system is designed to handle that with no problem. Any
* new properties will be added when the config is saved for that page.
* User Read and Write permissions are available to be set. Group Read is
* in place, but only "public" is working so far.
*
************************************************************/
//exit('Got here.');
// set to the user defined error handler
//$old_error_handler = set_error_handler("myErrorHandler");
//try {
session_start();
header("Cache-control: private"); // IE 6 Fix.
$show = true;
$hide = false;
$contentSourceIsFile = 0;
$showCachedPage = 0;
require("wikiFunctions.php");
require("wikiOptions.php");
require("wikiPaths.php");
require("defaultPageConfig.php");
@include($fileStuff['configFilePath']);
// In wikiPaths.php, this var is set.
if ($relocateToHomePage) {
header("Location: index.php?p=". $homePage);
exit;
}
// Lets store url preferences string for use in the links
// this is so a display preference like "wap" will be
// preserved for the next page call.
$urlPrefString = '';
if (isSet($_GET['disp']) && $_GET['disp'] == 'wap') {
$urlPrefString += '';
}
$username = "public";
$usersGroups = '';
$loggedIn = false;
if (isset($_SESSION['username'])) {
$username = $_SESSION['username'];
$loggedIn = true;
// read in user file
$fp = fopen($fileStuff['userDataFilePath'], "r");
$userData = fread($fp, filesize($fileStuff['userDataFilePath']));
fclose($fp);
$users = unserialize($userData);
$userData = '';
$usersCount = count($users);
$usersGroups = $users[$username]['userGroups'];
$usersWikiParser = $users[$username]['wikiParser'];
}
require("setPermissionVars.php");
$contents = '';
$urlTitleSuffix = '';
// This file sets all the variables that determine what happens...
require("wikiController.php");
if ($runEditPage)
$urlTitleSuffix = " - EditMode";
//die('hello ' . ($contentSourceIsFile) . '-' . ($showCachedPage));
if ($contentSourceIsFile || $showCachedPage) { // have to do this now, before the header is run, since it sets a cookie.
$lastVisitedPageNames = str_replace($fileStuff['fileName'].' ', '', isSet($_COOKIE['lastVisitedPageNames']) ? $_COOKIE['lastVisitedPageNames'] : ''
).
' '.$fileStuff['fileName'];
$lastVisitedPageNamesArray = explode(' ', $lastVisitedPageNames);
while (count($lastVisitedPageNamesArray) >= $lastVisitedPageNamesMax) {
unset($lastVisitedPageNamesArray[0]);
$lastVisitedPageNamesArray = array_merge($lastVisitedPageNamesArray);
}
$lastVisitedPageNamesArray = array_unique($lastVisitedPageNamesArray);
foreach ($lastVisitedPageNamesArray as $value)
$lastVisitedPageNamesLinkText[] = "$value";
//setcookie("lastVisitedPageNames", trim(implode(' ', $lastVisitedPageNamesArray)));
/*
setcookie("lastVisitedPageNames"
, trim(implode(' ', $lastVisitedPageNamesArray))
, 'expires' => time() + 86400
,'path' => '/'
,'domain' => 'freezingcode.com'
,'secure' => true
,'httponly' => true,
'samesite' => 'Strict'
);
*/
}
if ($runHeader) { require("wikiHeader.php"); }
if ($contentSourceOther) { require("contentSourceOther.php"); }
if ($contentSourceIsFile) { require("readInContentFile.php"); }
if ($contentSourceIsForm) { $contents = stripslashes($_POST['content']); }
if ($runConfigPage && $userIsAdmin) { require("config.php"); }
if ($runUserAdminPage && $userIsAdmin) { require("userAdmin.php"); }
if ($runPurgeCachePage && $userIsAdmin) { require("purgeCache.php"); }
if ($runEditPage && $userCanWriteThisPage) { require("editPage.php"); }
if ($runEditPageProcess && $userCanWriteThisPage) { require("editPageProcess.php"); }
//exit('got here in the index');
if ($runSearchPage) { require("search.php"); }
if ($runLoginPage) { require("login.php"); }
if ($runLogoutPage) { require("logout.php"); }
if ($runRenderPage) { require("renderPage.php"); }
if ($runFooter) { require("wikiFooter.php"); }
/*
}
catch (Exception $e) {
exit('made it into catch.');
echo ' Exception Message: ' .$e->getMessage() .'';
}
*/
/*
// error handler function
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting, so let it fall
// through to the standard PHP error handler
return false;
}
// $errstr may need to be escaped:
$errstr = htmlspecialchars($errstr);
switch ($errno) {
case E_USER_ERROR:
echo "My ERROR [$errno] $errstr
\n";
echo " Fatal error on line $errline in file $errfile";
echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")
\n";
echo "Aborting...
\n";
exit(1);
case E_USER_WARNING:
echo "My WARNING [$errno] $errstr
\n";
break;
case E_USER_NOTICE:
echo "My NOTICE [$errno] $errstr
\n";
break;
default:
echo "Unknown error type: [$errno] $errstr
\n";
break;
}
// Don't execute PHP internal error handler
return true;
}
*/
?>