<?php

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

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

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

							switch($action){

								case '':
									tips();
									break;
									
								case 'save_tips':
									save_tips();
									break;

							}//switch

						///////////////////////////////////////
						
function tips(){
	
	admin_validate();
	
	$data["themes"] = admin_get_themes();
	
	$theme = $GLOBALS["Get"]->val("theme");
	if(empty($theme))
		$theme = $GLOBALS["THEME"];
	
	if($theme){
	
	$sql_query = "SELECT page,message FROM tips WHERE theme='".$theme."'";
	$result = $GLOBALS["DB"]->result($sql_query);
	$tips = array();
	foreach($result as $res){
		$tips[$res["page"]] = $res["message"];
	}//foreach
	
	$data["theme"] = $theme;
	$data["tips"] = $tips;	
	$data["pages"]  = admin_get_pages($theme);	
	
	$layout[0] = "tips";
	
	}//if
	
	$data["section"] = "customize";
	$data["subsection"] = 8;
	$data["title_id"] = "50";	
	admin_output($layout,$data);
	
}//tips

function save_tips(){
	
	admin_validate();
	
	$tips = $GLOBALS["Get"]->val("tips");
	$theme = $GLOBALS["Get"]->val("theme");
	
	$sql_query = "DELETE FROM tips WHERE theme='".$theme."'";
	$GLOBALS["DB"]->execute($sql_query);
	
	while(list($key,$val) = each($tips)){
		$val = stripslashes(html_entity_decode($val));
		$val = hs_ereg_replace(preg_quote("&#124;"),"|",$val);
		$val = ereg_replace("\\\\","\\\\",$val);
		$sql_query = "INSERT INTO tips (page,message,theme)
					  VALUES ('".$key."','".ereg_replace("'","\'",$val)."','".$theme."')";
		$GLOBALS["DB"]->execute($sql_query);
	}//while
	
	load_page("index.php?section=tips&theme=".$theme);
	
}//save_tips
						
?>