<?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/userside.class.php");
require_once ("../classes/misc.class.php");

$message	= "";
$msg		= "";
$vUrl		= "";
$id			= isset($_REQUEST['id'])	?	stripslashes(trim($_REQUEST['id']))		:	"0";
$msgid		= isset($_REQUEST['msgid'])	?	stripslashes(trim($_REQUEST['msgid']))	:	"0";
$title		= isset($_POST['vTitle'])	?	stripslashes(trim($_POST['vTitle']))		:	"";
$mail		= isset($_POST['tContent'])		?	stripslashes(trim($_POST['tContent']))		:	"";
$page		= isset($_REQUEST['page'])	?	trim($_REQUEST['page'])	:	"1";

$script		= "";
$arrMsg		= array();
$array		= array();

if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {

	$objU		= new userside($objDB);
	$objU1		= new userside($objDB);
	$objM		= new misc($objDB);
	
	if (isset($_POST['SendM'])) {
		if ($id == $_SESSION['user_id']) {
			$msg	= "Error: Invalid operation.<br>";
		} else {
			if ($objU->is_expired($_SESSION['user_id'])) {
				$msg	= "Your profile has been expired, please renew your profile for using this service.";	
			} else {
				$msg	= $objM->send_message($_SESSION['user_id'], $_POST);
				if ($msg == "") {
					$msg		= "<font color='green'>Your message has been successfully sent.</font><br>";
				}
			}
		}
	} else {
		if ($msgid > 0) {
			$arrMsg	= $objM->get_message($msgid, $_SESSION['user_id']);
			if (!empty($arrMsg)) {
				$title	= "Re: ".$arrMsg['vTitle'];
				$mail	= "\n\n".$arrMsg['vLogin_From']." wrote:\n"."----------------------\n".$arrMsg['tContent'];
			}
		}
	}

	$array		= $objU->getuser(addslashes($id)); 
	if (!empty($array)) {
		$objU->set_values($array);
	} else {
		$message	= "Invalid profile.<br>";
	}

	$message	.= $msg;
	$script		= $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="profile.php?id=<?php echo $id?>&page=<?php echo $page?>">Back to Profile</a></div>
<?php if (!isset($_SESSION['userlogged']) OR $_SESSION['userlogged'] == "") {?>
        <div><i>+</i> <a href="login.php">Login</a> </div>
<?php } ?>		
	   
    </div>
<div>&nbsp;</div>
<?php if (isset($_SESSION['userlogged']) AND $_SESSION['userlogged'] == "YES") {?>
<div>
    <div>
        <div><i>+</i> <a href="logout.php" accesskey="1">Logout&nbsp;&nbsp;&nbsp;</a> </div>
        <div><i>+</i> <a href="dashbox.php" accesskey="2">Account</a> </div>
    </div>
</div>
<div>&nbsp;</div>
<?php } ?>

<a name="search"></a><strong>Send Mail to <?php echo $objU->vLogin?></strong>
<div>&nbsp;</div>
<div class="message"><?php echo $message?></div>
<div>&nbsp;</div>
<form name="frmSearch" method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<div></div>
<div>Mail Title: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="vTitle" type="text" class="inputel" size="30" maxlength="250" value="<?php echo $title?>">
</div>
<div>Mail Message:<textarea name="tContent" cols="40" rows="5" class="textareabox"><?php echo $mail?></textarea>
</div>
<div>&nbsp;</div>
<input name="SendM" type="submit" class="inputb" id="SendM" value="   Send Mail " />
<input type="hidden" name="id" value="<?php echo $id?>" />
<input type="hidden" name="msgid" value="<?php echo $msgid?>" />
<input type="hidden" name="page" value="<?php echo $page?>">
</form>
<?php include_once('footer.inc.php');?>