<?php

						/*************************************\
						
						    Handshakes Professional (3.0)
						            by DZOIC LTD
						       Copyright(c) 2005-2006
						        http://www.dzoic.com
						
						\*************************************/

						///////////////////////////////////////

						admin_validate_section("customize",1);
						$action = $GLOBALS["Get"]->val("action");

							switch($action){

								case '':
									system_messages();
									break;
									
								case 'save_errors':
									save_errors();
									break;
									
								case 'save_completes':
									save_completes();
									break;

							}//switch

						///////////////////////////////////////
						
function system_messages(){
	
	admin_validate();
	
	$data["section"] = "customize";
	$data["subsection"] = 1;
	$data["title_id"] = "47";	
	$data["themes"] = admin_get_themes();	
	$theme = $GLOBALS["Get"]->val("theme");
	
	if(empty($theme))
		$theme = $GLOBALS["THEME"];
	
	if($theme){
		$data["theme"] = $theme;
		include(DOC_ROOT."/themes/".$theme."/system/completes.inc.php");
		include(DOC_ROOT."/themes/".$theme."/system/errors.inc.php");	
		$data["completes"] = $completes;
		$data["errors"] = $errors;
		$layout[0] = "system_messages";
	}//if
	
	admin_output($layout,$data);
	
}//system_messages

function save_errors(){
	
	admin_validate();
	
	$theme  = $GLOBALS["Get"]->val("theme");
	$errors = $GLOBALS["Get"]->val("errors");
	
	$write_str = "<?php\n\n";
	while(list($key,$val) = each($errors)){
		$val = stripslashes(html_entity_decode($val));
		$val = hs_ereg_replace('"','\"',$val);
		$write_str.= "\$errors[".$key."] = \"".$val."\";\n";
	}//while
	$write_str.= "\n?>";
	
	$file = DOC_ROOT."/themes/".$theme."/system/errors.inc.php";
	$file_handler = fopen($file,"w");
	fwrite($file_handler,$write_str);
	fclose($file_handler);
	
	load_page("index.php?section=system_messages&theme=".$theme);
	
}//save_errors

function save_completes(){
	
	admin_validate();
	
	$completes = $GLOBALS["Get"]->val("completes");
	$theme     = $GLOBALS["Get"]->val("theme");
	
	$write_str = "<?php\n\n";
	while(list($key,$val) = each($completes)){
		$val = stripslashes(html_entity_decode($val));
		$val = hs_ereg_replace('"','\"',$val);
		$write_str.= "\$completes[".$key."] = \"".$val."\";\n";
	}//while
	$write_str.= "\n?>";
	
	$file = DOC_ROOT."/themes/".$theme."/system/completes.inc.php";
	$file_handler = fopen($file,"w");
	fwrite($file_handler,$write_str);
	fclose($file_handler);
	
	load_page("index.php?section=system_messages&theme=".$theme);
	
}//save_completes
						
?>