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')); } }
function wh_event_file($data_file, $event) { if (preg_match('~/databases/([^/]+)/([^/]+)/([^/]+)/([\\d]+)\\.json$~', $data_file, $matchs)) { $db_name = $matchs[2]; $table_name = $matchs[3]; $id = $matchs[4]; wh_event($db_name, $table_name, $event, $id); } }
function create_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)); } $base_path = "{$filename}/{$req['name']}"; if (file_exists($base_path)) { jsonp_nocache_exit(array('status' => 'error', 'error' => 'The request table already exists.', 'ori_cmd' => $req)); } else { mkdir($base_path, 0744); } $caption = array(); $caption['title'] = $req['title']; $caption['content'] = $req['content']; $caption['image'] = $req['image']; $caption['key'] = $req['key']; $listview = array(); array_push($listview, 'ID', 'Name'); $fields = array(); $general = array(); $general['ID'] = 'jqxInput-id'; $general['CREATE'] = 'jqxInput-time'; $general['TIME'] = 'jqxInput-time'; $general['Name'] = 'jqxInput-name'; $fields['general'] = $general; $onebox = array(); $onebox['title'] = 'ID'; $onebox['desc'] = 'Name'; $onebox['image'] = ''; $schema = array(); $schema['caption'] = $caption; $schema['listview'] = $listview; $schema['fields'] = $fields; $schema['onebox'] = $onebox; object_save("{$base_path}/schema.json", $schema); object_save("{$base_path}/listview.json", array()); object_save("{$base_path}/options.json", array()); wh_event($req['db_name'], $req['name'], 'create'); jsonp_nocache_exit(array('status' => 'ok')); }