<?php
############################################################
# \-\-\-\-\-\-\     AzDG  - S C R I P T S    /-/-/-/-/-/-/ #
############################################################
# AzDGDatingMedium        Version 1.9.3                    #
# Written by              AzDG (support@azdg.com)          #
# Created 24/10/02        Last Modified 22/03/06           #
# Scripts Home:           http://www.azdg.com              #
############################################################
# File name               send.php                         #
# File purpose            Send message to user             #
# File created by         AzDG <support@azdg.com>          #
############################################################
include_once 'include/config.inc.php';
include_once 'include/options.inc.php';
include_once 'include/security.inc.php';
include_once 'include/functions.inc.php';
include_once 'templates/'.C_TEMP.'/config.php';
IsSecure(C_SENDSH);
include_once C_PATH.'/header.php';

if (isset($id)&&is_numeric($id)) {

	/* Checking for allowing to send message */
	CheckAllowMessaging(get_info('m'),get_info('d'),True);

	/* Checking for allowing to send message to user with the same gender */
	IsAllowContact($id);

	/* Checking for ban */
	CheckForIgnor($id);



	if(!isset($a)) $a='';
	if ($a == "s") {
		$subject=cb(trim($subject));$message=cb(trim($message));

		include_once C_PATH.'/templates/'.C_TEMP.'/forum/smiles.php';
		$message=RemoveAzDGCode($message,C_BB_SM_ACL);
		if(!IsAccess(C_VERIMG_SM)) {
			$verifyimage = cb($verifyimage);
			if(strtoupper($verifyimage) != strtoupper(@$_SESSION['vc']))
			{
				include_once C_PATH.'/header.php';
				printm($w[497]);
			}
		}
		if(trim($subject) == '' || trim($message) == '') printm($w[164]);
		$confirm = ($confirm == "on") ? "2" : "1";


		// Checking for bad words
		if (C_BADWORDS_ENABLE) {
			if (C_BADWORDS_ERR) {
				if(is_badwords($subject) || is_badwords($message))
				printm(C_BADWORDS_MES,2);
			}
			elseif (C_BADWORDS_REP) {
				$subject = replace_badwords($subject);
				$message = replace_badwords($message);
			}
		}

		CheckAllowMessaging(get_info('m'),get_info('d'),False);

		// Send Confirm if it first unreaded email
		IsFirstMessage($id);

		mysql_query("INSERT INTO ".C_MYSQL_MESSAGES." VALUES (Null,'".get_info('m')."','".$id."','".$subject."','".$message."',NOW(''),'".ip2int(ip())."','".$confirm."')");

		AddUserToAddressBook($id);

		// Popularity
		if((C_POPULARITY == '1')&&(C_HITS_SEND_FROM)) pop_in(get_info('m'),C_HITS_MAIL_FROM);
		if((C_POPULARITY == '1')&&(C_HITS_SEND_TO)) pop_in($id,C_HITS_MAIL_TO);
		//////////////

		printm($w[165],2);
	} else {

		define('ENTER_YOUR_SUBJECT',$w[166]);
		define('ENTER_YOUR_MESSAGE',$w[167]);
		define('ID_VALUE',$id);
		define('SEND_MESSAGE_TO_USER',$w[514]);
		define('NOTIFY_ME',$w[203]);
		define('SEND_MESSAGE',$w[170]);
		define('SUBJECT',$w[168].$w[0]);
		define('MESSAGE',$w[169].$w[0]);
		if (IsAccess(C_VERIMG_SM)) // NOT
		{
			define('VERIFY_ALLOW', '0');
			define('VERIFY_ERROR', '');
		}
		else
		{
			define('VERIFY_ALLOW', '1');
			define('VERIFY_ERROR', $w[497]);
		}
		define('VERIFICATION', $w[498]);

		if(isset($uname)) define('USER_NAME',cb($uname));
		else define('USER_NAME','');

		include_once C_PATH.'/templates/'.C_TEMP.'/forum/smiles.php';
		BBCheck(C_BB_SM_ACL);

		include_once C_PATH.'/templates/'.C_TEMP.'/send.php';

	}} include_once C_PATH.'/footer.php';
?>