<?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");
$db_name = @$req['db_name']; $table_name = @$req['table_name']; $db_name || ($db_name = 'default'); $table_name || ($table_name = 'default'); $table_root = table_root($db_name, $table_name); $http_prefix = 'http://' . $_SERVER['HTTP_HOST']; $req_map_key = @$req['name']; if (empty($req_map_key)) { jsonp_nocache_exit(['status' => 'error', 'error' => 'map_key is empty.']); } $schema = object_read("{$table_root}/schema.json"); 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'];
function get_mapper_values($db_name, $table_name, $map_keys) { $table_root = table_root($db_name, $table_name); $mapper = object_read("{$table_root}/mapper.json"); if (empty($mapper)) { return false; } $db_domain = db_domain(); $current_url = get_current_url(false); $results = array(); foreach ($map_keys as $ori_map_key) { $map_key = mapper_key($ori_map_key); $map_val = @$mapper[$map_key]; if (empty($map_val)) { $results[$ori_map_key] = null; continue; } $map_val = intval($map_val); $data_file = "{$table_root}/{$map_val}.json"; if (!file_exists($data_file)) { $results[$ori_map_key] = null; continue; } $data_uri = substr($data_file, strlen($_SERVER['DOCUMENT_ROOT'])); $data_uri = preg_replace('/\\/' . $db_domain . '/i', '', $data_uri); $data_url = $current_url . $data_uri; $result_item = array($map_val, $data_file, $data_url); $results[$ori_map_key] = $result_item; } return $results; }
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; }