Location: PHPKode > projects > ChiCoMaS - Chilek CMS > chicomas/configuration.php
<?
/********************************************************************************/
function CheckOldConfigFile(){
	define("OLDCONFIGFILE","config.php");

	if (!file_exists( OLDCONFIGFILE ) || filesize( OLDCONFIGFILE) < 10)
		return FALSE;
	else
		return TRUE;
}

/********************************************************************************/
function ConvertConfigFile(){
	define("OLDCONFIGFILE","config.php");
	define("CONFIGFILE","config.inc");

	$conf = new ConfigTool();
	$conf->setConfigFromFile( CONFIGFILE );

	if(is_file(OLDCONFIGFILE)) include (OLDCONFIGFILE);

	$config_file_content.="##ChiCoMaS\n";
	$config_file_content.="##Configuration File\n";

	$config_file_content.="dbhost                    = '".$DBHost."'\n";
	$config_file_content.="dbuser                    = '".$DBUser."'\n";
	$config_file_content.="dbpass                    = '".$DBPass."'\n";
	$config_file_content.="dbname                    = '".$DBName."'\n";
	$config_file_content.="dbtype                    = 'mysql'\n";
	$config_file_content.="title                     = '".$title."'\n";
	$config_file_content.="width                     = '".$width."'\n";
	$config_file_content.="keywords                  = '".$keywords."'\n";
	$config_file_content.="description               = '".$description."'\n";
	$config_file_content.="logoname                  = '".$logoname."'\n";
	$config_file_content.="bodyposition              = '".$bodyposition."'\n";
	$config_file_content.="thisurl                   = '".$thisurl."'\n";
	$config_file_content.="textlogo                  = '".$textlogo."'\n";
	$config_file_content.="defaultlanguage           = '".$defaultlanguage."'\n";
	$config_file_content.="user_signup               = 0\n";
	$config_file_content.="user_getpassword          = 0\n";
	$config_file_content.="user_default_group        = 2\n";
	$config_file_content.="user_send_confirm_email   = 0\n";

	$handle=fopen(CONFIGFILE, "w");
	fwrite($handle,$config_file_content);
	fclose($handle);

	rename(OLDCONFIGFILE, OLDCONFIGFILE.".old");

}

