Exemple #1
0
function addMessage($name, $relation, $content)
{
    $array = array("name" => $name, "relation" => $relation, "content" => $content, "time" => date("Y-m-d H:i:s", time()));
    $encodeJson = json_encode($array);
    $decodeJson = json_decode($encodeJson);
    giant_lock();
    $filedata = getMessage("message.json");
    $json = json_decode($filedata);
    if ($json == null) {
        $json = array();
    }
    array_push($json, $decodeJson);
    $fp = fopen("message.json", "w");
    fwrite($fp, json_encode($json));
    fclose($fp);
    giant_unlock();
}
Exemple #2
0
function addMessage($author, $relationship, $msg)
{
    $array = array("author" => $author, "relationship" => $relationship, "msg" => $msg, "time" => date("Y-m-d H:i:s", time()));
    $encodeJson = json_encode($array);
    $decodeJson = json_decode($encodeJson);
    giant_lock();
    $filedata = getMessage("message.json");
    $json = json_decode($filedata);
    if ($json == null) {
        $json = array();
    }
    array_unshift($json, $decodeJson);
    $fp = fopen("message.json", "w");
    fwrite($fp, json_encode($json));
    fclose($fp);
    giant_unlock();
    return $array;
}
Exemple #3
0
        // it is not the weidota game client, forbid it
        operation_fail('代理出错,无法访问');
    }
}
// 网页访问 都是老师访问,需要检查SESSION
if (CHECK_SESSION) {
    checksession();
}
if (CHECK_ADMIN_PERMISSION) {
    $result = checkAdminPermisson();
    if (!$result) {
        operation_fail("你没有管理员权限");
    }
}
if (GIANT_LOCK) {
    giant_lock();
}
$__script_start_time = microtime(true);
if (CHECK_IMEI) {
    $ban_imeis = apcfetch("BAN_IMEIS");
    if (!$ban_imeis) {
        $ban_imeis = array();
        $data = db_fetch_all("select imei from ban_phone");
        foreach ($data as $e) {
            $imei = $e["imei"];
            $ban_imeis[$imei] = 1;
        }
    }
    $_imei = imei();
    $_ip = getIp();
    if (isset($ban_imeis[$_imei]) || isset($ban_imeis[$_ip])) {
Exemple #4
0
function curl_read($url, $timeout_ms = 5000)
{
    giant_unlock();
    // curl is slow, so unlock giant lock before cUrl
    try {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        // cross
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT_MS, $timeout_ms);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        $data = curl_exec($ch);
        if (!curl_errno($ch)) {
            curl_close($ch);
        } else {
            $error = curl_error($ch);
            curl_close($ch);
            throw new Exception($error);
        }
        giant_lock();
        return $data;
    } catch (Exception $ex) {
        giant_lock();
        throw $ex;
    }
}