<?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               bedroom.php                      #
# File purpose            Add users to bedroom             #
# 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';
ssecurity(TRUE,$w[152]);
include_once C_PATH.'/sheader.php';
if(!IsAccess(C_BEDSH)) sprintm($w[156]);

if (isset($id)&&is_numeric($id)) {
unset($m);

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

$sql = mysql_query("SELECT count(id) as total FROM ".C_MYSQL_BEDROOM." WHERE user = '".$id."' AND myid='".get_info('m')."'") or die(mysql_error());
$trows = mysql_fetch_array($sql);
$total = $trows['total'];
if($total != '0') sprintm($w[157]);

	if(isset($do)) {
	if(!isset($reason)) $reason='';
mysql_query("INSERT INTO ".C_MYSQL_BEDROOM." VALUES(null,'".get_info('m')."',NOW(''),'".$id."','".cb($reason)."')") or die(mysql_error());

$subject=$w[332];
$tm=array('<a href='.C_URL.'/view.php?l='.$l.'&id='.get_info('m').'>'.get_info('m').'</a>');
$message=template($w[333],$tm);
if(C_ADD_CONFIRM) {
  mysql_query("INSERT INTO ".C_MYSQL_MESSAGES." VALUES (Null,'".get_info('m')."','".$id."','".$subject."','".$message."',NOW(''),'".ip2int(ip())."','3')");
	AddUserToAddressBook($id);
}

if(C_POPULARITY == '1') pop_in($id,C_HITS_BEDROOM);
sprintm($w[158]);
	} else {
		define('ADD_TO_LIST',$w[219]);
		define('ENTER_YOUR_REASON',$w[521]);
		define('SEND_MESSAGE',$w[170]);
		define('ID_VALUE',$id);
	  if(isset($uname)) define('USER_NAME',cb($uname));
		else define('USER_NAME','');

		include_once C_PATH.'/templates/'.C_TEMP.'/bedroom.php';
	}

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