\n"; try { @ob_flush(); // Seems like it should be better to do the following but is problematic on PHP5.3 at least: while ( ob_get_level() > 0 ) ob_end_flush(); } catch( Exception $ignored ) {} echo "Error [".$errno."] ".$errstr."\n"; echo "At line ", $errline, " of ", $errfile, "\n"; $e = new Exception(); $trace = array_reverse($e->getTrace()); echo "================= Stack Trace ===================\n"; foreach( $trace AS $k => $v ) { printf( "%s[%d] %s%s%s()\n", $v['file'], $v['line'], (isset($v['class'])?$v['class']:''), (isset($v['type'])?$v['type']:''), (isset($v['function'])?$v['function']:'') ); } } set_error_handler('catch_setup_errors', E_ALL); class CheckResult { private $ok; private $use_class; private $description; function __construct( $success, $description=null, $use_class=null ) { $this->ok = (boolean) $success; $this->description = (isset($description)?$description : ($success===true? i18n('Passed') : i18n('Fail'))); $this->use_class = (isset($use_class)?$use_class:($success===true?'dep_ok' : 'dep_fail')); } public function getClass() { return $this->use_class; } public function setClass( $new_class ) { $this->use_class = $new_class; } public function getOK() { return $this->ok; } public function getDescription() { return translate($this->description); } public function setDescription( $new_desc ) { $this->description = $new_desc; } } /** * We put many of these checks before we even try to load always.php so that we * can try and do some diagnostic work to ensure it will load OK. */ function check_pgsql() { return new CheckResult(function_exists('pg_connect')); } function check_pdo() { return new CheckResult(class_exists('PDO')); } function check_pdo_pgsql() { global $loaded_extensions; if ( !check_pdo() ) return new CheckResult(false); return new CheckResult(isset($loaded_extensions['pdo_pgsql'])); } function check_database_connection() { global $c; if ( !check_pdo_pgsql() ) return new CheckResult(false); return new CheckResult( !( empty($c->schema_major) || $c->schema_major == 0 || empty($c->schema_minor) || $c->schema_minor == 0) ); } function check_gettext() { global $phpinfo, $loaded_extensions; if ( !function_exists('gettext') ) return new CheckResult(false); return new CheckResult(isset($loaded_extensions['gettext'])); } function check_iconv() { global $phpinfo, $loaded_extensions; if ( !function_exists('iconv') ) return new CheckResult(false); return new CheckResult(isset($loaded_extensions['iconv'])); } function check_ldap() { global $phpinfo, $loaded_extensions; if (!function_exists('ldap_connect')) return new CheckResult(false); return new CheckResult(isset($loaded_extensions['ldap'])); } function check_real_php() { global $phpinfo, $loaded_extensions; // Looking for "Server API
%s
", $errormessage ); } if ( !check_gettext()->getOK() ) do_error("The GNU 'gettext' extension for PHP is not available."); if ( !check_pgsql()->getOK() ) do_error("PHP 'pgsql' functions are not available"); if ( !check_pdo()->getOK() ) do_error("PHP 'PDO' module is not available"); if ( !check_pdo_pgsql()->getOK() ) do_error("The PDO drivers for PostgreSQL are not available"); if ( !check_database_connection()->getOK() ) do_error("Unable to connect to database"); if ( !check_iconv()->getOK() ) do_error("The 'iconv' extension for PHP is not available"); function get_phpinfo() { ob_start( ); phpinfo(); $phpinfo = ob_get_contents( ); ob_end_clean( ); $phpinfo = preg_replace( '{^.*?}s', '', $phpinfo); $phpinfo = preg_replace( '{.*?$}s', '', $phpinfo); return $phpinfo; } $phpinfo = get_phpinfo(); try { include("./always.php"); set_error_handler('log_setup_error', E_ALL); include("DAViCalSession.php"); if ( check_pgsql()->GetOK() ) { $session->LoginRequired( (isset($c->restrict_setup_to_admin) && $c->restrict_setup_to_admin ? 'Admin' : null ) ); } } catch( Exception $e ) { class FakeSession { function AllowedTo() { return true; } } $session = new FakeSession(1); } include("interactive-page.php"); include("page-header.php"); require_once("AwlQuery.php"); function check_datetime() { if ( class_exists('DateTime') ) return new CheckResult(true); $result = new CheckResult(false); $result->setClass('dep_warning'); $result->setDescription(i18n('Most of DAViCal will work but upgrading to PHP 5.2 or later is strongly recommended.')); return $result; } function check_schema_version() { global $c; if ( $c->want_dbversion[0] == $c->schema_major && $c->want_dbversion[1] == $c->schema_minor && $c->want_dbversion[2] == $c->schema_patch ) { return new CheckResult( true ); } $result = new CheckResult(false); if ( $c->want_dbversion[0] < $c->schema_major || ($c->want_dbversion[0] == $c->schema_major && $c->want_dbversion[1] < $c->schema_minor) || ($c->want_dbversion[0] == $c->schema_major && $c->want_dbversion[1] == $c->schema_minor && $c->want_dbversion[2] < $c->schema_patch) ) { $result->setClass('dep_warning'); } $result->setDescription( sprintf(i18n('Want: %s, Currently: %s'), implode('.',$c->want_dbversion), $c->schema_major.'.'.$c->schema_minor.'.'.$c->schema_patch)); return $result; } function check_davical_version() { global $c; $url = 'http://www.davical.org/current_davical_version?v='.$c->version_string; $version_file = @fopen($url, 'r'); if ( ! $version_file ) return new CheckResult( false, translate("Could not retrieve") . " '$url'", 'dep_warning' ); $current_version = htmlentities( trim(fread( $version_file,12)) ); fclose($version_file); $result = new CheckResult($c->version_string == $current_version); if ( ! $result->getOK() ) { if ( $c->version_string > $current_version ) { $result->setClass('dep_ok'); $result->setDescription( sprintf(i18n('Stable: %s, We have: %s !'), $current_version, $c->version_string) ); } else { $result->setDescription( sprintf(i18n('Want: %s, Currently: %s'), $current_version, $c->version_string) ); } } return $result; } function check_awl_version() { global $c; if ( !function_exists('awl_version') ) return new CheckResult(false); $result = new CheckResult($c->want_awl_version == awl_version()); if ( ! $result->getOK() ) { $result->setDescription( sprintf(i18n('Want: %s, Currently: %s'), $c->want_awl_version, awl_version()) ); if ( $c->want_awl_version < awl_version() ) $result->setClass('dep_warning'); } return $result; } function build_site_statistics() { $principals = translate('No. of Principals'); $collections = translate('No. of Collections'); $resources = translate('No. of Resources'); $table = <<'
. $config_warnings.'$paragraph_setup
| $th_dependency | $th_status |
|---|
$content_config1
$content_config2$content_config3
$content_cli1
$content_cli2
$site_statistics_table