summaryrefslogtreecommitdiffstats
path: root/lib/debug.lib.php
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2013-02-03 11:15:03 -0500
committerPaul Arthur <paul.arthur@flowerysong.com>2013-02-03 11:16:46 -0500
commitdd70337451390b260e95f998c8b79b9fefbf3b3a (patch)
tree4bfd3c3728841843badfadaca0920d4622c9f891 /lib/debug.lib.php
parentc8cd1da88fbf0df1a99463032d97ac42d221a774 (diff)
downloadampache-dd70337451390b260e95f998c8b79b9fefbf3b3a.tar.gz
ampache-dd70337451390b260e95f998c8b79b9fefbf3b3a.tar.bz2
ampache-dd70337451390b260e95f998c8b79b9fefbf3b3a.zip
Clean up PHP tests and reuse them in init.php
Also move the config-related functions out of debug.lib.php (why they were there in the first place is anyone's guess.)
Diffstat (limited to 'lib/debug.lib.php')
-rw-r--r--lib/debug.lib.php141
1 files changed, 31 insertions, 110 deletions
diff --git a/lib/debug.lib.php b/lib/debug.lib.php
index 0c8f9ab9..7ce061f6 100644
--- a/lib/debug.lib.php
+++ b/lib/debug.lib.php
@@ -20,43 +20,49 @@
*
*/
-/**
- * check_php_ver
- * checks the php version and makes
- * sure that it's good enough
- */
-function check_php_ver($level=0) {
+function check_php() {
+ if (
+ check_php_version() &&
+ check_php_hash() &&
+ check_php_hash_algo() &&
+ check_php_pdo() &&
+ check_php_session() &&
+ check_php_json() &&
+ check_php_safemode()
+ ) {
+ return true;
+ }
+
+ return false;
+}
+
+function check_php_version() {
if (floatval(phpversion()) < 5.3) {
return false;
}
return true;
}
-/**
- * check_php_session
- * checks to make sure the needed functions
- * for sessions exist
-*/
-function check_php_session() {
+function check_php_hash() {
+ return function_exists('hash_algos');
+}
- if (!function_exists('session_set_save_handler')) {
- return false;
- }
+function check_php_hash_algo() {
+ return function_exists('hash_algos') ? in_array('sha256', hash_algos()) : false;
+}
- return true;
+function check_php_json() {
+ return function_exists('json_encode');
+}
-} // check_php_session
+function check_php_session() {
+ return function_exists('session_set_save_handler');
+}
-/**
- * check_pdo
- *
- * Checks to make sure that PDO is available.
- */
-function check_pdo() {
+function check_php_pdo() {
if (class_exists('PDO') && in_array('mysql', PDO::getAvailableDrivers())) {
return true;
}
-
return false;
}
@@ -135,7 +141,7 @@ function check_php_timelimit() {
* check_safe_mode
* Checks to make sure we aren't in safe mode
*/
-function check_safemode() {
+function check_php_safemode() {
if (ini_get('safe_mode')) {
return false;
}
@@ -183,34 +189,6 @@ function check_override_exec_time() {
}
/**
- * check_gettext
- * This checks to see if you've got gettext installed
- */
-function check_gettext() {
-
- if (!function_exists('gettext')) {
- return false;
- }
-
- return true;
-
-} // check_gettext
-
-/**
- * check_mbstring
- * This checks for mbstring support
- */
-function check_mbstring() {
-
- if (!function_exists('mb_check_encoding')) {
- return false;
- }
-
- return true;
-
-} // check_mbstring
-
-/**
* check_config_writable
* This checks whether we can write the config file
*/
@@ -222,63 +200,6 @@ function check_config_writable() {
}
/**
- * generate_config
- * This takes an array of results and re-generates the config file
- * this is used by the installer and by the admin/system page
- */
-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);
-
- $data = explode("\n",$dist);
-
- /* 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)) {
-
- $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
-
- } // if key
-
- $final .= $line . "\n";
-
- } // end foreach line
-
- return $final;
-
-} // generate_config
-
-/**
- * escape_ini
- * Escape a value used for inserting into an ini file.
- * Won't quote ', like addslashes does.
- */
-function escape_ini($str) {
-
- return str_replace('"', '\"', $str);
-
-}
-
-
-/**
* debug_result
*
* Convenience function to format the output.