<?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");
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)); }
$req = get_param(); list($check_what) = null_exit($req, 'what'); if ($check_what === 'logos') { $outpu_logos = array(); $logo_dir = dirname(__FILE__) . '/uploads/logo'; foreach (glob("{$logo_dir}/*") as $file) { $file_uri = substr($file, strlen($_SERVER['DOCUMENT_ROOT'])); $outpu_logos[] = $file_uri; } jsonp_nocache_exit(array('status' => 'ok', 'count' => count($outpu_logos), 'items' => $outpu_logos)); } if ($check_what === 'values') { list($db, $table, $field) = null_exit($req, 'db', 'table', 'field'); $excepts = isset($req['except']) ? $req['except'] : array(); $filters = isset($req['filters']) ? $req['filters'] : array(); $table_root = table_root($db, $table); $res = array(); foreach (glob("{$table_root}/*") as $file) { if (is_dir($file)) { continue; } if (!preg_match('~/(\\d+)\\.json$~', $file, $matches)) { continue; } $data_obj = merge_fields(object_read($file)); if (empty($data_obj)) { continue; } $values = isset($data_obj[$field]) ? $data_obj[$field] : null; if (empty($values)) { continue;
function wh_event($db, $table, $event, $data = null) { $table_root = table_root($db, $table); $db_schema = object_read(dirname($table_root) . '/schema.json'); $db_hooks = @$db_schema['caption']['hooks']; !empty($db_hooks) or $db_hooks = array(); $table_schema = object_read("{$table_root}/schema.json"); $table_hooks = @$table_schema['caption']['hooks']; !empty($table_hooks) or $table_hooks = array(); $hooks = array_values(array_merge($db_hooks, $table_hooks)); if (empty($hooks)) { return false; } if (empty($data)) { $data = array(); } if (!is_array($data)) { $data = array($data); } $wh_data = array(); $wh_data['domain'] = db_domain(); $wh_data['db'] = $db; $wh_data['table'] = $table; $wh_data['items'] = $data; $wh_data['event'] = $event; $wh_data['hooks'] = $hooks; queue_in('webhook', array($wh_data)); if (function_exists('wh_checkpoint')) { wh_checkpoint(); } return true; }
<?php require_once 'functions.php'; header('Content-type: text/html; charset=utf-8'); $req = get_param(); list($db_name, $table_name, $apikey) = null_exit($req, 'db_name', 'table_name', 'apikey'); api_exit($db_name, $table_name, $apikey); $table_path = table_root($db_name, $table_name); $schema = object_read("{$table_path}/schema.json"); $fields = $schema['fields']; $onebox_url_routes = array(); foreach ($fields as $group_name => $group_data) { foreach ($group_data as $field_name => $field_type) { if (preg_match('/^jqxListBox-onebox/i', $field_type)) { $onebox_url_routes[] = [$group_name, $field_name]; } } } $counter_changed = 0; $counter_constant = 0; $counter_all = 0; foreach (glob("{$table_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)) {
function get_listview_column($db_name, $table_name, $field_name) { $table_root = table_root($db_name, $table_name); $schema = object_read("{$table_root}/schema.json"); $listview_data = object_read("{$table_root}/listview.json"); $id_index = array_search($field_name, $schema['listview']); $rep_list = array(); foreach ($listview_data as $subitem) { $id_cmp = $subitem[$id_index]; if (empty($id_cmp)) { continue; } if (is_array($id_cmp)) { foreach ($id_cmp as $item) { if (!in_array($item, $rep_list)) { $rep_list[] = $item; } } } else { if (!in_array($id_cmp, $rep_list)) { $rep_list[] = $id_cmp; } } } return $rep_list; }
function cp_table_exit($req) { $from_db = $req['db_name']; $from_table = $req['table_name']; $copyto_db = $req['db_dest']; $is_remove = @$req['remove_src'] === 'true'; null_exit($from_db, $from_table, $copyto_db); $table_root = table_root($from_db, $from_table); if (!file_exists($table_root)) { jsonp_nocache_exit(array('status' => 'error', 'error' => 'src table error')); } $copyto_table = get_bkable_table($copyto_db, $from_table); if ($copyto_table === false) { jsonp_nocache_exit(array('status' => 'error', 'error' => 'too mach same tables')); } $copyto_root = table_root($copyto_db, $copyto_table); if (smartCopy($table_root, $copyto_root) === false) { jsonp_nocache_exit(array('status' => 'error', 'error' => 'copy exec error')); } wh_event($copyto_db, $copyto_table, 'create'); if ($is_remove) { rmdir_Rf($table_root); wh_event($from_db, $from_table, 'destroy'); } jsonp_nocache_exit(array('status' => 'ok')); }