コード例 #1
0
ファイル: file.php プロジェクト: dalinhuang/zotop
 /**
  * 获取文件名称 , 第二个参数控制是否返回文件扩展名,默认为返回带扩展名的文件名称
  * @param string $file
  * @param boolean $stripext
  * @return string
  */
 public static function name($file, $stripext = false)
 {
     $name = basename($file);
     if ($stripext) {
         $ext = file::ext($file);
         $name = basename($file, '.' . $ext);
     }
     return $name;
 }
コード例 #2
0
ファイル: file.php プロジェクト: dalinhuang/zotop
 /**
  * 获取文件的类型
  * @param string $file
  * @return string
  */
 public static function type($file)
 {
     $ext = strpos($file, '.') === false ? $file : file::ext($file);
     $exts = file::exts();
     $type = 'unknown';
     foreach ($exts as $t => $e) {
         if (preg_match('/^(' . $e . ')$/', $ext)) {
             $type = $t;
             break;
         }
     }
     return $type;
 }
コード例 #3
0
ファイル: image.php プロジェクト: dalinhuang/zotop
 /**
  * 获取获取指定大小的图片url
  * @param string $image 图片文件名称
  * @return string
  */
 public static function url($image, $width = 0, $height = 0, $newext = '')
 {
     if ($width === 0) {
         return $image;
     }
     //计算相应宽度高度的图片地址
     $ext = file::ext($image);
     $img = substr($image, 0, strlen($image) - strlen($ext) - 1);
     $img = $img . '_' . $width;
     if ($height !== 0) {
         $img = $img . '_' . $height;
     }
     //新的扩展名
     if (!empty($newext)) {
         $ext = $newext;
     }
     //合成完整的图片url
     $img = $img . '.' . $ext;
     return $img;
 }
コード例 #4
0
ファイル: file.php プロジェクト: dalinhuang/zotop
 /**
  * 获取文件的类型
  * @param string $file
  * @return string
  */
 public static function type($file)
 {
     $ext = file::ext($file);
     if (preg_match('/^(jpe?g|png|[gt]if|bmp|ico|tif|tiff|psd|xbm|xcf)$/', $ext)) {
         $type = 'image';
     } elseif (preg_match('/^(doc|docx|xlt|xls|xlt|xltx|mdb|chm)$/', $ext)) {
         $type = 'document';
     } elseif (preg_match('/^(html|htm|txt|php|asp|js|css|htc|tml|config|module|data|sql)$/', $ext)) {
         $type = 'text';
     } elseif (preg_match('/^(rar|zip|7z|tar)$/', $ext)) {
         $type = 'zip';
     } elseif (preg_match('/^(swf|flv)$/', $ext)) {
         $type = 'flash';
     } elseif (preg_match('/^(mp3|mp4|wav|wmv|midi|ra|ram)$/', $ext)) {
         $type = 'audio';
     } elseif (preg_match('/^(mpg|mpeg|avi|rm|rmvb|mov)$/', $ext)) {
         $type = 'video';
     } else {
         $type = 'unknown';
     }
 }
コード例 #5
0
ファイル: dir.php プロジェクト: dalinhuang/zotop
 /**
  * 返回目录下的全部文件的数组
  * @param string $path 路径
  * @param array $ext 特定的文件格式,如只获取jpg,png格式
  * @param bool|int $recurse 子目录,或者子目录级数
  * @param bool $fullpath 全路径或者仅仅获取文件名称
  * @param array $ignore 忽略的文件夹名称
  * @return array
  */
 public static function files($path, $ext = '', $recurse = false, $fullpath = false, $ignore = array('.svn', 'CVS', '.DS_Store', '__MACOSX'))
 {
     $files = array();
     $path = path::clean($path);
     if (!is_dir($path)) {
         return false;
     }
     $handle = opendir($path);
     while (($file = readdir($handle)) !== false) {
         if ($file != '.' && $file != '..' && !in_array($file, $ignore)) {
             $f = $path . DS . $file;
             if (is_dir($f)) {
                 if ($recurse) {
                     if (is_bool($recurse)) {
                         $subfiles = dir::files($f, $ext, $recurse, $fullpath);
                     } else {
                         $subfiles = dir::files($f, $ext, $recurse - 1, $fullpath);
                     }
                     if (is_array($subfiles)) {
                         $files = array_merge($files, $subfiles);
                     }
                 }
             } else {
                 if (!empty($ext)) {
                     if (is_array($ext) && in_array(file::ext($file), $ext)) {
                         $files[] = $fullpath ? $f : $file;
                     }
                 } else {
                     $files[] = $fullpath ? $f : $file;
                 }
             }
         }
     }
     closedir($handle);
     return $files;
 }
