<?php 
/*
##################################################################
#                       PHP 4&5 MySQL 4&5                        #
##################################################################
#           Copyright (c) 2004-2008 Armia Systems Inc            #
##################################################################
#               This file is part of Cybermatch site             #
##################################################################
#    Developed By: simi (simi@armia.com)                         #

##################################################################
#               Developed On:   03-04-2008                       #
##################################################################
#               Modified By:                                     #
##################################################################
#               Modified On:                                     #
##################################################################
# This script may not be distributed, sold, given away for free  #
# to third party, or used as a part of any internet ervices such #
# as webdesign etc.                                              #
##################################################################
*/
require_once ("../config.inc.php");
require_once ("../includes/userlogincheck.mobile.inc.php");
require_once ("../includes/mysql_mobile.inc.php");
require_once ("../classes/misc.class.php");
require_once ("../classes/userside.class.php");

$message	= "";
$scripts	= "";
$arrElements= array();
$vNewPa		= isset($_POST['vNewPa'])	?	stripslashes(trim($_POST['vNewPa']))	:	"";
$vNewConPa	= isset($_POST['vNewConPa'])?	stripslashes(trim($_POST['vNewConPa']))	:	"";

if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objM		= new misc($objDB);
	$objU		= new userside($objDB);	
	
	if (isset($_POST['CNP'])) {
		if ($vNewPa == "") {
			$message	.= "Please enter new password.<br>";
			$arrElements[]	= "vNewPa";
		}
		if ($vNewConPa == "") {
			$message	.= "Please confirm new password.<br>";
			$arrElements[]	= "vNewConPa";
		}
		if ($vNewPa <> $vNewConPa) {
			$message	.= "Mismatch of passwords.<br>";
			$arrElements[]	= "vNewPa";
			$arrElements[]	= "vNewConPa";
		}
		if (!empty($arrElements)) {
			$scripts	= '<script language="javascript">';
			foreach ($arrElements as $key=>$value) {
				$scripts	.= 'document.frmTell.'.$value.'.className = "errorinput";';
			}
			$scripts	.= '</script>';
		}
		$message	.= $scripts;
		if ($message == "")
			$message	= $objM->change_password($_SESSION['user_id'], $vNewPa);
		if ($message == "")
			$message	= "<font color='green'>Your password has been successfully changed.</font><br>";
	}
	
	$scripts	= $objM->get_script($message);
	$message	= $objM->remove_script($message);
}
?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head><title>Cybermatch</title>
<link href="images/mobile.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div xmlns="http://www.w3.org/1999/xhtml">
<?php include_once('title.inc.php');?>
<div>&nbsp;</div>
    <div>
        <div><i>+</i> <a href="index.php">Home</a></div>
        <div><i>+</i> <a href="search.php">Search</a></div>
        <div><i>+</i> <a href="dashbox.php" accesskey="2">Account</a> </div>
        <div><i>+</i> <a href="logout.php">Logout</a></div>
    </div>
<div>&nbsp;</div>
<div><a name="search"></a><strong>Change Password</strong></div>
<div>&nbsp;</div>
<div class="message"><?php echo $message?></div>
<div>&nbsp;</div>

<form name="frmTell" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<div>New Password:  <input name="vNewPa" type="password" class="inputel" size="15" maxlength="100" />
</div>
<div>Confirm Password: <input name="vNewConPa" type="text" class="inputel" size="15" maxlength="100"/>
</div>
<div>&nbsp;</div>
<div><input type="submit" name="CNP" value="   Change Now " class="inputb"></div>
</form>
<?php include_once('footer.inc.php');?>