/********************************************************************************/
function Configuration($config_file){


	global $dbhost;
	global $dbuser;
	global $dbpass;
	global $dbname;

	global $title;
	global $width;
	global $keywords;
	global $description;
	global $logoname;
	global $model;
	global $bodyposition;
	global $thisurl;
	global $textlogo;

	global $defaultlanguage;

	global $user_signup;
	global $user_getpassword;
	global $user_default_group;
	global $user_send_confirm_email;

	if (!file_exists( CONFIGFILE ) || filesize( CONFIGFILE) < 10){
		$config_file_content.="##ChiCoMaS\n";
		$config_file_content.="##Configuration File\n";

		$handle=fopen(CONFIGFILE, "w");
		fwrite($handle,$config_file_content);
		fclose($handle);

		return FALSE;
	}

	$conf = new ConfigTool();
	$conf->setConfigFromFile( CONFIGFILE );
	//$conf->setIndent( 15 );

	//echo "<br />dbhost = " . $conf->get( 'dbhost' );

	//********************
	// dbhost
	//********************
	if ($conf->isDefined('dbhost'))
		$dbhost = $conf->get( 'dbhost' );
	else{
		$dbhost = "localhost";
		$conf->addKeyValue( "dbhost", "'localhost'" );
		$save_config_file = TRUE;
	}

	//********************
	// dbuser
	//********************
	if ($conf->isDefined('dbuser'))
		$dbuser = $conf->get( 'dbuser' );
	else{
		$dbuser = "root";
		$conf->addKeyValue( "dbuser", "'root'" );
		$save_config_file = TRUE;
	}

	//********************
	// dbpass
	//********************
	if ($conf->isDefined('dbpass'))
		$dbpass = $conf->get( 'dbpass' );
	else{
		$dbpass = "";
		$conf->addKeyValue( "dbpass", "''" );
		$save_config_file = TRUE;
	}

	//********************
	// dbname
	//********************
	if ($conf->isDefined('dbname'))
		$dbname = $conf->get( 'dbname' );
	else{
		$dbname = "";
		$conf->addKeyValue( "dbname", "'chicomas'" );
		$save_config_file = TRUE;
	}

	//********************
	// dbtype
	//********************
	if ($conf->isDefined('dbtype'))
		$dbtype = $conf->get( 'dbtype' );
	else{
		$dbtype = "mysql";
		$conf->addKeyValue( "dbtype", "'mysql'" );
		$save_config_file = TRUE;
	}
	
	//********************
	// title
	//********************
	if ($conf->isDefined('title'))
		$title = $conf->get( 'title' );
	else{
		$title = "ChiCoMaS - Chilek Content Management System";
		$conf->addKeyValue( "title", "'ChiCoMaS - Chilek Content Management System'" );
		$save_config_file = TRUE;
	}


	//********************
	// width
	//********************
	if ($conf->isDefined('width'))
		$width = $conf->get( 'width' );
	else{
		$width = "800px";
		$conf->addKeyValue( "width", "'800px'" );
		$save_config_file = TRUE;
	}


	//********************
	// keywords
	//********************
	if ($conf->isDefined('keywords'))
		$keywords = $conf->get( 'keywords' );
	else{
		$keywords = "chicomas, content, management, system, cms, tinymce, quixplorer, mysqlbackuppro, php, mysql";
		$conf->addKeyValue( "keywords", "'chicomas, content, management, system, cms, tinymce, quixplorer, mysqlbackuppro, php, mysql'" );
		$save_config_file = TRUE;
	}


	//********************
	// description
	//********************
	if ($conf->isDefined('description'))
		$description = $conf->get( 'description' );
	else{
		$description = "ChiCoMaS - Chilek Content Management System";
		$conf->addKeyValue( "description", "'ChiCoMaS - Chilek Content Management System'" );
		$save_config_file = TRUE;
	}


	//********************
	// logoname
	//********************
	if ($conf->isDefined('logoname'))
		$logoname = $conf->get( 'logoname' );
	else{
		$logoname = "";
		$conf->addKeyValue( "logoname", "''" );
		$save_config_file = TRUE;
	}


	//********************
	// bodyposition
	//********************
	if ($conf->isDefined('bodyposition'))
		$bodyposition = $conf->get( 'bodyposition' );
	else{
		$bodyposition = "center";
		$conf->addKeyValue( "bodyposition", "'center'" );
		$save_config_file = TRUE;
	}


	//********************
	// thisurl
	//********************
	if ($conf->isDefined('thisurl'))
		$thisurl = $conf->get( 'thisurl' );
	else{
		$thisurl = "http://localhost/chicomas/";
		$conf->addKeyValue( "thisurl", "'http://localhost/chicomas/'" );
		$save_config_file = TRUE;
	}


	//********************
	// textlogo
	//********************
	if ($conf->isDefined('textlogo'))
		$textlogo = $conf->get( 'textlogo' );
	else{
		$textlogo = "http://www.chicomas.com/";
		$conf->addKeyValue( "textlogo", "'http://www.chicomas.com/'" );
		$save_config_file = TRUE;
	}


	//********************
	// defaultlanguage
	//********************
	if (!session_is_registered("defaultlanguage")){
		if ($conf->isDefined('defaultlanguage'))
			$defaultlanguage = $conf->get( 'defaultlanguage' );
		else{
			$defaultlanguage = "en";
			$conf->addKeyValue( "defaultlanguage", "'en'" );
			$save_config_file = TRUE;
		}
	}

	//********************
	// user_signup
	//********************
	if ($conf->isDefined('user_signup'))
		$user_signup = $conf->get( 'user_signup' );
	else{
		$user_signup = 0;
		$conf->addKeyValue( "user_signup", "0" );
		$save_config_file = TRUE;
	}


	//********************
	// user_getpassword
	//********************
	if ($conf->isDefined('user_getpassword'))
		$user_getpassword = $conf->get( 'user_getpassword' );
	else{
		$user_getpassword = 0;
		$conf->addKeyValue( "user_getpassword", "0" );
		$save_config_file = TRUE;
	}

	//********************
	// user_default_group
	//********************
	if ($conf->isDefined('user_default_group'))
		$user_default_group = $conf->get( 'user_default_group' );
	else{
		$user_default_group = 2;
		$conf->addKeyValue( "user_default_group", "2" );
		$save_config_file = TRUE;
	}

	//********************
	// user_send_confirm_email
	//********************
	if ($conf->isDefined('user_send_confirm_email'))
		$user_send_confirm_email = $conf->get( 'user_send_confirm_email' );
	else{
		$user_send_confirm_email = 0;
		$conf->addKeyValue( "user_send_confirm_email", "0" );
		$save_config_file = TRUE;
	}

	//********************
	// Save Config File
	//********************
	if ($save_config_file) {
		$conf->setFileName( CONFIGFILE );
		$conf->saveToFile();
	}

/*
	$conf->updateKeyValue( "hello1", "Greetings!!!" );
	$conf->deleteKey( "hello2" );
	$conf->addKeyValue( "hello3", "'Greetings from Norway!'" );
*/

	return TRUE;
}

?>
Return current item: ChiCoMaS - Chilek CMS