Exemplo n.º 1
0
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));
}
Exemplo n.º 2
0
function put_object($db_name, $table_name, $base_name, $data)
{
    $table_root = table_root($db_name, $table_name);
    return object_save("{$table_root}/{$base_name}.json", $data);
}
Exemplo n.º 3
0
     $err_code = '1001';
 } else {
     if (!move_uploaded_file($uploaed_tmpname, $target_file)) {
         $err_code = '9004';
         break;
     }
     $err_code = '1000';
 }
 if ($is_image) {
     $thumb_file = $thumbnail_dir . "/{$save_name}";
     resize($target_file, $setting['thumb_x'], $setting['thumb_y'], $thumb_file);
     $preview_file = $preview_dir . "/{$save_name}";
     resize($target_file, $setting['prev_x'], $setting['prev_y'], $preview_file);
 }
 $data = array('md5' => $uni_name, 'file_name' => $uploaed_name, 'upload_size' => $upload_size, 'ori' => base_path($target_file), 'thumb' => base_path($thumb_file), 'prev' => base_path($preview_file), 'time' => time());
 object_save(UPLOAD_PATH . "/{$save_json}", $data);
 $list_file = CONFIG_PATH . '/' . $setting['list'];
 if (!file_exists($list_file)) {
     touch($list_file);
 }
 $fp = fopen($list_file, 'r+');
 if (flock($fp, LOCK_EX)) {
     $stat = fstat($fp);
     $ori_size = $stat['size'];
     if ($ori_size === 0) {
         $lst_data = array();
     } else {
         fseek($fp, 0);
         $contents = fread($fp, $ori_size);
         $lst_data = json_decode($contents, true);
         if (empty($lst_data)) {
Exemplo n.º 4
0
            $new_onebox['desc'] = $res_obj['description'];
            $new_onebox['image'] = $res_obj['image'];
            $new_onebox['url'] = $res_obj['ori_url'];
            $new_onebox['id'] = $res_obj['ID'];
            $new_onebox['time'] = $res_obj['update_time'];
            $new_onebox['ctime'] = $ctime;
            $new_oneboxs[] = $new_onebox;
            $same_onebox = true;
            foreach ($new_onebox as $key => $val) {
                if ($val !== @$onebox[$key]) {
                    $same_onebox = false;
                    break;
                }
            }
            if ($same_onebox) {
                $counter_constant++;
                echo '<span>' . $url . ' ok.</span><br>';
            } else {
                $counter_changed++;
                $counter_file_changed++;
                echo '<span>' . $url . '  updated!</span><br>';
            }
        }
        $data_obj[$route[0]][$route[1]] = $new_oneboxs;
    }
    if ($counter_file_changed > 0) {
        echo '<span>save ' . $file . '</span><br>';
        object_save($file, $data_obj);
    }
}
echo '<span>total: ' . $counter_all . ' (constant: ' . $counter_constant . '/ changed: ' . $counter_changed . ')</span>';
Exemplo n.º 5
0
function edit_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));
    }
    $old_name = "{$filename}/{$req['ori_name']}";
    if (!file_exists($old_name)) {
        jsonp_nocache_exit(array('status' => 'error', 'error' => 'The request table not found.', 'ori_cmd' => $req));
    }
    $filename = "{$filename}/{$req['name']}";
    if ($req['ori_name'] !== $req['name']) {
        rename($old_name, $filename);
    }
    touch($filename);
    $filename = "{$filename}/schema.json";
    $schema = object_read($filename);
    $caption = array();
    $caption['title'] = @$req['title'];
    $caption['content'] = @$req['content'];
    $caption['image'] = @$req['image'];
    $caption['key'] = @$req['key'];
    $caption['hooks'] = isset($req['hooks']) ? array_values($req['hooks']) : array();
    $schema['caption'] = $caption;
    object_save($filename, $schema);
    jsonp_nocache_exit(array('status' => 'ok'));
}