I want to, well, let's just say do something after user read the message. For example I tried to create text file, but it did not worked.
This is how I tried to do it:
I added
- Code: Select all
<?php file_put_contents($_SERVER['DOCUMENT_ROOT']."/test.txt", "hello"); ?>
Here's my full file after editing:
recieve-user.php
- Code: Select all
<?php
/*
|| #################################################################### ||
|| # ArrowChat # ||
|| # ---------------------------------------------------------------- # ||
|| # Copyright �2010-2012 ArrowSuites LLC. All Rights Reserved. # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # ---------------- ARROWCHAT IS NOT FREE SOFTWARE ---------------- # ||
|| # http://www.arrowchat.com | http://www.arrowchat.com/license/ # ||
|| #################################################################### ||
*/
// ########################## INCLUDE BACK-END ###########################
require_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'bootstrap.php');
require_once (dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . AC_FOLDER_INCLUDES . DIRECTORY_SEPARATOR . 'init.php');
// ########################### INITILIZATION #############################
$response = array();
$messages = array();
$time = time();
// ########################### GET POST DATA #############################
$fetchid = get_var('userid');
// ###################### START USER DATA RECEIVE ########################
if (!empty($fetchid))
{
$sql = get_user_details($fetchid);
$result = $db->execute($sql);
if ($result AND $db->count_select() > 0)
{
$chat = $db->fetch_array($result);
if ((($time-$chat['lastactivity']) < $online_timeout) AND $chat['status'] != 'invisible' AND $chat['status'] != 'offline')
{
if ($chat['status'] != 'busy' AND $chat['status'] != 'away')
{
$chat['status'] = 'available';
}
}
else
{
if ($chat['status'] == 'invisible')
{
}
else
{
$chat['status'] = 'offline';
}
}
$link = get_link($chat['link'], $fetchid);
$avatar = get_avatar($chat['avatar'], $fetchid);
$response = array('id' => $chat['userid'], 'n' => strip_tags($chat['username']), 's' => $chat['status'], 'a' => $avatar, 'l' => $link);
header('Content-type: application/json; charset=utf-8');
echo json_encode($response);
close_session();
exit;
}
else if (check_if_guest($fetchid))
{
$sql = get_guest_details($fetchid);
$result = $db->execute($sql);
if ($result AND $db->count_select() > 0)
{
$chat = $db->fetch_array($result);
if ((($time-$chat['lastactivity']) < $online_timeout) AND $chat['status'] != 'invisible' AND $chat['status'] != 'offline')
{
if ($chat['status'] != 'busy' AND $chat['status'] != 'away')
{
$chat['status'] = 'available';
}
}
else
{
if ($chat['status'] == 'invisible')
{
}
else
{
$chat['status'] = 'offline';
}
}
$link = "#";
$avatar = $base_url . AC_FOLDER_ADMIN . "/images/img-no-avatar.png";
$chat['username'] = create_guest_username($chat['userid'], $chat['guest_name']);
$response = array('id' => $chat['userid'], 'n' => strip_tags($chat['username']), 's' => $chat['status'], 'a' => $avatar, 'l' => $link);
header('Content-type: application/json; charset=utf-8');
echo json_encode($response);
close_session();
exit;
}
else
{
echo 1;
close_session();
exit;
}
}
else
{
$db->execute("
UPDATE arrowchat
SET arrowchat.read = '1',
arrowchat.user_read = '1'
WHERE arrowchat.from = '" . $db->escape_string($fetchid) . "'
OR arrowchat.to = '" . $db->escape_string($fetchid) . "'
");
file_put_contents($_SERVER['DOCUMENT_ROOT']."/test.txt", "hello");
$result = $db->execute("
SELECT unfocus_chat, focus_chat, typing
FROM arrowchat_status
WHERE userid = '" . $db->escape_string($userid) . "'
");
if ($result AND $db->count_select() > 0)
{
$row = $db->fetch_array($result);
$unfocus_chat = $row['unfocus_chat'];
$focus_chat = $row['focus_chat'];
$typing = $row['typing'];
$focus_chat = str_replace($fetchid, "", $focus_chat);
$unfocus_chat = str_replace($fetchid.":", "", $unfocus_chat);
$typing = preg_replace("#:$fetchid/[0-9]+#", "", $typing);
$db->execute("
UPDATE arrowchat_status
SET unfocus_chat = '" . $db->escape_string($unfocus_chat) . "',
focus_chat = '" . $db->escape_string($focus_chat) . "',
typing = '" . $db->escape_string($typing) . "'
WHERE userid = '" . $db->escape_string($userid) . "'
");
}
close_session();
exit;
}
?>
Also, if it's possible to do it, what are the variables for user id the message goes to and message id.
Thanks in advance.
Regards.