Example #1
0
function api_exit($db_name, $table_name, $apikey)
{
    if (!api_valid($db_name, $table_name, $apikey)) {
        jsonp_nocache_exit(array('status' => 'error', 'error' => 'api key error'));
    }
}
Example #2
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");
Example #3
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));