コード例 #1
0
ファイル: data.php プロジェクト: sdgdsffdsfff/web-pusher
function handle_list_command($list_name, $cmd_name)
{
    switch ($cmd_name) {
        case 'list':
            $res = mmc_array_values($list_name);
            if (count($res) === 0) {
                update_sched_tasks($list_name);
                $res = mmc_array_values($list_name);
            }
            return jsonp($res);
        case 'create':
        case 'update':
            $key_name = @$_POST['name'];
            if ($key_name) {
                return result_ok(mmc_array_set($list_name, md5($key_name), $_POST));
            } else {
                return '{"res": false}';
            }
        case 'delete':
            mmc_array_del($list_name, md5($_POST['name']));
            if (mmc_array_length($list_name) === 0) {
                del_cached_file($list_name);
            }
            return result_ok(true);
        case 'flush':
            sched_changed();
            return '{"res": false}';
        case 'names':
            return jsonp(mmc_array_keys($list_name));
        case 'tags':
            $items = mmc_array_values($list_name);
            $output_tags = [];
            foreach ($items as $item) {
                $tags = @$item['tags'];
                if ($tags) {
                    $tag_list = explode(' ', $tags);
                    foreach ($tag_list as $tag) {
                        $output_tags[] = $tag;
                    }
                }
            }
            return jsonp($output_tags);
        default:
            die('{"res": false}');
    }
}
コード例 #2
0
ファイル: omp.php プロジェクト: sdgdsffdsfff/web-pusher
function handle_reset()
{
    $device = @$_GET['device'];
    if (empty($device)) {
        $device = get_device();
    }
    if (empty($device)) {
        return 'no device';
    }
    //删除保存了的在线列表
    mmc_array_del(NS_DEVICE_LIST, $device);
    //删除保存了的账户信息
    $mem = api_open_mmc();
    $mem->ns_delete(NS_BINDED_LIST, $device);
    $mem->ns_delete(NS_BINDED_CAPTION, $device);
    foreach (mmc_array_keys(NS_BINDING_LIST) as $platform) {
        $ns_bind_list = NS_BINDING_LIST . $platform;
        mmc_array_del($ns_bind_list, $device);
    }
    //删除保存了的计划任务消息记录
    $mem->ns_delete(NS_SCHED_DEVICE, $device);
    $mem->ns_delete(NS_PLANS_DEVICE, $device);
    new_user($device, time() + COOKIE_TIMEOUT_NEW);
    //清空cookie
    unset($_COOKIE[COOKIE_DEVICE_SAVED]);
    setcookie(COOKIE_DEVICE_SAVED, '', time() - 3600, '/', COOKIE_DOMAIN);
    return 'succeed';
}