header('HTTP/1.0 500 Internal Server Error'); page_header("Sorry! Something's gone wrong."); ?> <h2>Sorry! Something's gone wrong.</h2> <em><?php echo $message; ?> </em> <!-- <?php echo "{$file}:{$line}"; ?> --> <?php page_footer(); } err_set_handler_display('jl_handle_error'); EnsureCookiesEnabled(); /* Get all the parameters which we might use (pulls them into $q_ prefixed vars) */ importparams(array('stash', '/^[0-9a-f]+$/', '', null), array('email', '/./', '', null), array(array('name', true), '//', '', null), array('password', '/[^\\s]/', '', null), array('t', '/^.+$/', '', null), array('rememberme', '/./', '', false)); /* General purpose login, asks for email also. */ if (0) { // CRUFT??? if (get_http_var("now")) { $P = person_signon(array('reason_web' => "Log in", 'reason_email' => "Log in to Journalisted", 'reason_email_subject' => 'Log in to Journalisted')); // account management page header("Location: /account"); exit; } } /* is there a token? (i.e. user coming in via a confirmation email) */ if (!is_null($q_t)) {
ini_set('magic_quotes_runtime', FALSE); define('STDIN', fopen('php://stdin', 'r')); define('STDOUT', fopen('php://stdout', 'w')); define('STDERR', fopen('php://stderr', 'w')); register_shutdown_function(create_function('', 'fclose(STDIN); fclose(STDOUT); fclose(STDERR); return true;')); } require_once 'Console/Getopt.php'; define('SUCCESS', 0); define('PROBLEM', 1); define('NO_ARGS', 10); define('INVALID_OPTION', 11); $args = Console_Getopt::readPHPArgv(); if (PEAR::isError($args)) { fwrite(STDERR, $args->getMessage() . "\n"); exit(NO_ARGS); } $options = Console_Getopt::getOpt($args, $short_opts, $long_opts); if (PEAR::isError($options)) { fwrite(STDERR, $options->getMessage() . "\n"); exit(INVALID_OPTION); } require_once 'error.php'; /* error display to standard error */ function err_display_stderr($num, $str, $file, $line, $context) { $stderr = fopen('php://stderr', 'w'); fwrite($stderr, "{$file}:{$line}\n{$str}\n"); fclose($stderr); } err_set_handler_display('err_display_stderr'); err_set_handler_log(null);
/* fyr_display_error NUMBER MESSAGE * Display an error message to the user. */ function fyr_display_error($num, $message, $file, $line, $context) { /* Nuke any existing page output to display the error message. */ if (OPTION_PHP_DEBUG_LEVEL == 0) { ob_clean(); } if (OPTION_FYR_REFLECT_EMAILS) { template_show_error("<strong>{$message}</strong> in {$file}:{$line}"); } else { /* Message will be in log file, don't display it for cleanliness */ template_show_error("Please try again later, or <a\n href=\"mailto:team@writetothem.com\">email us</a> to let us know."); } } err_set_handler_display('fyr_display_error'); /* fyr_get_host * Return the host from which a page was requested, or an * empty string if the host is not available */ function fyr_get_host() { $host = ''; if (array_key_exists('HTTP_HOST', $_SERVER)) { $host = $_SERVER['HTTP_HOST']; } return $host; } /* fyr_format_message_body_for_preview MESSAGE_BODY * Format a message body for HTML preview - handle leading spaces, * add HTML linebreaks and convert special characters to entities. */
<?php /* helper functions for admin pages */ // Error display require_once "../../phplib/error.php"; require_once "../../phplib/person.php"; function admin_display_error($num, $message, $file, $line, $context) { print "<p><strong>{$message}</strong> in {$file}:{$line}</p>"; } err_set_handler_display('admin_display_error'); function admCheckAccess() { $P = person_if_signed_on(); if (!is_null($P)) { // check for admin permission $perm = db_getOne("SELECT id FROM person_permission WHERE permission='admin' AND person_id=?", $P->id()); if (!is_null($perm)) { return TRUE; } } return FALSE; } // only returns if logged-in user has admin access function admEnforceAccess() { if (!admCheckAccess()) { // no access. stop right now. // should print error message, but hey. let's just dump back to homepage header('HTTP/1.0 403 Forbidden'); print "not logged in.";