コード例 #6
0
ファイル: index.php プロジェクト: dalinhuang/zotop
    $column['center'] = '<div class="zotop-icon zotop-icon-file folder"></div>';
    $column['name'] = '<a href="' . zotop::url('webftp/index/index', array('dir' => rawurlencode($dir . '/' . $folder))) . '"><b>' . $folder . '</b></a>';
    $column['name'] .= '<h5>';
    $column['name'] .= '<a href="' . zotop::url('webftp/folder/rename', array('dir' => rawurlencode($dir), 'file' => $file)) . '" class="dialog">重命名</a>';
    $column['name'] .= '&nbsp;&nbsp;<a href="' . zotop::url('webftp/folder/delete', array('dir' => rawurlencode($dir), 'file' => $file)) . '" class="dialog">删除</a>';
    $column['name'] .= '</h5>';
    $column['type w60'] = '文件夹';
    $column['encoding w60'] = '';
    $column['size w60'] = '--';
    $column['atime w120'] = time::format(@fileatime($path . DS . $folder));
    $column['mtime w120'] = time::format(@filemtime($path . DS . $folder));
    table::row($column);
}
foreach ($files as $file) {
    $column = array();
    $column['center'] = '<div class="zotop-icon zotop-icon-file ' . file::ext($file) . '"></div>';
    $column['name'] = '<div><b>' . $file . '</b></div>';
    $column['name'] .= '<h5>';
    $column['name'] .= '<a href="' . zotop::url('webftp/file/edit', array('file' => url::encode($dir . '/' . $file))) . '" class="dialog">编辑</a>';
    $column['name'] .= '&nbsp;&nbsp;<a href="' . zotop::url('webftp/file/rename', array('file' => url::encode($dir . '/' . $file))) . '" class="dialog">重命名</a>';
    $column['name'] .= '&nbsp;&nbsp;<a href="' . zotop::url('webftp/file/delete', array('file' => url::encode($dir . '/' . $file))) . '" class="dialog">删除</a>';
    $column['name'] .= '</h5>';
    $column['type w60'] = '文件';
    $column['encoding w60'] = file::isUTF8($path . DS . $file) ? 'UTF8' : '';
    $column['size w60'] = format::byte(@filesize($path . DS . $file));
    $column['atime w120'] = time::format(@fileatime($path . DS . $file));
    $column['mtime w120'] = time::format(@filemtime($path . DS . $file));
    table::row($column);
}
table::footer();
$this->bottom();
コード例 #7
0
ファイル: index.php プロジェクト: dalinhuang/zotop
</script>
<?php 
form::header(array('valid' => 'false', 'class' => 'list', 'action' => zotop::url('system/file/action')));
$column = array();
$column['select'] = html::checkbox(array('name' => 'table', 'class' => 'selectAll'));
$column['w40 center'] = '图标';
$column['name'] = '名称';
$column['user_name'] = '用户名';
//$column['type'] = '类型';
$column['size w60'] = '大小';
$column['atime w120'] = '创建时间';
table::header('list', $column);
foreach ($files as $file) {
    $column = array();
    $column['select'] = html::checkbox(array('name' => 'id[]', 'value' => $file['id'], 'class' => 'select'));
    $column['center w40'] = $file['type'] == 'image' ? '<div class="image">' . html::image($file['path'], array('style' => 'display:none;')) . '</div>' : '<div class="zotop-icon zotop-icon-file ' . file::ext($file['path']) . '"></div>';
    $column['name'] = '<div><b>' . $file['name'] . '</b></div>';
    $column['name'] .= '<h5>';
    $column['name'] .= '<a href="' . zotop::url('system/file/down/' . $file['id']) . '">下载</a>';
    $column['name'] .= '&nbsp;&nbsp;<a href="' . zotop::url('system/file/edit/' . $file['id']) . '" class="dialog">编辑</a>';
    $column['name'] .= '&nbsp;&nbsp;<a href="' . zotop::url('system/file/delete/' . $file['id']) . '" class="confirm">删除</a>';
    $column['name'] .= '</h5>';
    $column['user_name w100'] = '<a><b>' . $file['user_username'] . '</b></a><div class="textflow w100">' . $file['user_name'] . '</div>';
    //$column['type w60'] = ''.$file['type'].'';
    $column['size w60'] = '' . format::byte($file['size']) . '';
    $column['atime w120'] = '' . time::format($file['createtime']) . '';
    table::row($column);
}
table::footer();
form::buttons(array('type' => 'submit', 'value' => '永久删除'));
form::footer($pagination);
コード例 #8
0
ファイル: editor.php プロジェクト: dalinhuang/zotop
	<?php 
