示例#1
0
function wh_trigger_exit($db, $table, $event, $data)
{
    denies_with_json();
    if (!in_array($event, array('update', 'refresh'))) {
        jsonp_nocache_exit(array('status' => 'error', 'error' => 'invalid event type'));
    }
    if (wh_event($db, $table, $event, $data) === true) {
        jsonp_nocache_exit(array('status' => 'ok'));
    } else {
        jsonp_nocache_exit(array('status' => 'error'));
    }
}
示例#2
0
function process_onebox_result($req_url, $res_type)
{
    if ($res_obj = get_onebox_url($req_url)) {
        if ($res_type === 'json') {
            $res_obj['status'] = 'ok';
            return jsonp_nocache_exit($res_obj);
        }
        return html_nocache_exit(onebox_output($res_obj));
    } else {
        if ($res_type === 'json') {
            return jsonp_nocache_exit(array('status' => 'error', 'error' => 'no handler'));
        } else {
            return html_nocache_exit($req_url);
        }
    }
}
示例#3
0
<?php

require_once '../../admin/functions.php';
$is_mobile = preg_match('/(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i', $useragent) || preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i', substr($_SERVER['HTTP_USER_AGENT'], 0, 4));
jsonp_nocache_exit(['status' => 'ok', 'is_mobile' => $is_mobile]);
示例#4
0
            $is_matched_all = true;
            foreach ($filters as $filter) {
                if (mb_strpos($filter_source, $filter) === false) {
                    $is_matched_all = false;
                    break;
                }
            }
            if (!$is_matched_all) {
                continue;
            }
        }
        if (is_array($values)) {
            foreach ($values as $value) {
                if (!in_array($value, $res)) {
                    $res[] = $value;
                }
            }
        } else {
            if (!in_array($value, $res)) {
                $res[] = $value;
            }
        }
    }
    jsonp_nocache_exit(array('status' => 'ok', 'count' => count($res), 'items' => $res));
}
function walk_cb($item, $key, &$filter_source)
{
    $filter_source .= ' | ' . $item;
}
jsonp_nocache_exit(array('status' => 'error', 'error' => 'command error'));
示例#5
0
<?php

require_once 'functions.php';
denies_with_json();
$req = get_param();
list($db_name, $table_name, $check_what, $check_is) = null_exit($req, 'db_name', 'table_name', 'what', 'is');
if ($check_what === 'mapper') {
    list($mapped_id, $data_file, $data_url) = mapper_value_exit($db_name, $table_name, $check_is);
    jsonp_nocache_exit(array('status' => 'ok', 'id' => $mapped_id, 'url' => $data_url));
}
jsonp_nocache_exit(array('status' => 'error', 'error' => 'unknow command.'));
示例#6
0
<?php

/*-----------------------------
将jsondb的一个数据表格,当做列表来存取数据
(1)支持分页获取
(2)支持条件过滤
-----------------------------*/
require_once '../../admin/functions.php';
$db_name = 'default';
$table_name = 'default';
jsonp_nocache_exit($_GET);
示例#7
0
function edit_table_exit($req)
{
    $filename = dbs_path() . "/{$req['db_name']}";
    if (!file_exists($filename)) {
        jsonp_nocache_exit(array('status' => 'error', 'error' => 'The request database not found.', 'ori_cmd' => $req));
    }
    $old_name = "{$filename}/{$req['ori_name']}";
    if (!file_exists($old_name)) {
        jsonp_nocache_exit(array('status' => 'error', 'error' => 'The request table not found.', 'ori_cmd' => $req));
    }
    $filename = "{$filename}/{$req['name']}";
    if ($req['ori_name'] !== $req['name']) {
        rename($old_name, $filename);
    }
    touch($filename);
    $filename = "{$filename}/schema.json";
    $schema = object_read($filename);
    $caption = array();
    $caption['title'] = @$req['title'];
    $caption['content'] = @$req['content'];
    $caption['image'] = @$req['image'];
    $caption['key'] = @$req['key'];
    $caption['hooks'] = isset($req['hooks']) ? array_values($req['hooks']) : array();
    $schema['caption'] = $caption;
    object_save($filename, $schema);
    jsonp_nocache_exit(array('status' => 'ok'));
}
示例#8
0
<?php

