<?
//config function 
/**
 * getSiteConf()
 * get the site configration ,put it in the array
 * 
 * @return 
 */
function getSiteConf()
{
	global $PlusDB;
	$ret = array(); 
	// select the config
	$sql = "SELECT * from " . $PlusDB->prefix("configration") . " where conf_id>0  order by type asc";
	$rt = $PlusDB->query($sql);
	while ($row = $PlusDB->fetchArray($rt)) {
		$ret[] = array("conf_set" => $row['conf_set'], "conf_title" => $row['conf_title'], "conf_id" => $row['conf_id'], "conf_intro" => $row[conf_intro]);
	} 
	return $ret;
} 
function edit_conf()
{
	global $index_pages;
	$site_conf = getSiteConf();
	echo html_table_header("²ÎÊýÉè¶¨",2);
	echo form_header("admin.php?module=system", "save_conf", "form");
	if (sizeof($site_conf) > 0) {
		foreach($site_conf as $conf) {
			echo html_input_text($conf[conf_intro], "conf[" . $conf['conf_id'] . "]", $conf['conf_set'], 50, 255);
		} 
	} else echo "<tr><td colspan=2>"._NO_CONF_SET."</td></tr>";

	echo form_footer(_SUBMIT,_RESET, 2);
	echo html_table_footer();
} 
function save_conf()
{
	global $PlusDB, $_POST, $url;

	$site_conf = $_POST['conf']?$_POST['conf']:"";

	if (is_array($site_conf)) {
		foreach($site_conf as $key => $value) {
			$value = filtertxt(trim($value));
			$sql = "UPDATE " . $PlusDB->prefix('configration') . " SET conf_set='$value' WHERE conf_id='$key'";
			if ($PlusDB->queryF($sql)) {
			} else {
				error(_SYSTEM_UPDATE_FAIL);
			} //end if
		} 
		makeCacheConfig();
		succ($url, _SYSTEM_UPDATE_SUCCESS);
	} 
}
?>