예제 #1
0
header("Content-Type:text/json; charset=utf-8");
ini_set('display_errors', false);
//设置服务器不显示
//header("Content-Type: application/json");
//$topic_id=$_GET["topic_id"];
$con = mysql_connect('localhost', 'root', '123456');
if (!mysql_select_db("statistic_result", $con)) {
    die(mysql_error());
}
mysql_query("set names utf8");
$userInfo = array();
if ($_SERVER['REQUEST_METHOD'] == "GET") {
    $jsonp = $_GET["callback"];
    $sex_info = sex_callback();
    $vip_info = vip_callback();
    $terminal_info = terminal();
    $age_info = age_callback();
    global $userInfo;
    $userInfo["sex"] = $sex_info;
    $userInfo["vip"] = $vip_info;
    $userInfo["terminal"] = $terminal_info;
    $userInfo["age"] = $age_info;
    $jsonArr0 = json_encode($userInfo);
    $jsonArr = $jsonp . '(' . $jsonArr0 . ')';
    echo $jsonArr;
    exit;
}
//用户年龄
function age_callback()
{
    global $con;
예제 #2
0
파일: relay.php 프로젝트: pedra/Xhat
function sendMessage($msg, $user = null, $channel = null)
{
    terminal('MESSAGE OUT', $msg);
    //get global for users arrays
    global $clients, $users, $db;
    //Send for ALL
    if ($user == null) {
        foreach ($clients as $k => $v) {
            if (isset($users[$k]['channel']) && $users[$k]['channel'] == $channel && isset($users[$k]['userid'])) {
                $tmp = mask($db->encMSG(json_encode($msg), $users[$k]['userid']));
                socket_write($v, $tmp, strlen($tmp));
            }
        }
    } elseif (is_resource($clients[$user])) {
        $tmp = mask($db->encMSG(json_encode($msg), $users[$user]['userid']));
        socket_write($clients[$user], $tmp, strlen($tmp));
    }
}