require_once '../../admin/functions.php';
$req = get_param();
list($db_name, $table_name, $data, $apikey) = null_exit($req, 'db_name', 'table_name', 'data', 'apikey');
api_exit($db_name, $table_name, $apikey);
items_exit($data, 'ident', 'facility', 'priority', 'title');
$output = append_new_data($db_name, $table_name, $data);
unset($output['listview']);
jsonp_nocache_exit($output);
示例#9
0
function update_data_exit($req)
{
    $force_empty = @$req['force_empty'] === 'true';
    jsonp_nocache_exit(update_current_data(@$req['db_name'], @$req['table_name'], @$req['data'], $force_empty));
}
示例#10
0
if (empty($schema)) {
    jsonp_nocache_exit(['status' => 'error', 'error' => 'not found schema.json']);
}
$mapper = object_read("{$table_root}/mapper.json");
$map_key = mapper_key($req_map_key);
$map_val = @$mapper[$map_key];
if (empty($map_val)) {
    $map_val = strval(intval($req_map_key));
}
$map_file = "{$table_root}/{$map_val}.json";
if (!file_exists($map_file)) {
    jsonp_nocache_exit(['status' => 'error', 'error' => 'not found target file']);
}
$onebox = onebox_object($schema, $map_file);
$res = array();
$res['provider_name'] = '任玩堂游戏数据库';
$res['provider_url'] = 'http://db.appgame.com/';
$res['favicon_url'] = 'http://www.appgame.com/favicon.ico';
$res['ori_url'] = $onebox['url'];
$res['ID'] = $onebox['id'];
$res['title'] = $onebox['title'];
$res['image'] = $onebox['image'];
$res['update_time'] = $onebox['time'];
$res['create_time'] = $onebox['ctime'];
$res['description'] = $onebox['desc'];
$res_type = @$req['type'];
if ($res_type === 'json') {
    $res['status'] = 'ok';
    return jsonp_nocache_exit($res);
}
return html_nocache_exit(onebox_output($res));
示例#11
0
function getdata_exit($db_name, $table_name, $name)
{
    $map_key = $name;
    $table_root = table_root($db_name, $table_name);
    $mapper = object_read("{$table_root}/mapper.json");
    if (empty($mapper)) {
        jsonp_nocache_exit(['status' => 'error', 'error' => 'mapper file not found']);
    }
    $map_key = mapper_key($map_key);
    $map_val = @$mapper[$map_key];
    $map_file = "{$table_root}/{$map_val}.json";
    if (!file_exists($map_file)) {
        jsonp_nocache_exit(['status' => 'error', 'error' => 'data file not found']);
    }
    $data = object_read($map_file);
    if (empty($data)) {
        jsonp_nocache_exit(['status' => 'error', 'error' => 'data file is empty']);
    }
    items_exit($data);
    return $data;
}
示例#12
0
<?php

