Location: PHPKode > projects > chillyCMS > chillyCMS/backup/files/installation/install.include.php
<?php
//#################################################################################################
// Installation helper functions
//#################################################################################################
//	set_permissions()
//	languageform()
//	form_database($wrongs)
//	check_dbentries()
//	create_configfile()
//	execute_sql($name)
//#################################################################################################
defined('DOIT') or die('Restricted access');

//Set Permissions for installation folder and config file//////////////////////////////////////////
function set_permissions() {
	$error = false;
	if (!@chmod("../config.php", 755))	{ $error = true; }
	if (!@chmod_r(dirname(__FILE__),777))	{ $error = true; }
	if (!$error) { return true; } else { return false; }
}
//Databaseform/////////////////////////////////////////////////////////////////////////////////////
function make_recoveryform(&$msg) {
	$f = new Form("","post",'','OK','Error...',false,true);
	$f->addInput("text","dbhost","Host",'localhost',true,false,false,false,false,false,false,false,false,array('Wrong database server (usually "localhost") or...','below'));
	$f->addInput("text","dbuser","DB User",'root',true,false,false,false,false,false,false,false,false,array('...wrong database user or...','below'));
	$f->addInput("password","dbpw","DB Password",false,true,false,false,false,false,false,false,false,false,array('...wrong database password','below'));
	$f->addInput("text","dbname","DB Name",'cms',true,false,false,false,false,false,false,false,false,array('Wrong database name','below'));
	$f->addButton("submit","submit",false,"Recover!");

	$f->getErrors();

	//the get general form error message
	$msg = $f->getMsg();
	$success = false;

	if ($f->sent) {
		//Check database connection
		$link=@mysql_connect($_POST["dbhost"],$_POST["dbuser"],$_POST["dbpw"]);
		if (!$link) {
			$f->setError('dbhost');
			$f->setError('dbuser');
			$f->setError('dbpw');
		} else {
			if (!mysql_select_db($_POST["dbname"], $link)) {
				$f->setError('dbname');
			}
		}
		unset($link);
	}

	//if there were no errors proceed with whatever
	if ($f->sent && is_array($f->errors) && sizeof($f->errors)<1) { $doit = true; } else { $doit = false; }

	if ($doit) {
		$success = true;
		$return = create_configfile();
		if ($return===false) {
			$msg = array("Error creating config file. Do you have the permission?","bad");
			$success = false;
		}

		if (!exec_sql("drop1.sql") or !exec_sql("drop2.sql") or !exec_sql("database.sql")) {
			$msg = array("Error creating database. Please try again","bad");
			$success = false;
		} else {
			unset($page);
			$page = new Installpage();
		}
	}
	if ($success) {
		return $success;
	} else {
		return $f->render('table');
	}
}
//Create Configfile////////////////////////////////////////////////////////////////////////////////
function create_configfile() {
	$config='defined("DOIT") or die("Restricted access");
define("DB_HOST", "'.$_POST["dbhost"].'");
define("DB_USER", "'.$_POST["dbuser"].'");
define("DB_PW", "'.$_POST["dbpw"].'");
define("DB_DB", "'.$_POST["dbname"].'");
?>';
	if (write_file("../config.php","<?php\n".$config)) {
		$return = true;
	} else {
		$return = false;
	}
	return $return;
}
?>
Return current item: chillyCMS