/* * Display information about a user. */ include_once "{$lib}/class/mapfile.php"; include_once "{$lib}/class/session.php"; include_once "{$lib}/class/user.php"; include_once "{$lib}/class/userpref.php"; include_once "{$lib}/share/auth.php"; include_once "{$lib}/share/string.php"; pieLoadLocale(); pieRequireUser(); pieHead("edit"); if (@$_REQUEST['user']) { // A user has been specified. $_REQUEST['user'] = pieGetOption($_REQUEST['user']); $user = new User(); if (!$user->isValidName($_REQUEST['user'])) { pieError("BadUser"); } if (!$user->exists($_REQUEST['user'])) { pieError("BadUser"); } } elseif ($_SESSION['user']) { // No user has been specified: // display information about myself. $_REQUEST['user'] = $_SESSION['user']; } if (!@$_REQUEST['user']) { pieError("NoUser"); }
} // Determine the text that come before and after the edited section. $section = new Section(); if (($p = $section->offset($page->source, $_REQUEST['section'])) === false) { pieError('SectionNotFound'); } if (($old = $section->extract($page->source, $_REQUEST['section'])) === false) { pieError('SectionNotFound'); } $_REQUEST['source'] = substr($page->source, 0, $p) . rtrim($_REQUEST['source']) . "\n\n" . substr($page->source, $p + strlen($old)); } // Parse and compile the source. $data = array(); $compiler = new htmlCompiler(); $compiler->source = pieCleanString($_REQUEST['source']); if ($GLOBALS['pie']['page_header'] || $GLOBALS['pie']['page_footer']) { // Header and footer require meta data. $compiler->meta = array('title' => pieGetOption($_REQUEST['title']), 'author' => $GLOBALS['pie']['user'], 'stamp' => time()); } if (!$compiler->compile()) { $data['error'] = "<ul>\n"; foreach ($compiler->error as $i) { $data['error'] .= "<li class=\"warning\">{$i}</li>\n"; } $data['error'] .= "</ul>\n"; pieNotice("CompilerError", $data); } // Present the output: $data['preview'] = $compiler->output; pieNotice("ApprovePreview", $data); pieTail();
$_REQUEST['cols'] = 80; $_REQUEST['rows'] = 20; $_REQUEST['author'] = $GLOBALS['pie']['user']; $pref = new UserPref(); if (($t = $pref->read($GLOBALS['pie']['user'], "cols")) !== false) { $_REQUEST['cols'] = $t; } if (($t = $pref->read($GLOBALS['pie']['user'], "rows")) !== false) { $_REQUEST['rows'] = $t; } // Determine the source of the source (so to speak). if ($_POST['source']) { // User provided input via HTTP request. $_REQUEST['source'] = pieCleanString($_REQUEST['source']); $_REQUEST['title'] = pieGetOption($_REQUEST['title']); $_REQUEST['comment'] = pieGetOption($_REQUEST['comment']); } elseif (file_exists($preview)) { // Read source and meta data from temporary preview file. if (!($dump = file_get_contents($preview))) { pieError("SourceReadError"); } $meta = pieExplodePage($dump); foreach (array('source', 'title', 'comment') as $i) { $_REQUEST[$i] = $meta[$i]; } unset($meta); } elseif ($page->exists($_REQUEST['page'])) { // The page already exists. Use and edit the existing source. $diff = new Increment(); if (!($meta = $diff->readPage($_REQUEST['page'], $_REQUEST['stamp']))) { pieError("SourceVersionMissing");
include_once "{$lib}/class/locale.php"; include_once "{$lib}/class/page.php"; include_once "{$lib}/share/link.php"; include_once "{$lib}/share/stdio.php"; include_once "{$lib}/share/string.php"; pieHead(); if (!@$_REQUEST['search'] || !(strlen(@$_REQUEST['string']) >= 3)) { // Display the search form. pieError("SearchForm"); } // Perform search: if (@$_REQUEST['search'] && strlen(@$_REQUEST['string']) >= 3) { $page = new Page(); $result = array(); $val = 1; $pattern = pieGetOption($_REQUEST['string']); if (!$_REQUEST['regex']) { $pattern = preg_quote($pattern); } if ($_REQUEST['standalone']) { $pattern = '\\b' . $pattern . '\\b'; $val *= 3; } if ($_REQUEST['nameonly']) { $val *= 3; } $pattern = chr(29) . $pattern . chr(29); if (!$_REQUEST['casesensitive']) { $pattern .= "i"; } // Walk through all available pages.
<?php /* * Cancel editing a page. */ include_once "{$lib}/class/page.php"; include_once "{$lib}/class/session.php"; include_once "{$lib}/class/locale.php"; include_once "{$lib}/share/auth.php"; include_once "{$lib}/share/stdio.php"; include_once "{$lib}/share/storage.php"; pieRequireUser(); pieHead(); $_REQUEST['page'] = pieGetOption(@$_REQUEST['page']); $preview = pieTempName("_preview"); // Check permission: $page = new Page(); if (!$page->isValidName(@$_REQUEST['page'])) { pieError("PageNameInvalid"); } $page->name = $_REQUEST['page']; if (!$page->lock($GLOBALS['pie']['user'])) { pieError("PageLockError"); } // Clean up what has been set up while editing: if (file_exists($preview)) { unlink($preview); } $page->unlock($GLOBALS['pie']['user']); pieNotice("Cancelation"); pieTail();
if (!$resource->isValidName($alias)) { pieError("AliasNameInvalid"); } } // This is where the real work starts. // Decide what to do: if (@$original && @$alias && @$_REQUEST['create']) { if ($resource->exists($alias)) { // A resource with the name of the alias already exists. pieError("NameCollision", array('context' => $context, 'original' => htmlspecialchars($original), 'alias' => htmlspecialchars($alias))); } // Create a new alias for the specified resource. $resource->meta = array('author' => $GLOBALS['pie']['user']); $resource->name = $alias; if ($_REQUEST['comment']) { $resource->meta['comment'] = pieGetOption($_REQUEST['comment']); } if (!$resource->makeAlias($original)) { pieError("AliasError", array('context' => $context, 'original' => htmlspecialchars($original))); } pieError("AliasSuccess", array('context' => $context, 'original' => htmlspecialchars($original), 'alias' => htmlspecialchars($alias))); } elseif ($original && @$_REQUEST['create']) { // Display a form to create an alias for the resource. pieError("AliasForm", array('original' => htmlspecialchars($original), 'context' => $context)); } elseif (@$original && @$alias) { // Display detailed information about the specified alias. if (!$resource->exists($alias)) { pieError("ErrorExists", array('original' => htmlspecialchars($original), 'alias' => htmlspecialchars($alias), 'context' => $context)); } if (!$resource->read($alias, 0)) { pieError("SourceReadError");
*/ include_once "{$lib}/class/cache.php"; include_once "{$lib}/class/file.php"; include_once "{$lib}/share/errorimage.php"; include_once "{$lib}/share/string.php"; // Dump the specified file into the data stream. function dumpFile($file, $type) { header("Content-Type: {$type}"); header("Accept-Ranges: bytes"); header("Content-Length: " . filesize($file)); readfile($file); exit; } // Sanity check: $_REQUEST['file'] = pieGetOption(@$_REQUEST['file']); $file = new File(); if (!$file->isValidName($_REQUEST['file'])) { pieErrorImage(); } if (!$file->exists($_REQUEST['file'])) { pieErrorImage(); } $_REQUEST['stamp'] = abs(intval(@$_REQUEST['stamp'])); $_REQUEST['size'] = abs(intval(@$_REQUEST['size'])); if (!$file->read($_REQUEST['file'], $_REQUEST['stamp'])) { pieErrorImage(); } // Check for alias: while ($file->meta['type'] == "alias") { if ($GLOBALS['pie']['auto_redirect']) {
} // Prepare meta data of the file: $file->name = $name; $file->meta = array('stamp' => time(), 'author' => $GLOBALS['pie']['user']); // .. file size if ($_FILES['upload']['size']) { $file->meta['size'] = $_FILES['upload']['size']; } else { $file->meta['size'] = filesize(pieTempName("_upload")); } // .. file type if (preg_match('/^[a-z]+\\/[a-z]+[\\w\\-\\+\\.]*\\w+$/', $_FILES['upload']['type'])) { $file->meta['type'] = $_FILES['upload']['type']; } elseif (preg_match('/\\.([0-9A-Za-z]{1,5})$/', $name, $match)) { // File type is determined by file name suffix. $map = new MapFile(); if ($type = $map->read("{$lib}/share/suffix.map", strtolower($match[1]))) { $file->meta['type'] = $type; } } elseif (function_exists("mime_content_type")) { $file->meta['type'] = mime_content_type(pieTempName("_upload")); } if (@$_REQUEST['comment']) { $file->meta['comment'] = pieGetOption($_REQUEST['comment']); } if (!$file->write(pieTempName("_upload"))) { pieError("FileWriteError"); } pieLog("edit"); pieNotice("UploadComplete"); pieTail();
include_once "{$lib}/class/session.php"; include_once "{$lib}/class/user.php"; include_once "{$lib}/class/userpref.php"; include_once "{$lib}/share/auth.php"; include_once "{$lib}/share/log.php"; include_once "{$lib}/share/string.php"; pieRequireUser(); pieHead("edit"); $user = $_SESSION['user']; $pref = new UserPref(); if (@$_REQUEST['form'] == "useredit") { if ($_REQUEST['realname']) { $pref->write($user, 'realname', pieGetOption(@$_REQUEST['realname'])); } if ($_REQUEST['mail']) { $pref->write($user, 'mail', pieGetOption(@$_REQUEST['mail'])); } if ($_REQUEST['cols']) { $pref->write($user, 'cols', intval(@$_REQUEST['cols'])); } if ($_REQUEST['rows']) { $pref->write($user, 'rows', intval(@$_REQUEST['rows'])); } pieLog("user"); pieNotice("UpdateSuccessful"); } else { // Display the form. $data = array('user' => htmlspecialchars($user), 'admin' => "—", 'registered' => 0, 'cols' => 80, 'rows' => 20); $map = new MapFile(); $data['lastlogin'] = date($GLOBALS['pie']['time_format'], $map->read($GLOBALS['pie']['run_path'] . "/user/login.map", $user)); $data['updated'] = date($GLOBALS['pie']['time_format'], $pref->read($user, 'stamp'));
pieError("FileNameInvalid"); } if (!$object->exists($source)) { pieError("FileNotFound"); } if (!$object->read($source, 0)) { pieError("FileReadError"); } } else { pieError("ActionInvalid"); } // Validate the destination: if (!isset($_REQUEST['newname'])) { pieError("RenameForm", array('source' => $source)); } $destination = pieGetOption($_REQUEST['newname']); $destination = pieBeautifyName($destination); $_REQUEST['newname'] = $destination; if (!$object->isValidName($destination)) { pieError("NewNameInvalid"); } if ($object->exists($destination)) { pieError("DestinationExists"); } // Check permissions to delete the resource: $history = $object->history($object->name); if (@$_REQUEST['approve']) { // The user asked to rename the resource, no matter what. if ($GLOBALS['pie']['deny_removal'] && !pieIsSuperuser($GLOBALS['pie']['user'])) { pieError("ActionNotPermitted"); }
include_once "{$lib}/share/referers.php"; pieLoadLocale(); pieHead(); // Verify the input. if (@$_REQUEST['page'] && !@$_REQUEST['file']) { $resource = pieGetOption($_REQUEST['page']); $page = new Page(); if (!$page->isValidName($resource)) { pieError("PageNameInvalid"); } if (!$page->exists($resource)) { pieError("PageNotFound"); } $context = "page"; } elseif (@$_REQUEST['file'] && !@$_REQUEST['page']) { $resource = pieGetOption($_REQUEST['file']); $file = new File(); if (!$file->isValidName($resource)) { pieError("FileNameInvalid"); } if (!$file->exists($resource)) { pieError("FileNotFound"); } $context = "file"; } else { pieError("ActionInvalid"); } // Build the referer list. if (($referers = pieRefererList($resource, $context)) === false) { pieError("RefererError"); }
function printOutput($output) { if ($GLOBALS['pie']['context'] == 'edit') { print "<div class=\"output\">\n{$output}</div>\n"; } else { print $output; } pieTail(); exit; } // Start here: if (@$_REQUEST['string']) { $string = pieBeautifyName(pieGetOption($_REQUEST['string'])); $_REQUEST['page'] = $string; } elseif (@$_REQUEST['page']) { $string = pieBeautifyName(pieGetOption($_REQUEST['page'])); } else { pieHead(); pieError("GotoForm"); } $page = new Page(); if (!$page->isValidName($string)) { pieHead(); pieError("PageNameInvalid"); } if ($GLOBALS['pie']['page_caching']) { $cache = new Cache(); $cid = $cache->key('page', array('page' => $string)); if ($cache->exists($cid)) { $output = file_get_contents($cache->file($cid)); pieHead();