summaryrefslogtreecommitdiffstats
path: root/lib/debug.lib.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/debug.lib.php')
-rw-r--r--lib/debug.lib.php260
1 files changed, 130 insertions, 130 deletions
diff --git a/lib/debug.lib.php b/lib/debug.lib.php
index 8087bf4d..aca6c27a 100644
--- a/lib/debug.lib.php
+++ b/lib/debug.lib.php
@@ -1,5 +1,5 @@
<?php
-/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
+/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
@@ -27,19 +27,19 @@
*/
function check_php_ver($level=0) {
- if (floatval(phpversion()) < 5.3) {
- return false;
- }
+ if (floatval(phpversion()) < 5.3) {
+ return false;
+ }
- // Make sure that they have the sha256() algo installed
- if (!function_exists('hash_algos')) { return false; }
- $algos = hash_algos();
+ // Make sure that they have the sha256() algo installed
+ if (!function_exists('hash_algos')) { return false; }
+ $algos = hash_algos();
- if (!in_array('sha256',$algos)) {
- return false;
- }
+ if (!in_array('sha256',$algos)) {
+ return false;
+ }
- return true;
+ return true;
} // check_php_ver
@@ -49,11 +49,11 @@ function check_php_ver($level=0) {
*/
function check_php_mysql() {
- if (!function_exists('mysql_query')) {
- return false;
- }
+ if (!function_exists('mysql_query')) {
+ return false;
+ }
- return true;
+ return true;
} // check_php_mysql
@@ -64,11 +64,11 @@ function check_php_mysql() {
*/
function check_php_session() {
- if (!function_exists('session_set_save_handler')) {
- return false;
- }
+ if (!function_exists('session_set_save_handler')) {
+ return false;
+ }
- return true;
+ return true;
} // check_php_session
@@ -79,11 +79,11 @@ function check_php_session() {
*/
function check_php_pcre() {
- if (!function_exists('preg_match')) {
- return false;
- }
+ if (!function_exists('preg_match')) {
+ return false;
+ }
- return true;
+ return true;
} // check_php_pcre
@@ -93,37 +93,37 @@ function check_php_pcre() {
*/
function check_config_values($conf) {
- if (!$conf['database_hostname']) {
- return false;
- }
- if (!$conf['database_name']) {
- return false;
- }
- if (!$conf['database_username']) {
- return false;
- }
- if (!$conf['database_password']) {
- return false;
- }
- if (!$conf['session_length']) {
- return false;
- }
- if (!$conf['session_name']) {
- return false;
- }
- if (!isset($conf['session_cookielife'])) {
- return false;
- }
- if (!isset($conf['session_cookiesecure'])) {
- return false;
- }
- if (isset($conf['debug'])) {
- if (!isset($conf['log_path'])) {
- return false;
- }
- }
-
- return true;
+ if (!$conf['database_hostname']) {
+ return false;
+ }
+ if (!$conf['database_name']) {
+ return false;
+ }
+ if (!$conf['database_username']) {
+ return false;
+ }
+ if (!$conf['database_password']) {
+ return false;
+ }
+ if (!$conf['session_length']) {
+ return false;
+ }
+ if (!$conf['session_name']) {
+ return false;
+ }
+ if (!isset($conf['session_cookielife'])) {
+ return false;
+ }
+ if (!isset($conf['session_cookiesecure'])) {
+ return false;
+ }
+ if (isset($conf['debug'])) {
+ if (!isset($conf['log_path'])) {
+ return false;
+ }
+ }
+
+ return true;
} // check_config_values
@@ -135,14 +135,14 @@ function check_config_values($conf) {
*/
function check_php_memory() {
- $current_memory = ini_get('memory_limit');
- $current_memory = substr($current_memory,0,strlen($current_memory)-1);
+ $current_memory = ini_get('memory_limit');
+ $current_memory = substr($current_memory,0,strlen($current_memory)-1);
- if (intval($current_memory) < 48) {
- return false;
- }
+ if (intval($current_memory) < 48) {
+ return false;
+ }
- return true;
+ return true;
} // check_php_memory
@@ -153,8 +153,8 @@ function check_php_memory() {
*/
function check_php_timelimit() {
- $current = intval(ini_get('max_execution_time'));
- return ($current >= 60 || $current == 0);
+ $current = intval(ini_get('max_execution_time'));
+ return ($current >= 60 || $current == 0);
} // check_php_timelimit
@@ -163,10 +163,10 @@ function check_php_timelimit() {
* Checks to make sure we aren't in safe mode
*/
function check_safemode() {
- if (ini_get('safe_mode')) {
- return false;
- }
- return true;
+ if (ini_get('safe_mode')) {
+ return false;
+ }
+ return true;
}
/**
@@ -174,24 +174,24 @@ function check_safemode() {
* This checks to see if we can manually override the memory limit
*/
function check_override_memory() {
- /* Check memory */
- $current_memory = ini_get('memory_limit');
- $current_memory = substr($current_memory,0,strlen($current_memory)-1);
- $new_limit = ($current_memory+16) . "M";
+ /* Check memory */
+ $current_memory = ini_get('memory_limit');
+ $current_memory = substr($current_memory,0,strlen($current_memory)-1);
+ $new_limit = ($current_memory+16) . "M";
- /* Bump it by 16 megs (for getid3)*/
- if (!ini_set('memory_limit',$new_limit)) {
- return false;
- }
+ /* Bump it by 16 megs (for getid3)*/
+ if (!ini_set('memory_limit',$new_limit)) {
+ return false;
+ }
- // Make sure it actually worked
- $new_memory = ini_get('memory_limit');
+ // Make sure it actually worked
+ $new_memory = ini_get('memory_limit');
- if ($new_limit != $new_memory) {
- return false;
- }
+ if ($new_limit != $new_memory) {
+ return false;
+ }
- return true;
+ return true;
}
/**
@@ -199,14 +199,14 @@ function check_override_memory() {
* This checks to see if we can manually override the max execution time
*/
function check_override_exec_time() {
- $current = ini_get('max_execution_time');
- set_time_limit($current+60);
+ $current = ini_get('max_execution_time');
+ set_time_limit($current+60);
- if ($current == ini_get('max_execution_time')) {
- return false;
- }
+ if ($current == ini_get('max_execution_time')) {
+ return false;
+ }
- return true;
+ return true;
}
/**
@@ -215,11 +215,11 @@ function check_override_exec_time() {
*/
function check_gettext() {
- if (!function_exists('gettext')) {
- return false;
- }
+ if (!function_exists('gettext')) {
+ return false;
+ }
- return true;
+ return true;
} // check_gettext
@@ -229,11 +229,11 @@ function check_gettext() {
*/
function check_mbstring() {
- if (!function_exists('mb_check_encoding')) {
- return false;
- }
+ if (!function_exists('mb_check_encoding')) {
+ return false;
+ }
- return true;
+ return true;
} // check_mbstring
@@ -243,9 +243,9 @@ function check_mbstring() {
*/
function check_config_writable() {
- // file eixsts && is writable, or dir is writable
- return ((file_exists(Config::get('prefix') . '/config/ampache.cfg.php') && is_writable(Config::get('prefix') . '/config/ampache.cfg.php'))
- || (!file_exists(Config::get('prefix') . '/config/ampache.cfg.php') && is_writeable(Config::get('prefix') . '/config/')));
+ // file eixsts && is writable, or dir is writable
+ return ((file_exists(Config::get('prefix') . '/config/ampache.cfg.php') && is_writable(Config::get('prefix') . '/config/ampache.cfg.php'))
+ || (!file_exists(Config::get('prefix') . '/config/ampache.cfg.php') && is_writeable(Config::get('prefix') . '/config/')));
}
/**
@@ -255,41 +255,41 @@ function check_config_writable() {
*/
function generate_config($current) {
- /* Start building the new config file */
- $distfile = Config::get('prefix') . '/config/ampache.cfg.php.dist';
- $handle = fopen($distfile,'r');
- $dist = fread($handle,filesize($distfile));
- fclose($handle);
+ /* Start building the new config file */
+ $distfile = Config::get('prefix') . '/config/ampache.cfg.php.dist';
+ $handle = fopen($distfile,'r');
+ $dist = fread($handle,filesize($distfile));
+ fclose($handle);
- $data = explode("\n",$dist);
+ $data = explode("\n",$dist);
- /* Run throught the lines and set our settings */
- foreach ($data as $line) {
+ /* Run throught the lines and set our settings */
+ foreach ($data as $line) {
- /* Attempt to pull out Key */
- if (preg_match("/^;?([\w\d]+)\s+=\s+[\"]{1}(.*?)[\"]{1}$/",$line,$matches)
- || preg_match("/^;?([\w\d]+)\s+=\s+[\']{1}(.*?)[\']{1}$/", $line, $matches)
- || preg_match("/^;?([\w\d]+)\s+=\s+[\'\"]{0}(.*)[\'\"]{0}$/",$line,$matches)) {
+ /* Attempt to pull out Key */
+ if (preg_match("/^;?([\w\d]+)\s+=\s+[\"]{1}(.*?)[\"]{1}$/",$line,$matches)
+ || preg_match("/^;?([\w\d]+)\s+=\s+[\']{1}(.*?)[\']{1}$/", $line, $matches)
+ || preg_match("/^;?([\w\d]+)\s+=\s+[\'\"]{0}(.*)[\'\"]{0}$/",$line,$matches)) {
- $key = $matches[1];
- $value = $matches[2];
+ $key = $matches[1];
+ $value = $matches[2];
- /* Put in the current value */
- if ($key == 'config_version') {
- $line = $key . ' = ' . escape_ini($value);
- }
- elseif (isset($current[$key])) {
- $line = $key . ' = "' . escape_ini($current[$key]) . '"';
- unset($current[$key]);
- } // if set
+ /* Put in the current value */
+ if ($key == 'config_version') {
+ $line = $key . ' = ' . escape_ini($value);
+ }
+ elseif (isset($current[$key])) {
+ $line = $key . ' = "' . escape_ini($current[$key]) . '"';
+ unset($current[$key]);
+ } // if set
- } // if key
+ } // if key
- $final .= $line . "\n";
+ $final .= $line . "\n";
- } // end foreach line
+ } // end foreach line
- return $final;
+ return $final;
} // generate_config
@@ -300,7 +300,7 @@ function generate_config($current) {
*/
function escape_ini($str) {
- return str_replace('"', '\"', $str);
+ return str_replace('"', '\"', $str);
}
@@ -311,14 +311,14 @@ function escape_ini($str) {
*/
function debug_result($comment,$status=false,$value=false) {
- $class = $status ? 'ok' : 'notok';
- if (!$value) {
- $value = $status ? 'OK' : 'ERROR';
- }
+ $class = $status ? 'ok' : 'notok';
+ if (!$value) {
+ $value = $status ? 'OK' : 'ERROR';
+ }
- $final = '<span class="' . $class . '">' . scrub_out($value) . '</span> <em>' . $comment . '</em>';
+ $final = '<span class="' . $class . '">' . scrub_out($value) . '</span> <em>' . $comment . '</em>';
- return $final;
+ return $final;
} // debug_ok
?>