summaryrefslogtreecommitdiffstats
path: root/lib/init.php
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2012-02-21 12:33:21 -0500
committerPaul Arthur <paul.arthur@flowerysong.com>2012-02-21 12:33:21 -0500
commit82d0fb55180c3d3af17553d5cb45deb4e88b66e2 (patch)
treef41099543a3d064c6387eb82cd4dbfcbfbfc1d45 /lib/init.php
parent295f406fc5daaebd412c4e7a65ec233f17ae7958 (diff)
downloadampache-82d0fb55180c3d3af17553d5cb45deb4e88b66e2.tar.gz
ampache-82d0fb55180c3d3af17553d5cb45deb4e88b66e2.tar.bz2
ampache-82d0fb55180c3d3af17553d5cb45deb4e88b66e2.zip
Refactor the initial checks in init.php
Reduce the amount of code duplication.
Diffstat (limited to 'lib/init.php')
-rw-r--r--lib/init.php40
1 files changed, 20 insertions, 20 deletions
diff --git a/lib/init.php b/lib/init.php
index 148ad39b..bf9143d9 100644
--- a/lib/init.php
+++ b/lib/init.php
@@ -63,32 +63,32 @@ else {
$http_type = "http://";
}
-/*
- Check to make sure the config file exists. If it doesn't then go ahead and send
- them over to the install script.
-*/
+// Set up for redirection on important error cases
+$path = preg_replace('#(.*)/(\w+\.php)$#', '$1', $_SERVER['PHP_SELF']);
+$path = $http_type . $_SERVER['HTTP_HOST'] . $path;
+
+// Check to make sure the config file exists. If it doesn't then go ahead and
+// send them over to the install script.
if (!file_exists($configfile)) {
- $path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']);
- $link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/install.php";
- header ("Location: $link");
- exit();
+ $link = $path . '/install.php';
}
+else {
+ // Make sure the config file is set up and parsable
+ $results = @parse_ini_file($configfile);
-// Use the built in PHP function, suppress errors here so we can handle it
-// properly below
-$results = @parse_ini_file($configfile);
+ if (!count($results)) {
+ $link = $path . '/test.php?action=config';
+ }
+}
-if (!count($results)) {
- $path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']);
- $link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/test.php?action=config";
- header ("Location: $link");
- exit();
+// Verify that a few important but commonly disabled PHP functions exist and
+// that we're on a usable version
+if (!function_exists('hash') || !function_exists('inet_pton') || (floatval(phpversion()) < 5.3)) {
+ $link = $path . '/test.php';
}
-/** Verify a few commonly disabled PHP functions exist and re-direct to /test if not **/
-if (!function_exists('hash') OR !function_exists('inet_pton') OR (floatval(phpversion()) < 5.3)) {
- $path = preg_replace("/(.*)\/(\w+\.php)$/","\${1}", $_SERVER['PHP_SELF']);
- $link = $http_type . $_SERVER['HTTP_HOST'] . $path . "/test.php";
+// Do the redirect if we can't continue
+if ($link) {
header ("Location: $link");
exit();
}