示例#1
0
function handle_sched_status($list_name, $task_id, $status)
{
    $mod_task = mmc_array_get($list_name, $task_id);
    if (empty($mod_task)) {
        return jsonp(['stauts' => 'no', 'result' => 'error']);
    }
    if (array_key_exists('finish_time', $mod_task)) {
        $mod_task['status'] = $status;
        return result_ok(mmc_array_set($list_name, $task_id, $mod_task));
    } else {
        return jsonp(['stauts' => 'no', 'result' => 'error']);
    }
}
示例#2
0
function handle_bind_account($PARAMS)
{
    $device = @$PARAMS['device'];
    $platform = @$PARAMS['plat'];
    $caption = @$PARAMS['cap'];
    $username = check_input(@$PARAMS['user']);
    $nickname = check_input(@$PARAMS['nick']);
    $cap_view = make_capview($username, $nickname, $caption);
    /********************************
    	判断新收到的账户,是否应该被收录	
    	********************************/
    if (empty($username) && empty($nickname)) {
        omp_trace($PARAMS);
        return return_bind(array('status' => 'error'));
    }
    if (count($username) > 100 || count($nickname) > 100) {
        omp_trace('username or nickname too long');
        return return_bind(array('status' => 'error'));
    }
    $platform_list = mmc_array_keys(NS_BINDING_LIST);
    if (!in_array($platform, $platform_list)) {
        mmc_array_set(NS_BINDING_LIST, $platform, $caption);
    }
    $ns_bind_list = NS_BINDING_LIST . $platform;
    $bind_info = mmc_array_get($ns_bind_list, $device);
    omp_trace($bind_info);
    $changed = false;
    if ($bind_info) {
        if ($username) {
            if ($bind_info['username'] != $username) {
                $bind_info['username'] = $username;
                $changed = true;
            }
        }
        if ($nickname) {
            if ($bind_info['nickname'] != $nickname) {
                $bind_info['nickname'] = $nickname;
                $changed = true;
            }
        }
    } else {
        $bind_info = array();
        $bind_info['username'] = $username;
        $bind_info['nickname'] = $nickname;
        $changed = true;
    }
    $mem = api_open_mmc();
    if (!$changed) {
        omp_trace('not changed');
        //绑定信息没有改变的时候,确定绑定显示列表是正常输出的
        if ($binded_list = $mem->ns_get(NS_BINDED_CAPTION, $device)) {
            if (in_array($cap_view, $binded_list)) {
                omp_trace($cap_view . ' in binded_list');
                omp_trace($binded_list);
                return return_bind(array('status' => 'ok'));
            } else {
                omp_trace('but binbed capview missed');
            }
        } else {
            omp_trace('but binbed capview error');
        }
    }
    /********************************
    		记录绑定的账户
    	********************************/
    //1、收录绑定信息
    if (mmc_array_set($ns_bind_list, $device, $bind_info) > 0) {
        $caption && mmc_array_caption($ns_bind_list, $caption);
        omp_trace('update caption: ' . $caption);
    }
    //2、制作绑定账户的标识列表
    $new_key = md5($caption . '@' . $platform . '@' . $device);
    $new_val = md5($username . '(' . $nickname . ')@' . $device);
    $changed = false;
    if ($binded_list = $mem->ns_get(NS_BINDED_LIST, $device)) {
        if ($binded_list[$new_key] !== $new_val) {
            $binded_list[$new_key] = $new_val;
            $changed = true;
        }
    } else {
        $binded_list[$new_key] = $new_val;
        $changed = true;
    }
    //更新绑定账户标记列表
    if ($changed) {
        $mem->ns_set(NS_BINDED_LIST, $device, $binded_list);
        omp_trace('update bind md5 info: ' . json_encode($binded_list));
    }
    //3、制作绑定账户显示列表
    if ($bind_account = $mem->ns_get(NS_BINDED_CAPTION, $device)) {
        if (!in_array($cap_view, $bind_account)) {
            $bind_account[] = $cap_view;
            $mem->ns_set(NS_BINDED_CAPTION, $device, $bind_account);
            omp_trace('set account info ok: ' . json_encode($bind_account));
        }
    } else {
        $mem->ns_set(NS_BINDED_CAPTION, $device, array($cap_view));
        omp_trace('set 1st account info ok: ' . $cap_view);
    }
    /********************************
    	异步通知第三方代码
    	********************************/
    $bind_info['device'] = $device;
    $bind_info['platform'] = $platform;
    $bind_info['caption'] = $caption;
    counter(COUNT_ON_BINDING);
    call_async_php('/on_account_binding.php', $bind_info);
    return return_bind(array('status' => 'ok'));
}