summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/class/dba.class.php20
-rw-r--r--lib/debug.lib.php25
-rw-r--r--lib/install.lib.php2
-rw-r--r--templates/show_test.inc.php2
4 files changed, 22 insertions, 27 deletions
diff --git a/lib/class/dba.class.php b/lib/class/dba.class.php
index 75735819..03bf441c 100644
--- a/lib/class/dba.class.php
+++ b/lib/class/dba.class.php
@@ -277,6 +277,26 @@ class Dba {
} // _connect
/**
+ * check_database
+ *
+ * Make sure that we can connect to the database
+ */
+ public static function check_database($host,$username,$pass) {
+
+ $dbh = @mysql_connect($host, $username, $pass);
+
+ if (!is_resource($dbh)) {
+ return false;
+ }
+ if (!$host || !$username) {
+ return false;
+ }
+
+ return $dbh;
+
+ } // check_database
+
+ /**
* show_profile
* This function is used for debug, helps with profiling
*/
diff --git a/lib/debug.lib.php b/lib/debug.lib.php
index 4c8b0ec0..9b8b8e05 100644
--- a/lib/debug.lib.php
+++ b/lib/debug.lib.php
@@ -31,31 +31,6 @@
*/
/**
- * check_database
- *
- * checks the local mysql db and make sure life is good
- *
- * @param string $host Hostname
- * @param string $username Username
- * @param string $pass Password
- * @return mixed false or Database resource
- */
-function check_database($host,$username,$pass) {
-
- $dbh = @mysql_connect($host, $username, $pass);
-
- if (!is_resource($dbh)) {
- return false;
- }
- if (!$host || !$username) {
- return false;
- }
-
- return $dbh;
-
-} // check_database
-
-/**
* check_database_inserted
* checks to make sure that you have inserted the database
* and that the user you are using has access to it
diff --git a/lib/install.lib.php b/lib/install.lib.php
index 28368a4e..59266bca 100644
--- a/lib/install.lib.php
+++ b/lib/install.lib.php
@@ -83,7 +83,7 @@ function install_check_status($configfile) {
if they don't then they're cool
*/
$results = parse_ini_file($configfile);
- $dbh = check_database($results['database_hostname'],$results['database_username'],$results['database_password']);
+ $dbh = Dba::check_database($results['database_hostname'],$results['database_username'],$results['database_password']);
if (!is_resource($dbh)) {
Error::add('general', T_('Unable to connect to database, check your ampache config'));
diff --git a/templates/show_test.inc.php b/templates/show_test.inc.php
index 3a8372ff..1094f52f 100644
--- a/templates/show_test.inc.php
+++ b/templates/show_test.inc.php
@@ -194,7 +194,7 @@
<td valign="top"><?php echo T_("Database connection"); ?></td>
<td valign="top">[
<?php
- $db = check_database($results['database_hostname'], $results['database_username'], $results['database_password'],$results['database_name']);
+ $db = Dba::check_database($results['database_hostname'], $results['database_username'], $results['database_password'],$results['database_name']);
if (!$db) {
echo debug_result('',false);
}