From a31560aec4f004e58930277758f5412d86c62adc Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 23 Apr 2007 07:31:05 +0000 Subject: it technically logs in and streams.. but thats it, complete rewrite almost everything broken --- lib/debug.lib.php | 196 +++++++----------------------------------------------- 1 file changed, 23 insertions(+), 173 deletions(-) (limited to 'lib/debug.lib.php') diff --git a/lib/debug.lib.php b/lib/debug.lib.php index ca0d55cb..10ad838f 100644 --- a/lib/debug.lib.php +++ b/lib/debug.lib.php @@ -21,52 +21,29 @@ */ -/* - @header Debug Library - This library is loaded when somehow our mojo has - been lost, it contains functions for checking sql - connections, web paths etc.. +/** + * Debug Library + * This library is loaded when somehow our mojo has + * been lost, it contains functions for checking sql + * connections, web paths etc.. */ -/*! - @function read_config_file - @discussion checks to see if the config - file is readable, overkill I know.. - @param level 0 is readable, 1 detailed info -*/ - - -function read_config_file($file,$level=0) { - - $fp = @fopen($file, 'r'); - - if (!$level) { - return is_resource($fp); - } - - -} // read_config_file - /*! @function check_database @discussion checks the local mysql db and make sure life is good */ -function check_database($host,$username,$pass,$level=0) { +function check_database($host,$username,$pass,$database) { $dbh = @mysql_connect($host, $username, $pass); if (!is_resource($dbh)) { - $error['error_state'] = true; - $error['mysql_error'] = mysql_errno() . ": " . mysql_error() . "\n"; + return false; } if (!$host || !$username || !$pass) { - $error['error_state'] = true; - $error['mysql_error'] .= "
HOST:$host
User:$username
Pass:$pass
"; + return false; } - if ($error['error_state']) { return false; } - return $dbh; } // check_database @@ -101,13 +78,10 @@ function check_database_inserted($dbh,$db_name) { */ function check_php_ver($level=0) { - if (strcmp('4.1.2',phpversion()) > 0) { - $error['error_state'] = true; - $error['php_ver'] = phpversion(); + if (strcmp('5.0.0',phpversion()) > 0) { + return false; } - if ($error['error_state']) { return false; } - return true; } // check_php_ver @@ -119,12 +93,9 @@ function check_php_ver($level=0) { function check_php_mysql() { if (!function_exists('mysql_query')) { - $error['error_state'] = true; - $error['php_mysql'] = false; + return false; } - if ($error['error_state']) { return false; } - return true; } // check_php_mysql @@ -137,12 +108,9 @@ function check_php_mysql() { function check_php_session() { if (!function_exists('session_set_save_handler')) { - $error['error_state'] = true; - $error['php_session'] = false; + return false; } - if ($error['error_state']) { return false; } - return true; } // check_php_session @@ -154,12 +122,9 @@ function check_php_session() { function check_php_iconv() { if (!function_exists('iconv')) { - $error['error_state'] = true; - $error['php_iconv'] = false; + return false; } - if ($error['error_state']) { return false; } - return true; } // check_php_iconv @@ -172,12 +137,9 @@ function check_php_iconv() { function check_php_pcre() { if (!function_exists('preg_match')) { - $error['error_state'] = true; - $error['php_pcre'] = false; + return false; } - if ($error['error_state']) { return false; } - return true; } // check_php_pcre @@ -188,34 +150,33 @@ function check_php_pcre() { least set the needed variables */ function check_config_values($conf) { - $error = new Error(); - if (!$conf['local_host']) { + + if (!$conf['database_hostname']) { return false; } - if (!$conf['local_db']) { + if (!$conf['database_name']) { return false; } - if (!$conf['local_username']) { + if (!$conf['database_username']) { return false; } - if (!$conf['local_pass']) { + if (!$conf['database_password']) { return false; } - if (!$conf['local_length']) { + if (!$conf['session_length']) { return false; } - if (!$conf['sess_name']) { + if (!$conf['session_name']) { return false; } - if (!isset($conf['sess_cookielife'])) { + if (!isset($conf['session_cookielife'])) { return false; } - if (!isset($conf['sess_cookiesecure'])) { + if (!isset($conf['session_cookiesecure'])) { return false; } if (isset($conf['debug'])) { if (!isset($conf['log_path'])) { - $error->add_error('log_path',_("You defined the option \"debug = on\" but didn't define a log path for the log to be stored")); return false; } } @@ -224,117 +185,6 @@ function check_config_values($conf) { } // check_config_values -/*! - @function debug_read_config - @discussion this is the same as the read config function - except it will pull config values with a # before them - (basicly adding a #config="value" check) and not - ever dieing on a config file error -*/ -function debug_read_config($config_file,$debug) { - - $fp = @fopen($config_file,'r'); - if(!is_resource($fp)) return false; - $file_data = fread($fp,filesize($config_file)); - fclose($fp); - - // explode the var by \n's - $data = explode("\n",$file_data); - if($debug) echo "
";
-	$count = 0;
-
-	if (!count($data)) { 
-		debug_event('debug_read_config','Error Unable to Read config file','1'); 	
-		return false; 
-	} 
-
-	$results = array();
-    
-	foreach($data as $value) {
-	        $count++;
-        
-	        $value = trim($value);
-       
-	        if (preg_match("/^#?([\w\d]+)\s+=\s+[\"]{1}(.*?)[\"]{1}$/",$value,$matches)
-	                        || preg_match("/^#?([\w\d]+)\s+=\s+[\']{1}(.*?)[\']{1}$/", $value, $matches)
-	                        || preg_match("/^#?([\w\d]+)\s+=\s+[\'\"]{0}(.*)[\'\"]{0}$/",$value,$matches)) {
-
-
-                	if (is_array($results[$matches[1]]) && isset($matches[2]) ) {
-	                        if($debug) echo "Adding value $matches[2] to existing key $matches[1]\n";
-	                        array_push($results[$matches[1]], $matches[2]);
-	                }
-
-	                elseif (isset($results[$matches[1]]) && isset($matches[2]) ) {
-	                        if($debug) echo "Adding value $matches[2] to existing key $matches[1]\n";
-        	                $results[$matches[1]] = array($results[$matches[1]],$matches[2]);
-	                }
-
-	                elseif ($matches[2] !== "") {
-	                        if($debug) echo "Adding value $matches[2] for key $matches[1]\n";
-	                        $results[$matches[1]] = $matches[2];
-        	        }
-
-	                // if there is something there and it's not a comment
-	                elseif ($value{0} !== "#" AND strlen(trim($value)) > 0 AND !$test AND strlen($matches[2]) > 0) {
-        	                echo "Error Invalid Config Entry --> Line:$count"; return false;
-	                } // elseif it's not a comment and there is something there
-	
-	                else {
-	                        if($debug) echo "Key $matches[1] defined, but no value set\n";
-	                }
-
-        	} // end else
-
-	} // foreach
-
-	if (isset($config_name) && isset(${$config_name}) && count(${$config_name})) {
-		$results[$config_name] = ${$config_name};
-	}
-
-	if($debug) echo "
"; - - return $results; - -} // debug_read_config - -/*! - @function debug_compare_configs - @discussion this takes two config files, and then compares - the results and returns an array of the values - that are missing from the first one passed -*/ -function debug_compare_configs($config,$dist_config) { - - - - /* Get the results from the two difference configs including #'d values */ - $results = debug_read_config($config,0); - $dist_results = debug_read_config($dist_config,0); - - $missing = array(); - - foreach ($dist_results as $key=>$value) { - - if (!isset($results[$key])) { - /* If it's an array we need to split it out */ - if (is_array($value)) { - foreach ($value as $element) { - $missing[$key][] = $element; - } - } - else { - $missing[$key] = $value; - } // end else not array - } // if it's not set - - } // end foreach conf - - return $missing; - -} // debug_compare_configs - - /** * check_putenv * This checks to see if we can manually set the -- cgit