From deff15cc71390bc2bc6696a3f12c9e49f99838f4 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Tue, 30 Sep 2014 16:12:50 +0900 Subject: [PATCH] Update core classes with better debugging output Add server name to the print out and log print debug entry. For the debug log file add the full file path so we know which file exactly got accessed. --- www/libs/Class.Basic.inc | 29 ++++++++++++++++++++++++----- www/libs/Class.DB.IO.inc | 2 +- www/libs/Class.Login.inc | 1 - 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/www/libs/Class.Basic.inc b/www/libs/Class.Basic.inc index ef2a1efd..20212ed6 100644 --- a/www/libs/Class.Basic.inc +++ b/www/libs/Class.Basic.inc @@ -97,6 +97,8 @@ public $class_info; // class info var public $page_name; + public $host_name; + public $host_port; private $error_id; // error ID for errors in classes private $error_string; // error strings in classes (for error_id) @@ -176,6 +178,7 @@ // set the page name $this->page_name = $this->get_page_name(); + $this->host_name = $this->get_host_name(); // set the paths matching to the valid file types $this->data_path = array ( @@ -387,7 +390,7 @@ $this->fdebug_fp(); if ($enter) $string .= "\n"; - $string = "[".$this->print_time()."] [".$this->get_page_name()."] - ".$string; + $string = "[".$this->print_time()."] [".$this->get_page_name(2)."] - ".$string; fwrite($this->debug_fp, $string); $this->fdebug_fp(); } @@ -451,7 +454,7 @@ if (!isset($this->error_msg[$level])) $this->error_msg[$level] = ''; $error_string = '
'; - $error_string .= '['.$this->print_time().'] ['.$level.'] ['.$this->get_page_name().'] ['.$this->running_uid.'] {'.get_class($this).'} - '.$string; + $error_string .= '['.$this->print_time().'] ['.$level.'] ['.$this->host_name.'] ['.$this->page_name.'] ['.$this->running_uid.'] {'.get_class($this).'} - '.$string; $error_string .= "
"; if ($strip) { @@ -461,7 +464,7 @@ $string = preg_replace("/(<\/?)(\w+)([^>]*>)/", "", $string); } // same string put for print (no html crap inside) - $error_string_print = '['.$this->print_time().'] ['.$this->get_page_name().'] ['.$this->running_uid.'] {'.get_class($this).'} <'.$level.'> - '.$string; + $error_string_print = '['.$this->print_time().'] ['.$this->host_name.'] ['.$this->get_page_name(2).'] ['.$this->running_uid.'] {'.get_class($this).'} <'.$level.'> - '.$string; $error_string_print .= "\n"; // write to file if set $this->write_error_msg($level, $error_string_print); @@ -797,8 +800,22 @@ return $atag.$email; } + // METHOD get_host_name + // PARAMS none + // RETURN host name + // DESCRIPTION + // get the host name without the port as given by the SELF var + public static function get_host_name() + { + list($host_name, $port) = explode(":", $_SERVER['HTTP_HOST']); + $self->host_port = $port; + return $host_name; + } + // METHOD get_page_name - // PARAMS strip page file name extension, default is no + // PARAMS 1: strip page file name extension + // 0: keep filename as is + // 2: keep filename as is, but add dirname too // RETURN filename // DESCRIPTION // get the page name of the curronte page: @@ -806,8 +823,10 @@ { // get the file info $page_temp = pathinfo($_SERVER["PHP_SELF"]); - if ($strip_ext) + if ($strip_ext == 1) return $page_temp['filename']; + elseif ($strip_ext == 2) + return $page_temp['dirname'].'/'.$page_temp['basename']; else return $page_temp['basename']; } diff --git a/www/libs/Class.DB.IO.inc b/www/libs/Class.DB.IO.inc index 53764bfc..aec6f15c 100644 --- a/www/libs/Class.DB.IO.inc +++ b/www/libs/Class.DB.IO.inc @@ -312,7 +312,7 @@ $this->db_pwd = $db_config['db_pass']; $this->db_host = $db_config['db_host']; $this->db_port = array_key_exists('db_port', $db_config) ? $db_config['db_port'] : '5432'; - $this->db_schema = array_key_exists('db_schema', $db_config) ? $db_config['db_schema'] : 'public'; + $this->db_schema = array_key_exists('db_schema', $db_config) ? $db_config['db_schema'] : ''; // do not set to 'public' if not set, because the default is already public $this->db_encoding = array_key_exists('db_encoding', $db_config) ? $db_config['db_encoding'] : ''; $this->db_type = 'db_'.$db_config['db_type']; $this->db_ssl = array_key_exists('db_ssl', $db_config) ? $db_config['db_ssl'] : 'allow'; diff --git a/www/libs/Class.Login.inc b/www/libs/Class.Login.inc index 6a41df03..422192c0 100644 --- a/www/libs/Class.Login.inc +++ b/www/libs/Class.Login.inc @@ -269,7 +269,6 @@ { // if login errors is half of max errors and the last login error was less than 10s ago, forbid any new login try - // check with what kind of prefix the password begins: // $2a$ or $2y$: BLOWFISCH // $1$: MD5