public function public_dialog($path = '/', $callback = null, $ext = 'jpg|jpeg|png|gif|txt|xml|doc|ppt|pdf|zip|rar', $sign = '') { if (IS_POST) { $path = ltrim($path, '/'); $path = preg_replace("/\\.+/", '.', $path); //屏蔽非法路径 $path = str_replace(array('\\', '/', '\\/', '/\\'), DS, UPLOAD_PATH . $path); $data = file_list_upload($path); $this->ajaxReturn($data); } else { //验证签名,防止非法上传 $key = sign(array('callback' => $callback, 'ext' => $ext)); if ($sign != $key) { exit('<div style="padding:6px">签名错误</div>'); } $ext = preg_replace('/^\\W+|\\W+$/', '', $ext); $ext = preg_split('/\\W/', $ext); $this->assign('callback', $callback); $this->assign('ext', $ext); $this->display('dialog'); } }
private function ueLsFile() { $config = dict('', 'Ueditor'); $allowFiles = $config['fileManagerAllowFiles']; $listSize = $config['fileManagerListSize']; $path = $config['fileManagerListPath']; $allowFiles = implode('|', C('FILE_UPLOAD_FILE_CONFIG.exts')); /* 获取参数 */ $size = isset($_GET['size']) ? htmlspecialchars($_GET['size']) : $listSize; $start = isset($_GET['start']) ? htmlspecialchars($_GET['start']) : 0; $end = $start + $size; /* 获取文件列表 */ $path = UPLOAD_PATH . ltrim($path, DS); $files = file_list_upload($path, $allowFiles); if (empty($files)) { return array("state" => "no match file", "list" => array(), "start" => $start, "total" => count($files)); } /* 获取指定范围的列表 */ $len = count($files); for ($i = min($end, $len) - 1, $list = array(); $i < $len && $i >= 0 && $i >= $start; $i--) { $list[] = $files[$i]; } /* 返回数据 */ $result = array("state" => "SUCCESS", "list" => $list, "start" => $start, "total" => count($files)); return $result; }