Created
October 20, 2011 07:55
-
-
Save polymorphm/1300629 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// -*- mode: php; coding: utf-8 -*- | |
// | |
// <copyright-and-licence-header--blahblahblah> | |
if (!ini_get('display_errors')) { | |
ini_set('display_errors', 1); | |
} | |
error_reporting(E_ALL); | |
require_once dirname(__FILE__).'/libs/common.php'; | |
require_once dirname(__FILE__).'/libs/chat.php'; | |
require_once dirname(__FILE__).'/libs/operator.php'; | |
require_once dirname(__FILE__).'/libs/groups.php'; | |
function has_online_operators__main () { | |
if ($_SERVER['REQUEST_METHOD'] != 'POST' || | |
$_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') { | |
// raising error! ajax-only allowed | |
$data = array( | |
'error' => array( | |
'type' => 'ForbiddenHTTPError', | |
'message' => 'HTTP Error: 403 Forbidden', | |
), | |
); | |
@header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden'); | |
@header('Content-Type: application/json;charset=utf-8'); | |
echo json_encode($data); | |
return; | |
} | |
$groupid = verifyparam( "group", "/^\d{1,8}$/", ""); | |
if($groupid) { | |
loadsettings(); | |
if($settings['enablegroups'] == '1') { | |
$group = group_by_id($groupid); | |
if(!$group) { | |
$groupid = ""; | |
} | |
} else { | |
$groupid = ""; | |
} | |
} | |
$data = array( | |
'is_online' => $is_online = has_online_operators($groupid), | |
'error' => NULL, | |
); | |
@header('Content-Type: application/json;charset=utf-8'); | |
echo json_encode($data); | |
} | |
has_online_operators__main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment