";
exit();
}
// if parseInput is set to TRUE, set_config will test all your form input
// Should be safe to leave FALSE if you hide this file after installation.
$parseInput = FALSE;
// phpWebSite defaults the allowed database password characters to the below
// If you wish to add others, include them in the regular expression.
// This is ignored if parseInput = FALSE
$allowedChars = "[^\w0-9_\-\*\!\.]";
if(isset($_SERVER['PATH_TRANSLATED'])) {
$file_address = ereg_replace("[\][\]", "\\", $_SERVER["PATH_TRANSLATED"]);
$file_address = str_replace("setup/set_config.php", "", $file_address);
$file_address = str_replace("setup\set_config.php", "", $file_address);
} else {
$file_address = $_SERVER["SCRIPT_FILENAME"];
$file_address = str_replace("setup/set_config.php", "", $file_address);
$file_address = str_replace("setup\set_config.php", "", $file_address);
}
if (isset($_POST["step"])){
$step = $_POST["step"];
}
else {
$step = 1;
}
?>
Create Config File
phpWebSite - Config File Creation Utility
";
if (file_exists("../conf/config.php") && filesize("../conf/config.php") > 0){
echo "Your config.php file already exists. You will need to edit it by hand or move it to create another.";
exit();
}
define("PHPWS_SOURCE_DIR", "../");
require_once ("../core/Core.php");
/* Require Table package */
require_once('HTML/Table.php');
$core = new PHPWS_Core("noDB");
$default_address = $_SERVER["SERVER_NAME"].str_replace("setup/set_config.php", "", $_SERVER["PHP_SELF"]);
PHPWS_WizardBag::seed_rand();
$temp_hash = md5($file_address.rand());
$available_dbs = array ("mysql", "pgsql");
/* $unavailable_dbs = array("ibase", "mssql", "msql", "oci8", "odbc", "sybase"); */
if (isset($_POST["hostname"])) {
$hostname = $_POST["hostname"];
} else {
$hostname = "localhost";
}
if (isset($_POST["username"])) {
$username = $_POST["username"];
} else {
$username = "phpwebsite";
}
if (isset($_POST["password"])) {
$password = $_POST["password"];
} else {
$password = NULL;
}
if (isset($_POST["database"])) {
$database = $_POST["database"];
} else {
$database = "phpwebsite";
}
if (isset($_POST["tbl_prefix"])) {
$tbl_prefix = $_POST["tbl_prefix"];
} else {
$tbl_prefix = NULL;
}
if (isset($_POST["http_src"])) {
$http_src = $_POST["http_src"];
} else {
$http_src = $default_address;
}
if (isset($_POST["filepath"])) {
$filepath = $_POST["filepath"];
// used for magic quotes
if(get_magic_quotes_gpc()) {
$filepath = stripslashes($filepath);
}
} else {
$filepath = $file_address;
}
if (isset($_POST["hubhash"])) {
$hubhash = $_POST["hubhash"];
} else {
$hubhash = $temp_hash;
}
if (isset($_POST["install_pass"])) {
$install_pass = $_POST["install_pass"];
} else {
$install_pass = NULL;
}
$http_src = str_replace("http://", "", $http_src);
if ("/" != substr($http_src, strlen($http_src) - 1 , 1))
$http_src .= "/";
if (strstr($filepath, "/") && ("/" != substr($filepath, strlen($filepath) - 1 , 1)))
$filepath .= "/";
else if (strstr($filepath, "\\") && ("\\" != substr($filepath, strlen($filepath) - 1 , 1)))
$filepath .= "\\";
$dataArray = $_POST;
$dataArray['http_src'] = $http_src;
$dataArray['filepath'] = $filepath;
switch ($step){
case "1":
echo "You are missing a config.php file. This utility can help you create one.
You need to set your directory permissions before you continue. Read the docs/INSTALL.txt file for help on setting the correct permissions.
";
if(isset($PEAR_Errors)) {
echo $PEAR_Errors;
}
echo "";
break;
case "2":
include("./config.php");
// windows - make sure escape last backslash
$filepath = $dataArray['filepath'];
if(strstr($filepath, "\\") && ("\\\\" != substr($filepath, strlen($filepath) - 2, 2))) {
$filepath .= "\\";
$dataArray['filepath'] = $filepath;
}
$config_info = config_maker($dataArray);
if ($parseInput){
$dbversion = preg_replace("/[^\w]/i", "", $dataArray['dbversion']);
$username = preg_replace("/[^\w_0-9]/i", "", $dataArray['username']);
$password = preg_replace("/" . $allowedChars . "/i", "", $dataArray['password']);
$hostname = preg_replace("/[^\w_0-9.\-\(\)]/i", "", $dataArray['hostname']);
$database = preg_replace("/[^\w_0-9]/i", "", $dataArray['database']);
} else {
$dbversion = $dataArray['dbversion'];
$username = $dataArray['username'];
$password = $dataArray['password'];
$hostname = $dataArray['hostname'];
$database = $dataArray['database'];
}
if($dbversion == "mysql") {
if (!extension_loaded('mysql')){
echo "Sorry, you must have the mysql PHP libraries installed in order to use phpWebSite
";
exit();
}
}
$core->db = DB::connect("$dbversion://$username:$password@$hostname"."/".$database);
$badPassWords = array("passwd", "password", "pass", "qwerty", "asdf", "admin", "phpws", "phpwebsite", "test", "asd", "passpass");
if (isset($core->db->message))
$error = "DB";
elseif (!empty($tbl_prefix) && !(preg_match("/^[a-z]{1}[a-z0-9_]+$/iU", $tbl_prefix)))
$error = "prefix";
elseif (empty($filepath) || !is_dir($filepath))
$error = "badDir";
elseif (empty($http_src))
$error = "noAddress";
elseif (empty($install_pass) || in_array($install_pass, $badPassWords))
$error = "noPW";
if(isset($error)) {
$back = $_POST;
if(get_magic_quotes_gpc())
$back["filepath"] = stripslashes($back["filepath"]);
$back["step"] = 1;
echo "";
if ($error == "DB")
echo "Unable to connect to your server's database.
";
elseif ($error == "prefix")
echo "The table prefix entered was not valid.
";
elseif ($error == "badDir")
echo "The directory $filepath could not be found.
";
elseif ($error == "noPW")
echo "Your must enter an installation password and don't make it easy to guess.
";
elseif ($error == "noAddress")
echo "Your must enter a web address.
";
echo " Please reenter your settings.\n
";
exit();
}
if (PHPWS_File::writeFile("../conf/config.php", $config_info, TRUE, 1)){
echo "Configuration file saved under the name conf/config.php
After testing your installation, it would be best to make sure your conf/ directory is not writable.
";
echo "Don't forget the installation password you supplied.
Click ".PHPWS_Text::link($http_src . "setup/setup.php", "here")." to continue with the installation.
";
} else {
$transfer = $_POST;
unset($transfer["step"]);
$transfer["print_config"] = "1";
echo "Unable to save config.php file to ".$_POST["filepath"]."conf
";
echo "You have two options:
";
echo "Option 1
Click on the link below and cut and paste it into your newly created config.php file.
";
echo PHPWS_Text::link($http_src . "setup/config.php", "Cut and Paste", NULL, $transfer)."
";
unset($transfer["print_config"]);
$transfer["save_config"] = 1;
echo "Option 2
Right click on the link below and pick Save Target As. Then save the file as config.php. Upload the file to the \"conf\" directory in the phpWebSite root directory.
";
echo PHPWS_Text::link($_POST["http_src"]."setup/config.php", "Right Click Me", NULL, $transfer) . "
";;
unset($transfer["save_config"]);
}
$writeable = TRUE;
if(!is_writeable("../files")) {
echo "The files directory is not webserver writable, please read step 2 in ./docs/INSTALL.txt before you continue with the installation.
";
$writeable = FALSE;
}
if(!is_writeable("../images")) {
echo "The images directory is not webserver writable, please read step 2 in ./docs/INSTALL.txt before you continue with the installation.
";
$writeable = FALSE;
}
if(!is_writeable("../images/mod/controlpanel")) {
echo "The images/mod/controlpanel directory is not webserver writable, please read step 2 in ./docs/INSTALL.txt before you continue with the installation. Control panel icons will be missing if you continue.
";
$writeable = FALSE;
}
if(!$writeable) {
echo "
";
}
echo "It is recommended that you read step 10 and 11 in ./docs/INSTALL.txt when you have finished installation.";
break;
}
?>