<?php

function write_php_file($array, $filename=null){
	$v = "<?php\r\n session_start();";
	$v .= "\r\n\$DBSERVER ='".$array['db']['host']."';";
	$v .= "\r\n\$USERNAME ='".$array['db']['user']."';";
	$v .= "\r\n\$PASSWORD ='".$array['db']['pass']."';";
	$v .= "\r\n\$DATABASENAME ='".$array['db']['name']."';";
	$v .= "\r\n\$SMSUSERNAME ='';";
	$v .= "\r\n\$SMSPASSWORD ='';";
	$v .= "\r\n\$SMSIPPAGE ='';";

	$v .= "\r\n\$PRODUCTSPERPAGE =10;";
	$v .= "\r\n\$PRODUCTSPERPAGE_MYACCOUNT =5;";
	$v .= "\r\n\$Currency ='￥';";

	$v .= "\r\n\$SMSrate =1.50;";
	$v .= "\r\n\$SMSsendnumber =1065;";
	
	$v .= "\r\n\$AllPageTitle ='".$array['db']['pagetitle']."';";
	$v .= "\r\n\$SITE_URL ='".$array['db']['siteurl']."';";
    
	$v .= "\r\n\$adminemailadd ='';";

	$v .= "\r\n\$ADMIN_MAIN_SITE_NAME ='".$array['db']['sitename']."';";
	$v .= "\r\n\$site_currency_name ='';"; 
	$v .= "\r\n\$beian_id ='';";
	$v .= "\r\n\$paypaltoken ='';";
$v .= "\r\ndefine(\"DIR_WS_IMAGES\",'images/');";
$v .= "\r\ndefine(\"DIR_WS_ICONS\",DIR_WS_IMAGES.'icons/');";
$v .= "\r\ndefine(\"DIR_WS_BANNERS\",DIR_WS_IMAGES.'banners/');";
$v .= "\r\ndefine(\"DIR_WS_CATEGORIES\",DIR_WS_IMAGES.'categories/');";
$v .= "\r\ndefine(\"DIR_WS_PRODUCTS\",DIR_WS_IMAGES.'products/');";
$v .= "\r\ndefine(\"DIR_WS_MANUFACTURERS\",DIR_WS_IMAGES.'manufacturers/');";
	
$v .= "\r\n\$DIR_WS_IMAGES=\"images/\";";
$v .= "\r\n\$DIR_WS_ICONS=\"images/icons/\";";

//$v .= "\r\nset_error_handler('error_handler');";


	$v .="\r\n?>";
	return file_put_contents($filename, $v);
}