echo field::get('textarea', array('name' => 'source', 'value' => $content));
?>
	<script type="text/javascript">
		//显示按钮
		dialog.setTitle('编辑:<?php 
echo $file;
?>
').setWidth(800).setTip('小提示:快捷键 Ctrl+S 可以快速保存').setButtons([{text:'保 存',callback:save},{text:'关 闭'}]);
		//加载编辑器
		var so = new SWFObject("<?php 
echo url::decode('$common/swf/ScriptEditor.swf');
?>
", "SourceEditor", "100%", "460", "9", "#ffffff");
			so.addVariable("Language","<?php 
echo file::ext($file);
?>
");
			so.addVariable("AfterInit","setContent");
			so.addParam("wmode", "Opaque");
			so.write("SourceEditorPannel");
		
		function setContent(){
			content = $("textarea[name=source]").val();					
			$("#SourceEditor").get(0).setText(content);
			$('#SourceEditorLoading').hide();
		}

		function save(dialog,button){
			var content = $("#SourceEditor").get(0).getText().replace(' ',' ');
コード例 #9
0
ファイル: index.php プロジェクト: dalinhuang/zotop
 public function onDefault($dir = '')
 {
     $path = ROOT . DS . trim($dir, DS);
     $path = path::clean($path);
     $folders = dir::folders($path);
     $files = dir::files($path);
     $fileext = array('php', 'css', 'js', 'jpg', 'jpeg', 'gif', 'png', 'bmp', 'psd', 'html', 'htm', 'tpl', 'rar', 'zip', 'mp3');
     $page['title'] = '文件管理器';
     page::header($page);
     page::add('<div id="page" class="clearfix">');
     page::add('<div id="main">');
     page::add('<div id="main-inner">');
     page::top();
     page::navbar($this->navbar(), 'default');
     $column = array();
     $column['select'] = '';
     $column['name'] = '名称';
     $column['type'] = '类型';
     $column['size w60'] = '大小';
     $column['atime w120'] = '创建时间';
     $column['mtime w120'] = '修改时间';
     $column['manage rename w80'] = '重命名';
     $column['manage edit w80'] = '编辑';
     $column['manage delete'] = '删除';
     table::header('list', $column);
     foreach ($folders as $folder) {
         $column = array();
         $column['select w20 center'] = html::image(url::theme() . '/image/fileext/folder.gif');
         $column['name'] = '<a href="' . zotop::url('filemanager/index/default', array('dir' => $dir . DS . $folder)) . '"><b>' . $folder . '</b></a>';
         $column['type w60'] = '文件夹';
         $column['size w60'] = '--';
         $column['atime w120'] = time::format(@fileatime($path . DS . $folder));
         $column['mtime w120'] = time::format(@filemtime($path . DS . $folder));
         $column['manage rename w80'] = '<a>重命名</a>';
         $column['manage edit w80'] = '<a class="disabled">编辑</a>';
         $column['manage delete'] = '<a>删除</a>';
         table::row($column);
     }
     foreach ($files as $file) {
         $column = array();
         $column['select w20 center'] = in_array(file::ext($file), $fileext) ? html::image(url::theme() . '/image/fileext/' . file::ext($file) . '.gif') : html::image(url::theme() . '/image/fileext/unknown.gif');
         $column['name'] = '<a href="' . zotop::url('filemanager/index/default', array('dir' => $dir . DS . $file)) . '"><b>' . $file . '</b></a>';
         $column['type w60'] = '文件';
         $column['size w60'] = format::byte(@filesize($path . DS . $file));
         $column['atime w120'] = time::format(@fileatime($path . DS . $file));
         $column['mtime w120'] = time::format(@filemtime($path . DS . $file));
         $column['manage rename w80'] = '<a>重命名</a>';
         $column['manage edit w80'] = '<a href="' . zotop::url('filemanager/file/edit', array('filename' => $dir . DS . $file, 'dir' => '***')) . '">编辑</a>';
         $column['manage delete'] = '<a>删除</a>';
         table::row($column);
     }
     table::footer();
     page::bottom();
     page::add('</div>');
     page::add('</div>');
     page::add('<div id="side">');
     block::header('快捷操作');
     echo '<ul class="list">';
     echo '<li class="file"><a href="' . zotop::url('zotop/file/newfile') . '" class="dialog">新建文件</a></li>';
     echo '<li class="folder"><a href="' . zotop::url('zotop/file/newfolder') . '" class="dialog">新建文件夹</a></li>';
     echo '<li class="folder"><a href="' . zotop::url('zotop/file/upload') . '" class="dialog">文件上传</a></li>';
     echo '</ul>';
     block::footer();
     block::header('其他位置');
     echo '<ul class="list">';
     echo '<li class="root"><a>根目录</a></li>';
     echo '<li class="root"><a>模板目录</a></li>';
     echo '<li class="root"><a>模块目录</a></li>';
     echo '<li class="root"><a>缓存目录</a></li>';
     echo '</ul>';
     block::footer();
     page::add('</div>');
     page::add('</div>');
     page::footer();
 }
コード例 #10
0
ファイル: site.php プロジェクト: NatWeiss/JankyPHP
 static function drawFile($fname)
 {
     // settings
     ini_set('zlib.output_compression', 'Off');
     ini_set('output_buffering', 'Off');
     // clean output buffers
     for ($i = 0; $i < ob_get_level(); $i++) {
         ob_end_clean();
         if ($i > 10) {
             break;
         }
     }
     // content-type based on extension
     $types = array('default' => array('type' => 'application/octet-stream', 'attach' => true), 'mp3' => 'audio/mpeg', 'mov' => 'video/quicktime', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'gif' => 'image/gif', 'pdf' => 'application/pdf', 'zip' => array('type' => 'application/zip', 'attach' => true), 'doc' => array('type' => 'application/msword', 'attach' => true));
     // get type
     $ext = file::ext($fname);
     $t = isset($types[$ext]) ? $types[$ext] : current($types);
     if (!is_array($t)) {
         $t = array('type' => $t);
     }
     // headers
     $id = str::bc36(time());
     $chunk = 1024 * 1024;
     $time_limit = (int) ($chunk / 100);
     $filesize = filesize($fname);
     header("Cache-Control:");
     header("Cache-Control: public");
     header("Pragma: ");
     header('Content-Type: ' . $t['type']);
     header('Content-Disposition: ' . ($t['attach'] ? 'attachment' : 'inline') . ';' . ' filename="' . basename($fname) . '"');
     //' filename="'.file::name($fname).'-'.$id.'.'.file::ext($fname).'"');
     header("Content-Transfer-Encoding: binary\n");
     // check if http_range is sent by browser (or download manager)
     header("Accept-Ranges: bytes");
     if (isset($_SERVER['HTTP_RANGE'])) {
         list($a, $range) = explode("=", $_SERVER['HTTP_RANGE']);
         str_replace($range, "-", $range);
         $filesize2 = $filesize - 1;
         $new_length = $filesize2 - $range;
         header("HTTP/1.1 206 Partial Content");
         header("Content-Length: {$new_length}");
         header("Content-Range: bytes {$range}{$filesize2}/{$filesize}");
         $filesize = $new_length;
     } else {
         $filesize2 = $filesize - 1;
         header("Content-Range: bytes 0-{$filesize2}/{$filesize}");
     }
     header("Content-Length: " . $filesize);
     // draw
     $fp = fopen($fname, 'rb');
     if ($fp) {
         // resume
         if ($range > 0) {
             fseek($fp, $range);
         }
         // send
         while (!feof($fp) and connection_status() == 0) {
             set_time_limit($time_limit);
             $content = fread($fp, $chunk);
             echo $content;
             ob_flush();
             flush();
             $sent += strlen($content);
             unset($content);
             //funx::debug("$id sent ".(int)($sent/1024)."k".
             //	", memory used ".(int)(memory_get_usage(true)/1024)."k".
             //	", time limit ".(int)($time_limit/60)."m");
         }
         fclose($fp);
     }
     funx::debug("{$id} done ({$sent} of {$filesize}) (connection_status==" . (int) connection_status() . ")");
     return !connection_aborted() and connection_status() == 0 and $sent >= $filesize;
 }
コード例 #11
0
ファイル: _function.php プロジェクト: samplecms/package
/**
 * 返回后缀 如.jpg
 *
 *
 * @param string $url  
 * @return string
 */
function file_ext($url)
{
    return file::ext($url);
}