* @copyright 2011
* @version $Version: 0.1.0$
*/
if (file_exists(dirname(__FILE__).'/installed.txt')) {
if (isset($_GET['step'])) {
if ($_GET['step'] != 3) {
die('Please remove installed.txt file before running pre-installation script.');
}
} else {
die('Please remove installed.txt file before running pre-installation script.');
}
}
/**
* Checks a configuration.
*
* TODO: css to show problem
*/
function check($boolean, $message, $help = '', $fatal = false)
{
if ($fatal) {
$tdclass = 'required';
} else {
$tdclass = 'optional';
}
if ($boolean) {
$tdclass = $tdclass.'_pass';
} else {
$tdclass = $tdclass.'_fail';
}
echo '
';
echo $message;
if (!$boolean)
{
echo " $help
";
}
echo ' ';
}
/**
* Get step number.
*/
function getStep() {
$step = 0;
if (isset($_GET['step'])) {
$step = (int)$_GET['step'];
}
return $step;
}
/**
* checks if a folder is writable
*/
function is__writable($path) {
//will work in despite of Windows ACLs bug
//NOTE: use a trailing slash for folders!!!
//see http://bugs.php.net/bug.php?id=27609
//see http://bugs.php.net/bug.php?id=30931
if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
return is__writable($path.uniqid(mt_rand()).'.tmp');
else if (is_dir($path))
return is__writable($path.'/'.uniqid(mt_rand()).'.tmp');
// check tmp file for read/write capabilities
$rm = file_exists($path);
$f = @fopen($path, 'a');
if ($f===false)
return false;
fclose($f);
if (!$rm)
unlink($path);
return true;
}
function isWindows() {
if (function_exists('posix_getpwuid')) {
$processUser = posix_getpwuid(posix_geteuid());
$apacheuser = $processUser['name'];
return false;
} else {
$apacheuser = get_current_user();
return true;
}
}
/*
* Print static head.
*/
echo <<
AuthPuppy Authentication Server Demo
END;
/*
* Choose what to render
*/
$action = $_SERVER['PHP_SELF'];
$sf_dir = rtrim($_SERVER["DOCUMENT_ROOT"], '/\\');
// cut /web from the path (if it exists)
if (substr($sf_dir, -3) == "web") {
$sf_dir = substr($sf_dir, 0, -4);
}
switch (getStep()) {
/*
* Step 2, requirements
*/
case 2:
echo 'Please check requirements and click on Next at the bottom of this page to continue.
';
echo '
END;
}
break;
/*
* Step 1, welcome page
*/
default:
echo <<
Welcome to authPuppy. Before getting started, we need some information on the database. You will need to know the following items before proceeding.
Database name
Database username
Database password
Database host
In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…
END;
}
/*
* Print end of html
*/
echo '';