Files
Testing/arrowchat2/includes/json/receive/receive_buddylist.php
sean 0e8a8b3028
Some checks failed
deploy-testing / deploy (push) Has been cancelled
Initial testing snapshot
2026-11-17 16:15:01 -05:00

385 lines
9.6 KiB
PHP

<?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');
if (isset($_COOKIE['LAST_CALL1'])||isset($_COOKIE["ratecnt1"])) {
include_once($_SERVER["DOCUMENT_ROOT"]."/include/dbinclude.php");
$last = strtotime($_COOKIE['LAST_CALL1']);
$curr = strtotime(date("Y-m-d h:i:s"));
if($last!=$curr)
{
unset($_COOKIE["ratecnt1"]);
unset($_COOKIE["LAST_CALL1"]);
setcookie("ratecnt1", 0);
setcookie("LAST_CALL1", 0);
}
$sec = abs($curr-$last);
/*$database->database_query("INSERT INTO ratelimiting SET `date`='".$_COOKIE['LAST_CALL1']."',
addr='".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."',
ip='".$_SERVER["REMOTE_ADDR"]."',
browser='".$_SERVER['HTTP_USER_AGENT']."',
`time`='".time()."', num='".$_COOKIE["ratecnt1"]."', referrer='".$_SERVER['HTTP_REFERER']."'");*/
if ($sec <= 1&&$_COOKIE["ratecnt1"]>10) {
//mail("lepslair@gmail.com", "rate limited1234", "rrr");
if($_COOKIE["ratecnt1"]>=10){exit;}
if ($sec <= 1&&$_COOKIE["ratecnt1"]>50) {
if($_COOKIE["mailed1"]!=1){
/*mail("leprakhauns2@lepslair.com", "WOAH RATE LIMIT 50", $_COOKIE['LAST_CALL']."
".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."
".$_SERVER["REMOTE_ADDR"]."
".$_SERVER['HTTP_USER_AGENT']);
*/
}
$_COOKIE["mailed1"]=1;
/*mail("leprakhauns2@lepslair.com", "WOAH RATE LIMIT MYSQL", "INSERT INTO ratelimiting SET date='".$_COOKIE['LAST_CALL']."',
addr='".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."',
ip='".$_SERVER["REMOTE_ADDR"]."'
browser='".$_SERVER['HTTP_USER_AGENT']."',
time='".time()."'");*/
}
$database->database_query("INSERT INTO ratelimiting SET `date`='".$_COOKIE['LAST_CALL']."',
addr='".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]." 111',
ip='".$_SERVER["REMOTE_ADDR"]."',
browser='".$_SERVER['HTTP_USER_AGENT']."',
`time`='".time()."', num='".$_COOKIE["ratecnt"]."', referrer='".$_SERVER['HTTP_REFERER']."', `post`='".var_export($_POST, true)."'");
//$data = 'Rate Limit Exceeded'; // rate limit
//header('Content-Type: application/json');
//die (json_encode($data)); */
}
}
if(!isset($_COOKIE["ratecnt1"])){
setcookie("ratecnt1", 0);
}
if(!isset($_COOKIE["LAST_CALL1"])){
setcookie("LAST_CALL1", 0);
}
setcookie("LAST_CALL1", date("Y-m-d h:i:s"));
// ########################### INITILIZATION #############################
$response = array();
$messages = array();
$buddyList = array();
$time = time();
if (var_check('popout'))
{
$popout = true;
}
else
{
$popout = false;
}
if (var_check('mobile'))
{
if ($status != 'busy')
{
$db->execute("
UPDATE arrowchat_status
SET status = 'busy'
WHERE userid = '" . $db->escape_string($userid) . "'
");
}
}
// ###################### START BUDDY LIST RECEIVE #######################
if (logged_in($userid))
{
// Refresh the user's session
updateUserSession();
if ($disable_buddy_list == 1 OR check_if_guest($userid) OR NO_FREIND_SYSTEM == 1 OR ($is_admin == 1 AND $admin_chat_all == 1) OR ($is_mod == 1 AND $admin_chat_all == 1))
{
$sql = get_online_list($userid,$time);
}
else
{
$sql = get_friend_list($userid,$time);
}
$result = $db->execute($sql);
while ($chat = $db->fetch_array($result))
{
if ($chat['userid'] != $userid)
{
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')
{
if ($is_admin == 1 OR $is_mod == 1)
{
$chat['status'] = 'available';
}
}
else
{
$chat['status'] = 'offline';
}
}
$link = get_link($chat['link'], $chat['userid']);
$avatar = get_avatar($chat['avatar'], $chat['userid']);
if (!empty($block_chats))
{
$block_chats_unserialized = unserialize($block_chats);
if (!is_array($block_chats_unserialized))
{
$block_chats_unserialized = array();
}
}
else
{
$block_chats_unserialized = array();
}
// Determine if the user should be displayed
$show_user = false;
if (check_if_guest($userid))
{
if ($guests_chat_with == 1)
{
if (check_if_guest($chat['userid']))
$show_user = true;
}
else if ($guests_chat_with == 2)
{
$show_user = true;
}
else if ($guests_chat_with == 3)
{
if (!check_if_guest($chat['userid']))
$show_user = true;
}
else if ($guests_chat_with == 4)
{
if ($chat['is_admin'] == 1)
$show_user = true;
}
else
{
$show_user = true;
}
}
else
{
if ($users_chat_with == 1)
{
if (check_if_guest($chat['userid']))
$show_user = true;
}
else if ($users_chat_with == 2)
{
$show_user = true;
}
else if ($users_chat_with == 3)
{
if (!check_if_guest($chat['userid']))
$show_user = true;
}
else if ($guests_chat_with == 4)
{
if ($chat['is_admin'] == 1)
$show_user = true;
}
else
{
$show_user = true;
}
}
if ($hide_admins_buddylist == 1 AND $chat['is_admin'] == 1)
{
$show_user = false;
}
if (($is_admin == 1 AND $admin_chat_all == 1) OR ($is_mod == 1 AND $admin_chat_all == 1))
{
$show_user = true;
}
if (!in_array($chat['userid'], $block_chats_unserialized))
{
if (!empty($chat['username']) AND $show_user)
{
$buddyList[] = array('id' => $chat['userid'], 'n' => strip_tags($chat['username']), 's' => $chat['status'], 'a' => $avatar, 'l' => $link, 'admin' => $chat['is_admin']);
}
}
}
}
if ($guests_can_chat == 1)
{
$guest_sql = get_guest_list();
$result = $db->execute($guest_sql);
while ($chat = $db->fetch_array($result))
{
if ($chat['userid'] != $userid)
{
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')
{
if ($is_admin == 1 OR $is_mod == 1)
{
$chat['status'] = 'available';
}
}
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']);
if (!empty($block_chats))
{
$block_chats_unserialized = unserialize($block_chats);
if (!is_array($block_chats_unserialized))
{
$block_chats_unserialized = array();
}
}
else
{
$block_chats_unserialized = array();
}
// Determine if the user should be displayed
$show_user = false;
if (check_if_guest($userid))
{
if ($guests_chat_with == 1)
{
if (check_if_guest($chat['userid']))
$show_user = true;
}
else if ($guests_chat_with == 2)
{
$show_user = true;
}
else if ($guests_chat_with == 3)
{
if (!check_if_guest($chat['userid']))
$show_user = true;
}
else if ($guests_chat_with == 4)
{
if ($chat['is_admin'] == 1)
$show_user = true;
}
else
{
$show_user = true;
}
}
else
{
if ($users_chat_with == 1)
{
if (check_if_guest($chat['userid']))
$show_user = true;
}
else if ($users_chat_with == 2)
{
$show_user = true;
}
else if ($users_chat_with == 3)
{
if (!check_if_guest($chat['userid']))
$show_user = true;
}
else if ($guests_chat_with == 4)
{
if ($chat['is_admin'] == 1)
$show_user = true;
}
else
{
$show_user = true;
}
}
if ($hide_admins_buddylist == 1 AND $chat['is_admin'] == 1)
{
$show_user = false;
}
if (($is_admin == 1 AND $admin_chat_all == 1) OR ($is_mod == 1 AND $admin_chat_all == 1))
{
$show_user = true;
}
if (!in_array($chat['userid'], $block_chats_unserialized))
{
if (!empty($chat['username']) AND $show_user)
{
$buddyList[] = array('id' => $chat['userid'], 'n' => stripslashes(strip_tags($chat['username'])), 's' => $chat['status'], 'a' => $avatar, 'l' => $link, 'admin' => $chat['is_admin']);
}
}
}
}
}
$response['buddylist'] = $buddyList;
}
header('Content-type: application/json; charset=UTF-8');
echo json_encode($response);
close_session();
exit;
?>