<?php

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

						///////////////////////////////////////
							
						admin_validate_section("setup",1);
						$action = $GLOBALS["Get"]->val("action");
								
							switch($action){								
										
								case '':									
									admin_password();
									break;
									
								case 'save':
									update_admin_password();
									break;
									
							}//switch
							
						///////////////////////////////////////
						
function admin_password(){
	
	admin_validate();
	
	$data["section"] = "setup";
	$data["subsection"] = 1;
	$data["title_id"] = "2";	
	$done = $GLOBALS["Get"]->val("done");
	
	if($done)
		$data["message"] = "Password successfully changed.";	
	$layout[0] = "admin_password";
	
	admin_output($layout,$data);
	
}//admin_password

function update_admin_password(){
	
	admin_validate();
	
	$curr_login    = $GLOBALS["Get"]->val("curr_login");
	$curr_password = $GLOBALS["Get"]->val("curr_password");
	$new_login     = $GLOBALS["Get"]->val("new_login");
	$new_password  = $GLOBALS["Get"]->val("new_password");	
	
	$sql_query = "SELECT member_type FROM members WHERE (email=':email:' OR username=':email:') AND password=':password:'";
	$GLOBALS["DB"]->values = array("email" => $curr_login, "password" => md5($curr_password));
	$member_type = $GLOBALS["DB"]->single($sql_query);
	
	if($member_type != "a")
		load_page("index.php?section=admin_password&err_id=26");
	
	$sql_query = "UPDATE members SET email=':email:',username=':email:',password=':password:'
				  WHERE member_type='a'";
	$GLOBALS["DB"]->values = array ("email" => $new_login, "password" => md5($new_password));
	$GLOBALS["DB"]->execute($sql_query);
	
	$logged_in = admin_login($new_login,$new_password);
	
	if($logged_in)
		load_page("index.php?section=admin_password&done=1");
	else
		load_page("index.php?err_id=1");
	
}//update_admin_password

?>