diff --git a/inc/always.php.in b/inc/always.php.in index 6fae66ea..3b88c07a 100644 --- a/inc/always.php.in +++ b/inc/always.php.in @@ -15,7 +15,7 @@ unset($session); unset($request); unset($dbconn); // Default some of the configurable values $c->sysabbr = 'davical'; $c->admin_email = 'admin@davical.example.com'; -$c->system_name = "DAViCal CalDAV Server"; +$c->system_name = 'DAViCal CalDAV Server'; $c->domain_name = (isset($_SERVER['SERVER_NAME'])?$_SERVER['SERVER_NAME']:$_SERVER['SERVER_ADDR']); $c->save_time_zone_defs = true; $c->collections_always_exist = false; @@ -25,12 +25,12 @@ $c->enable_row_linking = true; $c->http_auth_mode = 'Basic'; // $c->default_locale = array('es_MX', 'es_AR', 'es', 'pt'); // An array of locales to try, or just a single locale // $c->local_tzid = 'Pacific/Auckland'; // Perhaps we should read from /etc/timezone - I wonder how standard that is? -$c->default_locale = "en"; -$c->base_url = preg_replace("#/[^/]+\.php.*$#", "", $_SERVER['SCRIPT_NAME']); -$c->base_directory = preg_replace("#/[^/]*$#", "", $_SERVER['DOCUMENT_ROOT']); +$c->default_locale = 'en'; +$c->base_url = preg_replace('#/[^/]+\.php.*$#', '', $_SERVER['SCRIPT_NAME']); +$c->base_directory = preg_replace('#/[^/]*$#', '', $_SERVER['DOCUMENT_ROOT']); -$c->stylesheets = array( $c->base_url."/davical.css" ); -$c->images = $c->base_url . "/images"; +$c->stylesheets = array( $c->base_url.'/davical.css' ); +$c->images = $c->base_url . '/images'; // Add a default for newly created users $c->template_usr = array( 'active' => true, @@ -51,17 +51,17 @@ $c->total_query_time = 0; $c->dbg = array(); // Utilities -require_once("AWLUtilities.php"); +require_once('AWLUtilities.php'); /** We actually discovered this and worked around it earlier, but we can't log it until the utilties are loaded */ if ( !isset($_SERVER['SERVER_NAME']) ) { - @dbg_error_log( "WARN", "Your webserver is not setting the SERVER_NAME parameter. You may need to set \$c->domain_name in your configuration. Using IP address meanhwhile..." ); + @dbg_error_log( 'WARN', "Your webserver is not setting the SERVER_NAME parameter. You may need to set \$c->domain_name in your configuration. Using IP address meanhwhile..." ); } /** * Calculate the simplest form of reference to this page, excluding the PATH_INFO following the script name. */ -$c->protocol_server_port_script = sprintf( "%s://%s%s%s", +$c->protocol_server_port_script = sprintf( '%s://%s%s%s', (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on'? 'https' : 'http'), $_SERVER['SERVER_NAME'], ( @@ -79,21 +79,21 @@ init_gettext( 'davical', '../locale' ); * access which could break DAViCal completely by causing output to start * too early. */ -if ( @file_exists("/etc/davical/".$_SERVER['SERVER_NAME']."-conf.php") ) { - include_once("/etc/davical/".$_SERVER['SERVER_NAME']."-conf.php"); +if ( @file_exists('/etc/davical/'.$_SERVER['SERVER_NAME'].'-conf.php') ) { + include_once('/etc/davical/'.$_SERVER['SERVER_NAME'].'-conf.php'); } -else if ( @file_exists("/etc/davical/config.php") ) { - include_once("/etc/davical/config.php"); +else if ( @file_exists('/etc/davical/config.php') ) { + include_once('/etc/davical/config.php'); } -else if ( @file_exists("../config/config.php") ) { - include_once("../config/config.php"); +else if ( @file_exists('../config/config.php') ) { + include_once('../config/config.php'); } else { - include_once("davical_configuration_missing.php"); + include_once('davical_configuration_missing.php'); exit; } if ( isset($c->deny_put_collection) ) { - @dbg_error_log( "WARN", "Deprecated 'deny_put_collection' configuration item renamed to 'readonly_webdav_collections'" ); + @dbg_error_log( 'WARN', 'Deprecated "deny_put_collection" configuration item renamed to "readonly_webdav_collections"' ); $c->readonly_webdav_collections = $c->deny_put_collection; } @@ -101,7 +101,7 @@ if ( !isset($c->page_title) ) $c->page_title = $c->system_name; if ( count($c->dbg) > 0 ) { // Only log this if debugging of some sort is turned on, somewhere - @dbg_error_log( "LOG", "==========> method =%s= =%s= =%s= =%s= =%s=", + @dbg_error_log( 'LOG', '==========> method =%s= =%s= =%s= =%s= =%s=', $_SERVER['REQUEST_METHOD'], $c->protocol_server_port_script, $_SERVER['PATH_INFO'], $c->base_url, $c->base_directory ); } @@ -121,9 +121,9 @@ if ( isset($c->version_string) && preg_match( '/(\d+)\.(\d+)\.(\d+)(.*)/', $c->v $c->code_major = $matches[1]; $c->code_minor = $matches[2]; $c->code_patch = $matches[3]; - $c->code_version = (($c->code_major * 1000) + $c->code_minor).".".$c->code_patch; - dbg_error_log("caldav", "Version (%d.%d.%d) == %s", $c->code_major, $c->code_minor, $c->code_patch, $c->code_version); - header( sprintf("Server: %d.%d", $c->code_major, $c->code_minor) ); + $c->code_version = (($c->code_major * 1000) + $c->code_minor).'.'.$c->code_patch; + dbg_error_log('caldav', 'Version (%d.%d.%d) == %s', $c->code_major, $c->code_minor, $c->code_patch, $c->code_version); + header( sprintf('Server: %d.%d', $c->code_major, $c->code_minor) ); } /** @@ -131,12 +131,12 @@ if ( isset($c->version_string) && preg_match( '/(\d+)\.(\d+)\.(\d+)(.*)/', $c->v */ $_SERVER['SERVER_NAME'] = $c->domain_name; -include_once("PgQuery.php"); +include_once('PgQuery.php'); $c->schema_version = 0; -$qry = new PgQuery( "SELECT schema_major, schema_minor, schema_patch FROM awl_db_revision ORDER BY schema_id DESC LIMIT 1;" ); -if ( $qry->Exec("always") && $row = $qry->Fetch() ) { - $c->schema_version = doubleval( sprintf( "%d%03d.%03d", $row->schema_major, $row->schema_minor, $row->schema_patch) ); +$qry = new PgQuery( 'SELECT schema_major, schema_minor, schema_patch FROM awl_db_revision ORDER BY schema_id DESC LIMIT 1;' ); +if ( $qry->Exec('always') && $row = $qry->Fetch() ) { + $c->schema_version = doubleval( sprintf( '%d%03d.%03d', $row->schema_major, $row->schema_minor, $row->schema_patch) ); $c->schema_major = $row->schema_major; $c->schema_minor = $row->schema_minor; $c->schema_patch = $row->schema_patch; @@ -194,51 +194,51 @@ function getUserByID( $user_no, $use_cache = true ) { */ function getStatusMessage($status) { switch( $status ) { - case 100: $ans = "Continue"; break; - case 101: $ans = "Switching Protocols"; break; - case 200: $ans = "OK"; break; - case 201: $ans = "Created"; break; - case 202: $ans = "Accepted"; break; - case 203: $ans = "Non-Authoritative Information"; break; - case 204: $ans = "No Content"; break; - case 205: $ans = "Reset Content"; break; - case 206: $ans = "Partial Content"; break; - case 207: $ans = "Multi-Status"; break; - case 300: $ans = "Multiple Choices"; break; - case 301: $ans = "Moved Permanently"; break; - case 302: $ans = "Found"; break; - case 303: $ans = "See Other"; break; - case 304: $ans = "Not Modified"; break; - case 305: $ans = "Use Proxy"; break; - case 307: $ans = "Temporary Redirect"; break; - case 400: $ans = "Bad Request"; break; - case 401: $ans = "Unauthorized"; break; - case 402: $ans = "Payment Required"; break; - case 403: $ans = "Forbidden"; break; - case 404: $ans = "Not Found"; break; - case 405: $ans = "Method Not Allowed"; break; - case 406: $ans = "Not Acceptable"; break; - case 407: $ans = "Proxy Authentication Required"; break; - case 408: $ans = "Request Timeout"; break; - case 409: $ans = "Conflict"; break; - case 410: $ans = "Gone"; break; - case 411: $ans = "Length Required"; break; - case 412: $ans = "Precondition Failed"; break; - case 413: $ans = "Request Entity Too Large"; break; - case 414: $ans = "Request-URI Too Long"; break; - case 415: $ans = "Unsupported Media Type"; break; - case 416: $ans = "Requested Range Not Satisfiable"; break; - case 417: $ans = "Expectation Failed"; break; - case 422: $ans = "Unprocessable Entity"; break; - case 423: $ans = "Locked"; break; - case 424: $ans = "Failed Dependency"; break; - case 500: $ans = "Internal Server Error"; break; - case 501: $ans = "Not Implemented"; break; - case 502: $ans = "Bad Gateway"; break; - case 503: $ans = "Service Unavailable"; break; - case 504: $ans = "Gateway Timeout"; break; - case 505: $ans = "HTTP Version Not Supported"; break; - default: $ans = "Unknown HTTP Status Code '$status'"; + case 100: $ans = 'Continue'; break; + case 101: $ans = 'Switching Protocols'; break; + case 200: $ans = 'OK'; break; + case 201: $ans = 'Created'; break; + case 202: $ans = 'Accepted'; break; + case 203: $ans = 'Non-Authoritative Information'; break; + case 204: $ans = 'No Content'; break; + case 205: $ans = 'Reset Content'; break; + case 206: $ans = 'Partial Content'; break; + case 207: $ans = 'Multi-Status'; break; + case 300: $ans = 'Multiple Choices'; break; + case 301: $ans = 'Moved Permanently'; break; + case 302: $ans = 'Found'; break; + case 303: $ans = 'See Other'; break; + case 304: $ans = 'Not Modified'; break; + case 305: $ans = 'Use Proxy'; break; + case 307: $ans = 'Temporary Redirect'; break; + case 400: $ans = 'Bad Request'; break; + case 401: $ans = 'Unauthorized'; break; + case 402: $ans = 'Payment Required'; break; + case 403: $ans = 'Forbidden'; break; + case 404: $ans = 'Not Found'; break; + case 405: $ans = 'Method Not Allowed'; break; + case 406: $ans = 'Not Acceptable'; break; + case 407: $ans = 'Proxy Authentication Required'; break; + case 408: $ans = 'Request Timeout'; break; + case 409: $ans = 'Conflict'; break; + case 410: $ans = 'Gone'; break; + case 411: $ans = 'Length Required'; break; + case 412: $ans = 'Precondition Failed'; break; + case 413: $ans = 'Request Entity Too Large'; break; + case 414: $ans = 'Request-URI Too Long'; break; + case 415: $ans = 'Unsupported Media Type'; break; + case 416: $ans = 'Requested Range Not Satisfiable'; break; + case 417: $ans = 'Expectation Failed'; break; + case 422: $ans = 'Unprocessable Entity'; break; + case 423: $ans = 'Locked'; break; + case 424: $ans = 'Failed Dependency'; break; + case 500: $ans = 'Internal Server Error'; break; + case 501: $ans = 'Not Implemented'; break; + case 502: $ans = 'Bad Gateway'; break; + case 503: $ans = 'Service Unavailable'; break; + case 504: $ans = 'Gateway Timeout'; break; + case 505: $ans = 'HTTP Version Not Supported'; break; + default: $ans = 'Unknown HTTP Status Code '.$status; } return $ans; }