<?php
/* Nulled by Wizzywig */
/***********تعريب***********/
/**          saher        **/
/**  منتديات شباب وصبايا  **/
/**   www.shababtop.com   **/
/**  saher1986@live.com   **/
/***************************/

// ########################## INCLUDE BACK-END ###########################
include ("../config.php");

// ########################### GET POST DATA #############################
$userid = $_POST['userid'];
$typing = $_POST['typing'];
$untype = $_POST['untype'];

// ######################### START POST TYPING ###########################
if (!empty($_POST['typing'])) {
	
	$sql = "SELECT typing 
		FROM arrowchat_status
		WHERE userid='".mysql_real_escape_string($typing)."'";
	$result = mysql_query($sql);

	if ($result && mysql_num_rows($result) > 0 && $userid != 0) {
	
		$row = mysql_fetch_array($result);
		$old_data = $row['typing'];
		
		if (empty($untype)) {
			
			if (!empty($old_data)) {
			
				if (preg_match("#:$userid/[0-9]+#", $old_data, $matches)) {
				
					$typing_insert = str_replace($matches[0], ":".$userid."/".time()."", $old_data);
				
				} else {
				
					$typing_insert = $old_data.":".$userid."/".time();
				
				}
			
			} else {
			
				$typing_insert = ":".$userid."/".time();
			
			}
			
		} else {
		
			if (preg_match("#:$userid/[0-9]+#", $old_data, $matches)) {
			
				$typing_insert = str_replace($matches[0], ":".$userid."/0", $old_data);
			
			} else {
			
				$typing_insert = ":".$userid."/0";
			
			}
		
		}
		
		$sql = "UPDATE arrowchat_status
			SET typing='".mysql_real_escape_string($typing_insert)."' 
			WHERE userid='".mysql_real_escape_string($typing)."'";
		mysql_query($sql);
	
	}

	echo "1";
	exit(0);
}

?>