1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 17:59:21 +02:00

it technically logs in and streams.. but thats it, complete rewrite almost everything broken

This commit is contained in:
Karl 'vollmerk' Vollmer 2007-04-23 07:31:05 +00:00
parent 8b27d66add
commit a31560aec4
199 changed files with 30445 additions and 33070 deletions

View file

@ -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'] .= "<br />HOST:$host<br />User:$username<br />Pass:$pass<br />";
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 "<pre>";
$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 <strong>$matches[2]</strong> to existing key <strong>$matches[1]</strong>\n";
array_push($results[$matches[1]], $matches[2]);
}
elseif (isset($results[$matches[1]]) && isset($matches[2]) ) {
if($debug) echo "Adding value <strong>$matches[2]</strong> to existing key $matches[1]</strong>\n";
$results[$matches[1]] = array($results[$matches[1]],$matches[2]);
}
elseif ($matches[2] !== "") {
if($debug) echo "Adding value <strong>$matches[2]</strong> for key <strong>$matches[1]</strong>\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 <strong>$matches[1]</strong> 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 "</pre>";
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