<?php require_once '../../admin/functions.php'; require_once 'Eventio/BBQ.php'; use Eventio\BBQ; use Eventio\BBQ\Queue\DirectoryQueue; use Eventio\BBQ\Job\Payload\StringPayload; define('CACHE_PATH', 'cache/bbq'); $req = get_param(); list($name, $key, $data) = null_exit($req, 'name', 'table_name', 'data', 'apikey'); items_exit($data, 'ident', 'facility', 'priority', 'message'); $bbq = new BBQ(); $queue = new DirectoryQueue('tasks', dirname(__FILE__) . '/' . CACHE_PATH); $bbq->registerQueue($queue); $bbq->pushJob('tasks', new StringPayload('New task payload')); $job = $bbq->fetchJob('tasks'); $payload = $job->getPayload(); echo $payload; $bbq->finalizeJob($job);
<?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);
<?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.'));
require_once 'functions.php'; denies_with_json(); $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; }
<?php require_once '../../admin/functions.php'; require_once 'php-export-data.class.php'; $req = get_param(); list($db_name, $table_name) = null_exit($req, 'db', 'table'); $columns = objects_read($db_name, $table_name, true); $exporter = new ExportDataExcel('browser', $db_name . '-' . $table_name . '.xls'); $exporter->initialize(); //开始发送表格流数据到浏览器 $has_header = false; foreach ($columns as $column) { if (!$has_header) { $exporter->addRow(array_keys($column)); $has_header = true; } $datas = array(); foreach ($column as $key => $val) { if (is_array($val)) { $unicode_str = json_encode($val); $datas[] = decodeUnicode($unicode_str); } else { $datas[] = $val; } } $exporter->addRow($datas); } $exporter->finalize(); //完成页脚,发送剩余数据到浏览器 function decodeUnicode($str) {
<?php require_once '../../admin/functions.php'; define('CACHE_PATH', 'cache/msg'); define('TIME_INTERVAL', 30); define('MAX_DEQUEUE_COUNT', 1000); define('ITEMS_SUFFIX', 'bucket'); if (is_direct_call()) { $req = get_param(); list($name) = null_exit($req, 'name'); $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)
<?php require_once 'functions.php'; null_exit(@$_GET['type']); defined('UPLOAD_PATH') or define('UPLOAD_PATH', db_root(WWWROOT_DIR) . '/uploads'); defined('CONFIG_PATH') or define('CONFIG_PATH', db_root(GLOBAL_DIR)); $settings = array('icon' => array('list' => 'icon_libs.json', 'max_file_size' => 1024000, 'page_size' => 16 * 16, 'thumb_x' => 32, 'thumb_y' => 32, 'prev_x' => 64, 'prev_y' => 64, 'types' => array('jpg', 'png', 'jpeg', 'gif')), 'logo' => array('list' => 'logo_libs.json', 'max_file_size' => 2048000, 'page_size' => 8 * 8, 'thumb_x' => 64, 'thumb_y' => 64, 'prev_x' => 256, 'prev_y' => 256, 'types' => array('jpg', 'png', 'jpeg', 'gif')), 'image' => array('list' => 'image_libs.json', 'max_file_size' => 4096000, 'page_size' => 8 * 8, 'thumb_x' => 128, 'thumb_y' => 128, 'prev_x' => 512, 'prev_y' => 512, 'types' => array('jpg', 'png', 'jpeg', 'gif')), 'video' => array('list' => 'video_libs.json', 'max_file_size' => 0, 'page_size' => 8 * 8, 'types' => array()), 'music' => array('list' => 'music_libs.json', 'max_file_size' => 0, 'page_size' => 8 * 8, 'types' => array()), 'file' => array('list' => 'file_libs.json', 'max_file_size' => 0, 'page_size' => 32, 'types' => array())); $setting = $settings[$_GET['type']]; $is_image = in_array($_GET['type'], array('icon', 'logo', 'image')); $cmd = isset($_GET['cmd']) ? $_GET['cmd'] : 'read'; //这是读取上传库的列表长度 if ($cmd === 'count') { $list_file = CONFIG_PATH . '/' . $setting['list']; $datas = async_read($list_file); jsonp_nocache_exit(count($datas)); } //这是读取上传库的列表,全部读取,仅仅ID if ($cmd === 'list') { $startindex = isset($_GET['startindex']) ? intval($_GET['startindex']) : null; $endindex = isset($_GET['endindex']) ? intval($_GET['endindex']) : null; $pagesize = isset($_GET['pagesize']) ? intval($_GET['pagesize']) : null; $list_file = CONFIG_PATH . '/' . $setting['list']; $datas = async_read($list_file); if (empty($endindex) or empty($pagesize)) { jsonp_nocache_exit($datas); } if (empty($startindex)) { $startindex = 0; } $count = count($datas); $index = $startindex * $pagesize;
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')); }
<?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));