<?php
//+-----------------------------------------------------+//
//+ Copyright Floopo.com
//+ configbuilder.php
//+ Creates the output for config (settings.php) file
//+-----------------------------------------------------+//

defined('BASEPATH') or die('You can not directly access this file');//check its within this framework

//_________load all the vars from database_____________________

$builder = $dbase->SelectRecord("SELECT *, 
                                  (SELECT page_name FROM web_pages WHERE page_ref = 1) AS page_name1,
                                  (SELECT page_name FROM web_pages WHERE page_ref = 2) AS page_name2
                                FROM system_settings
								WHERE place_holder = 'yes'");						  

//_________Some additional stuff________________________________

$comment         = '//System Setting - Generated on: '.date('d-m-Y, g:i a');
$php_opening     = '<?php';
$php_closing     = '?>';



//_________List out "numerical" vars____________________________

$nums = array('debug_mode',
			  'display_followers_block',
			  'display_login_box',
			  'display_signup_splash',
			  'display_members_name',
			  'image_file_size',
			  'allow_registration',
			  'members_only',
              'following_list',
              'page_limits',
			  'avatar_file_size');


//_________List out "bad" characters that can break things______



//_________start creating the list of vars_______________________

foreach($builder as $key=>$value){

//remove bad characters
$value = str_replace("'", "\'", $value);

//add .php to language
$value =(($key == 'language')? $value.'.php' : $value);

if(!is_numeric($key)){ //skip some stuff in the array

if(in_array($key, $nums)){

$value = ((is_numeric($value))? $value : 0); //just in case

$config_line .= '$config[\''.$key.'\'] = '.$value.';'."\n";
}else{
$config_line .= '$config[\''.$key.'\'] = \''.$value.'\';'."\n";
}
}
}




//_________final build____________________________________________

$config_line = "$php_opening\n\n$comment\n\n\n$config_line\n\n$php_closing";

?>