include_once $GLOBALS['pie']['library_path'] . '/class/user.php'; include_once $GLOBALS['pie']['library_path'] . '/share/log.php'; $user = new User(); if (!$user->isValidName($_REQUEST['username'])) { pieLog('error'); include $GLOBALS['pie']['custom_path'] . '/frame/private_login.php'; exit; } if (!$user->exists($_REQUEST['username'])) { pieLog('error'); include $GLOBALS['pie']['custom_path'] . '/frame/private_login.php'; exit; } $pw = $user->read($_REQUEST['username']); if ($pw != $user->encrypt($_REQUEST['password'])) { // The entered password differs from the registered password. // Try the crypt() command to handle old style passwords. $salt = substr($pw, 0, 2); if ($pw != crypt($_REQUEST['password'], $salt)) { // The entered password is just wrong. pieLog('error'); include $GLOBALS['pie']['custom_path'] . '/frame/private_login.php'; exit; } } // Login successful. Spaw standard login action. include $GLOBALS['pie']['library_path'] . '/action/login.php'; } else { include $GLOBALS['pie']['custom_path'] . '/frame/private_login.php'; exit; }
include_once "{$lib}/share/stdio.php"; include_once "{$lib}/share/string.php"; include_once "{$lib}/share/log.php"; pieRequireSuperuser(); pieHead("edit"); if (@$_REQUEST['username'] && @$_REQUEST['password']) { // A user has been specified. $user = new User(); if (!$user->isValidName($_REQUEST['username'])) { pieError("InvalidUsername"); } if ($user->exists($_REQUEST['username'])) { pieError("UserExists"); } if ($_REQUEST['password'] != $_REQUEST['retype']) { pieError("PasswordMismatch"); } // Userdata acceptable. Create new user. if (!$user->write($_REQUEST['username'], $user->encrypt($_REQUEST['password']))) { pieError("FailureForm"); } $pref = new UserPref(); $pref->write($_REQUEST['username'], "registered", time()); $GLOBALS['pie']['user'] = $_REQUEST['username']; pieLog("user"); pieNotice("SuccessForm"); } else { // Print the form. pieNotice('RegisterForm'); } pieTail();
<?php /* * Create the local logging facilities below ${run_path}. */ $GLOBALS['pie']['log'] = 'Logging'; if (!file_exists("{$lib}/share/log.php")) { bye("The log library ({$lib}/share/log.php) could not be found."); } include_once "{$lib}/share/log.php"; if (!is_dir("{$run}/log")) { if (!mkdir("{$run}/log")) { bye("The directory for the log file(s) ({$run}/log) could not be created."); } } if (!touch("{$run}/log/pie.log")) { bye("The initial log file could not be created."); } pieLog('setup');
} $total++; } // Walk directory for the second time. This time, encountered // files (and pages contained therein) are imported for real. rewinddir($dh); while (($file = readdir($dh)) !== false) { if ($file == "." || $file == "..") { continue; } if (!importFile($_REQUEST['path'] . "/{$file}")) { pieError("ImportError", array('page' => htmlspecialchars($file))); } $count++; } } elseif (is_readable($_REQUEST['path'])) { // Just one file is to be imported. if (!importFile($_REQUEST['path'])) { pieError("ImportError", array('page' => htmlspecialchars($_REQUEST['path']))); } $total = 1; $count = 1; } // Update the cache. $cache = new Cache(); if ($cache->exists($cache->key('latest', array()))) { $cache->delete($cache->key('latest', array())); } pieLog("alter"); pieNotice("ImportSuccess", array('total' => $total, 'count' => $count)); pieTail();
} pieHead(); if (@$_REQUEST['page']) { // Purge the cache of a single page. $_REQUEST['page'] = pieGetOption($_REQUEST['page']); $_REQUEST['page'] = pieBeautifyName($_REQUEST['page']); if (!$page->isValidName($_REQUEST['page'])) { pieError('PageNameInvalid'); } if (!$page->exists($_REQUEST['page'])) { pieError('PageNotFound'); } $cid = $cache->key('page', array('page' => $_REQUEST['page'])); if (!$cache->exists($cid)) { pieError('PurgeSuccess'); } if ($cache->delete($cid)) { pieNotice('PurgeSuccess'); } else { pieError('PurgeError'); } } else { // Purge the caches of all pages. if ($cache->expire('page', 0)) { pieNotice('ExpirationSuccess'); } else { pieError('ExpirationError'); } } pieLog('edit'); pieTail();
$cid = $cache->key('page', array('page' => $_REQUEST['page'])); if (!($f = fopen($cache->file($cid), 'w'))) { pieError("CacheWriteError"); } if (!fwrite($f, $compiler->output)) { pieError("CacheWriteError"); } fclose($f); } // Clean up. if (file_exists($preview)) { unlink($preview); } if ($GLOBALS['pie']['edit_timeout']) { pieExpireDirectory($GLOBALS['pie']['run_path'] . "/temp", $GLOBALS['pie']['edit_timeout']); } $page->unlock($GLOBALS['pie']['user']); // Purge list of latest changes. if ($GLOBALS['pie']['query_caching']) { $cache = new Cache(); $cache->delete($cache->key('latest', array())); } // Print output. pieLog("edit"); pieNotice("PageUpdated"); if ($GLOBALS['pie']['context'] == 'edit') { print "<div class=\"output\">\n" . $compiler->output . "</div>\n"; } else { print "<hr />\n<br />\n" . $compiler->output; } pieTail();