Beispiel #1
0
 /**
  * 用户app 添加、编辑
  */
 public function user_app()
 {
     $path = _DIR($this->in['path']);
     if ($this->in['action'] == 'add') {
         $path .= '.oexe';
     }
     $data = json_decode(rawurldecode($this->in['data']), true);
     unset($data['name']);
     unset($data['desc']);
     unset($data['group']);
     $res = file_put_contents($path, json_encode($data));
     show_json($this->L['success']);
 }
Beispiel #2
0
 public function fileSave()
 {
     $filestr = rawurldecode($this->in['filestr']);
     $charset = $this->in['charset'];
     $path = _DIR($this->in['path']);
     if (!is_writable($path)) {
         show_json($this->L['no_permission_write_file'], false);
     }
     if ($charset != '' || $charset != 'utf-8') {
         $filestr = mb_convert_encoding($filestr, $this->in['charset'], 'utf-8');
     }
     $fp = fopen($path, 'wb');
     fwrite($fp, $filestr);
     fclose($fp);
     show_json($this->L['save_success']);
 }
 public function fileSave()
 {
     if ($_SERVER['HTTP_REFERER'] != $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]) {
         if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
             $filestr = rawurldecode($this->in['filestr']);
             $charset = $this->in['charset'];
             $path = _DIR($this->in['path']);
             if (!is_writable($path)) {
                 show_json($this->L['no_permission_write_file'], false);
             }
             if ($charset != '' || $charset != 'utf-8') {
                 $filestr = mb_convert_encoding($filestr, $this->in['charset'], 'utf-8');
             }
             $fp = fopen($path, 'wb');
             fwrite($fp, $filestr);
             fclose($fp);
             show_json($this->L['save_success']);
         }
     } else {
         header('Location: index.php');
     }
 }
 private function path_share()
 {
     $path_hidden = $this->config['setting_system']['path_hidden'];
     $ex_name = explode(',', $path_hidden);
     $userShare = init_controller('userShare');
     $share_list = $userShare->get();
     $list = array('folderlist' => array(), 'filelist' => array(), 'share_list' => $share_list, 'path_type' => "writeable");
     foreach ($share_list as $key => $value) {
         $value['path'] = $key;
         $value['atime'] = '';
         $value['ctime'] = '';
         $value['mode'] = '';
         $value['is_readable'] = 1;
         $value['is_writable'] = 1;
         $value['exists'] = intval(file_exists(_DIR($share_list[$key]['path'])));
         if ($value['type'] == 'file') {
             if (in_array($value['name'], $ex_name)) {
                 continue;
             }
             $value['ext'] = get_path_ext($share_list[$key]['path']);
             $list['filelist'][] = $value;
         } else {
             if (in_array($value['name'], $ex_name)) {
                 continue;
             }
             $list['folderlist'][] = $value;
         }
     }
     return $list;
 }
 public function serverDownload()
 {
     $url = rawurldecode($this->in['url']);
     $save_path = _DIR($this->in['save_path']);
     $save_path = $save_path . 'download_' . rand(100, 999) . '.tmp';
     $result = file_download_this($url, $save_path);
     if ($result == 1) {
         show_json($this->L['download_success'], true, $save_path);
     } else {
         if ($result == -1) {
             show_json($this->L['download_error_create'], false);
         } else {
             show_json($this->L['download_error_exists'], false);
         }
     }
 }
 public function serverDownload()
 {
     $uuid = 'download_' . $this->in['uuid'];
     if ($this->in['type'] == 'percent') {
         //获取下载进度
         //show_json($_SESSION[$uuid]);
         if (isset($_SESSION[$uuid])) {
             $info = $_SESSION[$uuid];
             $result = array('length' => (int) $info['length'], 'size' => (int) filesize($info['path']), 'time' => mtime());
             show_json($result);
         } else {
             show_json('', false);
         }
     }
     //下载
     $save_path = _DIR($this->in['save_path']);
     if (!is_writeable($save_path)) {
         show_json($this->L['no_permission_write'], false);
     }
     $url = rawurldecode($this->in['url']);
     $header = url_header($url);
     if (!$header) {
         show_json($this->L['download_error_exists'], false);
     }
     $save_path = $save_path . urldecode($header['name']);
     if (!checkExt($save_path)) {
         $save_path = $_DIR($this->in['save_path']) . date() . '.temp';
     }
     $save_path = iconv_system($save_path);
     $save_path = get_filename_auto($save_path);
     session_start();
     $_SESSION[$uuid] = array('length' => $header['length'], 'path' => $save_path);
     session_write_close();
     if (file_download_this($url, $save_path)) {
         $name = get_path_this(iconv_app($save_path));
         show_json($this->L['download_success'], true, $name);
     } else {
         show_json($this->L['download_error_create'], false);
     }
 }