require_once '../../admin/functions.php';
$req = get_param();
$db_name = @$req['db_name'];
$table_name = @$req['table_name'];
$db_name || ($db_name = 'default');
$table_name || ($table_name = 'default');
$map_key = @$req['name'];
$direct = @$req['direct'];
list($map_val, $data_file, $data_url) = mapper_value_exit($db_name, $table_name, $map_key);
if ($direct === 'true') {
    jsonp_nocache_exit(object_read($data_file));
}
if ($direct === 'false') {
    jsonp_nocache_exit(array('status' => 'ok', 'ID' => $map_val, 'data_file' => $data_url));
}
header("Location: {$data_url}");
示例#13
0
    $req_page = min($req_page, $max_pages);
    if ($order !== 'desc') {
        $list_data = array_reverse($list_data);
        $order = 'asc';
    }
    $res_list = array_slice($list_data, ($req_page - 1) * $page_size, $page_size);
    $results = array();
    $md5_src = '';
    foreach ($res_list as $uni_name) {
        $results[] = object_read(UPLOAD_PATH . "/{$uni_name}.json");
        $md5_src .= $uni_name;
    }
    jsonp_nocache_exit(array('status' => 'ok', 'total' => $total, 'order' => $order, 'page' => $req_page, 'pages' => $max_pages, 'count' => count($results), 'digest' => md5($md5_src), 'results' => $results));
}
if ($cmd !== 'write') {
    jsonp_nocache_exit(array('status' => 'error', 'error' => 'not valid cmd'));
}
//接下来是处理上传文件
$origin_dir = UPLOAD_PATH . "/ori";
$preview_dir = UPLOAD_PATH . "/prev";
$thumbnail_dir = UPLOAD_PATH . "/thumb";
$uploaed_tmpname = @$_FILES["fileToUpload"]["tmp_name"];
$uploaed_name = @$_FILES["fileToUpload"]["name"];
$upload_size = @$_FILES["fileToUpload"]["size"];
$upload_type = pathinfo($uploaed_name, PATHINFO_EXTENSION);
$uni_name = md5_file($uploaed_tmpname);
$save_name = "{$uni_name}.{$upload_type}";
$save_json = "{$uni_name}.json";
//参数检查
if (one_null($uploaed_tmpname, $uploaed_name, $upload_size, $upload_type, $uni_name)) {
    exit('9000');
示例#14
0
<?php

require_once '../../admin/functions.php';
jsonp_nocache_exit(get_browser());
示例#15
0
function mapper_value_exit($db_name, $table_name, $map_key)
{
    $result = get_mapper_value($db_name, $table_name, $map_key);
    if ($result === false) {
        jsonp_nocache_exit(array('status' => 'error', 'error' => 'no valid mapped id'));
    }
    return $result;
}
示例#16
0
<?php

require_once '../../admin/functions.php';
define('AUTO_FIELD_LIST', 'auto-field-list');
define('AUTO_FIELD_CAPVIEW', 'auto-field-capview');
$req = get_param();
$db_name = @$req['db_name'];
$db_name || ($db_name = 'default');
$table_name = @$req['table_name'];
$table_name || ($table_name = 'default');
$list_caption = @$req['caption'];
$list_item = @$req['caption'];
$map_key = mapper_key(@$req['mapper']);
if (!api_valid($db_name, $table_name, @$req['apikey'])) {
    jsonp_nocache_exit(array('status' => 'error', 'error' => 'api key error'));
}
if (empty($map_key)) {
    jsonp_nocache_exit(array('status' => 'error', 'error' => 'not mapper in parameter'));
}
$table_root = table_root($db_name, $table_name);
$schema = object_read("{$table_root}/schema.json");
$mapper = object_read("{$table_root}/mapper.json");
示例#17
0
    $items = @$req['items'];
    if (!empty($items)) {
        if (enqueue_items($name, $items)) {
            jsonp_nocache_exit(array('status' => 'ok'));
        } else {
            jsonp_nocache_exit(array('status' => 'error', 'error' => 'enqueue to file error'));
        }
    } else {
        if ($items = dequeue_items($name, @$req['max'])) {
            jsonp_nocache_exit(array('status' => 'ok', 'count' => count($items), 'items' => $items));
        } else {
            if (file_exists(current_queuing_file($name))) {
                $time_to_wait = TIME_INTERVAL - intval(time()) % TIME_INTERVAL;
                jsonp_nocache_exit(array('status' => 'error', 'error' => 'wait for queue item', 'wait_time' => $time_to_wait));
            } else {
                jsonp_nocache_exit(array('status' => 'error', 'error' => 'empty queue'));
            }
        }
    }
}
function enqueue_items($name, $items)
{
    $file_to_write = current_queuing_file($name, true);
    $data_to_write = '';
    if (is_array($items)) {
        foreach ($items as $item) {
            $item_text = json_encode($item);
            $data_to_write .= $item_text . PHP_EOL;
        }
    } else {
        $data_to_write = json_encode($items) . PHP_EOL;
示例#18
0
function combobox_to_checkbox_exit($req)
{
    $db_name = @$req['db_name'];
    $table_name = @$req['table_name'];
    $field = @$req['field'];
    $seperator = @$req['seperator'];
    if (all_empty(array($db_name, $table_name, $field, $seperator))) {
        jsonp_nocache_exit(array('status' => 'error', 'error' => 'command parameter error.'));
    }
    $data_path = table_root($db_name, $table_name);
    $schema = object_read("{$data_path}/schema.json");
    $fields = $schema['fields'];
    $group_name = null;
    $field_type = null;
    foreach ($fields as $group => $items) {
        foreach ($items as $name => $value) {
            if ($name === $field) {
                $group_name = $group;
                $field_type = $value;
                break 2;
            }
        }
    }
    if (all_empty(array($group_name, $field_type))) {
        jsonp_nocache_exit(array('status' => 'error', 'error' => 'command parameter field name error.'));
    }
    if ($field_type !== 'jqxComboBox') {
        jsonp_nocache_exit(array('status' => 'error', 'error' => 'the target field not a combobox.'));
    }
    $schema['fields'][$group_name][$field] = 'jqxCheckBox';
    object_save("{$data_path}/schema.json", $schema);
    foreach (glob("{$data_path}/*.json") as $file) {
        if (is_dir($file)) {
            continue;
        }
        if (!preg_match('~/(\\d+)\\.json$~', $file, $matches)) {
            continue;
        }
        $item_id = $matches[1];
        $data_obj = object_read($file);
        if (empty($data_obj)) {
            continue;
        }
        $combo_str = @$data_obj[$group_name][$field];
        if (empty($combo_str)) {
            continue;
        }
        $check_arr = explode($seperator, $combo_str);
        $data_obj[$group_name][$field] = $check_arr;
        object_save($file, $data_obj);
    }
    $counter = refresh_listview($db_name, $table_name);
    jsonp_nocache_exit(array('status' => 'ok', 'counter' => $counter));
}
示例#19
0
<?php

/*-----------------------------
将jsondb的多个数据表格,当做配置数据的时候使用
可以一次获取多张数据表的数据作为一个配置列表
apikey就选用该数据库的密钥
-----------------------------*/
require_once '../../admin/functions.php';
$req = get_param();
list($db_name, $tables, $apikey) = null_exit($req, 'db', 'tables', 'apikey');
if (!is_array($tables)) {
    jsonp_nocache_exit(array('status' => 'error', 'error' => 'tables must be array'));
}
$results = [];
foreach ($tables as $table_name) {
    if (!api_valid($db_name, $table_name, $apikey)) {
        continue;
    }
    $results[$table_name] = objects_read($db_name, $table_name);
}
jsonp_nocache_exit(array('status' => 'ok', 'md5' => md5(json_encode($results)), 'count' => count($results), 'items' => $results));