diff --git a/ChangeLog.md b/ChangeLog.md new file mode 100755 index 0000000..2fa4894 --- /dev/null +++ b/ChangeLog.md @@ -0,0 +1,500 @@ +###ver3.0 `2014/3/23` +----- +####update: + - 文档分享[文件、文件夹分享;支持添加密码;文件分享支持多种格式在线预览] + - 回收站;(避免误删除) + - 系统设置(自定义程序的一些配置) + - 头部菜单管理 + - 文件夹下载,多选批量下载 + - 数据全面安全优化 + - 上传优化: + - 分片上传,不再受php.ini环境限制; + - 加入上传速度 + - 上传目录:随着当前目录变化而变化。 + - 上传完成可点击,进入文件所在目录 + - 界面简化(不显示切换到当前目录;保存路径不要,列表不自动删除;不需要最大化,以及调整窗口大小) + - 上传;总status ——放到标题栏 + - 大文件分片上传尝试(失败情况处理) + - 上传文件夹:不刷新f5 - 最后刷新 + - 显示文件名,大小; + - 允许重复文件上传 + - 上传前可以删除 + - 进图展示优化:显示文件大小、速度、完成进度 + - 编辑器: + - 编辑器 函数列表;c9 IDE;展示并定位;实时更新:php function、js:function + - 函数列表开启与关闭配置 + - php代码自动补全 缺少关键字部分 + - 下拉列表;点击其他地方则消失 + - 非txt则open;不能open则tips bindary:fla ...;右键加入:强制编辑 + - 字体优化 + - 修复github主题光标位置错位问题(选中、编辑都会出现) + - 离线下载优化:加入取消机制;避免持续执行;显示文件大小、速度、完成进度 + - 图片缓存,按照文件MD5来缓存;与路径无关 + - 文件列表,hover的title更多详细信息展示 + - 对话框,标题栏右键加入:刷新、新窗口打开 + - 对话框双击最大化、取消最大化(只对可以缩放的对话框有效) + - 对话框最大化、最小化对话框放大按钮图标改变 + - 权限前端验证(上传等 上传格式前端限制);前端检测 - 新建、上传、删除 + - 设置中心 - -用户管理 非管理员显示优化 + - 公共js部分采用动态调用方式;后续优化可由js完成前端MVC + - 文件、文件夹创建快捷方式 + - 文件夹创建工程项目 + - 未知文件打开提示、不自动下载 + - 右键菜单:加入字母快捷打开 + - 右键自适应:隐藏 - -zip - 视频;多选时:含有视频音频文件时才显示——加入播放列表 + - 右键触发到菜单上(暂时修改jquery-contentMenu 屏蔽右键按下移动触发菜单功能) + - 拖拽优化:框选、tasktap切换;选中其他文字问题;性能问题 + - 框选文件,超出屏幕则自定滚动选中;屏蔽文字可以被选中的问题 + - simple主题,界面UI优化 + - seajs text:tpl修改为html; + - 统一走proxy;隐藏真实地址;web_root,web_host, + - 统一proxy后,office打开权限问题解决:加密方式生成临时访问地址 + - 播放器更多格式支持:wmv、avi、mpg等 + +####fix bug and 优化: + - win下 中文路径导致的问题处理 + - public中拖拽问题 复制粘贴问题 + - 桌面任务栏,右键菜单绑定丢失问题 + - 对话框,标题栏右键菜单不显示问题处理 + - 用户名支持中文 + - 密码含有特殊字符bug处理 + - 播放器解决第一次打开有时候无法播放的问题。 + - 桌面新建位置问题;列表在不同情况下新建问题。始终放在最后 + - firefox兼容性 mac兼容性;ie9 10兼容性; + - appstore 创建、修复只允许管理员操作,显示优化 + - app创建,js代码类型时,单引号导致不可用问题。 + - 循环跳转 session判断 if(!isset($_SESSION)){session_start();} + - win下 中文扩展名导致获取目录列表问题:扩展名获取优化 + - 编辑器保存 ajax 异步请求。loading + - 上传目录错误问题;(上传到了其他目录 ie8 中文) + - 优化mac下gd库支持 + - 窗口拖动到task之下,出不来问题。top大于一定值则锁定 + - 多个同域名;登陆退出互不干扰 + - office变更 https://view.officeapps.live.com/op/view.aspx?src= + - appstore icon方式;默认减少; + - 列表模式:重命名oexe没修改但自动加入了;(oexe不显示) + - 非管理员,zip压缩导致文件名被截断问题修复;win-win 中文解压缩处理;mac-mac中文解压缩处理 + - 下载有BOM问题 + - wwwroot识别问题; + + +###ver2.8 `2014/11/23` +----- +####update: + - 上传控件优化 + - 兼容性优化;支持ie8以上 + - 更新font-awesome到最新版本 +####fix bug: + - 安全优化 + - 上传图片取消大文件压缩选项 + - 优化部分操作下显示问题 + + +###ver2.73 `2014/9/17` +####fix bug: + - 安全优化补丁 + + +###ver2.72 `2014/9/16` +####fix bug:(bug解决和程序优化) + - 任意执行:远程下载apache 扩漏洞:判断扩展名中是否含有.php. + - 不存在的用户 + - 桌面:开始按钮被tab盖住了 + - 主题切换,错位问题 + - 透明对话框拖动时 标题栏不显示问题 + +###ver2.71 `2014/8/31` +----- +####update: + - 编辑器配置保存:文字大小、主题风格;主题修改 + - 精简初始桌面应用 + +####fix bug:(bug解决和程序优化) + - 修改用户密码失败: + - 打开设置设置壁纸,关掉,再打开个人中心,桌面乱掉 + - 桌面开始菜单 最大化问题 + - 语言选择下拉菜单错位 + - 修改主题重叠问题 + - appstore 添加应用tips不见 + + +###ver2.7 `2014/8/25` +----- +####update: + - 安全及性能优化 + - 静态文件加入?版本标识,版本更新后不缓存 + - webuploader 升级到0.14 优化部分上传问题 + - 错误级别:error_reporting(E_ERROR | E_WARNING); + - 地址栏(tab模式、编辑模式)两种模式宽度自适应 + - 自建office解析服务器配置 + - 最大化全屏 + +####fix bug:(bug解决和程序优化) + - install 加入iconv、mbstring检测 + - 右键重命名 快捷键冒泡处理 + - 文件列表图片缩略图拖拽问题 + - 标题超出部分截取优化 + - 编辑器预览滚动条自适应 + + + +###ver2.61 `2014/7/12` +----- +####update: + - 实时搜索,根据搜索框内容变化,实时选中匹配到的结果; + - 弹出搜索框遍历子文件夹递归搜索 + - session key 加入kod_前缀 避免和其他系统key冲突 + - 编辑器选中优化 选择鼠标到窗口外事件处理 + +####fix bug:(bug解决和程序优化) + - backspace后退截获浏览器事件,作为后退前一次访问的文件夹; + - 搜索首字母不匹配问题 + - 弹出层中的弹出层关闭,父窗口失去焦点问题。 + - 代码中grunt部分代码拆分开,放到程序外面;提交到git、osc + - 桌面:删除alert enter快捷键删除 + - install 检测 加入跳过,(只判断用到的函数) 加入多语言 + - zip压缩没有权限 提示红色,false 统一查找 + - 登录成功后 验证码输错清除 + - 非root用户拖拽到文件夹问题 + - 非root解压问题 不能解压 + - list oexe 图标问题 + - 用户目录不存在判断 + - fileCahe 互斥锁 reset 不用 + - ie 8~10样式问题调整 + + +###ver2.6 `2014/7/6` +----- +####update: + - 完全性优化;加入严格的校验机制 + - 首次运行环境检测[data目录检测,必须的函数支持提示] + - 上传已存在处理——创建副本(另外包括粘贴,解压) + - 选中优化 ctrl选中拖拽 + - 键盘快捷键选中文件,多个字符支持 + - 文件文件夹权限修改(右键——属性,即可修改) + - 对话框加入ico,对应任务栏 + - 右键等部分菜单效果优化 + - 远程下载加入进度条,下载速度等信息 + +####fix bug:(bug解决和程序优化) + - 下载前判断当前目录可写 + - 文件扩展名处理,分为用户方式和扩展名权限方式 + - 上传结束提示:是否成功、失败原因 + - 上传扩展名限制 解决apache .php.*当做php执行bug + - 文件名非法字符限定 'si", // 去掉 javascript - "'<[\/\!]*?[^<>]*?>'si", // 去掉 HTML 标记 - "'([\r\n])[\s]+'", // 去掉空白字符 - "'&(quot|#34);'i", // 替换 HTML 实体 - "'&(amp|#38);'i", - "'&(lt|#60);'i", - "'&(gt|#62);'i", - "'&(nbsp|#160);'i", - "'&(iexcl|#161);'i", - "'&(cent|#162);'i", - "'&(pound|#163);'i", - "'&(copy|#169);'i", - "'&#(\d+);'e"); // 作为 PHP 代码运行 - $replace = array ("", - "", - "", - "\"", - "&", - "<", - ">", - " ", - chr(161), - chr(162), - chr(163), - chr(169), - "chr(\\1)"); - $text = preg_replace ($search, $replace, $document); - return $text; -} - -// 获取内容第一条 -function match($content, $preg){ - $preg = "/" . $preg . "/isU"; - preg_match($preg, $content, $result); - return $result[1]; -} -// 获取内容,获取一个页面若干信息.结果在 1,2,3……中 -function match_all($content, $preg){ - $preg = "/" . $preg . "/isU"; - preg_match_all($preg, $content, $result); - return $result; -} - -/** - * 获取指定长度的 utf8 字符串 - * - * @param string $string - * @param int $length - * @param string $dot - * @return string - */ -function get_utf8_str($string, $length, $dot = '...'){ - if (strlen($string) <= $length) return $string; - - $strcut = ''; - $n = $tn = $noc = 0; - - while ($n < strlen($string)) { - $t = ord($string[$n]); - if ($t == 9 || $t == 10 || (32 <= $t && $t <= 126)) { - $tn = 1; - $n++; - $noc++; - } elseif (194 <= $t && $t <= 223) { - $tn = 2; - $n += 2; - $noc += 2; - } elseif (224 <= $t && $t <= 239) { - $tn = 3; - $n += 3; - $noc += 2; - } elseif (240 <= $t && $t <= 247) { - $tn = 4; - $n += 4; - $noc += 2; - } elseif (248 <= $t && $t <= 251) { - $tn = 5; - $n += 5; - $noc += 2; - } elseif ($t == 252 || $t == 253) { - $tn = 6; - $n += 6; - $noc += 2; - } else { - $n++; - } - if ($noc >= $length) break; - } - if ($noc > $length) { - $n -= $tn; - } - if ($n < strlen($string)) { - $strcut = substr($string, 0, $n); - return $strcut . $dot; - } else { - return $string ; - } -} - -/** - * 字符串截取,支持中文和其他编码 - * - * @param string $str 需要转换的字符串 - * @param string $start 开始位置 - * @param string $length 截取长度 - * @param string $charset 编码格式 - * @param string $suffix 截断显示字符 - * @return string - */ -function msubstr($str, $start = 0, $length, $charset = "utf-8", $suffix = true){ - if (function_exists("mb_substr")) { - $i_str_len = mb_strlen($str); - $s_sub_str = mb_substr($str, $start, $length, $charset); - if ($length >= $i_str_len) { - return $s_sub_str; - } - return $s_sub_str . '...'; - } elseif (function_exists('iconv_substr')) { - return iconv_substr($str, $start, $length, $charset); - } - $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/"; - $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/"; - $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/"; - $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/"; - preg_match_all($re[$charset], $str, $match); - $slice = join("", array_slice($match[0], $start, $length)); - if ($suffix) return $slice . "…"; - return $slice; -} - -function web2wap(&$content){ - $search = array ("/]+src=\"([^\">]+)\"[^>]+>/siU", - "/]+href=\"([^\">]+)\"[^>]*>(.*)<\/a>/siU", - "']*>'si", - "'

'si", - "'

'si", - "']*?>.*?'si", // 去掉 javascript - "'<[\/\!]*?[^<>]*?>'si", // 去掉 HTML 标记 - "'([\r\n])[\s]+'", // 去掉空白字符 - ); // 作为 PHP 代码运行 - $replace = array ("#img#\\1#/img#", - "#link#\\1#\\2#/link#", - "[br]", - "", - "[br]", - "", - "", - "", - ); - $text = preg_replace ($search, $replace, $content); - $text = str_replace("[br]", "
", $text); - $img_start = ""; - $text = preg_replace ("/#img#(.*)#\/img#/isUe", "'$img_start'.urlencode('\\1').'$img_end'", $text); - $text = preg_replace ("/#link#(.*)#(.*)#\/link#/isU", "\\2", $text); - while (preg_match("//siU", $text)) { - $text = str_replace('

', '
', $text); - } - return $text; -} - -/** - * 获取变量的名字 - * eg hello="123" 获取ss字符串 - */ -function get_var_name(&$aVar){ - foreach($GLOBALS as $key => $var) { - if ($aVar == $GLOBALS[$key] && $key != "argc") { - return $key; - } - } -} -// -----------------变量调试------------------- -/** - * 格式化输出变量,或者对象 - * - * @param mixed $var - * @param boolean $exit - */ -function pr($var, $exit = false){ - ob_start(); - $style = ''; - if (is_array($var)) { - print_r($var); - } else if (is_object($var)) { - echo get_class($var) . " Object"; - } else if (is_resource($var)) { - echo (string)$var; - } else { - echo var_dump($var); - } - $out = ob_get_clean(); //缓冲输出给$out 变量 - $out = preg_replace('/"(.*)"/', '"' . '\\1' . '"', $out); //高亮字符串变量 - $out = preg_replace('/=\>(.*)/', '=>' . '' . '\\1' . '', $out); //高亮=>后面的值 - $out = preg_replace('/\[(.*)\]/', '[' . '\\1' . ']', $out); //高亮变量 - $from = array(' ', '(', ')', '=>'); - $to = array(' ', '(', ')', '=>'); - $out = str_replace($from, $to, $out); - - $keywords = array('Array', 'int', 'string', 'class', 'object', 'null'); //关键字高亮 - $keywords_to = $keywords; - foreach($keywords as $key => $val) { - $keywords_to[$key] = '' . $val . ''; - } - $out = str_replace($keywords, $keywords_to, $out); - $out = str_replace("\n\n", "\n", $out); - echo $style . '
' . get_var_name($var) . ' = ' . $out . '
'; - if ($exit) exit; //为真则退出 -} - -/** - * 调试输出变量,对象的值。 -参数任意个(任意类型的变量) - * - * @return echo - */ -function debug_out(){ - $avg_num = func_num_args(); - $avg_list = func_get_args(); - ob_start(); - for($i = 0; $i < $avg_num; $i++) { - pr($avg_list[$i]); - } - $out = ob_get_clean(); - echo $out; - exit; -} - -/** - * 取$from~$to范围内的随机数 - * - * @param $from 下限 - * @param $to 上限 - * @return unknown_type - */ -function rand_from_to($from, $to){ - $size = $from - $to; //数值区间 - $max = 30000; //最大 - if ($size < $max) { - return $from + mt_rand(0, $size); - } else { - if ($size % $max) { - return $from + random_from_to(0, $size / $max) * $max + mt_rand(0, $size % $max); - } else { - return $from + random_from_to(0, $size / $max) * $max + mt_rand(0, $max); - } - } -} - -/** - * 产生随机字串,可用来自动生成密码 默认长度6位 字母和数字混合 - * - * @param string $len 长度 - * @param string $type 字串类型:0 字母 1 数字 2 大写字母 3 小写字母 4 中文 - * 其他为数字字母混合(去掉了 容易混淆的字符oOLl和数字01,) - * @param string $addChars 额外字符 - * @return string - */ -function rand_string($len = 4, $type = ''){ - $str = ''; - switch ($type) { - case 0://大小写中英文 - $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; - break; - case 1://数字 - $chars = str_repeat('0123456789', 3); - break; - case 2://大写字母 - $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - break; - case 3://小写字母 - $chars = 'abcdefghijklmnopqrstuvwxyz'; - break; - default: - // 默认去掉了容易混淆的字符oOLl和数字01,要添加请使用addChars参数 - $chars = 'ABCDEFGHIJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'; - break; - } - if ($len > 10) { // 位数过长重复字符串一定次数 - $chars = $type == 1 ? str_repeat($chars, $len) : str_repeat($chars, 5); - } - if ($type != 4) { - $chars = str_shuffle($chars); - $str = substr($chars, 0, $len); - } else { - // 中文随机字 - for($i = 0; $i < $len; $i ++) { - $str .= msubstr($chars, floor(mt_rand(0, mb_strlen($chars, 'utf-8') - 1)), 1); - } - } - return $str; -} - -/** - * 生成自动密码 - */ -function make_password(){ - $temp = '0123456789abcdefghijklmnopqrstuvwxyz'. - 'ABCDEFGHIJKMNPQRSTUVWXYZ~!@#$^*)_+}{}[]|":;,.'.time(); - for($i=0;$i<10;$i++){ - $temp = str_shuffle($temp.substr($temp,-5)); - } - return md5($temp); -} - - -/** - * php DES解密函数 - * - * @param string $key 密钥 - * @param string $encrypted 加密字符串 - * @return string - */ -function des_decode($key, $encrypted){ - $encrypted = base64_decode($encrypted); - $td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_CBC, ''); //使用MCRYPT_DES算法,cbc模式 - $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); - $ks = mcrypt_enc_get_key_size($td); - - mcrypt_generic_init($td, $key, $key); //初始处理 - $decrypted = mdecrypt_generic($td, $encrypted); //解密 - - mcrypt_generic_deinit($td); //结束 - mcrypt_module_close($td); - return pkcs5_unpad($decrypted); -} -/** - * php DES加密函数 - * - * @param string $key 密钥 - * @param string $text 字符串 - * @return string - */ -function des_encode($key, $text){ - $y = pkcs5_pad($text); - $td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_CBC, ''); //使用MCRYPT_DES算法,cbc模式 - $ks = mcrypt_enc_get_key_size($td); - - mcrypt_generic_init($td, $key, $key); //初始处理 - $encrypted = mcrypt_generic($td, $y); //解密 - mcrypt_generic_deinit($td); //结束 - mcrypt_module_close($td); - return base64_encode($encrypted); -} -function pkcs5_unpad($text){ - $pad = ord($text{strlen($text)-1}); - if ($pad > strlen($text)) return $text; - if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return $text; - return substr($text, 0, -1 * $pad); -} -function pkcs5_pad($text, $block = 8){ - $pad = $block - (strlen($text) % $block); - return $text . str_repeat(chr($pad), $pad); -} + newInstanceArgs($args); +} +/** + * 生产controller对象 + */ +function init_controller($controller_name){ + if (!class_exists($controller_name)) { + $model_file = CONTROLLER_DIR.$controller_name.'.class.php'; + if(!is_file($model_file)){ + return false; + } + require_once ($model_file); + } + $reflectionObj = new ReflectionClass($controller_name); + $args = func_get_args(); + array_shift($args); + return $reflectionObj -> newInstanceArgs($args); +} + +/** + * 加载类 + */ +function load_class($class){ + $filename = CLASS_DIR.$class.'.class.php'; + if (file_exists($filename)) { + require($filename); + }else{ + pr($filename.' is not exist',1); + } +} +/** + * 加载函数库 + */ +function load_function($function){ + $filename = FUNCTION_DIR.$function.'.function.php'; + if (file_exists($filename)) { + require($filename); + }else{ + pr($filename.' is not exist',1); + } +} +/** + * 文本字符串转换 + */ +function mystr($str){ + $from = array("\r\n", " "); + $to = array("
", " "); + return str_replace($from, $to, $str); +} + +// 清除多余空格和回车字符 +function strip($str){ + return preg_replace('!\s+!', '', $str); +} + +/** + * 获取精确时间 + */ +function mtime(){ + $t= explode(' ',microtime()); + $time = $t[0]+$t[1]; + return $time; +} +/** + * 过滤HTML + */ +function clear_html($HTML, $br = true){ + $HTML = htmlspecialchars(trim($HTML)); + $HTML = str_replace("\t", ' ', $HTML); + if ($br) { + return nl2br($HTML); + } else { + return str_replace("\n", '', $HTML); + } +} + +/** + * 将obj深度转化成array + * + * @param $obj 要转换的数据 可能是数组 也可能是个对象 还可能是一般数据类型 + * @return array || 一般数据类型 + */ +function obj2array($obj){ + if (is_array($obj)) { + foreach($obj as &$value) { + $value = obj2array($value); + } + return $obj; + } elseif (is_object($obj)) { + $obj = get_object_vars($obj); + return obj2array($obj); + } else { + return $obj; + } +} + +/** + * 计算时间差 + * + * @param char $pretime + * @return char + */ +function spend_time(&$pretime){ + $now = microtime(1); + $spend = round($now - $pretime, 5); + $pretime = $now; + return $spend; +} + +function check_code($code){ + header("Content-type: image/png"); + $fontsize = 18;$len = strlen($code); + $width = 70;$height=27; + $im = @imagecreatetruecolor($width, $height) or die("create image error!"); + $background_color = imagecolorallocate($im, 255, 255, 255); + imagefill($im, 0, 0, $background_color); + for ($i = 0; $i < 2000; $i++) {//获取随机淡色 + $line_color = imagecolorallocate($im, mt_rand(180,255),mt_rand(160, 255),mt_rand(100, 255)); + imageline($im,mt_rand(0,$width),mt_rand(0,$height), //画直线 + mt_rand(0,$width), mt_rand(0,$height),$line_color); + imagearc($im,mt_rand(0,$width),mt_rand(0,$height), //画弧线 + mt_rand(0,$width), mt_rand(0,$height), $height, $width,$line_color); + } + $border_color = imagecolorallocate($im, 160, 160, 160); + imagerectangle($im, 0, 0, $width-1, $height-1, $border_color);//画矩形,边框颜色200,200,200 + + for ($i = 0; $i < $len; $i++) {//写入随机字串 + $current = $str[mt_rand(0, strlen($str)-1)]; + $text_color = imagecolorallocate($im,mt_rand(30, 140),mt_rand(30,140),mt_rand(30,140)); + imagechar($im,10,$i*$fontsize+6,rand(1,$height/3),$code[$i],$text_color); + } + imagejpeg($im);//显示图 + imagedestroy($im);//销毁图片 +} + +/** + * 返回当前浮点式的时间,单位秒;主要用在调试程序程序时间时用 + * + * @return float + */ +function microtime_float(){ + list($usec, $sec) = explode(' ', microtime()); + return ((float)$usec + (float)$sec); +} +/** + * 计算N次方根 + * @param $num + * @param $root + */ +function croot($num, $root = 3){ + $root = intval($root); + if (!$root) { + return $num; + } + return exp(log($num) / $root); +} + +function add_magic_quotes($array){ + foreach ((array) $array as $k => $v) { + if (is_array($v)) { + $array[$k] = add_magic_quotes($v); + } else { + $array[$k] = addslashes($v); + } + } + return $array; +} +// 字符串加转义 +function add_slashes($string){ + if (!$GLOBALS['magic_quotes_gpc']) { + if (is_array($string)) { + foreach($string as $key => $val) { + $string[$key] = add_slashes($val); + } + } else { + $string = addslashes($string); + } + } + return $string; +} + +/** + * hex to binary + */ +if (!function_exists('hex2bin')) { + function hex2bin($hexdata) { + return pack('H*', $hexdata); + } +} + +/** + * 二维数组按照指定的键值进行排序, + * + * @param $keys 根据键值 + * @param $type 升序降序 + * @return array $array = array( + * array('name'=>'手机','brand'=>'诺基亚','price'=>1050), + * array('name'=>'手表','brand'=>'卡西欧','price'=>960) + * );$out = array_sort($array,'price'); + */ +function array_sort($arr, $keys, $type = 'asc'){ + $keysvalue = $new_array = array(); + foreach ($arr as $k => $v) { + $keysvalue[$k] = $v[$keys]; + } + if ($type == 'asc') { + asort($keysvalue); + } else { + arsort($keysvalue); + } + reset($keysvalue); + foreach ($keysvalue as $k => $v) { + $new_array[$k] = $arr[$k]; + } + return $new_array; +} +/** + * 遍历数组,对每个元素调用 $callback,假如返回值不为假值,则直接返回该返回值; + * 假如每次 $callback 都返回假值,最终返回 false + * + * @param $array + * @param $callback + * @return mixed + */ +function array_try($array, $callback){ + if (!$array || !$callback) { + return false; + } + $args = func_get_args(); + array_shift($args); + array_shift($args); + if (!$args) { + $args = array(); + } + foreach($array as $v) { + $params = $args; + array_unshift($params, $v); + $x = call_user_func_array($callback, $params); + if ($x) { + return $x; + } + } + return false; +} +// 求多个数组的并集 +function array_union(){ + $argsCount = func_num_args(); + if ($argsCount < 2) { + return false; + } else if (2 === $argsCount) { + list($arr1, $arr2) = func_get_args(); + + while ((list($k, $v) = each($arr2))) { + if (!in_array($v, $arr1)) $arr1[] = $v; + } + return $arr1; + } else { // 三个以上的数组合并 + $arg_list = func_get_args(); + $all = call_user_func_array('array_union', $arg_list); + return array_union($arg_list[0], $all); + } +} +// 取出数组中第n项 +function array_get($arr,$index){ + foreach($arr as $k=>$v){ + $index--; + if($index<0) return array($k,$v); + } +} + +/** + * 打包返回AJAX请求的数据 + * @params {int} 返回状态码, 通常0表示正常 + * @params {array} 返回的数据集合 + */ +function show_json($data,$code = true,$info=''){ + $use_time = mtime() - $GLOBALS['config']['app_startTime']; + $result = array('code' => $code,'use_time'=>$use_time,'data' => $data); + if ($info != '') { + $result['info'] = $info; + } + header("X-Powered-By: kodExplorer."); + header('Content-Type: application/json; charset=utf-8'); + echo json_encode($result); + exit; +} + +/** + * 简单模版转换,用于根据配置获取列表: + * 参数:cute1:第一次切割的字符串,cute2第二次切割的字符串, + * arraylist为待处理的字符串,$this 为标记当前项,$this_str为当项标记的替换。 + * $tpl为处理后填充到静态模版({0}代表切割后左值,{1}代表切割后右值,{this}代表当前项填充值) + * 例子: + * $arr="default=淡蓝(默认)=5|mac=mac海洋=6|mac1=mac1海洋=7"; + * $tpl="
  • {1}_{2}
  • \n"; + * echo getTplList('|','=',$arr,$tpl,'mac'),'
    '; + */ +function getTplList($cute1, $cute2, $arraylist, $tpl,$this,$this_str=''){ + $list = explode($cute1, $arraylist); + if ($this_str == '') $this_str ="this"; + $html = ''; + foreach ($list as $value) { + $info = explode($cute2, $value); + $arr_replace = array(); + foreach ($info as $key => $value) { + $arr_replace[$key]='{'.$key .'}'; + } + if ($info[0] == $this) { + $temp = str_replace($arr_replace, $info, $tpl); + $temp = str_replace('{this}', $this_str, $temp); + } else { + $temp = str_replace($arr_replace, $info, $tpl); + $temp = str_replace('{this}', '', $temp); + } + $html .= $temp; + } + return $html; +} + +//获取当前url地址 +function get_url() { + $sys_protocal = isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] + == '443' ? 'https://' : 'http://'; + $php_self = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; + $path_info = isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : ''; + $relate_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : + $php_self.(isset($_SERVER['QUERY_STRING']) ? '?'.$_SERVER['QUERY_STRING'] : $path_info); + return $sys_protocal.(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '').$relate_url; +} + +/** + * 去掉HTML代码中的HTML标签,返回纯文本 + * @param string $document 待处理的字符串 + * @return string + */ +function html2txt($document){ + $search = array ("']*?>.*?'si", // 去掉 javascript + "'<[\/\!]*?[^<>]*?>'si", // 去掉 HTML 标记 + "'([\r\n])[\s]+'", // 去掉空白字符 + "'&(quot|#34);'i", // 替换 HTML 实体 + "'&(amp|#38);'i", + "'&(lt|#60);'i", + "'&(gt|#62);'i", + "'&(nbsp|#160);'i", + "'&(iexcl|#161);'i", + "'&(cent|#162);'i", + "'&(pound|#163);'i", + "'&(copy|#169);'i", + "'&#(\d+);'e"); // 作为 PHP 代码运行 + $replace = array ("", + "", + "", + "\"", + "&", + "<", + ">", + " ", + chr(161), + chr(162), + chr(163), + chr(169), + "chr(\\1)"); + $text = preg_replace ($search, $replace, $document); + return $text; +} + +// 获取内容第一条 +function match($content, $preg){ + $preg = "/" . $preg . "/isU"; + preg_match($preg, $content, $result); + return $result[1]; +} +// 获取内容,获取一个页面若干信息.结果在 1,2,3……中 +function match_all($content, $preg){ + $preg = "/" . $preg . "/isU"; + preg_match_all($preg, $content, $result); + return $result; +} + +/** + * 获取指定长度的 utf8 字符串 + * + * @param string $string + * @param int $length + * @param string $dot + * @return string + */ +function get_utf8_str($string, $length, $dot = '...'){ + if (strlen($string) <= $length) return $string; + + $strcut = ''; + $n = $tn = $noc = 0; + + while ($n < strlen($string)) { + $t = ord($string[$n]); + if ($t == 9 || $t == 10 || (32 <= $t && $t <= 126)) { + $tn = 1; + $n++; + $noc++; + } elseif (194 <= $t && $t <= 223) { + $tn = 2; + $n += 2; + $noc += 2; + } elseif (224 <= $t && $t <= 239) { + $tn = 3; + $n += 3; + $noc += 2; + } elseif (240 <= $t && $t <= 247) { + $tn = 4; + $n += 4; + $noc += 2; + } elseif (248 <= $t && $t <= 251) { + $tn = 5; + $n += 5; + $noc += 2; + } elseif ($t == 252 || $t == 253) { + $tn = 6; + $n += 6; + $noc += 2; + } else { + $n++; + } + if ($noc >= $length) break; + } + if ($noc > $length) { + $n -= $tn; + } + if ($n < strlen($string)) { + $strcut = substr($string, 0, $n); + return $strcut . $dot; + } else { + return $string ; + } +} + +/** + * 字符串截取,支持中文和其他编码 + * + * @param string $str 需要转换的字符串 + * @param string $start 开始位置 + * @param string $length 截取长度 + * @param string $charset 编码格式 + * @param string $suffix 截断显示字符 + * @return string + */ +function msubstr($str, $start = 0, $length, $charset = "utf-8", $suffix = true){ + if (function_exists("mb_substr")) { + $i_str_len = mb_strlen($str); + $s_sub_str = mb_substr($str, $start, $length, $charset); + if ($length >= $i_str_len) { + return $s_sub_str; + } + return $s_sub_str . '...'; + } elseif (function_exists('iconv_substr')) { + return iconv_substr($str, $start, $length, $charset); + } + $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/"; + $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/"; + $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/"; + $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/"; + preg_match_all($re[$charset], $str, $match); + $slice = join("", array_slice($match[0], $start, $length)); + if ($suffix) return $slice . "…"; + return $slice; +} + +function web2wap(&$content){ + $search = array ("/]+src=\"([^\">]+)\"[^>]+>/siU", + "/]+href=\"([^\">]+)\"[^>]*>(.*)<\/a>/siU", + "']*>'si", + "'

    'si", + "'

    'si", + "']*?>.*?'si", // 去掉 javascript + "'<[\/\!]*?[^<>]*?>'si", // 去掉 HTML 标记 + "'([\r\n])[\s]+'", // 去掉空白字符 + ); // 作为 PHP 代码运行 + $replace = array ("#img#\\1#/img#", + "#link#\\1#\\2#/link#", + "[br]", + "", + "[br]", + "", + "", + "", + ); + $text = preg_replace ($search, $replace, $content); + $text = str_replace("[br]", "
    ", $text); + $img_start = ""; + $text = preg_replace ("/#img#(.*)#\/img#/isUe", "'$img_start'.urlencode('\\1').'$img_end'", $text); + $text = preg_replace ("/#link#(.*)#(.*)#\/link#/isU", "\\2", $text); + while (preg_match("//siU", $text)) { + $text = str_replace('

    ', '
    ', $text); + } + return $text; +} + +/** + * 获取变量的名字 + * eg hello="123" 获取ss字符串 + */ +function get_var_name(&$aVar){ + foreach($GLOBALS as $key => $var) { + if ($aVar == $GLOBALS[$key] && $key != "argc") { + return $key; + } + } +} +// -----------------变量调试------------------- +/** + * 格式化输出变量,或者对象 + * + * @param mixed $var + * @param boolean $exit + */ +function pr($var, $exit = false){ + ob_start(); + $style = ''; + if (is_array($var)) { + print_r($var); + } else if (is_object($var)) { + echo get_class($var) . " Object"; + } else if (is_resource($var)) { + echo (string)$var; + } else { + echo var_dump($var); + } + $out = ob_get_clean(); //缓冲输出给$out 变量 + $out = preg_replace('/"(.*)"/', '"' . '\\1' . '"', $out); //高亮字符串变量 + $out = preg_replace('/=\>(.*)/', '=>' . '' . '\\1' . '', $out); //高亮=>后面的值 + $out = preg_replace('/\[(.*)\]/', '[' . '\\1' . ']', $out); //高亮变量 + $from = array(' ', '(', ')', '=>'); + $to = array(' ', '(', ')', '=>'); + $out = str_replace($from, $to, $out); + + $keywords = array('Array', 'int', 'string', 'class', 'object', 'null'); //关键字高亮 + $keywords_to = $keywords; + foreach($keywords as $key => $val) { + $keywords_to[$key] = '' . $val . ''; + } + $out = str_replace($keywords, $keywords_to, $out); + $out = str_replace("\n\n", "\n", $out); + echo $style . '
    ' . get_var_name($var) . ' = ' . $out . '
    '; + if ($exit) exit; //为真则退出 +} + +/** + * 调试输出变量,对象的值。 + * 参数任意个(任意类型的变量) + * + * @return echo + */ +function debug_out(){ + $avg_num = func_num_args(); + $avg_list = func_get_args(); + ob_start(); + for($i = 0; $i < $avg_num; $i++) { + pr($avg_list[$i]); + } + $out = ob_get_clean(); + echo $out; + exit; +} + +/** + * 取$from~$to范围内的随机数 + * + * @param $from 下限 + * @param $to 上限 + * @return unknown_type + */ +function rand_from_to($from, $to){ + $size = $from - $to; //数值区间 + $max = 30000; //最大 + if ($size < $max) { + return $from + mt_rand(0, $size); + } else { + if ($size % $max) { + return $from + random_from_to(0, $size / $max) * $max + mt_rand(0, $size % $max); + } else { + return $from + random_from_to(0, $size / $max) * $max + mt_rand(0, $max); + } + } +} + +/** + * 产生随机字串,可用来自动生成密码 默认长度6位 字母和数字混合 + * + * @param string $len 长度 + * @param string $type 字串类型:0 字母 1 数字 2 大写字母 3 小写字母 4 中文 + * 其他为数字字母混合(去掉了 容易混淆的字符oOLl和数字01,) + * @param string $addChars 额外字符 + * @return string + */ +function rand_string($len = 4, $type){ + $str = ''; + switch ($type) { + case 0://大小写中英文 + $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + break; + case 1://数字 + $chars = str_repeat('0123456789', 3); + break; + case 2://大写字母 + $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + break; + case 3://小写字母 + $chars = 'abcdefghijklmnopqrstuvwxyz'; + break; + default: + // 默认去掉了容易混淆的字符oOLl和数字01,要添加请使用addChars参数 + $chars = 'ABCDEFGHIJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'; + break; + } + if ($len > 10) { // 位数过长重复字符串一定次数 + $chars = $type == 1 ? str_repeat($chars, $len) : str_repeat($chars, 5); + } + if ($type != 4) { + $chars = str_shuffle($chars); + $str = substr($chars, 0, $len); + } else { + // 中文随机字 + for($i = 0; $i < $len; $i ++) { + $str .= msubstr($chars, floor(mt_rand(0, mb_strlen($chars, 'utf-8') - 1)), 1); + } + } + return $str; +} + +/** + * 生成自动密码 + */ +function make_password(){ + $temp = '0123456789abcdefghijklmnopqrstuvwxyz'. + 'ABCDEFGHIJKMNPQRSTUVWXYZ~!@#$^*)_+}{}[]|":;,.'.time(); + for($i=0;$i<10;$i++){ + $temp = str_shuffle($temp.substr($temp,-5)); + } + return md5($temp); +} + + +/** + * php DES解密函数 + * + * @param string $key 密钥 + * @param string $encrypted 加密字符串 + * @return string + */ +function des_decode($key, $encrypted){ + $encrypted = base64_decode($encrypted); + $td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_CBC, ''); //使用MCRYPT_DES算法,cbc模式 + $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size($td), MCRYPT_RAND); + $ks = mcrypt_enc_get_key_size($td); + + mcrypt_generic_init($td, $key, $key); //初始处理 + $decrypted = mdecrypt_generic($td, $encrypted); //解密 + + mcrypt_generic_deinit($td); //结束 + mcrypt_module_close($td); + return pkcs5_unpad($decrypted); +} +/** + * php DES加密函数 + * + * @param string $key 密钥 + * @param string $text 字符串 + * @return string + */ +function des_encode($key, $text){ + $y = pkcs5_pad($text); + $td = mcrypt_module_open(MCRYPT_DES, '', MCRYPT_MODE_CBC, ''); //使用MCRYPT_DES算法,cbc模式 + $ks = mcrypt_enc_get_key_size($td); + + mcrypt_generic_init($td, $key, $key); //初始处理 + $encrypted = mcrypt_generic($td, $y); //解密 + mcrypt_generic_deinit($td); //结束 + mcrypt_module_close($td); + return base64_encode($encrypted); +} +function pkcs5_unpad($text){ + $pad = ord($text{strlen($text)-1}); + if ($pad > strlen($text)) return $text; + if (strspn($text, chr($pad), strlen($text) - $pad) != $pad) return $text; + return substr($text, 0, -1 * $pad); +} +function pkcs5_pad($text, $block = 8){ + $pad = $block - (strlen($text) % $block); + return $text . str_repeat(chr($pad), $pad); +} diff --git a/lib/function/file.function.php b/lib/function/file.function.php old mode 100644 new mode 100755 index 3bd3db3..75ab376 --- a/lib/function/file.function.php +++ b/lib/function/file.function.php @@ -1,718 +1,790 @@ - iconv_app($name), - 'path' => iconv_app(get_path_father($path)), - 'ext' => get_path_ext($path), - 'type' => 'file', - 'mode' => get_mode($path), - 'atime' => date($date_formate, fileatime($path)), //访问时间 - 'ctime' => date($date_formate, filectime($path)), //创建时间 - 'mtime' => date($date_formate, filemtime($path)), //最后修改时间 - 'is_readable' => intval(is_readable($path)), - 'is_writeable' => intval(is_writeable($path)), - 'size' => $size, - 'size_friendly' => size_format($size, 2) - ); - return $info; -} -/** - * 获取文件夹细信息 - */ -function folder_info($path,$date_formate=false){ - if (!$date_formate) $date_formate = $GLOBALS['L']['time_type']; - $info = array( - 'name' => iconv_app(get_path_this($path)), - 'path' => iconv_app(get_path_father($path)), - 'type' => 'folder', - 'mode' => get_mode($path), - 'atime' => date($date_formate, fileatime($path)), //访问时间 - 'ctime' => date($date_formate, filectime($path)), //创建时间 - 'mtime' => date($date_formate, filemtime($path)), //最后修改时间 - 'is_readable' => intval(is_readable($path)), - 'is_writeable' => intval(is_writeable($path)) - ); - return $info; -} - - -/** - * 获取一个路径(文件夹&文件) 当前文件[夹]名 - * test/11/ ==>11 test/1.c ==>1.c - */ -function get_path_this($path){ - $path = str_replace('\\','/', rtrim(trim($path),'/')); - return substr($path,strrpos($path,'/')+1); -} -/** - * 获取一个路径(文件夹&文件) 父目录 - * /test/11/==>/test/ /test/1.c ==>/www/test/ - */ -function get_path_father($path){ - $path = str_replace('\\','/', rtrim(trim($path),'/')); - return substr($path, 0, strrpos($path,'/')+1); -} -/** - * 获取扩展名 - */ -function get_path_ext($path){ - $name = get_path_this($path); - if(strstr($name,'.')){ - $ext = substr($name,strrpos($name,'.')+1); - return strtolower($ext); - }else{ - return ''; - } -} - -//自动获取不重复文件(夹)名 -function get_filename_auto($path){ - $i=1; - $father = get_path_father($path); - $name = get_path_this($path); - $ext = get_path_ext($name); - if (strlen($ext)>0) { - $ext='.'.$ext; - $name = substr($name,0,strlen($name)-strlen($ext)); - } - while(file_exists($path)){ - $path = $father.$name.'('.$i.')'.$ext; - $i++; - } - return $path; -} - -/** - * 判断文件夹是否可写 - */ -function path_writable($path) { - $file = $path.'/test'.time().'.txt'; - $dir = $path.'/test'.time(); - if(@is_writable($path) && @touch($file) && @unlink($file)) return true; - if(@mkdir($dir,0777) && @rmdir($dir)) return true; - return false; -} - -/** - * 获取文件夹详细信息,文件夹属性时调用,包含子文件夹数量,文件数量,总大小 - */ -function path_info($path){ - //if (!is_dir($path)) return false; - $pathinfo = _path_info_more($path);//子目录文件大小统计信息 - $folderinfo = folder_info($path); - return array_merge($pathinfo,$folderinfo); -} - -/** - * 检查名称是否合法 - */ -function path_check($path){ - $check = array('/','\\',':','*','?','"','<','>','|'); - $path = rtrim($path,'/'); - $path = get_path_this($path); - foreach ($check as $v) { - if (strstr($path,$v)) { - return false; - } - } - return true; -} - -/** - * 递归获取文件夹信息: 子文件夹数量,文件数量,总大小 - */ -function _path_info_more($dir, &$file_num = 0, &$path_num = 0, &$size = 0){ - if (!$dh = opendir($dir)) return false; - while (($file = readdir($dh)) !== false) { - if ($file != "." && $file != "..") { - $fullpath = $dir . "/" . $file; - if (!is_dir($fullpath)) { - $file_num ++; - $size += filesize($fullpath); - } else { - _path_info_more($fullpath, $file_num, $path_num, $size); - $path_num ++; - } - } - } - closedir($dh); - $pathinfo['file_num'] = $file_num; - $pathinfo['folder_num'] = $path_num; - $pathinfo['size'] = $size; - $pathinfo['size_friendly'] = size_format($size); - return $pathinfo; -} - - -/** - * 获取多选文件信息,包含子文件夹数量,文件数量,总大小,父目录权限 - */ -function path_info_muti($list,$time_type){ - if (count($list) == 1) { - if ($list[0]['type']=="folder"){ - return path_info($list[0]['path'],$time_type); - }else{ - return file_info($list[0]['path'],$time_type); - } - } - $pathinfo = array( - 'file_num' => 0, - 'folder_num' => 0, - 'size' => 0, - 'size_friendly' => '', - 'father_name' => '', - 'mod' => '' - ); - foreach ($list as $val){ - if ($val['type'] == 'folder') { - $pathinfo['folder_num'] ++; - $temp = path_info($val['path']); - $pathinfo['folder_num'] += $temp['folder_num']; - $pathinfo['file_num'] += $temp['file_num']; - $pathinfo['size'] += $temp['size']; - }else{ - $pathinfo['file_num']++; - $pathinfo['size'] += filesize($val['path']); - } - } - $pathinfo['size_friendly'] = size_format($pathinfo['size']); - $pathinfo['father_name'] = get_path_father($list[0]['path']); - $pathinfo['mode'] = get_mode($pathinfo['father_name']); - return $pathinfo; -} - -/** - * 获取文件夹下列表信息 - * dir 包含结尾/ d:/wwwroot/test/ - * 传入需要读取的文件夹路径,为程序编码 - */ -function path_list($dir,$list_file=true,$check_children=false){ - $dir = rtrim($dir,'/').'/'; - if (!is_dir($dir) || !($dh = opendir($dir))){ - return array('folderlist'=>array(),'filelist'=>array()); - } - $folderlist = array();$filelist = array();//文件夹与文件 - while (($file = readdir($dh)) !== false) { - if ($file != "." && $file != ".." && $file != ".svn" ) { - $fullpath = $dir . $file; - if (is_dir($fullpath)) { - $info = folder_info($fullpath); - if($check_children){ - $info['isParent'] = path_haschildren($fullpath,$list_file); - } - $folderlist[] = $info; - } else if($list_file) {//是否列出文件 - $info = file_info($fullpath); - if($check_children) $info['isParent'] = false; - $filelist[] = $info; - } - } - } - closedir($dh); - return array('folderlist' => $folderlist,'filelist' => $filelist); -} - -// 判断文件夹是否含有子内容【区分为文件或者只筛选文件夹才算】 -function path_haschildren($dir,$check_file=false){ - $dir = rtrim($dir,'/').'/'; - if (!$dh = @opendir($dir)) return false; - while (($file = readdir($dh)) !== false){ - if ($file != "." && $file != "..") { - $fullpath = $dir.$file; - if ($check_file) {//有子目录或者文件都说明有子内容 - if(is_dir($fullpath.'/') || is_file($fullpath)) return true; - }else{//只检查有没有文件 - if(is_dir($fullpath.'/')) return true; - } - } - } - closedir($dh); - return false; -} - -/** - * 删除文件 传入参数编码为操作系统编码. win--gbk - */ -function del_file($fullpath){ - if (!@unlink($fullpath)) { // 删除不了,尝试修改文件权限 - @chmod($fullpath, 0777); - if (!@unlink($fullpath)) { - return false; - } - } else { - return true; - } -} - -/** - * 删除文件夹 传入参数编码为操作系统编码. win--gbk - */ -function del_dir($dir){ - if (!$dh = opendir($dir)) return false; - while (($file = readdir($dh)) !== false) { - if ($file != "." && $file != "..") { - $fullpath = $dir . '/' . $file; - if (!is_dir($fullpath)) { - if (!unlink($fullpath)) { // 删除不了,尝试修改文件权限 - chmod($fullpath, 0777); - if (!unlink($fullpath)) { - return false; - } - } - } else { - if (!del_dir($fullpath)) { - chmod($fullpath, 0777); - if (!del_dir($fullpath)) return false; - } - } - } - } - closedir($dh); - if (rmdir($dir)) { - return true; - } else { - return false; - } -} - -/** - * 复制文件夹 - * eg:将D:/wwwroot/下面wordpress复制到 - * D:/wwwroot/www/explorer/0000/del/1/ - * 末尾都不需要加斜杠,复制到地址如果不加源文件夹名, - * 就会将wordpress下面文件复制到D:/wwwroot/www/explorer/0000/del/1/下面 - * $from = 'D:/wwwroot/wordpress'; - * $to = 'D:/wwwroot/www/explorer/0000/del/1/wordpress'; - */ - -function copy_dir($source, $dest){ - if (!$dest) return false; - if ($source == substr($dest,0,strlen($source))) return;//防止无限递归 - $result = false; - if (is_file($source)) { - if ($dest[strlen($dest)-1] == '/') { - $__dest = $dest . "/" . basename($source); - } else { - $__dest = $dest; - } - $result = copy($source, $__dest); - chmod($__dest, 0777); - }elseif (is_dir($source)) { - if ($dest[strlen($dest)-1] == '/') { - $dest = $dest . basename($source); - mkdir($dest, 0777); - } else { - mkdir($dest, 0777); - } - if (!$dh = opendir($source)) return false; - while (($file = readdir($dh)) !== false) { - if ($file != "." && $file != "..") { - if (!is_dir($source . "/" . $file)) { - $__dest = $dest . "/" . $file; - } else { - $__dest = $dest . "/" . $file; - } - $result = copy_dir($source . "/" . $file, $__dest); - } - } - closedir($dh); - } - return $result; -} - -/** - * 创建目录 - * - * @param string $dir - * @param int $mode - * @return bool - */ -function mk_dir($dir, $mode = 0777){ - if (is_dir($dir) || mkdir($dir, $mode)) - return true; - if (!mk_dir(dirname($dir), $mode)) - return false; - return mkdir($dir, $mode); -} - -/* -* 获取文件&文件夹列表(支持文件夹层级) -* path : 文件夹 $dir ——返回的文件夹array files ——返回的文件array -* $deepest 是否完整递归;$deep 递归层级 -*/ -function recursion_dir($path,&$dir,&$file,$deepest=-1,$deep=0){ - $path = rtrim($path,'/').'/'; - if (!is_array($file)) $file=array(); - if (!is_array($dir)) $dir=array(); - if (!$dh = opendir($path)) return false; - while(($val=readdir($dh)) !== false){ - if ($val=='.' || $val=='..') continue; - $value = strval($path.$val); - if (is_file($value)){ - $file[] = $value; - }else if(is_dir($value)){ - $dir[]=$value; - if ($deepest==-1 || $deep<$deepest){ - recursion_dir($value."/",$dir,$file,$deepest,$deep+1); - } - } - } - closedir($dh); - return true; -} -/* - * $search 为包含的字符串 - * is_content 表示是否搜索文件内容;默认不搜索 - * is_case 表示区分大小写,默认不区分 - */ -function path_search($path,$search,$is_content=false,$file_ext='',$is_case=false){ - $ext_arr=explode("|",$file_ext); - recursion_dir($path,$dirs,$files,-1,0); - $strpos = 'stripos';//是否区分大小写 - if ($is_case) $strpos = 'strpos'; - - $filelist = array(); - $folderlist = array(); - foreach($files as $f){ - $ext = get_path_ext($f); - $path_this = get_path_this($f); - if ($file_ext !='' && !in_array($ext,$ext_arr)) continue;//文件类型不在用户限定内 - if ($strpos($path_this,$search) !== false){//搜索文件名;搜到就返回;搜不到继续 - $filelist[] = file_info($f); - continue; - } - if ($is_content && is_file($f)){ - $fp = fopen($f, "r"); - $content = @fread($fp,filesize($f)); - fclose($fp); - if ($strpos($content,$search) !== false){ - $filelist[] = file_info($f); - } - } - } - if ($file_ext == '') {//没限定扩展名则才搜索文件夹 - foreach($dirs as $f){ - $path_this = get_path_this($f); - if ($strpos($path_this,$search) !== false){ - $folderlist[]= array( - 'name' => iconv_app(get_path_this($f)), - 'path' => iconv_app(get_path_father($f)) - ); - } - } - } - return array('folderlist' => $folderlist,'filelist' => $filelist); -} - -/** - * 修改文件、文件夹权限 - * @param $path 文件(夹)目录 - * @return :string - */ -function chmod_path($path,$mod){ - //$mod = 0777;// - if (!isset($mod)) $mod = 0777; - if (!is_dir($path)) return chmod($path,$mod); - if (!$dh = opendir($path)) return false; - while (($file = readdir($dh)) !== false){ - if ($file != "." && $file != "..") { - $fullpath = $path . '/' . $file; - return chmod_path($fullpath,$mod); - } - } - closedir($dh); - return chmod($path,$mod); -} - -/** - * 文件大小格式化 - * - * @param $ :$bytes, int 文件大小 - * @param $ :$precision int 保留小数点 - * @return :string - */ -function size_format($bytes, $precision = 2){ - if ($bytes == 0) return "0 B"; - $unit = array('TB' => 1099511627776, // pow( 1024, 4) - 'GB' => 1073741824, // pow( 1024, 3) - 'MB' => 1048576, // pow( 1024, 2) - 'kB' => 1024, // pow( 1024, 1) - 'B ' => 1, // pow( 1024, 0) - ); - foreach ($unit as $un => $mag) { - if (doubleval($bytes) >= $mag) - return round($bytes / $mag, $precision).' '.$un; - } -} - -/** - * 判断路径是不是绝对路径 - * 返回true('/foo/bar','c:\windows'). - * - * @return 返回true则为绝对路径,否则为相对路径 - */ -function path_is_absolute($path){ - if (realpath($path) == $path)// *nux 的绝对路径 /home/my - return true; - if (strlen($path) == 0 || $path[0] == '.') - return false; - if (preg_match('#^[a-zA-Z]:\\\\#', $path))// windows 的绝对路径 c:\aaa\ - return true; - return (bool)preg_match('#^[/\\\\]#', $path); //绝对路径 运行 / 和 \绝对路径,其他的则为相对路径 -} - -/** - * 获取扩展名的文件类型 - * - * @param $ :$ext string 扩展名 - * @return :string; - */ -function ext_type($ext){ - $ext2type = array( - 'text' => array('txt','ini','log','asc','csv','tsv','vbs','bat','cmd','inc','conf','inf'), - 'code' => array('css','htm','html','php','js','c','cpp','h','java','cs','sql','xml'), - 'picture' => array('jpg','jpeg','png','gif','ico','bmp','tif','tiff','dib','rle'), - 'audio' => array('mp3','ogg','oga','mid','midi','ram','wav','wma','aac','ac3','aif','aiff','m3a','m4a','m4b','mka','mp1','mx3','mp2'), - 'flash' => array('swf'), - 'video' => array('rm','rmvb','flv','mkv','wmv','asf','avi','aiff','mp4','divx','dv','m4v','mov','mpeg','vob','mpg','mpv','ogm','ogv','qt'), - 'document' => array('doc','docx','docm','dotm','odt','pages','pdf','rtf','xls','xlsx','xlsb','xlsm','ppt','pptx','pptm','odp'), - 'rar_achieve' => array('rar','arj','tar','ace','gz','lzh','uue','bz2'), - 'zip_achieve' => array('zip','gzip','cab','tbz','tbz2'), - 'other_achieve' => array('dmg','sea','sit','sqx') - ); - foreach ($ext2type as $type => $exts) { - if (in_array($ext, $exts)) { - return $type; - } - } -} - -/** - * 文件下载 - */ -function file_download($file){ - if (!file_exists($file)) show_json('file not exists'); - if (isset($_SERVER['HTTP_RANGE']) && ($_SERVER['HTTP_RANGE'] != "") && - preg_match("/^bytes=([0-9]+)-$/i", $_SERVER['HTTP_RANGE'], $match) && ($match[1] < $fsize)) { - $start = $match[1]; - }else{ - $start = 0; - } - - $size = filesize($file); - header("Cache-Control: public"); - header("Content-Type: application/octet-stream"); - $filename = get_path_this($file);//解决在IE中下载时中文乱码问题 - if(preg_match('/MSIE/',$_SERVER['HTTP_USER_AGENT'])){ - $filename = str_replace('+','%20',urlencode($filename)); - } - header("Content-Disposition: attachment;filename=".get_path_this($file)); - - if ($start > 0) { - header("HTTP/1.1 206 Partial Content"); - header("Content-Length: " . ($size - $start)); - header("Content-Ranges: bytes".$start ."-".($size - 1)."/" .$size); - }else{ - header("Content-Length: $size"); - header("Accept-Ranges: bytes"); - } - - $fp = fopen($file, "rb"); - fseek($fp, $start); - while (!feof($fp)) { - set_time_limit(0); - print (fread($fp, 1024 * 8)); //输出文件 - flush(); - ob_flush(); - } - fclose($fp); - exit; -} - -/** - * 文件代理输出 - */ -function file_proxy_out($file){ - if (!file_exists($file)) show_json('file not exists',false); - $mime = get_file_mime(get_path_ext($file)); - header("Cache-Control:public"); - header("Content-Type:".$mime); - header("Content-Length: ".filesize($file)); //输出总长 - $fp = fopen($file, "rb"); - set_time_limit(0); - while (!feof($fp)) { - print (fread($fp, 1024 * 8)); //输出文件 - flush(); - ob_flush(); - } - fclose($fp); - exit; -} - - -/** - * 文件下载到服务器 - */ -function file_download_this($from, $file_name){ - $fp = @fopen ($from, "rb"); - if ($fp){ - $new_fp = @fopen ($file_name, "wb"); - while(!feof($fp)){ - fwrite($new_fp, fread($fp, 1024 * 8 ), 1024 * 8); - } - return true; - }else{ - return false; - } -} - -/** - * 获取文件(夹)权限 rwx_rwx_rwx - */ -function get_mode($file){ - $Mode = fileperms($file); - $Owner = array();$Group=array();$World=array(); - if ($Mode &0x1000) $Type = 'p'; // FIFO pipe - elseif ($Mode &0x2000) $Type = 'c'; // Character special - elseif ($Mode &0x4000) $Type = 'd'; // Directory - elseif ($Mode &0x6000) $Type = 'b'; // Block special - elseif ($Mode &0x8000) $Type = '-'; // Regular - elseif ($Mode &0xA000) $Type = 'l'; // Symbolic Link - elseif ($Mode &0xC000) $Type = 's'; // Socket - else $Type = 'u'; // UNKNOWN - // Determine les permissions par Groupe - $Owner['r'] = ($Mode &00400) ? 'r' : '-'; - $Owner['w'] = ($Mode &00200) ? 'w' : '-'; - $Owner['x'] = ($Mode &00100) ? 'x' : '-'; - $Group['r'] = ($Mode &00040) ? 'r' : '-'; - $Group['w'] = ($Mode &00020) ? 'w' : '-'; - $Group['e'] = ($Mode &00010) ? 'x' : '-'; - $World['r'] = ($Mode &00004) ? 'r' : '-'; - $World['w'] = ($Mode &00002) ? 'w' : '-'; - $World['e'] = ($Mode &00001) ? 'x' : '-'; - // Adjuste pour SUID, SGID et sticky bit - if ($Mode &0x800) $Owner['e'] = ($Owner['e'] == 'x') ? 's' : 'S'; - if ($Mode &0x400) $Group['e'] = ($Group['e'] == 'x') ? 's' : 'S'; - if ($Mode &0x200) $World['e'] = ($World['e'] == 'x') ? 't' : 'T'; - $Mode = $Type.$Owner['r'].$Owner['w'].$Owner['x'].' '. - $Group['r'].$Group['w'].$Group['e'].' '. - $World['r'].$World['w'].$World['e']; - return $Mode; -} - -/** - * 获取可以上传的最大值 - * return * byte - */ -function get_post_max(){ - $upload = ini_get('upload_max_filesize'); - $upload = $upload==''?ini_get('upload_max_size'):$upload; - $post = ini_get('post_max_size'); - $upload = intval($upload)*1024*1024; - $post = intval($post)*1024*1024; - return $upload<$post?$upload:$post; -} - -/** - * 文件上传处理。单个文件上传,多个分多次请求 - * 调用demo - * upload('file','D:/www/'); - */ -function upload($fileInput, $path = './'){ - global $config,$L; - $file = $_FILES[$fileInput]; - if (!isset($file)) show_json($L['upload_error_null'],false); - - $file_name = iconv_system($file['name']); - $info = _upload($file['tmp_name'],$file['size'],$path.$file_name); - show_json($info['data'],$info['code'],$info['path']); -} -function _upload($tmp_name,$size,$save_path){ - global $L; - $save_path = get_filename_auto($save_path); - if(move_uploaded_file($tmp_name,$save_path)){ - return array('code'=>true,'data'=>$L['upload_success'],'path'=>$save_path); - }else { - return array('code'=>fasle,'data'=>$L['move_error']); - } -} - -/** - * 写日志 - * @param string $log 日志信息 - * @param string $type 日志类型 [system|app|...] - * @param string $level 日志级别 - * @return boolean - */ -function write_log($log, $type = 'default', $level = 'log'){ - $now_time = date('[y-m-d H:i:s]'); - $now_day = date('Y_m_d'); - // 根据类型设置日志目标位置 - $target = LOG_PATH . strtolower($type) . '/'; - mk_dir($target, 0777); - if (! is_writable($target)) exit('path can not write!'); - switch($level){// 分级写日志 - case 'error': $target .= 'Error_' . $now_day . '.log';break; - case 'warning': $target .= 'Warning_' . $now_day . '.log';break; - case 'debug': $target .= 'Debug_' . $now_day . '.log';break; - case 'info': $target .= 'Info_' . $now_day . '.log';break; - case 'db': $target .= 'Db_' . $now_day . '.log';break; - default: $target .= 'Log_' . $now_day . '.log';break; - } - //检测日志文件大小, 超过配置大小则重命名 - if (file_exists($target) && filesize($target) <= 100000) { - $file_name = substr(basename($target),0,strrpos(basename($target),'.log')).'.log'; - rename($target, dirname($target) .'/'. $file_name); - } - clearstatcache(); - return error_log("$now_time $log\n", 3, $target); + iconv_app($name), + 'path' => iconv_app(get_path_father($path)), + 'ext' => get_path_ext($path), + 'type' => 'file', + 'mode' => get_mode($path), + 'atime' => fileatime($path), //最后访问时间 + 'ctime' => filectime($path), //创建时间 + 'mtime' => filemtime($path), //最后修改时间 + 'is_readable' => intval(is_readable($path)), + 'is_writeable' => intval(is_writeable($path)), + 'size' => $size, + 'size_friendly' => size_format($size, 2) + ); + return $info; +} +/** + * 获取文件夹细信息 + */ +function folder_info($path){ + $info = array( + 'name' => iconv_app(get_path_this($path)), + 'path' => iconv_app(get_path_father($path)), + 'type' => 'folder', + 'mode' => get_mode($path), + 'atime' => fileatime($path), //访问时间 + 'ctime' => filectime($path), //创建时间 + 'mtime' => filemtime($path), //最后修改时间 + 'is_readable' => intval(is_readable($path)), + 'is_writeable' => intval(is_writeable($path)) + ); + return $info; +} + + +/** + * 获取一个路径(文件夹&文件) 当前文件[夹]名 + * test/11/ ==>11 test/1.c ==>1.c + */ +function get_path_this($path){ + $path = str_replace('\\','/', rtrim(trim($path),'/')); + return substr($path,strrpos($path,'/')+1); +} +/** + * 获取一个路径(文件夹&文件) 父目录 + * /test/11/==>/test/ /test/1.c ==>/www/test/ + */ +function get_path_father($path){ + $path = str_replace('\\','/', rtrim(trim($path),'/')); + return substr($path, 0, strrpos($path,'/')+1); +} +/** + * 获取扩展名 + */ +function get_path_ext($path){ + $name = get_path_this($path); + $ext = ''; + if(strstr($name,'.')){ + $ext = substr($name,strrpos($name,'.')+1); + $ext = strtolower($ext); + } + if (strlen($ext)>3 && preg_match("/([\x81-\xfe][\x40-\xfe])/", $ext, $match)) { + $ext = ''; + } + return $ext; +} + + + +//自动获取不重复文件(夹)名 +//如果传入$file_add 则检测存在则自定重命名 a.txt 为a{$file_add}.txt +function get_filename_auto($path,$file_add){ + $i=1; + $father = get_path_father($path); + $name = get_path_this($path); + $ext = get_path_ext($name); + if (strlen($ext)>0) { + $ext='.'.$ext; + $name = substr($name,0,strlen($name)-strlen($ext)); + } + while(file_exists($path)){ + if (isset($file_add) && $file_add != '') { + $path = $father.$name.$file_add.$ext; + $file_add.'-'; + }else{ + $path = $father.$name.'('.$i.')'.$ext; + $i++; + } + } + return $path; +} + +/** + * 判断文件夹是否可写 + */ +function path_writable($path) { + $file = $path.'/test'.time().'.txt'; + $dir = $path.'/test'.time(); + if(@is_writable($path) && @touch($file) && @unlink($file)) return true; + if(@mkdir($dir,0777) && @rmdir($dir)) return true; + return false; +} + +/** + * 获取文件夹详细信息,文件夹属性时调用,包含子文件夹数量,文件数量,总大小 + */ +function path_info($path){ + //if (!is_dir($path)) return false; + $pathinfo = _path_info_more($path);//子目录文件大小统计信息 + $folderinfo = folder_info($path); + return array_merge($pathinfo,$folderinfo); +} + +/** + * 检查名称是否合法 + */ +function path_check($path){ + $check = array('/','\\',':','*','?','"','<','>','|'); + $path = rtrim($path,'/'); + $path = get_path_this($path); + foreach ($check as $v) { + if (strstr($path,$v)) { + return false; + } + } + return true; +} + +/** + * 递归获取文件夹信息: 子文件夹数量,文件数量,总大小 + */ +function _path_info_more($dir, &$file_num = 0, &$path_num = 0, &$size = 0){ + if (!$dh = opendir($dir)) return false; + while (($file = readdir($dh)) !== false) { + if ($file != "." && $file != "..") { + $fullpath = $dir . "/" . $file; + if (!is_dir($fullpath)) { + $file_num ++; + $size += get_filesize($fullpath); + } else { + _path_info_more($fullpath, $file_num, $path_num, $size); + $path_num ++; + } + } + } + closedir($dh); + $pathinfo['file_num'] = $file_num; + $pathinfo['folder_num'] = $path_num; + $pathinfo['size'] = $size; + $pathinfo['size_friendly'] = size_format($size); + return $pathinfo; +} + + +/** + * 获取多选文件信息,包含子文件夹数量,文件数量,总大小,父目录权限 + */ +function path_info_muti($list,$time_type){ + if (count($list) == 1) { + if ($list[0]['type']=="folder"){ + return path_info($list[0]['path'],$time_type); + }else{ + return file_info($list[0]['path'],$time_type); + } + } + $pathinfo = array( + 'file_num' => 0, + 'folder_num' => 0, + 'size' => 0, + 'size_friendly' => '', + 'father_name' => '', + 'mod' => '' + ); + foreach ($list as $val){ + if ($val['type'] == 'folder') { + $pathinfo['folder_num'] ++; + $temp = path_info($val['path']); + $pathinfo['folder_num'] += $temp['folder_num']; + $pathinfo['file_num'] += $temp['file_num']; + $pathinfo['size'] += $temp['size']; + }else{ + $pathinfo['file_num']++; + $pathinfo['size'] += get_filesize($val['path']); + } + } + $pathinfo['size_friendly'] = size_format($pathinfo['size']); + $father_name = get_path_father($list[0]['path']); + $pathinfo['mode'] = get_mode($father_name); + return $pathinfo; +} + +/** + * 获取文件夹下列表信息 + * dir 包含结尾/ d:/wwwroot/test/ + * 传入需要读取的文件夹路径,为程序编码 + */ +function path_list($dir,$list_file=true,$check_children=false){ + $dir = rtrim($dir,'/').'/'; + if (!is_dir($dir) || !($dh = opendir($dir))){ + return array('folderlist'=>array(),'filelist'=>array()); + } + $folderlist = array();$filelist = array();//文件夹与文件 + while (($file = readdir($dh)) !== false) { + if ($file != "." && $file != ".." && $file != ".svn" ) { + $fullpath = $dir . $file; + if (is_dir($fullpath)) { + $info = folder_info($fullpath); + if($check_children){ + $info['isParent'] = path_haschildren($fullpath,$list_file); + } + $folderlist[] = $info; + } else if($list_file) {//是否列出文件 + $info = file_info($fullpath); + if($check_children) $info['isParent'] = false; + $filelist[] = $info; + } + } + } + closedir($dh); + return array('folderlist' => $folderlist,'filelist' => $filelist); +} + +// 判断文件夹是否含有子内容【区分为文件或者只筛选文件夹才算】 +function path_haschildren($dir,$check_file=false){ + $dir = rtrim($dir,'/').'/'; + if (!$dh = @opendir($dir)) return false; + while (($file = readdir($dh)) !== false){ + if ($file != "." && $file != "..") { + $fullpath = $dir.$file; + if ($check_file) {//有子目录或者文件都说明有子内容 + if(is_dir($fullpath.'/') || is_file($fullpath)) return true; + }else{//只检查有没有文件 + if(is_dir($fullpath.'/')) return true; + } + } + } + closedir($dh); + return false; +} + +/** + * 删除文件 传入参数编码为操作系统编码. win--gbk + */ +function del_file($fullpath){ + if (!@unlink($fullpath)) { // 删除不了,尝试修改文件权限 + @chmod($fullpath, 0777); + if (!@unlink($fullpath)) { + return false; + } + } else { + return true; + } +} + +/** + * 删除文件夹 传入参数编码为操作系统编码. win--gbk + */ +function del_dir($dir){ + if (!$dh = opendir($dir)) return false; + while (($file = readdir($dh)) !== false) { + if ($file != "." && $file != "..") { + $fullpath = $dir . '/' . $file; + if (!is_dir($fullpath)) { + if (!unlink($fullpath)) { // 删除不了,尝试修改文件权限 + chmod($fullpath, 0777); + if (!unlink($fullpath)) { + return false; + } + } + } else { + if (!del_dir($fullpath)) { + chmod($fullpath, 0777); + if (!del_dir($fullpath)) return false; + } + } + } + } + closedir($dh); + if (rmdir($dir)) { + return true; + } else { + return false; + } +} + +/** + * 复制文件夹 + * eg:将D:/wwwroot/下面wordpress复制到 + * D:/wwwroot/www/explorer/0000/del/1/ + * 末尾都不需要加斜杠,复制到地址如果不加源文件夹名, + * 就会将wordpress下面文件复制到D:/wwwroot/www/explorer/0000/del/1/下面 + * $from = 'D:/wwwroot/wordpress'; + * $to = 'D:/wwwroot/www/explorer/0000/del/1/wordpress'; + */ + +function copy_dir($source, $dest){ + if (!$dest) return false; + if ($source == substr($dest,0,strlen($source))) return;//防止无限递归 + $result = false; + if (is_file($source)) { + if ($dest[strlen($dest)-1] == '/') { + $__dest = $dest . "/" . basename($source); + } else { + $__dest = $dest; + } + $result = copy($source, $__dest); + chmod($__dest, 0777); + }elseif (is_dir($source)) { + if ($dest[strlen($dest)-1] == '/') { + $dest = $dest . basename($source); + mkdir($dest, 0777); + } else { + mkdir($dest, 0777); + } + if (!$dh = opendir($source)) return false; + while (($file = readdir($dh)) !== false) { + if ($file != "." && $file != "..") { + if (!is_dir($source . "/" . $file)) { + $__dest = $dest . "/" . $file; + } else { + $__dest = $dest . "/" . $file; + } + $result = copy_dir($source . "/" . $file, $__dest); + } + } + closedir($dh); + } + return $result; +} + +/** + * 创建目录 + * + * @param string $dir + * @param int $mode + * @return bool + */ +function mk_dir($dir, $mode = 0777){ + if (is_dir($dir) || mkdir($dir, $mode)) + return true; + if (!mk_dir(dirname($dir), $mode)) + return false; + return mkdir($dir, $mode); +} + +/* +* 获取文件&文件夹列表(支持文件夹层级) +* path : 文件夹 $dir ——返回的文件夹array files ——返回的文件array +* $deepest 是否完整递归;$deep 递归层级 +*/ +function recursion_dir($path,&$dir,&$file,$deepest=-1,$deep=0){ + $path = rtrim($path,'/').'/'; + if (!is_array($file)) $file=array(); + if (!is_array($dir)) $dir=array(); + if (!$dh = opendir($path)) return false; + while(($val=readdir($dh)) !== false){ + if ($val=='.' || $val=='..') continue; + $value = strval($path.$val); + if (is_file($value)){ + $file[] = $value; + }else if(is_dir($value)){ + $dir[]=$value; + if ($deepest==-1 || $deep<$deepest){ + recursion_dir($value."/",$dir,$file,$deepest,$deep+1); + } + } + } + closedir($dh); + return true; +} +/* + * $search 为包含的字符串 + * is_content 表示是否搜索文件内容;默认不搜索 + * is_case 表示区分大小写,默认不区分 + */ +function path_search($path,$search,$is_content=false,$file_ext='',$is_case=false){ + $ext_arr=explode("|",$file_ext); + recursion_dir($path,$dirs,$files,-1,0); + $strpos = 'stripos';//是否区分大小写 + if ($is_case) $strpos = 'strpos'; + + $filelist = array(); + $folderlist = array(); + foreach($files as $f){ + $ext = get_path_ext($f); + $path_this = get_path_this($f); + if ($file_ext !='' && !in_array($ext,$ext_arr)) continue;//文件类型不在用户限定内 + if ($strpos($path_this,$search) !== false){//搜索文件名;搜到就返回;搜不到继续 + $filelist[] = file_info($f); + continue; + } + if ($is_content && is_file($f)){ + $fp = fopen($f, "r"); + $content = @fread($fp,get_filesize($f)); + fclose($fp); + if ($strpos($content,iconv_app($search)) !== false){ + $filelist[] = file_info($f); + } + } + } + if ($file_ext == '') {//没限定扩展名则才搜索文件夹 + foreach($dirs as $f){ + $path_this = get_path_this($f); + if ($strpos($path_this,$search) !== false){ + $folderlist[]= array( + 'name' => iconv_app(get_path_this($f)), + 'path' => iconv_app(get_path_father($f)) + ); + } + } + } + return array('folderlist' => $folderlist,'filelist' => $filelist); +} + +/** + * 修改文件、文件夹权限 + * @param $path 文件(夹)目录 + * @return :string + */ +function chmod_path($path,$mod){ + //$mod = 0777;// + if (!isset($mod)) $mod = 0777; + if (!is_dir($path)) return chmod($path,$mod); + if (!$dh = opendir($path)) return false; + while (($file = readdir($dh)) !== false){ + if ($file != "." && $file != "..") { + $fullpath = $path . '/' . $file; + return chmod_path($fullpath,$mod); + } + } + closedir($dh); + return chmod($path,$mod); +} + +/** + * 文件大小格式化 + * + * @param $ :$bytes, int 文件大小 + * @param $ :$precision int 保留小数点 + * @return :string + */ +function size_format($bytes, $precision = 2){ + if ($bytes == 0) return "0 B"; + $unit = array( + 'TB' => 1099511627776, // pow( 1024, 4) + 'GB' => 1073741824, // pow( 1024, 3) + 'MB' => 1048576, // pow( 1024, 2) + 'kB' => 1024, // pow( 1024, 1) + 'B ' => 1, // pow( 1024, 0) + ); + foreach ($unit as $un => $mag) { + if (doubleval($bytes) >= $mag) + return round($bytes / $mag, $precision).' '.$un; + } +} + +/** + * 判断路径是不是绝对路径 + * 返回true('/foo/bar','c:\windows'). + * + * @return 返回true则为绝对路径,否则为相对路径 + */ +function path_is_absolute($path){ + if (realpath($path) == $path)// *nux 的绝对路径 /home/my + return true; + if (strlen($path) == 0 || $path[0] == '.') + return false; + if (preg_match('#^[a-zA-Z]:\\\\#', $path))// windows 的绝对路径 c:\aaa\ + return true; + return (bool)preg_match('#^[/\\\\]#', $path); //绝对路径 运行 / 和 \绝对路径,其他的则为相对路径 +} + +/** + * 获取扩展名的文件类型 + * + * @param $ :$ext string 扩展名 + * @return :string; + */ +function ext_type($ext){ + $ext2type = array( + 'text' => array('txt','ini','log','asc','csv','tsv','vbs','bat','cmd','inc','conf','inf'), + 'code' => array('css','htm','html','php','js','c','cpp','h','java','cs','sql','xml'), + 'picture' => array('jpg','jpeg','png','gif','ico','bmp','tif','tiff','dib','rle'), + 'audio' => array('mp3','ogg','oga','mid','midi','ram','wav','wma','aac','ac3','aif','aiff','m3a','m4a','m4b','mka','mp1','mx3','mp2'), + 'flash' => array('swf'), + 'video' => array('rm','rmvb','flv','mkv','wmv','asf','avi','aiff','mp4','divx','dv','m4v','mov','mpeg','vob','mpg','mpv','ogm','ogv','qt'), + 'document' => array('doc','docx','docm','dotm','odt','pages','pdf','rtf','xls','xlsx','xlsb','xlsm','ppt','pptx','pptm','odp'), + 'rar_achieve' => array('rar','arj','tar','ace','gz','lzh','uue','bz2'), + 'zip_achieve' => array('zip','gzip','cab','tbz','tbz2'), + 'other_achieve' => array('dmg','sea','sit','sqx') + ); + foreach ($ext2type as $type => $exts) { + if (in_array($ext, $exts)) { + return $type; + } + } +} + +/** + * 输出、文件下载 + * 默认以附件方式下载;$download为false时则为输出文件 + */ +function file_put_out($file,$download=false){ + if (!is_file($file)) show_json('not a file!'); + set_time_limit(0); + //ob_clean();//清除之前所有输出缓冲 + if (!file_exists($file)) show_json('file not exists',false); + if (isset($_SERVER['HTTP_RANGE']) && ($_SERVER['HTTP_RANGE'] != "") && + preg_match("/^bytes=([0-9]+)-$/i", $_SERVER['HTTP_RANGE'], $match) && ($match[1] < $fsize)) { + $start = $match[1]; + }else{ + $start = 0; + } + $size = get_filesize($file); + header("Cache-Control: public"); + header("X-Powered-By: kodExplorer."); + if ($download) { + header("Content-Type: application/octet-stream"); + $filename = get_path_this($file);//解决在IE中下载时中文乱码问题 + if(preg_match('/MSIE/',$_SERVER['HTTP_USER_AGENT'])){ + $filename = str_replace('+','%20',urlencode($filename)); + } + header("Content-Disposition: attachment;filename=".$filename); + }else{ + $mime = get_file_mime(get_path_ext($file)); + header("Content-Type: ".$mime); + } + if ($start > 0){ + header("HTTP/1.1 206 Partial Content"); + header("Content-Ranges: bytes".$start ."-".($size - 1)."/" .$size); + header("Content-Length: ".($size - $start)); + }else{ + header("Accept-Ranges: bytes"); + header("Content-Length: $size"); + } + + $fp = fopen($file, "rb"); + fseek($fp, $start); + while (!feof($fp)) { + print (fread($fp, 1024 * 8)); //输出文件 + flush(); + ob_flush(); + } + fclose($fp); +} + +/** + * 文件下载到服务器 + */ +function file_download_this($from, $file_name){ + set_time_limit(0); + $fp = @fopen ($from, "rb"); + if ($fp){ + $new_fp = @fopen ($file_name, "wb"); + fclose($new_fp); + + $temp_file = $file_name.'.download'; + $download_fp = @fopen ($temp_file, "wb"); + while(!feof($fp)){ + if(!file_exists($file_name)){//删除目标文件;则终止下载 + fclose($download_fp); + del_file($temp_file); + del_file($file_name); + return false; + } + fwrite($download_fp, fread($fp, 1024 * 8 ), 1024 * 8); + } + //下载完成,重命名临时文件到目标文件 + del_file($file_name); + rename($temp_file,$file_name); + return true; + }else{ + return false; + } +} + +/** + * 获取文件(夹)权限 rwx_rwx_rwx + */ +function get_mode($file){ + $Mode = fileperms($file); + $theMode = ' '.decoct($Mode); + $theMode = substr($theMode,-4); + $Owner = array();$Group=array();$World=array(); + if ($Mode &0x1000) $Type = 'p'; // FIFO pipe + elseif ($Mode &0x2000) $Type = 'c'; // Character special + elseif ($Mode &0x4000) $Type = 'd'; // Directory + elseif ($Mode &0x6000) $Type = 'b'; // Block special + elseif ($Mode &0x8000) $Type = '-'; // Regular + elseif ($Mode &0xA000) $Type = 'l'; // Symbolic Link + elseif ($Mode &0xC000) $Type = 's'; // Socket + else $Type = 'u'; // UNKNOWN + // Determine les permissions par Groupe + $Owner['r'] = ($Mode &00400) ? 'r' : '-'; + $Owner['w'] = ($Mode &00200) ? 'w' : '-'; + $Owner['x'] = ($Mode &00100) ? 'x' : '-'; + $Group['r'] = ($Mode &00040) ? 'r' : '-'; + $Group['w'] = ($Mode &00020) ? 'w' : '-'; + $Group['e'] = ($Mode &00010) ? 'x' : '-'; + $World['r'] = ($Mode &00004) ? 'r' : '-'; + $World['w'] = ($Mode &00002) ? 'w' : '-'; + $World['e'] = ($Mode &00001) ? 'x' : '-'; + // Adjuste pour SUID, SGID et sticky bit + if ($Mode &0x800) $Owner['e'] = ($Owner['e'] == 'x') ? 's' : 'S'; + if ($Mode &0x400) $Group['e'] = ($Group['e'] == 'x') ? 's' : 'S'; + if ($Mode &0x200) $World['e'] = ($World['e'] == 'x') ? 't' : 'T'; + $Mode = $Type.$Owner['r'].$Owner['w'].$Owner['x'].' '. + $Group['r'].$Group['w'].$Group['e'].' '. + $World['r'].$World['w'].$World['e']; + return $Mode.' ('.$theMode.') '; +} + +/** + * 获取可以上传的最大值 + * return * byte + */ +function get_post_max(){ + $upload = ini_get('upload_max_filesize'); + $upload = $upload==''?ini_get('upload_max_size'):$upload; + $post = ini_get('post_max_size'); + $upload = intval($upload)*1024*1024; + $post = intval($post)*1024*1024; + return $upload<$post?$upload:$post; +} + +/** + * 文件上传处理。单个文件上传,多个分多次请求 + * 调用demo + * upload('file','D:/www/'); + */ +function upload($fileInput, $path = './'){ + global $config,$L; + $file = $_FILES[$fileInput]; + if (!isset($file)) show_json($L['upload_error_null'],false); + + $file_name = iconv_system($file['name']); + $save_path = get_filename_auto($path.$file_name); + if(move_uploaded_file($file['tmp_name'],$save_path)){ + show_json($L['upload_success'],true,iconv_app($save_pathe)); + }else { + show_json($L['move_error'],false); + } +} + +//分片上传处理 +function upload_chunk($fileInput, $path = './',$temp_path){ + global $config,$L; + $file = $_FILES[$fileInput]; + $chunk = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0; + $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 1; + if (!isset($file)) show_json($L['upload_error_null'],false); + $file_name = iconv_system($file['name']); + + if ($chunks>1) {//并发上传,不一定有前后顺序 + $temp_file_pre = $temp_path.md5($temp_path.$file_name).'.part'; + if (get_filesize($file['tmp_name']) ==0) { + show_json($L['upload_success'],false,'chunk_'.$chunk.' error!'); + } + if(move_uploaded_file($file['tmp_name'],$temp_file_pre.$chunk)){ + $done = true; + for($index = 0; $index<$chunks; $index++ ){ + if (!file_exists($temp_file_pre.$index)) { + $done = false; + break; + } + } + if (!$done){ + show_json($L['upload_success'],true,'chunk_'.$chunk.' success!'); + } + + $save_path = $path.$file_name; + $out = fopen($save_path, "wb"); + if ($done && flock($out, LOCK_EX)) { + for( $index = 0; $index < $chunks; $index++ ) { + if (!$in = fopen($temp_file_pre.$index,"rb")) break; + while ($buff = fread($in, 4096)) { + fwrite($out, $buff); + } + fclose($in); + unlink($temp_file_pre.$index); + } + flock($out, LOCK_UN); + fclose($out); + } + show_json($L['upload_success'],true,iconv_app($save_path)); + }else { + show_json($L['move_error'],false); + } + } + + //正常上传 + $save_path = get_filename_auto($path.$file_name); //自动重命名 + if(move_uploaded_file($file['tmp_name'],$save_path)){ + show_json($L['upload_success'],true,iconv_app($save_path)); + }else { + show_json($L['move_error'],false); + } +} + +/** + * 写日志 + * @param string $log 日志信息 + * @param string $type 日志类型 [system|app|...] + * @param string $level 日志级别 + * @return boolean + */ +function write_log($log, $type = 'default', $level = 'log'){ + $now_time = date('[y-m-d H:i:s]'); + $now_day = date('Y_m_d'); + // 根据类型设置日志目标位置 + $target = LOG_PATH . strtolower($type) . '/'; + mk_dir($target, 0777); + if (! is_writable($target)) exit('path can not write!'); + switch($level){// 分级写日志 + case 'error': $target .= 'Error_' . $now_day . '.log';break; + case 'warning': $target .= 'Warning_' . $now_day . '.log';break; + case 'debug': $target .= 'Debug_' . $now_day . '.log';break; + case 'info': $target .= 'Info_' . $now_day . '.log';break; + case 'db': $target .= 'Db_' . $now_day . '.log';break; + default: $target .= 'Log_' . $now_day . '.log';break; + } + //检测日志文件大小, 超过配置大小则重命名 + if (file_exists($target) && get_filesize($target) <= 100000) { + $file_name = substr(basename($target),0,strrpos(basename($target),'.log')).'.log'; + rename($target, dirname($target) .'/'. $file_name); + } + clearstatcache(); + return error_log("$now_time $log\n", 3, $target); } \ No newline at end of file diff --git a/lib/function/web.function.php b/lib/function/web.function.php old mode 100644 new mode 100755 index f1c2a34..f9e3157 --- a/lib/function/web.function.php +++ b/lib/function/web.function.php @@ -1,550 +1,573 @@ -$length,'name'=>$name); -} - - -// url检查 -function check_url($url){ - $array = get_headers($url,true); - if (preg_match('/404/', $array[0])) { - return false; - } elseif (preg_match('/403/', $array[0])) { - return false; - } else { - return true; - } -} - -/** - * 获取网络url文件内容,加入ua,以解决防采集的站 - */ -function curl_get_contents($url){ - $ch = curl_init(); - $timeout = 4; - $user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1)"; - curl_setopt ($ch, CURLOPT_URL, $url); - curl_setopt ($ch, CURLOPT_HEADER, 0); - curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); - curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); - $file_contents = curl_exec($ch); - curl_close($ch); - return $file_contents; -} - -// 返回refer URL 地址 -function refer_url(){ - return isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : ''; -} -// 返回当前页面的 URL 地址 -function this_url(){ - $s_url = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] ? 'https' : 'http'; - $s_url .= '://'; - return $s_url . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; -} - -function select_var($array){ - if (!is_array($array)) return -1; - ksort($array); - $chosen = -1; - foreach ($array as $k => $v) { - if (isset($v)) { - $chosen = $v; - break; - } - } - return $chosen; -} - - -function stripslashes_deep($value){ - $value = is_array($value) ? array_map('stripslashes_deep', $value) : (isset($value) ? stripslashes($value) : null); - return $value; -} - -/** - * GET/POST数据统一入口 - * 将GET和POST的数据进行过滤,去掉非法字符以及hacker code,返回一个数组 - * 注意如果GET和POST有相同的Key,POST优先 - * - * @return array $_GET和$_POST数据过滤处理后的值 - */ -function parse_incoming(){ - global $_GET, $_POST,$_COOKIE; - - $_COOKIE = stripslashes_deep($_COOKIE); - $_GET = stripslashes_deep($_GET); - $_POST = stripslashes_deep($_POST); - $return = array(); - $return = array_merge($_GET,$_POST); - $remote = array_get($return,0); - $remote = explode('/',trim($remote[0],'/')); - $return['URLremote'] = $remote; - return $return; -} - -function url2absolute($index_url, $preg_url){ - if (preg_match('/[a-zA-Z]*\:\/\//', $preg_url)) return $preg_url; - preg_match('/([a-zA-Z]*\:\/\/.*)\//', $index_url, $match); - $index_url_temp = $match[1]; - - foreach(explode('/', $preg_url) as $key => $var) { - if ($key == 0 && $var == '') { - preg_match('/([a-zA-Z]*\:\/\/[^\/]*)\//', $index_url, $match); - $index_url_temp = $match[1] . $preg_url; - break; - } - if ($var == '..') { - preg_match('/([a-zA-Z]*\:\/\/.*)\//', $index_url_temp, $match); - $index_url_temp = $match[1]; - } elseif ($var != '.') $index_url_temp .= '/' . $var; - } - return $index_url_temp; -} - -// 将字符串转换成URL的编码,gbk的和utf8的 $to="gbk" 或"utf8" -function urlcode($str, $to){ - if ($to == "gbk") { - $result = RawUrlEncode($str); //gbk字符(主要是中文)转换为url %BA%EC形式 - } else { - $key = mb_convert_encoding($str, "utf-8", "gbk"); //对于百度utf8中文url - $result = urlencode($key); - } - return $result; -} - -// 输出js -function exec_js($js){ - echo "\n"; -} -// 禁止缓存 -function no_cache(){ - header("Pragma:no-cache\r\n"); - header("Cache-Control:no-cache\r\n"); - header("Expires:0\r\n"); -} -// 生成javascript转向 -function go_url($url, $msg = ''){ - header("Content-type: text/html; charset=utf-8\r\n"); - echo "\n"; - exit; -} - -/** - * 消息框。eg - * msg("falied","/",10); - * msg("ok"); - */ -function show_msg($message, $url = '#', $time = 3, $isgo = 1) -{ - $goto = "content='$time;url=$url'"; - if ($isgo != "1") { - $goto = ""; - } //是否自动跳转 - echo<< - - - -
    -
    提示信息
    -
    $message
    -
    $time 秒后自动跳转,如不想等待可 点击这里
    - - -END; - exit; -} - -function send_http_status($i_status, $s_message = ''){ - $a_status = array( - // Informational 1xx - 100 => 'Continue', - 101 => 'Switching Protocols', - // Success 2xx - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - // Redirection 3xx - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', // 1.1 - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', // 306 is deprecated but reserved - 307 => 'Temporary Redirect', - // Client Error 4xx - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - // Server Error 5xx - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 509 => 'Bandwidth Limit Exceeded' - ); - - if (array_key_exists($i_status, $a_status)) { - header('HTTP/1.1 ' . $i_status . ' ' . $a_status[$i_status]); - } - if ($s_message) { - echo $s_message; - exit(); - } -} - -// 获取操作系统信息 -function get_os (){ - $agent = $_SERVER['HTTP_USER_AGENT']; - $os = false; - if (eregi('win', $agent) && strpos($agent, '95')) { - $os = 'Windows 95'; - } else if (eregi('win 9x', $agent) && strpos($agent, '4.90')) { - $os = 'Windows ME'; - } else if (eregi('win', $agent) && ereg('98', $agent)) { - $os = 'Windows 98'; - } else if (eregi('win', $agent) && eregi('nt 5.1', $agent)) { - $os = 'Windows XP'; - } else if (eregi('win', $agent) && eregi('nt 5', $agent)) { - $os = 'Windows 2000'; - } else if (eregi('win', $agent) && eregi('nt', $agent)) { - $os = 'Windows NT'; - } else if (eregi('win', $agent) && ereg('32', $agent)) { - $os = 'Windows 32'; - } else if (eregi('linux', $agent)) { - $os = 'Linux'; - } else if (eregi('unix', $agent)) { - $os = 'Unix'; - } else if (eregi('sun', $agent) && eregi('os', $agent)) { - $os = 'SunOS'; - } else if (eregi('ibm', $agent) && eregi('os', $agent)) { - $os = 'IBM OS/2'; - } else if (eregi('Mac', $agent) && eregi('PC', $agent)) { - $os = 'Macintosh'; - } else if (eregi('PowerPC', $agent)) { - $os = 'PowerPC'; - } else if (eregi('AIX', $agent)) { - $os = 'AIX'; - } else if (eregi('HPUX', $agent)) { - $os = 'HPUX'; - } else if (eregi('NetBSD', $agent)) { - $os = 'NetBSD'; - } else if (eregi('BSD', $agent)) { - $os = 'BSD'; - } else if (ereg('OSF1', $agent)) { - $os = 'OSF1'; - } else if (ereg('IRIX', $agent)) { - $os = 'IRIX'; - } else if (eregi('FreeBSD', $agent)) { - $os = 'FreeBSD'; - } else if (eregi('teleport', $agent)) { - $os = 'teleport'; - } else if (eregi('flashget', $agent)) { - $os = 'flashget'; - } else if (eregi('webzip', $agent)) { - $os = 'webzip'; - } else if (eregi('offline', $agent)) { - $os = 'offline'; - } else { - $os = 'Unknown'; - } - return $os; -} - -//根据扩展名获取mime -function get_file_mime($ext){ - $mimetypes = array( - "323" => "text/h323", - "acx" => "application/internet-property-stream", - "ai" => "application/postscript", - "aif" => "audio/x-aiff", - "aifc" => "audio/x-aiff", - "aiff" => "audio/x-aiff", - "asf" => "video/x-ms-asf", - "asr" => "video/x-ms-asf", - "asx" => "video/x-ms-asf", - "au" => "audio/basic", - "avi" => "video/x-msvideo", - "axs" => "application/olescript", - "bas" => "text/plain", - "bcpio" => "application/x-bcpio", - "bin" => "application/octet-stream", - "bmp" => "image/bmp", - "c" => "text/plain", - "cat" => "application/vnd.ms-pkiseccat", - "cdf" => "application/x-cdf", - "cer" => "application/x-x509-ca-cert", - "class" => "application/octet-stream", - "clp" => "application/x-msclip", - "cmx" => "image/x-cmx", - "cod" => "image/cis-cod", - "cpio" => "application/x-cpio", - "crd" => "application/x-mscardfile", - "crl" => "application/pkix-crl", - "crt" => "application/x-x509-ca-cert", - "csh" => "application/x-csh", - "css" => "text/css", - "dcr" => "application/x-director", - "der" => "application/x-x509-ca-cert", - "dir" => "application/x-director", - "dll" => "application/x-msdownload", - "dms" => "application/octet-stream", - "doc" => "application/msword", - "dot" => "application/msword", - "dvi" => "application/x-dvi", - "dxr" => "application/x-director", - "eps" => "application/postscript", - "etx" => "text/x-setext", - "evy" => "application/envoy", - "exe" => "application/octet-stream", - "fif" => "application/fractals", - "flr" => "x-world/x-vrml", - "gif" => "image/gif", - "gtar" => "application/x-gtar", - "gz" => "application/x-gzip", - "h" => "text/plain", - "hdf" => "application/x-hdf", - "hlp" => "application/winhlp", - "hqx" => "application/mac-binhex40", - "hta" => "application/hta", - "htc" => "text/x-component", - "htm" => "text/html", - "html" => "text/html", - "htt" => "text/webviewhtml", - "ico" => "image/x-icon", - "ief" => "image/ief", - "iii" => "application/x-iphone", - "ins" => "application/x-internet-signup", - "isp" => "application/x-internet-signup", - "jfif" => "image/pipeg", - "jpe" => "image/jpeg", - "jpeg" => "image/jpeg", - "jpg" => "image/jpeg", - "js" => "application/x-javascript", - "latex" => "application/x-latex", - "lha" => "application/octet-stream", - "lsf" => "video/x-la-asf", - "lsx" => "video/x-la-asf", - "lzh" => "application/octet-stream", - "m13" => "application/x-msmediaview", - "m14" => "application/x-msmediaview", - "m3u" => "audio/x-mpegurl", - "man" => "application/x-troff-man", - "mdb" => "application/x-msaccess", - "me" => "application/x-troff-me", - "mht" => "message/rfc822", - "mhtml" => "message/rfc822", - "mid" => "audio/mid", - "mny" => "application/x-msmoney", - "mov" => "video/quicktime", - "movie" => "video/x-sgi-movie", - "mp2" => "video/mpeg", - "mp3" => "audio/mpeg", - "mp4" => "video/mpeg", - "mpa" => "video/mpeg", - "mpe" => "video/mpeg", - "mpeg" => "video/mpeg", - "mpg" => "video/mpeg", - "mpp" => "application/vnd.ms-project", - "mpv2" => "video/mpeg", - "ms" => "application/x-troff-ms", - "mvb" => "application/x-msmediaview", - "nws" => "message/rfc822", - "oda" => "application/oda", - "p10" => "application/pkcs10", - "p12" => "application/x-pkcs12", - "p7b" => "application/x-pkcs7-certificates", - "p7c" => "application/x-pkcs7-mime", - "p7m" => "application/x-pkcs7-mime", - "p7r" => "application/x-pkcs7-certreqresp", - "p7s" => "application/x-pkcs7-signature", - "pbm" => "image/x-portable-bitmap", - "pdf" => "application/pdf", - "pfx" => "application/x-pkcs12", - "pgm" => "image/x-portable-graymap", - "pko" => "application/ynd.ms-pkipko", - "pma" => "application/x-perfmon", - "pmc" => "application/x-perfmon", - "pml" => "application/x-perfmon", - "pmr" => "application/x-perfmon", - "pmw" => "application/x-perfmon", - "png" => "image/png", - "pnm" => "image/x-portable-anymap", - "pot," => "application/vnd.ms-powerpoint", - "ppm" => "image/x-portable-pixmap", - "pps" => "application/vnd.ms-powerpoint", - "ppt" => "application/vnd.ms-powerpoint", - "prf" => "application/pics-rules", - "ps" => "application/postscript", - "pub" => "application/x-mspublisher", - "qt" => "video/quicktime", - "ra" => "audio/x-pn-realaudio", - "ram" => "audio/x-pn-realaudio", - "ras" => "image/x-cmu-raster", - "rgb" => "image/x-rgb", - "rmi audio/mid" => "http://www.dreamdu.com", - "roff" => "application/x-troff", - "rtf" => "application/rtf", - "rtx" => "text/richtext", - "scd" => "application/x-msschedule", - "sct" => "text/scriptlet", - "setpay" => "application/set-payment-initiation", - "setreg" => "application/set-registration-initiation", - "sh" => "application/x-sh", - "shar" => "application/x-shar", - "sit" => "application/x-stuffit", - "snd" => "audio/basic", - "spc" => "application/x-pkcs7-certificates", - "spl" => "application/futuresplash", - "src" => "application/x-wais-source", - "sst" => "application/vnd.ms-pkicertstore", - "stl" => "application/vnd.ms-pkistl", - "stm" => "text/html", - "svg" => "image/svg+xml", - "sv4cpio" => "application/x-sv4cpio", - "sv4crc" => "application/x-sv4crc", - "swf" => "application/x-shockwave-flash", - "t" => "application/x-troff", - "tar" => "application/x-tar", - "tcl" => "application/x-tcl", - "tex" => "application/x-tex", - "texi" => "application/x-texinfo", - "texinfo" => "application/x-texinfo", - "tgz" => "application/x-compressed", - "tif" => "image/tiff", - "tiff" => "image/tiff", - "tr" => "application/x-troff", - "trm" => "application/x-msterminal", - "tsv" => "text/tab-separated-values", - "txt" => "text/plain", - "uls" => "text/iuls", - "ustar" => "application/x-ustar", - "vcf" => "text/x-vcard", - "vrml" => "x-world/x-vrml", - "wav" => "audio/x-wav", - "wcm" => "application/vnd.ms-works", - "wdb" => "application/vnd.ms-works", - "wks" => "application/vnd.ms-works", - "wmf" => "application/x-msmetafile", - "wps" => "application/vnd.ms-works", - "wri" => "application/x-mswrite", - "wrl" => "x-world/x-vrml", - "wrz" => "x-world/x-vrml", - "xaf" => "x-world/x-vrml", - "xbm" => "image/x-xbitmap", - "xla" => "application/vnd.ms-excel", - "xlc" => "application/vnd.ms-excel", - "xlm" => "application/vnd.ms-excel", - "xls" => "application/vnd.ms-excel", - "xlt" => "application/vnd.ms-excel", - "xlw" => "application/vnd.ms-excel", - "xof" => "x-world/x-vrml", - "xpm" => "image/x-xpixmap", - "xwd" => "image/x-xwindowdump", - "z" => "application/x-compress", - "zip" => "application/zip" - ); - if (array_key_exists($ext,$mimetypes)){ - return $mimetypes[$ext]; - }else{ - return 'application/octet-stream'; - } -} +$length,'name'=>$name); +} + + +// url检查 +function check_url($url){ + $array = get_headers($url,true); + if (preg_match('/404/', $array[0])) { + return false; + } elseif (preg_match('/403/', $array[0])) { + return false; + } else { + return true; + } +} + +/** + * 获取网络url文件内容,加入ua,以解决防采集的站 + */ +function curl_get_contents($url){ + $ch = curl_init(); + $timeout = 4; + $user_agent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1)"; + curl_setopt ($ch, CURLOPT_URL, $url); + curl_setopt ($ch, CURLOPT_HEADER, 0); + curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); + curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); + $file_contents = curl_exec($ch); + curl_close($ch); + return $file_contents; +} + +// 返回refer URL 地址 +function refer_url(){ + return isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : ''; +} +// 返回当前页面的 URL 地址 +function this_url(){ + $s_url = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] ? 'https' : 'http'; + $s_url .= '://'; + return $s_url . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; +} + +function select_var($array){ + if (!is_array($array)) return -1; + ksort($array); + $chosen = -1; + foreach ($array as $k => $v) { + if (isset($v)) { + $chosen = $v; + break; + } + } + return $chosen; +} + + +function stripslashes_deep($value){ + $value = is_array($value) ? array_map('stripslashes_deep', $value) : (isset($value) ? stripslashes($value) : null); + return $value; +} + +/** + * GET/POST数据统一入口 + * 将GET和POST的数据进行过滤,去掉非法字符以及hacker code,返回一个数组 + * 注意如果GET和POST有相同的Key,POST优先 + * + * @return array $_GET和$_POST数据过滤处理后的值 + */ +function parse_incoming(){ + global $_GET, $_POST,$_COOKIE; + + $_COOKIE = stripslashes_deep($_COOKIE); + $_GET = stripslashes_deep($_GET); + $_POST = stripslashes_deep($_POST); + $return = array(); + $return = array_merge($_GET,$_POST); + $remote = array_get($return,0); + $remote = explode('/',trim($remote[0],'/')); + $return['URLremote'] = $remote; + return $return; +} + +function url2absolute($index_url, $preg_url){ + if (preg_match('/[a-zA-Z]*\:\/\//', $preg_url)) return $preg_url; + preg_match('/([a-zA-Z]*\:\/\/.*)\//', $index_url, $match); + $index_url_temp = $match[1]; + + foreach(explode('/', $preg_url) as $key => $var) { + if ($key == 0 && $var == '') { + preg_match('/([a-zA-Z]*\:\/\/[^\/]*)\//', $index_url, $match); + $index_url_temp = $match[1] . $preg_url; + break; + } + if ($var == '..') { + preg_match('/([a-zA-Z]*\:\/\/.*)\//', $index_url_temp, $match); + $index_url_temp = $match[1]; + } elseif ($var != '.') $index_url_temp .= '/' . $var; + } + return $index_url_temp; +} + +// 将字符串转换成URL的编码,gbk的和utf8的 $to="gbk" 或"utf8" +function urlcode($str, $to){ + if ($to == "gbk") { + $result = RawUrlEncode($str); //gbk字符(主要是中文)转换为url %BA%EC形式 + } else { + $key = mb_convert_encoding($str, "utf-8", "gbk"); //对于百度utf8中文url + $result = urlencode($key); + } + return $result; +} + +// 输出js +function exec_js($js){ + echo "\n"; +} +// 禁止缓存 +function no_cache(){ + header("Pragma:no-cache\r\n"); + header("Cache-Control:no-cache\r\n"); + header("Expires:0\r\n"); +} +// 生成javascript转向 +function go_url($url, $msg = ''){ + header("Content-type: text/html; charset=utf-8\r\n"); + echo "\n"; + exit; +} + +/** + * 消息框。eg + * msg("falied","/",10); + * msg("ok"); + */ +function show_msg($message, $url = '#', $time = 3, $isgo = 1) +{ + $goto = "content='$time;url=$url'"; + if ($isgo != "1") { + $goto = ""; + } //是否自动跳转 + echo<< + + + +
    +
    提示信息
    +
    $message
    +
    $time 秒后自动跳转,如不想等待可 点击这里
    + + +END; + exit; +} + +function send_http_status($i_status, $s_message = ''){ + $a_status = array( + // Informational 1xx + 100 => 'Continue', + 101 => 'Switching Protocols', + // Success 2xx + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + // Redirection 3xx + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', // 1.1 + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', // 306 is deprecated but reserved + 307 => 'Temporary Redirect', + // Client Error 4xx + 400 => 'Bad Request', + 401 => 'Unauthorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Long', + 415 => 'Unsupported Media Type', + 416 => 'Requested Range Not Satisfiable', + 417 => 'Expectation Failed', + // Server Error 5xx + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version Not Supported', + 509 => 'Bandwidth Limit Exceeded' + ); + + if (array_key_exists($i_status, $a_status)) { + header('HTTP/1.1 ' . $i_status . ' ' . $a_status[$i_status]); + } + if ($s_message) { + echo $s_message; + exit(); + } +} + +// 获取操作系统信息 +function get_os (){ + $agent = $_SERVER['HTTP_USER_AGENT']; + $os = false; + if (eregi('win', $agent) && strpos($agent, '95')) { + $os = 'Windows 95'; + } else if (eregi('win 9x', $agent) && strpos($agent, '4.90')) { + $os = 'Windows ME'; + } else if (eregi('win', $agent) && ereg('98', $agent)) { + $os = 'Windows 98'; + } else if (eregi('win', $agent) && eregi('nt 5.1', $agent)) { + $os = 'Windows XP'; + } else if (eregi('win', $agent) && eregi('nt 5', $agent)) { + $os = 'Windows 2000'; + } else if (eregi('win', $agent) && eregi('nt', $agent)) { + $os = 'Windows NT'; + } else if (eregi('win', $agent) && ereg('32', $agent)) { + $os = 'Windows 32'; + } else if (eregi('linux', $agent)) { + $os = 'Linux'; + } else if (eregi('unix', $agent)) { + $os = 'Unix'; + } else if (eregi('sun', $agent) && eregi('os', $agent)) { + $os = 'SunOS'; + } else if (eregi('ibm', $agent) && eregi('os', $agent)) { + $os = 'IBM OS/2'; + } else if (eregi('Mac', $agent) && eregi('PC', $agent)) { + $os = 'Macintosh'; + } else if (eregi('PowerPC', $agent)) { + $os = 'PowerPC'; + } else if (eregi('AIX', $agent)) { + $os = 'AIX'; + } else if (eregi('HPUX', $agent)) { + $os = 'HPUX'; + } else if (eregi('NetBSD', $agent)) { + $os = 'NetBSD'; + } else if (eregi('BSD', $agent)) { + $os = 'BSD'; + } else if (ereg('OSF1', $agent)) { + $os = 'OSF1'; + } else if (ereg('IRIX', $agent)) { + $os = 'IRIX'; + } else if (eregi('FreeBSD', $agent)) { + $os = 'FreeBSD'; + } else if (eregi('teleport', $agent)) { + $os = 'teleport'; + } else if (eregi('flashget', $agent)) { + $os = 'flashget'; + } else if (eregi('webzip', $agent)) { + $os = 'webzip'; + } else if (eregi('offline', $agent)) { + $os = 'offline'; + } else { + $os = 'Unknown'; + } + return $os; +} + +//根据扩展名获取mime +function get_file_mime($ext){ + $mimetypes = array( + "323" => "text/h323", + "acx" => "application/internet-property-stream", + "ai" => "application/postscript", + "aif" => "audio/x-aiff", + "aifc" => "audio/x-aiff", + "aiff" => "audio/x-aiff", + "asf" => "video/x-ms-asf", + "asr" => "video/x-ms-asf", + "asx" => "video/x-ms-asf", + "au" => "audio/basic", + "avi" => "video/x-msvideo", + "axs" => "application/olescript", + "bas" => "text/plain", + "bcpio" => "application/x-bcpio", + "bin" => "application/octet-stream", + "bmp" => "image/bmp", + "c" => "text/plain", + "cat" => "application/vnd.ms-pkiseccat", + "cdf" => "application/x-cdf", + "cer" => "application/x-x509-ca-cert", + "class" => "application/octet-stream", + "clp" => "application/x-msclip", + "cmx" => "image/x-cmx", + "cod" => "image/cis-cod", + "cpio" => "application/x-cpio", + "crd" => "application/x-mscardfile", + "crl" => "application/pkix-crl", + "crt" => "application/x-x509-ca-cert", + "csh" => "application/x-csh", + "css" => "text/css", + "dcr" => "application/x-director", + "der" => "application/x-x509-ca-cert", + "dir" => "application/x-director", + "dll" => "application/x-msdownload", + "dms" => "application/octet-stream", + "doc" => "application/msword", + "dot" => "application/msword", + "dvi" => "application/x-dvi", + "dxr" => "application/x-director", + "eps" => "application/postscript", + "etx" => "text/x-setext", + "evy" => "application/envoy", + "exe" => "application/octet-stream", + "fif" => "application/fractals", + "flr" => "x-world/x-vrml", + "gif" => "image/gif", + "gtar" => "application/x-gtar", + "gz" => "application/x-gzip", + "h" => "text/plain", + "hdf" => "application/x-hdf", + "hlp" => "application/winhlp", + "hqx" => "application/mac-binhex40", + "hta" => "application/hta", + "htc" => "text/x-component", + "htm" => "text/html", + "html" => "text/html", + "htt" => "text/webviewhtml", + "ico" => "image/x-icon", + "ief" => "image/ief", + "iii" => "application/x-iphone", + "ins" => "application/x-internet-signup", + "isp" => "application/x-internet-signup", + "jfif" => "image/pipeg", + "jpe" => "image/jpeg", + "jpeg" => "image/jpeg", + "jpg" => "image/jpeg", + "js" => "application/x-javascript", + "latex" => "application/x-latex", + "lha" => "application/octet-stream", + "lsf" => "video/x-la-asf", + "lsx" => "video/x-la-asf", + "lzh" => "application/octet-stream", + "m13" => "application/x-msmediaview", + "m14" => "application/x-msmediaview", + "m3u" => "audio/x-mpegurl", + "man" => "application/x-troff-man", + "mdb" => "application/x-msaccess", + "me" => "application/x-troff-me", + "mht" => "message/rfc822", + "mhtml" => "message/rfc822", + "mid" => "audio/mid", + "mny" => "application/x-msmoney", + "mov" => "video/quicktime", + "movie" => "video/x-sgi-movie", + "mp2" => "video/mpeg", + "mp3" => "audio/mpeg", + "mp4" => "video/mpeg", + "mpa" => "video/mpeg", + "mpe" => "video/mpeg", + "mpeg" => "video/mpeg", + "mpg" => "video/mpeg", + "mpp" => "application/vnd.ms-project", + "mpv2" => "video/mpeg", + "ms" => "application/x-troff-ms", + "mvb" => "application/x-msmediaview", + "nws" => "message/rfc822", + "oda" => "application/oda", + "p10" => "application/pkcs10", + "p12" => "application/x-pkcs12", + "p7b" => "application/x-pkcs7-certificates", + "p7c" => "application/x-pkcs7-mime", + "p7m" => "application/x-pkcs7-mime", + "p7r" => "application/x-pkcs7-certreqresp", + "p7s" => "application/x-pkcs7-signature", + "pbm" => "image/x-portable-bitmap", + "pdf" => "application/pdf", + "pfx" => "application/x-pkcs12", + "pgm" => "image/x-portable-graymap", + "pko" => "application/ynd.ms-pkipko", + "pma" => "application/x-perfmon", + "pmc" => "application/x-perfmon", + "pml" => "application/x-perfmon", + "pmr" => "application/x-perfmon", + "pmw" => "application/x-perfmon", + "png" => "image/png", + "pnm" => "image/x-portable-anymap", + "pot," => "application/vnd.ms-powerpoint", + "ppm" => "image/x-portable-pixmap", + "pps" => "application/vnd.ms-powerpoint", + "ppt" => "application/vnd.ms-powerpoint", + "prf" => "application/pics-rules", + "ps" => "application/postscript", + "pub" => "application/x-mspublisher", + "qt" => "video/quicktime", + "ra" => "audio/x-pn-realaudio", + "ram" => "audio/x-pn-realaudio", + "ras" => "image/x-cmu-raster", + "rgb" => "image/x-rgb", + "rmi audio/mid" => "http://www.dreamdu.com", + "roff" => "application/x-troff", + "rtf" => "application/rtf", + "rtx" => "text/richtext", + "scd" => "application/x-msschedule", + "sct" => "text/scriptlet", + "setpay" => "application/set-payment-initiation", + "setreg" => "application/set-registration-initiation", + "sh" => "application/x-sh", + "shar" => "application/x-shar", + "sit" => "application/x-stuffit", + "snd" => "audio/basic", + "spc" => "application/x-pkcs7-certificates", + "spl" => "application/futuresplash", + "src" => "application/x-wais-source", + "sst" => "application/vnd.ms-pkicertstore", + "stl" => "application/vnd.ms-pkistl", + "stm" => "text/html", + "svg" => "image/svg+xml", + "sv4cpio" => "application/x-sv4cpio", + "sv4crc" => "application/x-sv4crc", + "swf" => "application/x-shockwave-flash", + "t" => "application/x-troff", + "tar" => "application/x-tar", + "tcl" => "application/x-tcl", + "tex" => "application/x-tex", + "texi" => "application/x-texinfo", + "texinfo" => "application/x-texinfo", + "tgz" => "application/x-compressed", + "tif" => "image/tiff", + "tiff" => "image/tiff", + "tr" => "application/x-troff", + "trm" => "application/x-msterminal", + "tsv" => "text/tab-separated-values", + "txt" => "text/plain", + "uls" => "text/iuls", + "ustar" => "application/x-ustar", + "vcf" => "text/x-vcard", + "vrml" => "x-world/x-vrml", + "wav" => "audio/x-wav", + "wcm" => "application/vnd.ms-works", + "wdb" => "application/vnd.ms-works", + "wks" => "application/vnd.ms-works", + "wmf" => "application/x-msmetafile", + "wps" => "application/vnd.ms-works", + "wri" => "application/x-mswrite", + "wrl" => "x-world/x-vrml", + "wrz" => "x-world/x-vrml", + "xaf" => "x-world/x-vrml", + "xbm" => "image/x-xbitmap", + "xla" => "application/vnd.ms-excel", + "xlc" => "application/vnd.ms-excel", + "xlm" => "application/vnd.ms-excel", + "xls" => "application/vnd.ms-excel", + "xlt" => "application/vnd.ms-excel", + "xlw" => "application/vnd.ms-excel", + "xof" => "x-world/x-vrml", + "xpm" => "image/x-xpixmap", + "xwd" => "image/x-xwindowdump", + "z" => "application/x-compress", + "zip" => "application/zip" + ); + + //代码 或文本浏览器输出 + $text = array('oexe','inc','inf','csv','log','asc','tsv'); + $code = array("abap","abc","as","ada","adb","htgroups","htpasswd","conf","htaccess","htgroups", + "htpasswd","asciidoc","asm","ahk","bat","cmd","c9search_results","cpp","c","cc","cxx","h","hh","hpp", + "cirru","cr","clj","cljs","CBL","COB","coffee","cf","cson","Cakefile","cfm","cs","css","curly","d", + "di","dart","diff","patch","Dockerfile","dot","dummy","dummy","e","ejs","ex","exs","elm","erl", + "hrl","frt","fs","ldr","ftl","gcode","feature",".gitignore","glsl","frag","vert","go","groovy", + "haml","hbs","handlebars","tpl","mustache","hs","hx","html","htm","xhtml","erb","rhtml","ini", + "cfg","prefs","io","jack","jade","java","js","jsm","json","jq","jsp","jsx","jl","tex","latex", + "ltx","bib","lean","hlean","less","liquid","lisp","ls","logic","lql","lsl","lua","lp","lucene", + "Makefile","GNUmakefile","makefile","OCamlMakefile","make","md","markdown","mask","matlab", + "mel","mc","mush","mysql","nix","m","mm","ml","mli","pas","p","pl","pm","pgsql","php","phtml", + "ps1","praat","praatscript","psc","proc","plg","prolog","properties","proto","py","r","Rd", + "Rhtml","rb","ru","gemspec","rake","Guardfile","Rakefile","Gemfile","rs","sass","scad","scala", + "scm","rkt","scss","sh","bash",".bashrc","sjs","smarty","tpl","snippets","soy","space","sql", + "styl","stylus","svg","tcl","tex","txt","textile","toml","twig","ts","typescript","str","vala", + "vbs","vb","vm","v","vh","sv","svh","vhd","vhdl","xml","rdf","rss", + "wsdl","xslt","atom","mathml","mml","xul","xbl","xaml","xq","yaml","yml","htm", + "xib","storyboard","plist","csproj"); + if (array_key_exists($ext,$mimetypes)){ + return $mimetypes[$ext]; + }else{ + if(in_array($ext,$text) || in_array($ext,$code)){ + return "text/plain"; + } + return 'application/octet-stream'; + } +} diff --git a/lib/index.html b/lib/index.html old mode 100644 new mode 100755 diff --git a/lib/plugins/adminer/adminer.css b/lib/plugins/adminer/adminer.css old mode 100644 new mode 100755 index db40bfa..a94633c --- a/lib/plugins/adminer/adminer.css +++ b/lib/plugins/adminer/adminer.css @@ -1,147 +1,147 @@ -/* CSS by Brade - www.bradezone.com */ -*{margin:0;padding:0} -/* 颜色微调【同样颜色灰度值调节】 */ -::-webkit-scrollbar-track-piece{background-color:#f5f5f5;border-left:1px solid #d2d2d2} -::-webkit-scrollbar{width:10px;height:10px} -::-webkit-scrollbar-thumb{background-color:#c2c2c2;background-clip:padding-box;border:1px solid #979797;min-height:28px} -::-webkit-scrollbar-thumb:hover{border:1px solid #636363;background-color:#929292} - -body,select,input,button{font:13px "微软雅黑",Microsoft Yahei,STXihei,arial,sans-serif;background:#fff;color:#333} -code,pre,textarea{font: 14px Consolas, "Liberation Mono", Courier, monospace !important;} -/* generic */ -a{-ms-transition: all 0.3s; --webkit-transition: all 0.3s; --moz-transition: all 0.3s; --o-transition: all 0.3s; -transition: all 0.3s; -} -a,a:visited{color:#06c;text-decoration:none;padding: 1px 4px;} -a:hover{background:#C7D1DD;border-radius:10px;color:#555;text-decoration: none !important;} -p{padding-bottom:4px;margin-bottom:4px} -h1{font-size:18px;font-weight:bold;padding-bottom:0px;height:25px;padding:0 0 8px 0;color:#666;border:0;background:none;} - -h2{font-size:24px;margin:0px;background:transparent;border:0;color:#366ec2; -padding: 10px 0;;border-bottom: 3px solid #eee;margin-bottom: 10px;} -h3{font-size:18px;font-weight:bold;padding:4px 0;margin:0} -form#form{overflow:hidden} -fieldset{float:left;min-height:48px;padding:0 4px 4px 4px;border:1px solid #ccc;margin-bottom:8px;margin-right:4px} -fieldset div{margin-top:4px} -input,select,textarea{color:#555;border:1px solid #ccc;padding: 2px 5px;} -fieldset select{margin-right:4px} -optgroup{font-size:11px} -code{background:#ffc;padding:2px 4px;} -code a:hover{background:transparent} -table{margin:4px 0 8px;border:1px solid #ccc;font-size:inherit} -tbody tr:hover td,tbody tr:hover th{background:#ffc} -th,td{text-align:left;padding:2px 4px;vertical-align:top;font-weight:normal;border:1px dotted #ccc;border-width:0 0 0 1px; -margin:0;background:inherit} - -thead tr{text-align: center;font-weight: 800;color: #444;height:25px;line-height: 25px;} -thead tr td{background: #F7F6F6;color: #222;font-weight: 800;border-bottom: 1px solid #CCC;white-space:nowrap;} -th:first-child,td:first-child{border-color:transparent;white-space:nowrap} -td[align=right]{text-align:right} -table code{font-size:13px;line-height:18px} -.hidden{display:none} -.error,.message{padding:0;background:transparent;font-weight:bold} -.error{color:#c00} -.message{color:#090} -/* specific */ -#content{margin:0 0 0 255px;height:100%;padding: 40px 10px 10px 0;} -#content:after{content:".";clear:both;height:0;overflow:hidden;display:block} -#lang{z-index: 10;background:#5579BA;color: #fff;position: fixed; -top: 0;right: 0px;padding: 0 20px 0 10px;line-height:30px;height: 35px;box-shadow: 0 -5px 50px #666;} - -#lang select{border-color: #fff;height: 22px;line-height: 22px;padding:0px;font-size:12px;} -#content > p > a,.tabs a{border: 1px solid #ccc;display: inline-block;padding: 3px 1em; -margin-bottom: 4px;background: #eee;color: #555; -letter-spacing: 1px;border-radius: 15px;} -#content > p > a:hover,.tabs a:hover{background:#6787c1;color:#eee;border-right:1px solid #5579BA;} -#content > p > a.active,.tabs a.active{background:#5579BA;color:#fff;border-right:1px solid #5579BA;} - -#menu{background:#E3E7EC;position:fixed;top: 30px;bottom:0px;overflow-x:hidden; - overflow-y: auto;left:0px;width:201px;padding:10px 15px;color:#333; - border-right:1px solid #ddf;margin:0;} -#menu a{color:#333;display: inline-block;margin:1px;line-height:18px;} -#menu a:hover{background:#333;color:#000;background: #C7D1DD;border:none;border-radius:10px;} -#menu a.h1,#menu a.h1:hover{display:block;height:0;width:175px;padding:40px 0 0 0;overflow:hidden;float:left;border:0;margin:0; -outline:0;background:url(http://www.bradezone.com/random/adminer_logo.gif) no-repeat;line-height:32px} -#menu p{white-space:nowrap;border:0;padding:0 0 4px 0;margin:0 0 4px 0;overflow: hidden !important;} -#menu p a.active{background: #8C9EB4;color: #fff;border-radius:10px;} -#menu h1 a{display: none;} -#menu h1:before{content: "Adminer ";line-height: 40px;} -#menu h1{text-align: center;margin-bottom: 10px;} -.logout a{border-bottom: 1px solid #ccc;} -.links a {white-space: nowrap;margin-right: 0px;} -.icon {background: #ccc;} - -#content #breadcrumb{background: #5579BA;border-left: 1px solid #6787c1;height: 30px;color:#ddd;font-size: 16px;position:fixed;top:0; -left: 231px;width:100%;line-height:30px;padding:2px 10px;z-index:11;margin:0;} -#content #breadcrumb a{color:#fff;display:inline;padding:3px 6px;background:none;letter-spacing:0;text-decoration: underline;border:none;} -#content #breadcrumb a:hover{background:transparent;color:#f90;} -#schema .table{padding:4px 8px;background:#f3f3f3} -/* IE hacks */ -*+html th:first-child,*+html td:first-child{border-color:inherit;white-space:inherit} -* html #lang,* html #menu,* html #breadcrumb{position:absolute} -* html #lang{padding-top:10px;height:30px;box-shadow: 0 -20px 50px #000;} -* html form#form{height:100%} -#logins a,#tables a{background: none} -#logout{color:#333;text-decoration:none;padding:4px 1em;} -#logout:hover{border-color:#333;background:#333;color:#fff} -.js .column{background:#ddd} - -input,object{ - border:1px solid #ccc; - color: #226; font-weight: normal; - background-color: #fcfdfe; - font-style:14px; - padding-top:4px 8px; - border-right-color:#888\9; - border-bottom-color:#888\9; -} -textarea{border: 1px solid #ccc;} -input[type=text] {padding:4px;background: #fffffa;font-size:12px;} -input[type=text]:focus{background: #ffffe6;border: 1px solid #5FA3EC;} -input[type=checkbox]{display: inline-block;margin-right: 10px;margin-left: 5px;} -input[type="button"],input[type="reset"],input[type="submit"]{ - height:25px; - color: #6e6e6e; - text-decoration: none; - position: relative; - display: inline-block; - text-shadow: 0 1px 0 #fff; - -webkit-transition: border-color .15s; - -moz-transition: border .15s; - -o-transition: border-color .15s; - transition: border-color .15s; - background: #f3f3f3; - background-image: -moz-linear-gradient(top, #fafafa, #eeeeee); /* Firefox */ - background: -webkit-gradient(linear,0% 40%,0% 70%,from(#FaFaFa),to(#eeeeee)); - border: solid 1px #bbb; - border-radius: 2px; - -webkit-border-radius: 2px; - -moz-border-radius: 2px; - padding:2px 1.2em; - cursor: pointer; - margin-bottom:2px; -} -input[type=button]:hover,input[type=reset]:hover,input[type=submit]:hover{ - color: #333; - border-color: #aaa; - box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3); -} -input.default {color: #000 !important;font-weight: 800;box-shadow: 0px 0px 5px #ccc;} -input[type=button]:active,input[type=reset]:active,input[type=submit]:active{ - color: #448; - background: -webkit-gradient(linear,0% 40%,0% 70%,from(#F1F1F1),to(#FaFaFa)); - background: -moz-linear-gradient(linear,0% 40%,0% 70%,from(#F1F1F1),to(#FaFaFa)); - border-color: #888; -} -input[type="radio"]{border:none;display:inline-block;margin: 5px;} -input:focus{border:1px solid #75A1F0;outline:none;box-shadow:0 0 8px #75A1F0; --webkit-transition:all 0.218s;-moz-transition: all .218s;-o-transition: all 0.218s;transition: all 0.218s;} - -.js .checkable .checked td, .js .checkable .checked th {background: #ff9;} -.nowrap td, .nowrap th, td.nowrap {white-space: pre;line-height: 24px;} -code{background:none !important;} -.jush-sql{background:#eee;} - +/* CSS by Brade - www.bradezone.com */ +*{margin:0;padding:0} +/* 颜色微调【同样颜色灰度值调节】 */ +::-webkit-scrollbar-track-piece{background-color:#f5f5f5;border-left:1px solid #d2d2d2} +::-webkit-scrollbar{width:10px;height:10px} +::-webkit-scrollbar-thumb{background-color:#c2c2c2;background-clip:padding-box;border:1px solid #979797;min-height:28px} +::-webkit-scrollbar-thumb:hover{border:1px solid #636363;background-color:#929292} + +body,select,input,button{font:13px "微软雅黑",Microsoft Yahei,STXihei,arial,sans-serif;background:#fff;color:#333} +code,pre,textarea{font: 14px Consolas, "Liberation Mono", Courier, monospace !important;} +/* generic */ +a{-ms-transition: all 0.3s; +-webkit-transition: all 0.3s; +-moz-transition: all 0.3s; +-o-transition: all 0.3s; +transition: all 0.3s; +} +a,a:visited{color:#06c;text-decoration:none;padding: 1px 4px;} +a:hover{background:#C7D1DD;border-radius:10px;color:#555;text-decoration: none !important;} +p{padding-bottom:4px;margin-bottom:4px} +h1{font-size:18px;font-weight:bold;padding-bottom:0px;height:25px;padding:0 0 8px 0;color:#666;border:0;background:none;} + +h2{font-size:24px;margin:0px;background:transparent;border:0;color:#366ec2; +padding: 10px 0;;border-bottom: 3px solid #eee;margin-bottom: 10px;} +h3{font-size:18px;font-weight:bold;padding:4px 0;margin:0} +form#form{overflow:hidden} +fieldset{float:left;min-height:48px;padding:0 4px 4px 4px;border:1px solid #ccc;margin-bottom:8px;margin-right:4px} +fieldset div{margin-top:4px} +input,select,textarea{color:#555;border:1px solid #ccc;padding: 2px 5px;} +fieldset select{margin-right:4px} +optgroup{font-size:11px} +code{background:#ffc;padding:2px 4px;} +code a:hover{background:transparent} +table{margin:4px 0 8px;border:1px solid #ccc;font-size:inherit} +tbody tr:hover td,tbody tr:hover th{background:#ffc} +th,td{text-align:left;padding:2px 4px;vertical-align:top;font-weight:normal;border:1px dotted #ccc;border-width:0 0 0 1px; +margin:0;background:inherit} + +thead tr{text-align: center;font-weight: 800;color: #444;height:25px;line-height: 25px;} +thead tr td{background: #F7F6F6;color: #222;font-weight: 800;border-bottom: 1px solid #CCC;white-space:nowrap;} +th:first-child,td:first-child{border-color:transparent;white-space:nowrap} +td[align=right]{text-align:right} +table code{font-size:13px;line-height:18px} +.hidden{display:none} +.error,.message{padding:0;background:transparent;font-weight:bold} +.error{color:#c00} +.message{color:#090} +/* specific */ +#content{margin:0 0 0 255px;height:100%;padding: 40px 10px 10px 0;} +#content:after{content:".";clear:both;height:0;overflow:hidden;display:block} +#lang{z-index: 10;background:#5579BA;color: #fff;position: fixed; +top: 0;right: 0px;padding: 0 20px 0 10px;line-height:30px;height: 35px;box-shadow: 0 -5px 50px #666;} + +#lang select{border-color: #fff;height: 22px;line-height: 22px;padding:0px;font-size:12px;} +#content > p > a,.tabs a{border: 1px solid #ccc;display: inline-block;padding: 3px 1em; +margin-bottom: 4px;background: #eee;color: #555; +letter-spacing: 1px;border-radius: 15px;} +#content > p > a:hover,.tabs a:hover{background:#6787c1;color:#eee;border-right:1px solid #5579BA;} +#content > p > a.active,.tabs a.active{background:#5579BA;color:#fff;border-right:1px solid #5579BA;} + +#menu{background:#E3E7EC;position:fixed;top: 30px;bottom:0px;overflow-x:hidden; + overflow-y: auto;left:0px;width:201px;padding:10px 15px;color:#333; + border-right:1px solid #ddf;margin:0;} +#menu a{color:#333;display: inline-block;margin:1px;line-height:18px;} +#menu a:hover{background:#333;color:#000;background: #C7D1DD;border:none;border-radius:10px;} +#menu a.h1,#menu a.h1:hover{display:block;height:0;width:175px;padding:40px 0 0 0;overflow:hidden;float:left;border:0;margin:0; +outline:0;background:url(http://www.bradezone.com/random/adminer_logo.gif) no-repeat;line-height:32px} +#menu p{white-space:nowrap;border:0;padding:0 0 4px 0;margin:0 0 4px 0;overflow: hidden !important;} +#menu p a.active{background: #8C9EB4;color: #fff;border-radius:10px;} +#menu h1 a{display: none;} +#menu h1:before{content: "Adminer ";line-height: 40px;} +#menu h1{text-align: center;margin-bottom: 10px;} +.logout a{border-bottom: 1px solid #ccc;} +.links a {white-space: nowrap;margin-right: 0px;} +.icon {background: #ccc;} + +#content #breadcrumb{background: #5579BA;border-left: 1px solid #6787c1;height: 30px;color:#ddd;font-size: 16px;position:fixed;top:0; +left: 231px;width:100%;line-height:30px;padding:2px 10px;z-index:11;margin:0;} +#content #breadcrumb a{color:#fff;display:inline;padding:3px 6px;background:none;letter-spacing:0;text-decoration: underline;border:none;} +#content #breadcrumb a:hover{background:transparent;color:#f90;} +#schema .table{padding:4px 8px;background:#f3f3f3} +/* IE hacks */ +*+html th:first-child,*+html td:first-child{border-color:inherit;white-space:inherit} +* html #lang,* html #menu,* html #breadcrumb{position:absolute} +* html #lang{padding-top:10px;height:30px;box-shadow: 0 -20px 50px #000;} +* html form#form{height:100%} +#logins a,#tables a{background: none} +#logout{color:#333;text-decoration:none;padding:4px 1em;} +#logout:hover{border-color:#333;background:#333;color:#fff} +.js .column{background:#ddd} + +input,object{ + border:1px solid #ccc; + color: #226; font-weight: normal; + background-color: #fcfdfe; + font-style:14px; + padding-top:4px 8px; + border-right-color:#888\9; + border-bottom-color:#888\9; +} +textarea{border: 1px solid #ccc;} +input[type=text] {padding:4px;background: #fffffa;font-size:12px;} +input[type=text]:focus{background: #ffffe6;border: 1px solid #5FA3EC;} +input[type=checkbox]{display: inline-block;margin-right: 10px;margin-left: 5px;} +input[type="button"],input[type="reset"],input[type="submit"]{ + height:25px; + color: #6e6e6e; + text-decoration: none; + position: relative; + display: inline-block; + text-shadow: 0 1px 0 #fff; + -webkit-transition: border-color .15s; + -moz-transition: border .15s; + -o-transition: border-color .15s; + transition: border-color .15s; + background: #f3f3f3; + background-image: -moz-linear-gradient(top, #fafafa, #eeeeee); /* Firefox */ + background: -webkit-gradient(linear,0% 40%,0% 70%,from(#FaFaFa),to(#eeeeee)); + border: solid 1px #bbb; + border-radius: 2px; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + padding:2px 1.2em; + cursor: pointer; + margin-bottom:2px; +} +input[type=button]:hover,input[type=reset]:hover,input[type=submit]:hover{ + color: #333; + border-color: #aaa; + box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3); +} +input.default {color: #000 !important;font-weight: 800;box-shadow: 0px 0px 5px #ccc;} +input[type=button]:active,input[type=reset]:active,input[type=submit]:active{ + color: #448; + background: -webkit-gradient(linear,0% 40%,0% 70%,from(#F1F1F1),to(#FaFaFa)); + background: -moz-linear-gradient(linear,0% 40%,0% 70%,from(#F1F1F1),to(#FaFaFa)); + border-color: #888; +} +input[type="radio"]{border:none;display:inline-block;margin: 5px;} +input:focus{border:1px solid #75A1F0;outline:none;box-shadow:0 0 8px #75A1F0; +-webkit-transition:all 0.218s;-moz-transition: all .218s;-o-transition: all 0.218s;transition: all 0.218s;} + +.js .checkable .checked td, .js .checkable .checked th {background: #ff9;} +.nowrap td, .nowrap th, td.nowrap {white-space: pre;line-height: 24px;} +code{background:none !important;} +.jush-sql{background:#eee;} + diff --git a/lib/plugins/adminer/index.php b/lib/plugins/adminer/index.php old mode 100644 new mode 100755 diff --git a/lib/plugins/index.html b/lib/plugins/index.html old mode 100644 new mode 100755 diff --git a/static/images/app/365.png b/static/images/app/365.png old mode 100644 new mode 100755 diff --git a/static/images/app/app_s1.png b/static/images/app/app_s1.png old mode 100644 new mode 100755 diff --git a/static/images/app/app_s2.png b/static/images/app/app_s2.png old mode 100644 new mode 100755 diff --git a/static/images/app/baidu.png b/static/images/app/baidu.png new file mode 100755 index 0000000..424d055 Binary files /dev/null and b/static/images/app/baidu.png differ diff --git a/static/images/app/ball8.png b/static/images/app/ball8.png new file mode 100755 index 0000000..785a1b9 Binary files /dev/null and b/static/images/app/ball8.png differ diff --git a/static/images/app/cal.png b/static/images/app/cal.png old mode 100644 new mode 100755 diff --git a/static/images/app/calcu.png b/static/images/app/calcu.png old mode 100644 new mode 100755 diff --git a/static/images/app/chuangyebang.jpg b/static/images/app/chuangyebang.jpg old mode 100644 new mode 100755 diff --git a/static/images/app/computer.png b/static/images/app/computer.png old mode 100644 new mode 100755 diff --git a/static/images/app/douban.png b/static/images/app/douban.png old mode 100644 new mode 100755 diff --git a/static/images/app/fruite.jpg b/static/images/app/fruite.jpg old mode 100644 new mode 100755 diff --git a/static/images/app/geling.jpg b/static/images/app/geling.jpg old mode 100644 new mode 100755 diff --git a/static/images/app/haozhaopian.jpg b/static/images/app/haozhaopian.jpg old mode 100644 new mode 100755 diff --git a/static/images/app/icloud.png b/static/images/app/icloud.png new file mode 100755 index 0000000..27e0714 Binary files /dev/null and b/static/images/app/icloud.png differ diff --git a/static/images/app/internet.png b/static/images/app/internet.png old mode 100644 new mode 100755 diff --git a/static/images/app/iqiyi.png b/static/images/app/iqiyi.png old mode 100644 new mode 100755 diff --git a/static/images/app/js.png b/static/images/app/js.png old mode 100644 new mode 100755 diff --git a/static/images/app/kuaidi.gif b/static/images/app/kuaidi.gif old mode 100644 new mode 100755 diff --git a/static/images/app/kugou.png b/static/images/app/kugou.png old mode 100644 new mode 100755 diff --git a/static/images/app/kugou2.png b/static/images/app/kugou2.png new file mode 100755 index 0000000..e6af11f Binary files /dev/null and b/static/images/app/kugou2.png differ diff --git a/static/images/app/kugou_radio.png b/static/images/app/kugou_radio.png old mode 100644 new mode 100755 diff --git a/static/images/app/linux.png b/static/images/app/linux.png old mode 100644 new mode 100755 diff --git a/static/images/app/map.png b/static/images/app/map.png old mode 100644 new mode 100755 diff --git a/static/images/app/market.png b/static/images/app/market.png old mode 100644 new mode 100755 diff --git a/static/images/app/meishi.png b/static/images/app/meishi.png old mode 100644 new mode 100755 diff --git a/static/images/app/meitu.gif b/static/images/app/meitu.gif old mode 100644 new mode 100755 diff --git a/static/images/app/oexe.png b/static/images/app/oexe.png old mode 100644 new mode 100755 diff --git a/static/images/app/pptv.jpg b/static/images/app/pptv.jpg old mode 100644 new mode 100755 diff --git a/static/images/app/ps.png b/static/images/app/ps.png old mode 100644 new mode 100755 diff --git a/static/images/app/qqmusic.png b/static/images/app/qqmusic.png old mode 100644 new mode 100755 diff --git a/static/images/app/recycle.png b/static/images/app/recycle.png new file mode 100755 index 0000000..619f29f Binary files /dev/null and b/static/images/app/recycle.png differ diff --git a/static/images/app/recycle_full.png b/static/images/app/recycle_full.png new file mode 100755 index 0000000..6b5b254 Binary files /dev/null and b/static/images/app/recycle_full.png differ diff --git a/static/images/app/setting.png b/static/images/app/setting.png old mode 100644 new mode 100755 diff --git a/static/images/app/souhu.jpg b/static/images/app/souhu.jpg old mode 100644 new mode 100755 diff --git a/static/images/app/time.png b/static/images/app/time.png old mode 100644 new mode 100755 diff --git a/static/images/app/ttpod.png b/static/images/app/ttpod.png new file mode 100755 index 0000000..045cd61 Binary files /dev/null and b/static/images/app/ttpod.png differ diff --git a/static/images/app/weather.png b/static/images/app/weather.png new file mode 100755 index 0000000..cd9a8c9 Binary files /dev/null and b/static/images/app/weather.png differ diff --git a/static/images/app/xiami.jpg b/static/images/app/xiami.jpg old mode 100644 new mode 100755 diff --git a/static/images/app/xiangqi.jpg b/static/images/app/xiangqi.jpg old mode 100644 new mode 100755 diff --git a/static/images/app/yingyuetai.png b/static/images/app/yingyuetai.png old mode 100644 new mode 100755 diff --git a/static/images/app/youdao.jpg b/static/images/app/youdao.jpg old mode 100644 new mode 100755 diff --git a/static/images/app/zhiwu.jpg b/static/images/app/zhiwu.jpg old mode 100644 new mode 100755 diff --git a/static/images/bg.gif b/static/images/bg.gif old mode 100644 new mode 100755 diff --git a/static/images/buttons_40.png b/static/images/buttons_40.png old mode 100644 new mode 100755 diff --git a/static/images/desktop/narrow.png b/static/images/desktop/narrow.png old mode 100644 new mode 100755 diff --git a/static/images/desktop/start.png b/static/images/desktop/start.png old mode 100644 new mode 100755 diff --git a/static/images/desktop/taskbarbg.png b/static/images/desktop/taskbarbg.png old mode 100644 new mode 100755 diff --git a/static/images/desktop/taskbarhover.png b/static/images/desktop/taskbarhover.png old mode 100644 new mode 100755 diff --git a/static/images/dialog_loading.gif b/static/images/dialog_loading.gif old mode 100644 new mode 100755 diff --git a/static/images/drop_upload.png b/static/images/drop_upload.png new file mode 100755 index 0000000..f715cbc Binary files /dev/null and b/static/images/drop_upload.png differ diff --git a/static/images/favicon.ico b/static/images/favicon.ico old mode 100644 new mode 100755 diff --git a/static/images/file.png b/static/images/file.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/air.png b/static/images/file_16/air.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/appStore.png b/static/images/file_16/appStore.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/avi.png b/static/images/file_16/avi.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/cmd.png b/static/images/file_16/cmd.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/code.png b/static/images/file_16/code.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/cpp.png b/static/images/file_16/cpp.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/css.png b/static/images/file_16/css.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/dll.png b/static/images/file_16/dll.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/doc.png b/static/images/file_16/doc.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/edit.png b/static/images/file_16/edit.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/error.png b/static/images/file_16/error.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/exe.png b/static/images/file_16/exe.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/file.png b/static/images/file_16/file.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/fla.png b/static/images/file_16/fla.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/flv.png b/static/images/file_16/flv.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/folder.png b/static/images/file_16/folder.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/html.png b/static/images/file_16/html.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/info.png b/static/images/file_16/info.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/ini.png b/static/images/file_16/ini.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/jpg.png b/static/images/file_16/jpg.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/js.png b/static/images/file_16/js.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/mp3.png b/static/images/file_16/mp3.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/oexe.png b/static/images/file_16/oexe.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/pdf.png b/static/images/file_16/pdf.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/php.png b/static/images/file_16/php.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/ppt.png b/static/images/file_16/ppt.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/ps.png b/static/images/file_16/ps.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/psd.png b/static/images/file_16/psd.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/py.png b/static/images/file_16/py.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/rar.gif b/static/images/file_16/rar.gif old mode 100644 new mode 100755 diff --git a/static/images/file_16/search.png b/static/images/file_16/search.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/setting.png b/static/images/file_16/setting.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/swf.png b/static/images/file_16/swf.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/ttf.png b/static/images/file_16/ttf.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/txt.png b/static/images/file_16/txt.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/up.png b/static/images/file_16/up.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/xls.png b/static/images/file_16/xls.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/xml.png b/static/images/file_16/xml.png old mode 100644 new mode 100755 diff --git a/static/images/file_16/zip.png b/static/images/file_16/zip.png old mode 100644 new mode 100755 diff --git a/static/images/folder.png b/static/images/folder.png old mode 100644 new mode 100755 diff --git a/static/images/folder_simple.png b/static/images/folder_simple.png new file mode 100755 index 0000000..fc522d6 Binary files /dev/null and b/static/images/folder_simple.png differ diff --git a/static/images/image.png b/static/images/image.png old mode 100644 new mode 100755 diff --git a/static/images/lazy.gif b/static/images/lazy.gif old mode 100644 new mode 100755 diff --git a/static/images/left.jpg b/static/images/left.jpg old mode 100644 new mode 100755 diff --git a/static/images/line.png b/static/images/line.png old mode 100644 new mode 100755 diff --git a/static/images/line_x.png b/static/images/line_x.png old mode 100644 new mode 100755 diff --git a/static/images/loading.gif b/static/images/loading.gif old mode 100644 new mode 100755 diff --git a/static/images/loading_simple.gif b/static/images/loading_simple.gif old mode 100644 new mode 100755 diff --git a/static/images/loading_tree.gif b/static/images/loading_tree.gif old mode 100644 new mode 100755 diff --git a/static/images/login.png b/static/images/login.png new file mode 100755 index 0000000..7b5d506 Binary files /dev/null and b/static/images/login.png differ diff --git a/static/images/resize.png b/static/images/resize.png old mode 100644 new mode 100755 diff --git a/static/images/resize_corner.png b/static/images/resize_corner.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/movie/qqplayer.jpg b/static/images/thumb/movie/qqplayer.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/movie/qqplayer.png b/static/images/thumb/movie/qqplayer.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/movie/tvlive.jpg b/static/images/thumb/movie/tvlive.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/movie/tvlive.png b/static/images/thumb/movie/tvlive.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/movie/vplayer.jpg b/static/images/thumb/movie/vplayer.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/movie/vplayer.png b/static/images/thumb/movie/vplayer.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/movie/webplayer.jpg b/static/images/thumb/movie/webplayer.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/movie/webplayer.png b/static/images/thumb/movie/webplayer.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/movie/youtube.jpg b/static/images/thumb/movie/youtube.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/movie/youtube.png b/static/images/thumb/movie/youtube.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/beveled.jpg b/static/images/thumb/music/beveled.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/jma.png b/static/images/thumb/music/jma.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/kuwo.jpg b/static/images/thumb/music/kuwo.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/kuwo.png b/static/images/thumb/music/kuwo.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/manila.jpg b/static/images/thumb/music/manila.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/manila.png b/static/images/thumb/music/manila.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/mp3player.jpg b/static/images/thumb/music/mp3player.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/qqmusic.jpg b/static/images/thumb/music/qqmusic.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/qqmusic.png b/static/images/thumb/music/qqmusic.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/scplayer.png b/static/images/thumb/music/scplayer.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/somusic.jpg b/static/images/thumb/music/somusic.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/somusic.png b/static/images/thumb/music/somusic.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/ting.jpg b/static/images/thumb/music/ting.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/music/xdj.jpg b/static/images/thumb/music/xdj.jpg old mode 100644 new mode 100755 diff --git a/static/images/thumb/theme/color.png b/static/images/thumb/theme/color.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/theme/default.png b/static/images/thumb/theme/default.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/theme/metro.png b/static/images/thumb/theme/metro.png old mode 100644 new mode 100755 diff --git a/static/images/thumb/theme/simple.png b/static/images/thumb/theme/simple.png old mode 100644 new mode 100755 diff --git a/static/images/topBanner.jpg b/static/images/topBanner.jpg old mode 100644 new mode 100755 diff --git a/static/images/tree.png b/static/images/tree.png old mode 100644 new mode 100755 diff --git a/static/images/wall_page/1.jpg b/static/images/wall_page/1.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/10.jpg b/static/images/wall_page/10.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/11.jpg b/static/images/wall_page/11.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/12.jpg b/static/images/wall_page/12.jpg old mode 100644 new mode 100755 index 39e7ee4..b5ea65c Binary files a/static/images/wall_page/12.jpg and b/static/images/wall_page/12.jpg differ diff --git a/static/images/wall_page/13.jpg b/static/images/wall_page/13.jpg old mode 100644 new mode 100755 index d61392a..b45a4c8 Binary files a/static/images/wall_page/13.jpg and b/static/images/wall_page/13.jpg differ diff --git a/static/images/wall_page/14.jpg b/static/images/wall_page/14.jpg deleted file mode 100644 index 014f3e2..0000000 Binary files a/static/images/wall_page/14.jpg and /dev/null differ diff --git a/static/images/wall_page/15.jpg b/static/images/wall_page/15.jpg deleted file mode 100644 index 32fdfdf..0000000 Binary files a/static/images/wall_page/15.jpg and /dev/null differ diff --git a/static/images/wall_page/2.jpg b/static/images/wall_page/2.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/3.jpg b/static/images/wall_page/3.jpg old mode 100644 new mode 100755 index 6d76ee3..133cb11 Binary files a/static/images/wall_page/3.jpg and b/static/images/wall_page/3.jpg differ diff --git a/static/images/wall_page/4.jpg b/static/images/wall_page/4.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/5.jpg b/static/images/wall_page/5.jpg old mode 100644 new mode 100755 index 99d04ec..ba0150b Binary files a/static/images/wall_page/5.jpg and b/static/images/wall_page/5.jpg differ diff --git a/static/images/wall_page/6.jpg b/static/images/wall_page/6.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/7.jpg b/static/images/wall_page/7.jpg old mode 100644 new mode 100755 index a09eef6..2c651f3 Binary files a/static/images/wall_page/7.jpg and b/static/images/wall_page/7.jpg differ diff --git a/static/images/wall_page/8.jpg b/static/images/wall_page/8.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/9.jpg b/static/images/wall_page/9.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/thumb/1.jpg b/static/images/wall_page/thumb/1.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/thumb/10.jpg b/static/images/wall_page/thumb/10.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/thumb/11.jpg b/static/images/wall_page/thumb/11.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/thumb/12.jpg b/static/images/wall_page/thumb/12.jpg old mode 100644 new mode 100755 index bcfd1f5..4d671ba Binary files a/static/images/wall_page/thumb/12.jpg and b/static/images/wall_page/thumb/12.jpg differ diff --git a/static/images/wall_page/thumb/13.jpg b/static/images/wall_page/thumb/13.jpg old mode 100644 new mode 100755 index 6a0e27d..ea8d49e Binary files a/static/images/wall_page/thumb/13.jpg and b/static/images/wall_page/thumb/13.jpg differ diff --git a/static/images/wall_page/thumb/14.jpg b/static/images/wall_page/thumb/14.jpg deleted file mode 100644 index 79fdf39..0000000 Binary files a/static/images/wall_page/thumb/14.jpg and /dev/null differ diff --git a/static/images/wall_page/thumb/15.jpg b/static/images/wall_page/thumb/15.jpg deleted file mode 100644 index aa31637..0000000 Binary files a/static/images/wall_page/thumb/15.jpg and /dev/null differ diff --git a/static/images/wall_page/thumb/2.jpg b/static/images/wall_page/thumb/2.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/thumb/3.jpg b/static/images/wall_page/thumb/3.jpg old mode 100644 new mode 100755 index 692c761..81fb04e Binary files a/static/images/wall_page/thumb/3.jpg and b/static/images/wall_page/thumb/3.jpg differ diff --git a/static/images/wall_page/thumb/4.jpg b/static/images/wall_page/thumb/4.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/thumb/5.jpg b/static/images/wall_page/thumb/5.jpg old mode 100644 new mode 100755 index c6b1322..3941028 Binary files a/static/images/wall_page/thumb/5.jpg and b/static/images/wall_page/thumb/5.jpg differ diff --git a/static/images/wall_page/thumb/6.jpg b/static/images/wall_page/thumb/6.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/thumb/7.jpg b/static/images/wall_page/thumb/7.jpg old mode 100644 new mode 100755 index 9f16894..017f214 Binary files a/static/images/wall_page/thumb/7.jpg and b/static/images/wall_page/thumb/7.jpg differ diff --git a/static/images/wall_page/thumb/8.jpg b/static/images/wall_page/thumb/8.jpg old mode 100644 new mode 100755 diff --git a/static/images/wall_page/thumb/9.jpg b/static/images/wall_page/thumb/9.jpg old mode 100644 new mode 100755 diff --git a/static/images/ybutton.png b/static/images/ybutton.png old mode 100644 new mode 100755 diff --git a/static/index.html b/static/index.html old mode 100644 new mode 100755 diff --git a/static/js/_dev/common/CMPlayer.js b/static/js/_dev/common/CMPlayer.js deleted file mode 100644 index 730569d..0000000 --- a/static/js/_dev/common/CMPlayer.js +++ /dev/null @@ -1,143 +0,0 @@ -define(function(require, exports) { - var _skin = { - ting:{path:'music/ting',width:410,height:530}, - beveled:{path:'music/beveled',width:350,height:200}, - kuwo:{path:'music/kuwo',width:480,height:200}, - manila:{path:'music/manila',width:320,height:400}, - mp3player:{path:'music/mp3player',width:320,height:410}, - qqmusic:{path:'music/qqmusic',width:300,height:400}, - somusic:{path:'music/somusic',width:420,height:137}, - xdj:{path:'music/xdj',width:595,height:235}, - - //---适合视频播放 - webplayer:{path:'movie/webplayer',width:600,height:400}, - qqplayer:{path:'movie/qqplayer',width:600,height:400}, - tvlive:{path:'movie/tvlive',width:600,height:400}, - youtube:{path:'movie/youtube',width:600,height:400}, - vplayer:{path:'movie/vplayer',width:600,height:400} - }; - - var _getPlayer = function(type){ - if (type =='music' ) return 'music_player'; - if(type == undefined) type = 'mp3'; - if (inArray(core.filetype['music'],type)) { - return 'music_player'; - }else { - return 'movie_player'; - } - }; - - // 创建播放器;动态获取皮肤以及对应大小尺寸 - var _create = function(player){ - var playerSkin,playerTitle,resize,ico; - if (player == 'music_player') { - ico=core.ico('mp3'); - playerSkin = _skin[G.musictheme]; - playerTitle= 'music player'; - resize = false; - }else { - ico=core.ico('flv'); - playerSkin = _skin[G.movietheme]; - playerTitle= 'movie player'; - resize = true; - } - var html = core.createFlash(G.static_path+'js/lib/cmp4/cmp.swf', - 'context_menu=2&auto_play=1&play_mode=1&skin=skins/'+playerSkin.path+'.zip',player); - var playerDialog = { - id:player+'_dialog', - simple:true, - ico:ico, - title:playerTitle, - width:playerSkin.width, - height:playerSkin.height, - content:html, - resize:resize, - padding:0, - fixed:true, - close:function(){ - var cmpo = _get(player); - if (cmpo && cmpo.sendEvent) { - cmpo.sendEvent('view_stop'); - } - } - } - if (window.top.CMP){ - art.dialog.through(playerDialog); - }else{ - $.dialog(playerDialog); - } - }; - // 文件数组创建播放器列表 - var _makeList = function(fileList){ - var play_url,i,xml=''; - for (i = fileList.length - 1; i >= 0; i--) { - var path,name; - if (fileList[i].search('fileProxy') == -1) { - path = urlEncode(fileList[i]); - name = core.pathThis(fileList[i]); - }else{//非服务器路径下文件 或者网络文件 - path = fileList[i]; - name = core.pathThis(urlDecode(path)); - } - path = path.replace(/%2F/g,'/'); - path = path.replace(/%3F/g,'?'); - path = path.replace(/%26/g,'&'); - path = path.replace(/%3A/g,':'); - path = path.replace(/%3D/g,'='); - xml +=''; - }; - return xml; - }; - //获取播放器 - var _get = function(player){ - if (window.top.CMP) { - return window.top.CMP.get(player); - }else{ - return CMP.get(player); - } - }; - var _insert = function(fileList,player){ - var new_list = _makeList(fileList); - var cmpo = _get(player); - if (cmpo) { - cmpo.config('play_mode','normal');//写入配置,播放模式改为自动跳到next - var old_length = cmpo.list().length; - cmpo.list_xml(new_list,true); - cmpo.sendEvent('view_play',old_length+1); - } - }; - - return { - changeTheme:function (key,value) { - var player,playerSkin,cmpo; - if (key =='music') { - G.musictheme = value; - player = 'music_player'; - }else if(key == 'movie'){ - G.movietheme = value; - player = 'movie_player'; - } - - //如果存在播放器,则实时改变皮肤。 - cmpo = _get(player); - if (cmpo){ - playerSkin = _skin[value]; - window.top.art.dialog.list[player+'_dialog'].size(playerSkin.width,playerSkin.height); - cmpo.sendEvent("skin_load",'skins/'+playerSkin.path+'.zip'); - } - }, - play:function(fileList,type){ - var player = _getPlayer(type); - var cmpo = _get(player); - if (!cmpo) { - _create(player); - setTimeout(function(){ - _insert(fileList,player); - },1000); - }else{ - _insert(fileList,player); - window.top.art.dialog.list[player+'_dialog'].display(true); - } - } - }; -}); \ No newline at end of file diff --git a/static/js/_dev/common/core.js b/static/js/_dev/common/core.js deleted file mode 100644 index 36b3d76..0000000 --- a/static/js/_dev/common/core.js +++ /dev/null @@ -1,647 +0,0 @@ -define(function(require, exports) { - return { - filetype : { - 'music' : ['mp3','wma','wav','mid','aac','ogg','oga','midi','ram','ac3','aif','aiff','m3a', - 'm4a','m4b','mka','mp1','mx3','mp2'], - 'movie' : ['avi','flv','f4v','wmv','3gp','rmvb','mp4','rm','rmvb','flv','mkv','wmv','asf','avi', - 'aiff','mp4','divx','dv','m4v','mov','mpeg','vob','mpg','mpv','ogm','ogv','qt'], - 'image' : ['jpg','jpeg','png','bmp','gif','ico','tif','tiff','dib','rle'], - 'code' : ['html','htm','js','css','less','scss','sass','py','php','rb','erl','lua','pl','c','cpp' - ,'m','h','java','jsp','cs','asp','sql','as','go','lsp','yml','json','tpl','xml', - 'cmd','reg','bat','vbs','sh'], - 'doc' : ['doc','docx','docm','xls','xlsx','xlsb','xlsm','ppt','pptx','pptm'], - 'text' : ['txt','ini','inc','inf','conf','oexe','md','htaccess','csv','log','asc','tsv'], - 'bindary':['pdf','bin','zip','swf','gzip','rar','arj','tar','gz','cab','tbz','tbz2','lzh','uue','bz2' - ,'ace','exe','so','dll','chm','rtf','odp','odt','pages','class','psd','ttf'] - }, - ico:function(type){ - var path = G.static_path + 'images/file_16/'; - var arr=['folder','file','edit','search','up','setting','appStore','error','info', - 'mp3','flv','pdf','doc','xls','ppt','html','swf']; - var index = $.inArray(type,arr); - if (index == -1) { - return path+'file.png'; - }else{ - return path+type+'.png'; - } - }, - contextmenu:function(event){ - rightMenu.hidden(); - var e = event || window.event; - if (e && ($.nodeName(e.target,'TEXTAREA') || - $.nodeName(e.target,'INPUT'))){ - return true; - } - //return false; - }, - //获取当前文件名 - pathThis:function(path){ - path = path.replace(/\\/g, "/"); - var arr = path.split('/'); - var name = arr[arr.length -1]; - if (name=='') name = arr[arr.length -2]; - return name; - }, - //获取文件父目录 - pathFather:function(path){ - path = path.replace(/\\/g, "/"); - var index = path.lastIndexOf('/'); - return path.substr(0,index+1); - }, - //获取路径扩展名 - pathExt:function(path){ - path = path.replace(/\\/g, "/"); - path = path.replace(/\/+/g, "/"); - var index = path.lastIndexOf('.'); - path = path.substr(index+1); - return path.toLowerCase(); - }, - //绝对路径转url路径 - path2url :function(path){ - if (path.substr(0,4) == 'http') return path; - - path = path.replace(/\\/g, "/"); - path = path.replace(/\/+/g, "/"); - path = path.replace(/\/\.*\//g, "/"); - - //public path - if (path.substring(0,G.public_path.length) == G.public_path) { - return G.app_host+'data/public/'+path.replace(G.public_path,''); - } - - //user group - if (G.is_root) { - if (path.substring(0,G.web_root.length) == G.web_root){//服务器路径下 - return G.web_host+path.replace(G.web_root,''); - } - var host = G.basic_path.replace(G.web_root,'')+'/'; - host = G.web_host+host; - return host+'index.php?explorer/fileProxy&path=' +urlEncode(path); - }else{ - return G.web_host+G.web_root+path; - } - }, - ajaxError:function(XMLHttpRequest, textStatus, errorThrown){ - core.tips.close(LNG.system_error,false); - var response = XMLHttpRequest.responseText; - var error = '
    '+response+'
    '; - var dialog = $.dialog.list['ajaxErrorDialog']; - - //已经退出 - if (response.substr(0,17) == '') { - FrameCall.goRefresh(); - return; - } - - if (dialog) { - dialog.content(error); - }else{ - $.dialog({ - id:'ajaxErrorDialog', - padding:0, - fixed:true, - resize:true, - ico:core.ico('error'), - title:'ajax error', - content:error - }); - } - }, - // setting 对话框 - setting:function(setting){ - if (setting == undefined) setting = ''; - if (window.top.frames["Opensetting_mode"] == undefined) { - $.dialog.open('./index.php?setting#'+setting,{ - id:'setting_mode', - fixed:true, - ico:core.ico('setting'), - resize:true, - title:LNG.setting, - width:960, - height:580 - }); - }else{ - $.dialog.list['setting_mode'].display(true); - FrameCall.top('Opensetting_mode','Setting.setGoto','"'+setting+'"'); - } - }, - appStore:function(){ - $.dialog.open('./index.php?app',{ - id:'app_store', - fixed:true, - ico:core.ico('appStore'), - resize:true, - title:LNG.app_store, - width:800, - height:500 - }); - }, - openApp:function(app){ - if (app.type == 'url') { - var icon = app.icon; - if (app.icon.search(G.static_path)==-1 && app.icon.substring(0,4) !='http') { - icon = G.static_path + 'images/app/' + app.icon; - } - //高宽css px或者*% - if (typeof(app.width)!='number' - && app.width.search('%') == -1){app.width = parseInt(app.width);} - if (typeof(app.height)!='number' - && app.height.search('%') == -1){app.height = parseInt(app.height);} - $.dialog.open(app.content,{ - title:app.name, - fixed:true, - ico:icon, - resize:app.resize, - simple:app.simple, - title:app.name.replace('.oexe',''), - width:app.width, - height:app.height - }); - }else{ - var exec = app.content; - eval('{'+exec+'}'); - } - }, - update:function(action){ - var url = base64_decode('aHR0cDovL3N0YXRpYy5rYWxjYWRkbGUuY29tL3VwZGF0ZS9tYWluLmpz'); - require.async(url,function(up){ - try{ - up.todo(action); - }catch(e){}; - }); - }, - explorer:function (path,title) { - if (path == undefined) path = ''; - $.dialog.open('?/explorer&type=iframe&path='+path,{ - resize:true,fixed:true, - ico:core.ico('folder'), - title:LNG.ui_filemanage, - width:880,height:550 - }); - //dlg.DOM.wrap.find('.aui_loading').remove(); - }, - setSkin:function(theme,css){ - css = css +'?ver='+G.version - var url = './../../../style/skin/'+theme+css; - var local = G.static_path+'style/skin/'+theme+css; - require.async(url,function(){ - $("#link_css_list").attr("href",local); - //加载完成后,删除多余link - $('link[rel=stylesheet]').each(function(){ - var href = $(this).attr('href'); - if (href.substring(href.length-css.length) == css - && $(this).attr('id')!='link_css_list') { - $(this).remove(); - } - }); - }); - }, - //编辑器全屏 编辑器调用父窗口全屏 - editorFull:function(){ - var $frame = $('iframe[name=OpenopenEditor]'); - $frame.toggleClass('frame_fullscreen'); - }, - language:function(lang){ - Cookie.set('kod_user_language',lang,24*365);//365 day - window.location.reload(); - }, - // tips - tips:{ - loading:function(msg){ - Tips.loading(msg,'info',Global.topbar_height); - }, - close:function(msg,code){ - if (typeof(msg) == 'object') { - Tips.close(msg.data,msg.code,Global.topbar_height); - }else{ - Tips.close(msg,code,Global.topbar_height); - } - }, - tips:function(msg,code){ - if (typeof(msg) == 'object') { - Tips.tips(msg.data,msg.code,Global.topbar_height); - }else{ - Tips.tips(msg,code,Global.topbar_height); - } - } - }, - //flash构造 - createFlash:function(swf,flashvars,id){ - var html = - '' - + '' - + '' - + '' - + '' - + '' - +''; - return html; - }, - //搜索模块 - search:function(search,path){ - var result = {}; - var tpl = require('../tpl/search'); - var dialog; - var param; - var __init = function(){ - var render = template.compile(tpl.html); - if ($('.dialog_do_search').length == 0) {//没有对话框则初始化。 - __bindEvent(); - param = {search:search,path:path,is_content:undefined,is_case:undefined,ext:'',LNG:LNG}; - dialog = $.dialog({ - id:'dialog_do_search', - padding:0, - fixed:true, - ico:core.ico('search'), - resize:true, - title:LNG.search, - width:450, - content:render(param) - }); - __doSearch(param); - $('#search_ext').tooltip({placement:'bottom',html:true});//tips - $('#search_path').tooltip({placement:'bottom',html:true, - title:function(){return $('#search_path').val()} - }); - }else{ - $('#search_value').val(search); - $('#search_path').val(path); - __reSearch(); - $.dialog.list['dialog_do_search'].display(true); - } - }; - - var __reSearch = function(){ - param = { - search:$('#search_value').val(), - path:$('#search_path').val(), - is_content:$('#search_is_content').attr("checked"), - is_case:$('#search_is_case').attr("checked"), - ext:$('#search_ext').val()}; - __doSearch(param); - } - //搜索相关事件绑定 - var __bindEvent = function(){ - __bindKeyDown(); - $('#search_value,#search_ext,#search_path').keyEnter(__reSearch); - $('.search_header a.button').die('click').live('click',__reSearch); - $('.search_result .list .name').die('click').live('click',function(e){ - var fileName = $(this).find('a').html(); - var pathName = $(this).parent().find('.path a').html() + fileName; - if ($(this).parent().hasClass('file')) { - ui.pathOpen.open(pathName);//打开文件 - }else{ - if (Config.pageApp == 'explorer'){ - ui.path.list(pathName+'/','tips'); - }else{ - core.explorer(pathName+'/'); - } - } - }); - $('.search_result .list .path a').die('click').live('click',function(e){ - var path = $(this).html(); - if (Config.pageApp == 'explorer'){ - ui.path.list(path,'tips'); - }else{ - core.explorer(path); - } - }); - }; - var __bindKeyDown = function(){ - $('#search_value').die('keyup').live('keyup',function(){ - ui.path.setSearchByStr($(this).val()); - }); - } - - //执行搜索 - var __doSearch = function(param){ - var fade = 150; - $('#search_value').focus(); - $('.search_result .list').remove(); - var $message = $('.search_result .message td'); - if (!param.search || !param.path) { - $message.hide().html(LNG.search_info).fadeIn(fade); - return; - } - if (param.search.length<=1) { - $message.hide().html('too short!').fadeIn(fade); - return; - } - $.ajax({ - url:'index.php?explorer/search', - dataType:'json', - type:'POST', - data:param, - beforeSend:function(){ - $message.hide().html(LNG.searching+'').fadeIn(fade); - }, - error:core.ajaxError, - success:function(data){ - if (!data.code) { - $message.hide().html(data.data).fadeIn(fade); - return; - } - if (data.data.filelist.length == 0 && data.data.folderlist.length == 0) { - $message.hide().html(LNG.search_null).fadeIn(fade); - return; - } - $message.hide(); - var render = template.compile(tpl.list); - data.data.LNG = LNG; - $(render(data.data)).insertAfter('.search_result .message').fadeIn(fade); - } - }); - } - __init(); - }, - - upload:function() { - G.upload_path = G.this_path; - var upload_path = urlDecode(G.upload_path); - uploader.option('server','index.php?explorer/fileUpload&path='+G.upload_path); - var display = (upload_path.length<=30?upload_path:'...'+upload_path.substr(upload_path.length-30)); - if ($('.dialog_file_upload').length != 0) {//有对话框则返回 - $('.file_upload .upload_path b').html(display); - $.dialog.list['dialog_file_upload'].display(true); - return; - } - var tpl = require('../tpl/upload'); - var render = template.compile(tpl.html); - var maxsize = WebUploader.Base.formatSize(G.upload_max); - $.dialog({ - padding:5, - height:430, - resize:true, - ico:core.ico('up'), - id:'dialog_file_upload', - fixed: true, - title:LNG.upload_muti, - content:render({LNG:LNG,maxsize:maxsize}), - close:function(){ - $.each(uploader.getFiles(),function(index,file){ - uploader.skipFile(file); - uploader.removeFile(file); - }); - } - }); - - $('.file_upload .tips').tooltip({placement:'bottom'}); - $('.file_upload .upload_path').tooltip({ - placement:'bottom', - title:function(){ - return G.upload_path; - } - }); - $('.file_upload .upload_path b').html(display); - // 菜单切换 - $('.file_upload .top_nav a.menu').unbind('click').bind('click',function(){ - if ($(this).hasClass('tab_upload')) { - $('.file_upload .tab_upload').addClass('this'); - $('.file_upload .tab_download').removeClass('this'); - $('.file_upload .upload_box').removeClass('hidden'); - $('.file_upload .download_box').addClass('hidden'); - }else{ - $('.file_upload .tab_upload').removeClass('this'); - $('.file_upload .tab_download').addClass('this'); - $('.file_upload .upload_box').addClass('hidden'); - $('.file_upload .download_box').removeClass('hidden'); - } - }); - // 远程下载 - $('.file_upload .download_box button').unbind('click').bind('click',function(){ - core.server_dwonload(G.upload_path); - }); - uploader.addButton({id: '#picker'}); - }, - server_dwonload:function(path){ - var $box = $('.download_box'),$list=$box.find('#download_list'); - var url = $box.find('input').val(); - $box.find('input').val(''); - - //url为空或不对 - if (!url || url.substr(0,4)!='http') { - core.tips.tips('url false!',false); - return; - }; - - var uuid = UUID(); - var html ='
    ' + - '
    ' + url - + ''+LNG.upload_ready - + '
    '; - if ($list.find('.item').length>0) { - $(html).insertBefore($list.find('.item:eq(0)')) - }else{ - $list.append(html) - } - - var repeatTime,delayTime,preInfo,preSpeed=0; - var $state=$('#'+uuid+' .state').text(LNG.download_ready); - var $percent = $('
    ' + - '
    '+ - '
    ').appendTo('#'+uuid).find('.progress-bar'); - $.ajax({//开始下载文件 - url:'./index.php?explorer/serverDownload&type=download&save_path='+path+ - '&url='+urlEncode2(url)+'&uuid='+uuid, - dataType:'json', - error:function(a, b, c){ - core.ajaxError(a, b, c); - clearInterval(repeatTime);repeatTime=false; - clearTimeout(delayTime);repeatTime=false; - $percent.parent().remove(); - $state.addClass('error').text(LNG.download_error); - }, - success:function(data){ - clearInterval(repeatTime);repeatTime=false; - clearTimeout(delayTime);repeatTime=false; - if (!data.code) { - $state.addClass('error').text(LNG.error); - }else{ - FrameCall.father('ui.f5_callback',"function(){ui.path.setSelectByFilename('" - +data.info+"');}"); - $state.text(LNG.download_success); - $('#'+uuid+' .info .title').html(data.info); - } - $percent.parent().remove(); - } - }); - - var ajax_process = function(){//定时获取下载文件的大小,计算出下载速度和百分比。 - $.ajax({ - url:'./index.php?explorer/serverDownload&type=percent&uuid='+uuid, - dataType:'json', - success:function(data){ - if (!repeatTime) return; - if (!data.code) {//header获取 - $state.text(LNG.loading); - return; - } - var speedStr = '',info = data.data; - if (!info) return; - info.size = parseFloat(info.size); - info.time = parseFloat(info.time); - if (preInfo){ - var speed = (info.size-preInfo.size)/(info.time-preInfo.time); - //速度防跳跃缓冲 忽略掉当前降低到20%的当前次 - if (speed*0.2 < preSpeed) { - var temp = preSpeed; - preSpeed = speed; - speed = temp; - }else{ - preSpeed = speed; - } - speedStr = core.file_size(speed)+"/s"; - } - if (info['length']==0){ - $percent.css('width','100%' ).text(LNG.loading); - }else{ - var percent = round(info.size/info.length*100,1); - $percent.css('width', percent+'%').text(percent+'%'); - } - $state.text(speedStr+'('+core.file_size(info.length)+')'); - preInfo = info; - } - }); - } - - delayTime = setTimeout(function(){ - ajax_process(); - repeatTime = setInterval(function(){ - ajax_process(); - },1000); - },100); - }, - - file_size:function(size){ - if (size == 0) return "0B"; - size = parseFloat(size); - var unit = { - 'GB' : 1073741824, // pow( 1024, 3) - 'MB' : 1048576, // pow( 1024, 2) - 'KB' : 1024, // pow( 1024, 1) - 'B ' : 0 // pow( 1024, 0) - }; - for (var key in unit) { - if (size >= unit[key]){ - return (size/unit[key]).toFixed(1)+key; - } - } - return '0B'; - }, - - upload_init:function() {//upload init - var list = '#thelist',state = 'span.state'; - uploader = WebUploader.create({ - swf:G.static_path+'js/lib/webuploader/Uploader.swf', - dnd:'body', //拖拽 - threads:3, //最大同时上传线程 - fileSizeLimit:G.upload_max, - resize: false - }); - - var select_name_arr = [];//删除后文件选中列表记录 - // 当有文件被添加进队列的时候 - uploader.on('uploadBeforeSend',function(obj,data){ - var full = urlEncode(obj.file.fullPath); - if (full == undefined || full == 'undefined') full = ''; - data.fullPath = full; - }).on('fileQueued', function(file){ - var $dom = $(list),name; - var name = file.fullPath; - if (name == undefined || name == 'undefined') name = file.name; - - if ($(list).find('.item').length>0) { - $dom = $(list).find('.item:eq(0)'); - } - var html = '
    ' + - '
    ' + name - + ''+LNG.upload_ready - + '
    '; - if ($(list).find('.item').length>0) { - $(html).insertBefore($(list).find('.item:eq(0)')) - }else{ - $(list).append(html) - } - uploader.upload(); - }).on('uploadProgress', function( file, percentage){ - var $li = $( '#'+file.id ), - $percent = $li.find('.progress .progress-bar'); - // 避免重复创建 - if ( !$percent.length ) { - $percent = $('
    ' + - '
    ' + - '
    ' + - '
    ').appendTo( $li ).find('.progress-bar'); - } - $li.find('.state').text((percentage*100).toFixed(2)+'%'); - $percent.css( 'width', percentage*100+'%'); - }).on('uploadAccept', function(obj,server) { - obj.file.serverData = server;//添加服务器返回变量 - try{ - select_name_arr.push(core.pathThis(server['info'])); - }catch(e){}; - }).on('uploadSuccess', function(file){ - var data = file.serverData; - if (data.code){ - $('#'+file.id ).find(state).text(data.data); - }else{ - $('#'+file.id ).find(state).addClass('error').text(data.data); - } - uploader.removeFile(file); - $('#'+file.id).find('.progress').fadeOut(); - var select = select_name_arr;//copy一份,因为刷新数据为异步 - ui.f5_callback(function(){ - ui.path.setSelectByFilename(select); - }); - }).on('uploadError', function(file,reason){ - $('#'+file.id).find(state).addClass('error').text(LNG.upload_error); - }).on('uploadFinished', function(file){ - // $(list).find('.item').delay(2000).each(function(index){ - // $(this).delay(index*300).slideUp(600); - // }); - select_name_arr = []; - if (Config.pageApp == 'explorer') { - ui.tree.checkIfChange(G.this_path); - } - }).on('error',function(info,code){ - core.tips.tips(info,false); - }); - - var timer; - inState = false; - dragOver = function(e){ - //stopPP(e); - if (inState == false){ - inState = true; - MaskView.tips(LNG.upload_drag_tips); - } - if (timer) window.clearTimeout(timer) - }; - dragLeave = function(e){ - stopPP(e); - if (timer){ - window.clearTimeout(timer); - } - timer = window.setTimeout(function() { - inState = false; - MaskView.close(); - },100); - } - dragDrop = function(e){ - e = e.originalEvent || e; - var txt = e.dataTransfer.getData("text/plain"); - if (txt && txt.substring(0,4) == 'http') { - ui.path.pathOperate.appAddURL(txt); - }else{ - core.upload();//满足 拖拽到当前,则上传到当前。 - } - stopPP(e); - if (inState) { - inState = false; - MaskView.close(); - } - } - } - }; -}); \ No newline at end of file diff --git a/static/js/_dev/common/pathOpen.js b/static/js/_dev/common/pathOpen.js deleted file mode 100644 index 05ff6ff..0000000 --- a/static/js/_dev/common/pathOpen.js +++ /dev/null @@ -1,199 +0,0 @@ -define(function(require, exports) { - //双击或者选中后enter 打开 执行事件 - //或者打开指定文件 - var _open = function(path,ext){ - if (path == undefined) return; - - if (ext == undefined) ext = core.pathExt(path);//没有扩展名则自动解析 - ext = ext.toLowerCase(); - if (ext == 'folder'){ - if (Config.pageApp == 'explorer'){ - ui.path.list(path+'/');//更新文件列表 - }else{ - core.explorer(path); - } - return; - } - if (ext == 'swf') { - var url = core.path2url(path); - _openWindow(url,core.ico('swf'),core.pathThis(path)); - return; - } - if (ext == 'oexe') { - core.openApp(path); - return; - } - if (ext == 'pdf') { - var uuid = 'pdf'+UUID(); - var url = core.path2url(path); - var html = ''; - $.dialog({ - resize:true, - fixed:true, - ico:core.ico('pdf'), - title:core.pathThis(path), - width:800, - height:400, - padding:0, - content:html - }); - new PDFObject({url:url}).embed(uuid); - return; - } - if (ext=='html' || ext =='htm'){ - var url = core.path2url(path); - _openWindow(url,core.ico('html'),core.pathThis(path)); - return; - } - if (inArray(core.filetype['image'],ext)){//单张图片打开 - var url = urlDecode(path); - if (path.indexOf('http:') == -1) { - url = core.path2url(url); - } - MaskView.image(url); - return; - } - if (inArray(core.filetype['music'],ext) - || inArray(core.filetype['movie'],ext) ) { - var url = core.path2url(path); - _player(url,ext); - return; - } - if (inArray(core.filetype['doc'],ext)){ - var url = core.path2url(path); - _openOffice(url,ext); - return; - } - if (inArray(core.filetype['bindary'],ext)) {//二进制文件,则下载 - _download(path); - return; - } - _openEditor(path);//代码文件,编辑 - } - var _download = function(path){ - if (!path) return; - var url='index.php?explorer/fileDownload&path='+urlEncode2(path); - var html = ''+ - LNG.download_ready +'...'; - var dlg = $.dialog({ - icon:'succeed', - title:false, - time:1, - content:html - }); - dlg.DOM.wrap.find('.aui_loading').remove(); - }; - //新的页面作为地址打开。鼠标右键,IE下打开 - var _openIE = function(path){ - if (path==undefined) return; - var url=core.path2url(path); - window.open(url); - }; - var _openWindow = function(url,ico,title,name) { - if (!url) return; - if (name == undefined) name = 'openWindow'+UUID(); - - var html = ""; - // if(url.substr(url.length-4).toLowerCase() == '.swf'){ - // html = core.createFlash(url,'',name); - // } - art.dialog.through({ - id:name, - title:title, - ico:ico, - width:'70%', - height:'65%', - padding:0, - content:html, - resize:true - }); - }; - var _openEditor = function(path){ - if (!path) return; - var ext = core.pathExt(path); - var filename = core.pathThis(path); - if (inArray(core.filetype['bindary'],ext) || - inArray(core.filetype['music'],ext) || - inArray(core.filetype['image'],ext) || - inArray(core.filetype['movie'],ext) || - inArray(core.filetype['doc'],ext) - ){ - core.tips.tips(ext+LNG.edit_can_not,false); - return; - } - if (window.top.frames["OpenopenEditor"] == undefined) { - var url ='./index.php?editor/edit&filename='+urlEncode(urlEncode2(path));//3次 - var title = filename+' ——'+LNG.edit; - _openWindow(url,core.ico('edit'),title.substring(title.length-50),'openEditor'); - }else{ - if ($.dialog.list['openEditor']) $.dialog.list['openEditor'].display(true);; - FrameCall.top('OpenopenEditor','Editor.add','"'+urlEncode2(path)+'"');//2次 - } - }; - var _openOffice = function(url,ext){ - if (G.office_server !='') { - var office_url = G.office_server + urlEncode(url); - var title = core.pathThis(urlDecode(url)); - art.dialog.open(office_url,{ - ico:ico, - title:title,width:'70%', - height:'65%', - resize:true - }); - return; - } - - var app_url,temp_url,frame,ico; - switch (ext) { - case 'doc': - case 'docx': - case 'docm': - case 'dot': - ico=core.ico('doc'); - app_url ='http://sg1b-word-view.officeapps.live.com/wv/wordviewerframe.aspx?ui=zh-CN&rs=zh-CN&WOPISrc='; - break; - case 'ppt': - case 'pptm': - case 'pptx': - ico=core.ico('ppt'); - app_url ='http://sg1b-powerpoint.officeapps.live.com/p/PowerPointFrame.aspx?PowerPointView=ReadingView&ui=zh-CN&rs=zh-CN&WOPISrc='; - break; - case 'xls': - case 'xlsb': - case 'xlsm': - case 'xlsx': - ico=core.ico('xls'); - app_url = 'http://sg1b-excel.officeapps.live.com/x/_layouts/xlviewerinternal.aspx?ui=zh-CN&rs=zh-CN&WOPISrc='; - break; - default:break; - } - temp_url = 'http://sg1b-15-view-wopi.wopi.live.net:808/oh/wopi/files/@/wFileId?wFileId='; - temp_url += urlEncode(url); - frame = app_url+urlEncode(temp_url)+'&access_token=1&access_token_ttl=0'; - - var title = core.pathThis(urlDecode(url)); - art.dialog.open(frame,{ - ico:ico, - title:title,width:'70%', - height:'65%', - resize:true - }); - } - //传入音乐播放地址,多个的话传入数组。可以扩展播放网络音乐 - var _player = function(list,ext){ - if (!list) return; - if (typeof(list) == 'string') list=[list]; - CMPlayer = require('./CMPlayer'); - CMPlayer.play(list,ext); - }; - //对外接口 - return{ - open:_open, - play:_player, - openEditor:_openEditor, - openIE:_openIE, - download:_download - } -}); diff --git a/static/js/_dev/common/pathOperate.js b/static/js/_dev/common/pathOperate.js deleted file mode 100644 index 882f4eb..0000000 --- a/static/js/_dev/common/pathOperate.js +++ /dev/null @@ -1,554 +0,0 @@ -define(function(require, exports) { - var tpl = require('../tpl/fileinfo'); - var path_not_allow = ['/','\\',':','*','?','"','<','>','|'];//win文件名命不允许的字符 - //检测文件名是否合法,根据操作系统,规则不一样 - //win 不允许 / \ : * ? " < > |,lin* 不允许 ‘、’ - var _pathAllow = function(path){ - //字符串中检验是否出现某些字符,check=['-','='] - var _strHasChar = function(str,check){ - var len=check.length; - var reg=""; - for (var i=0; i0) return true; - } - return false; - }; - if (_strHasChar(path,path_not_allow)){ - core.tips.tips(LNG.path_not_allow+':/ \ : * ? " < > |',false); - return false; - } - return true; - }; - //组装数据 - var _json = function(json){ - var send = 'list=['; - for (var i in json) { - send += '{"type":"'+json[i].type+'","path":"'+urlEncode2(json[i].path)+'"}'; - if (i != json.length-1) send+= ','; - }; - return send+']'; - } - // 新建文件 - var newFile = function(path,callback){ - if (!path) return; - var filename = core.pathThis(path); - if (!_pathAllow(filename)){ - if (typeof(callback) == 'function')callback(); - return; - } - $.ajax({ - dataType:'json', - url: 'index.php?explorer/mkfile&path='+urlEncode2(path), - beforeSend:function(){ - core.tips.loading(); - }, - error:core.ajaxError, - success: function(data) { - core.tips.close(data); - if (typeof(callback) == 'function')callback(data); - } - }); - }; - // 新建文件夹 - var newFolder = function(path,callback){ - if (!path) return; - var filename = core.pathThis(path); - if (!_pathAllow(filename)){ - if (typeof(callback) == 'function')callback(); - return; - } - $.ajax({ - dataType:'json', - url: 'index.php?explorer/mkdir&path='+urlEncode2(path), - beforeSend:function(){ - core.tips.loading(); - }, - error:core.ajaxError, - success: function(data) { - core.tips.close(data); - if (typeof (callback) == 'function')callback(data); - } - }); - }; - // 树目录重命名文件夹 - var rname = function(from,to,callback){ - if (!from || !to) return; - if (from == to) return; - if (!_pathAllow(core.pathThis(to))){ - if (typeof(callback) == 'function')callback(); - return; - } - $.ajax({ - type: "POST", - dataType:'json', - url: 'index.php?explorer/pathRname', - data: 'path='+urlEncode(from)+'&rname_to='+urlEncode(to), - beforeSend:function(){ - core.tips.loading(); - }, - error:core.ajaxError, - success: function(data) { - core.tips.close(data); - if (typeof(callback) == 'function')callback(data); - //ui.tree.refresh(treeNode.getParentNode()); - } - }); - }; - - //多条数据操作 - //参数形如:list=[{"type":"file","file":"D:/test/a.txt"}] - //删除 文件|文件夹 & 包含批量删除 - var remove = function(param,callback){ - if (param.length<1) return; - var name = param[0]['path']; - if (name.length > 20) { - name = '...'+name.substr(-20); - }; - - $.dialog({ - id:'dialog_path_remove', - fixed: true,//不跟随页面滚动 - icon:'question', - title:LNG.remove_title, - padding:40, - lock:true, - background:"#000", - opacity:0.5, - content:name+'
    '+LNG.remove_info+'【'+param.length+'】', - ok:function() { - $.ajax({ - url: 'index.php?explorer/pathDelete', - type:'POST', - dataType:'json', - data:_json(param), - beforeSend:function(){ - core.tips.loading(); - }, - error:core.ajaxError, - success: function(data) { - core.tips.close(data); - if (typeof(callback) == 'function')callback(data); - } - }); - }, - cancel: true - }); - }; - //复制 - var copy = function(param){ - if (param.length<1) return; - $.ajax({ - url:'index.php?explorer/pathCopy', - type:'POST', - dataType:'json', - data:_json(param), - error:core.ajaxError, - success: function(data) { - core.tips.tips(data); - } - }); - }; - //剪切 - var cute = function(param){ - if (param.length<1) return; - $.ajax({ - url:'index.php?explorer/pathCute', - type:'POST', - dataType:'json', - data:_json(param), - error:core.ajaxError, - success:function(data){ - core.tips.tips(data); - } - }); - }; - // 粘贴 - var past = function(path,callback){ - if (!path) return; - var url='index.php?explorer/pathPast&path='+urlEncode2(path); - $.ajax({ - url:url, - dataType:'json', - beforeSend: function(){ - core.tips.loading(LNG.moving); - }, - error:core.ajaxError, - success:function(data){ - if (data.code){ - core.tips.close(data); - }else{ - core.tips.close(data.info,false); - } - if (typeof(callback) == 'function')callback(data); - } - }); - }; - - //获取文件夹属性 - var info = function(param){ - if (param.length<1) param = [{path:G.this_path,type:"folder"}];//当前目录属性 - $.ajax({ - url:'index.php?explorer/pathInfo', - type:'POST', - dataType:'json', - data:_json(param), - beforeSend: function(){ - core.tips.loading(LNG.getting); - }, - error:core.ajaxError, - success:function(data){ - if (!data.code){ - core.tips.close(data);return; - } - core.tips.close(LNG.get_success,true); - var tpl_file = 'path_info_more'; - var title = LNG.info; - if (param.length ==1) { - tpl_file = ((param[0].type =='folder')?'path_info':'file_info'); - title = core.pathThis(param[0].path); - if (title.length>15) { - title = title.substr(0,15)+"... "+LNG.info - } - } - var render = template.compile(tpl[tpl_file]); - var dialog_id = UUID(); - data.data.LNG = LNG;//模板中的多语言注入 - $.dialog({ - id:dialog_id, - padding:5, - ico:core.ico('info'), - fixed: true,//不跟随页面滚动 - title:title, - content:render(data.data), - width:'350px', - cancel: true - }); - _chmod(dialog_id,param); - } - }); - }; - var _chmod = function(dialog_id,param){ - $('.'+dialog_id).find('.edit_chmod').click(function(){ - var $input = $(this).parent().find('input'); - var $button = $(this); - $.ajax({ - url:'index.php?explorer/pathChmod&mod='+$input.val(), - type:'POST', - data:_json(param), - beforeSend: function(){ - $button.text(LNG.loading); - }, - error:function(data){ - $button.text(LNG.button_save); - }, - success:function(data){ - $button.text(data.data) - .animate({opacity:0.6},400,0) - .delay(1000) - .animate({opacity:1},200,0,function(){ - $button.text(LNG.button_save); - }); - } - }); - }); - } - - var zip = function(param,callback){ - if (param.length<1) return; - $.ajax({ - url:'index.php?explorer/zip', - type:'POST', - dataType:'json', - data:_json(param), - beforeSend: function(){ - core.tips.loading(LNG.ziping); - }, - error:core.ajaxError, - success:function(data){ - core.tips.close(data); - core.tips.tips(data); - if (typeof (callback) == 'function') callback(data); - } - }); - }; - var unZip = function(path,callback){ - if (!path) return; - var url='index.php?explorer/unzip&path='+urlEncode2(path); - $.ajax({ - url:url, - beforeSend: function(){ - core.tips.loading(LNG.unziping); - }, - error:core.ajaxError, - success:function(data){ - core.tips.close(data); - if (typeof (callback) == 'function') callback(data); - } - }); - }; - // 粘贴 - var cuteDrag = function(param,dragTo,callback){ - if (!dragTo) return; - $.ajax({ - url:'index.php?explorer/pathCuteDrag', - type:'POST', - dataType:'json', - data:_json(param)+'&path='+urlEncode2(dragTo), - beforeSend: function(){ - core.tips.loading(LNG.moving); - }, - error:core.ajaxError, - success:function(data){ - core.tips.close(data); - if (typeof (callback) == 'function') callback(data); - } - }); - }; - // 创建副本 - var copyDrag = function(param,dragTo,callback){ - if (!dragTo) return; - $.ajax({ - url:'index.php?explorer/pathCopyDrag', - type:'POST', - dataType:'json', - data:_json(param)+'&path='+urlEncode2(dragTo), - beforeSend: function(){ - core.tips.loading(LNG.moving); - }, - error:core.ajaxError, - success:function(data){ - core.tips.close(data); - if (typeof (callback) == 'function') callback(data); - } - }); - }; - - //==查看剪贴板 - var clipboard = function(){ - $.ajax({ - url:'index.php?explorer/clipboard', - dataType:'json', - error:core.ajaxError, - success:function(data){ - if (!data.code) return; - $.dialog({ - title:LNG.clipboard, - padding:0, - height:200, - width:400, - content:data.data - }); - } - }); - }; - //==添加收藏夹 - var fav = function(path){ - if (!path) return; - var pram='&name='+urlEncode(core.pathThis(path))+'&path='+urlEncode(path); - core.setting('fav'+pram); - }; - - - //获取数据 - var _app_param = function(dom) { - var param ={}; - param.type = dom.find("input[type=radio]:checked").val(); - param.content = dom.find("textarea").val(); - param.group = dom.find("[name=group]").val(); - dom.find('input[type=text]').each(function(){ - var name = $(this).attr('name'); - param[name]=$(this).val(); - }); - dom.find('input[type=checkbox]').each(function(){ - var name = $(this).attr('name'); - param[name] = $(this).attr('checked')=='checked'?1:0; - }); - return param; - } - var _bindAppEvent = function(dom) { - dom.find('.type input').change(function() { - var val = $(this).attr('apptype'); - dom.find('[data-type]').addClass('hidden'); - dom.find('[data-type='+val+']').removeClass('hidden'); - }); - } - - - //应用添加、修改——创建文件;appstore 添加、修改——修改数据 - var appEdit = function(path,callback,action){//path——path/jsondata - //action:user_add user_edit root_add root_edit - var title = LNG.app_create,dom, - url,html, - uuid = UUID(), - editpath, - tpl = require('../tpl/app'), - iconpath = G.basic_path+'static/images/app/', - render = template.compile(tpl.html); - if (action == undefined) {action= 'user_edit'}; - if (action == 'root_edit') {path = json_decode(path);}; - if (action == 'user_edit' || action == 'root_edit'){ - title = LNG.app_edit; - html = render({LNG:LNG,iconPath:iconpath,uuid:uuid,data:path}); - }else{ - html = render({LNG:LNG,iconPath:iconpath,uuid:uuid,data:{}}); - } - $.dialog({ - fixed: true,//不跟随页面滚动 - width:450, - height:310, - id:uuid, - padding:15, - title:title, - content:html, - button:[ - {name:LNG.preview,callback:function(){ - var data = _app_param(dom); - core.openApp(data); - return false; - }}, - {name:LNG.button_save,focus:true,callback:function(){ - var data = _app_param(dom); - switch(action){ - case 'user_add': - var filename = urlEncode2(G.this_path+data.name); - url = './index.php?app/user_app&action=add&path='+filename; - break; - case 'user_edit': - url = './index.php?app/user_app&path='+urlEncode2(path.path); - break; - case 'root_add':url = './index.php?app/add&name='+data.name;break; - case 'root_edit':url = './index.php?app/edit&name='+data.name+'&old_name='+path.name;break; - default:break; - } - $.ajax({ - url: url, - type:'POST', - dataType:'json', - data:'data='+urlEncode2(json_encode(data)), - beforeSend:function(){ - core.tips.loading(); - }, - error:core.ajaxError, - success: function(data) { - core.tips.close(data); - if (!data.code) return; - if (action == 'root_edit' || action == 'root_add') { - //刷新应用列表 - if (!data.code) {return;}; - FrameCall.top('Openapp_store','App.reload','""'); - }else{ - if (typeof (callback) == 'function'){ - callback(); - }else{ - ui.f5(); - } - } - } - }); - }} - ] - }); - dom = $('.'+uuid); - //init 选中、初始化数据、显示隐藏 - if (path.group) { - dom.find('option').eq(path.group).attr('selected',1); - } - dom.find('.aui_content').css('overflow','inherit'); - switch(action){ - case 'user_edit' : - dom.find('.name').addClass('hidden'); - dom.find('.desc').addClass('hidden'); - dom.find('.group').addClass('hidden'); - dom.find('option[value='+path.group+']').attr('checked',true); - break; - case 'user_add': - dom.find('.desc').addClass('hidden'); - dom.find('.group').addClass('hidden'); - dom.find('[apptype=url]').attr('checked',true); - dom.find('[data-type=url] input[name=resize]').attr('checked',true); - dom.find('input[name=width]').attr('value','800'); - dom.find('input[name=height]').attr('value','600'); - dom.find('input[name=icon]').attr('value','oexe.png'); - break; - case 'root_add': - dom.find('[apptype=url]').attr('checked',true); - dom.find('[data-type=url] input[name=resize]').attr('checked',true); - dom.find('input[name=width]').attr('value','800'); - dom.find('input[name=height]').attr('value','600'); - dom.find('input[name=icon]').attr('value','oexe.png'); - break; - case 'root_edit': - dom.find('option[value='+path.group+']').attr('selected',true); - break; - default:break; - } - _bindAppEvent(dom); - }; - var appList = function(){ - core.appStore(); - }; - //ui.path.pathOperate.appAddURL('http://www.baidu.com'); - var appAddURL = function(url){ - if (url && url.length<4 && url.substring(0,4)!='http') return; - $.ajax({ - url: './index.php?app/get_url_title&url='+url, - dataType:'json', - beforeSend:function(){ - core.tips.loading(); - }, - success: function(result) { - var name = result.data; - core.tips.close(result); - var data = { - content:"window.open('"+url+"');", - desc: "", - group: "others", - type: "app", - icon: "internet.png", - name: name, - resize: 1, - simple: 0, - height: "", - width: "" - }; - var filename = urlEncode2(G.this_path+name); - url = './index.php?app/user_app&action=add&path='+filename; - $.ajax({ - url: url, - type:'POST', - dataType:'json', - data:'data='+urlEncode2(json_encode(data)), - success: function(data) { - core.tips.close(data); - if (!data.code) return; - ui.f5(); - } - }); - } - }); - }; - - return{ - appEdit:appEdit, - appList:appList, - appAddURL:appAddURL, - - newFile:newFile, - newFolder:newFolder, - rname:rname, - unZip:unZip, - - //参数为json数据,可以操作多个对象 - zip:zip, - copy:copy, - cute:cute, - info:info, - remove:remove, - cuteDrag:cuteDrag, - copyDrag:copyDrag, - - past:past, - clipboard:clipboard, - fav:fav - } -}); \ No newline at end of file diff --git a/static/js/_dev/common/rightMenu.js b/static/js/_dev/common/rightMenu.js deleted file mode 100644 index e2ab2c9..0000000 --- a/static/js/_dev/common/rightMenu.js +++ /dev/null @@ -1,603 +0,0 @@ -//点击右键,获取元素menu的值,对应为右键菜单div的id值。实现通用。 -//流程:给需要右键菜单的元素,加上menu属性,并赋值,把值作为右键菜单div的id值 -define(function(require, exports) { - var fileMenuSelector = ".menufile"; - var folderMenuSelector = ".menufolder"; - var selectMoreSelector = ".menuMore"; - var selectAppSelector = ".menuApp"; - var selectTreeSelectorFav = ".menuTreeFav"; - var selectTreeSelectorRoot = ".menuTreeRoot"; - var selectTreeSelectorFolder = ".menuTreeFolder"; - var selectTreeSelectorFile = ".menuTreeFile"; - - var _init_explorer = function(){ - $('').appendTo('body'); - $('.context-menu-list').die("click").live("click",function(e){ - stopPP(e);return false;//屏蔽html点击隐藏 - }); - - _bindBody_explorer(); - _bindFolder(); - _bindFile(); - _bindSelectMore(); - _bindTreeFav(); - _bindTreeRoot(); - _bindTreeFolder(); - _bindApp(); - _bindDialog(); - _bindTask(); - _bindTaskBar(); - //初始化绑定筛选排序方式 - $('.set_set'+G.list_type).addClass('selected'); - $('.set_sort_'+G.sort_field).addClass('selected'); - $('.set_sort_'+G.sort_order).addClass('selected'); - $('.context-menu-root').addClass('fadein'); - }; - var _init_desktop = function(){ - $('').appendTo('body'); - $('.context-menu-list').die("click").live("click",function(e){ - stopPP(e);return false;//屏蔽html点击隐藏 - }); - _bindBody_desktop(); - _bindApp(); - _bindSystem(); - _bindFolder(); - _bindFile(); - _bindTask(); - _bindDialog(); - _bindSelectMore(); - _bindTaskBar(); - $('.set_sort_'+G.sort_field).addClass('selected'); - $('.set_sort_'+G.sort_order).addClass('selected'); - $('.context-menu-root').addClass('fadein'); - }; - - //初始化编辑器 树目录右键菜单 - var _init_editor = function(){ - $('').appendTo('body'); - $('.context-menu-list').die("click").live("click",function(e){ - stopPP(e); - return false;//屏蔽html点击隐藏 - }); - _bindTreeFav(); - _bindTreeRoot(); - _bindApp(); - _bindTask(); - _bindDialog(); - _bindTreeFolderEditor(); - _bindEditorFile(); - _bindTaskBar(); - $('.context-menu-root').addClass('fadein'); - }; - - - var _bindBody_explorer = function(){ - $.contextMenu({ - selector: Config.BodyContent, - zIndex:9999, - callback: function(key, options) {_menuBody(key, options);}, - items: { - "refresh":{name:LNG.refresh,className:"refresh",icon:"refresh",accesskey: "e"}, - "upload":{name:LNG.upload,className:"upload",icon:"upload",accesskey: "u"}, - "past":{name:LNG.past,className:"past",icon:"paste",accesskey: "p"}, - "copy_see":{name:LNG.clipboard,className:"copy_see",icon:"eye",accesskey: "b"}, - "sep1":"--------", - "listIcon": { - name: LNG.list_type, - accesskey: "v", - icon:"eye-open", - items:{ - "seticon":{name:LNG.list_icon,className:"seticon",icon:"th",accesskey: "i",className:'menu_seticon set_seticon'}, - "setlist":{name:LNG.list_list,className:"setlist",icon:"list",accesskey: "l",className:'menu_seticon set_setlist'} - } - }, - "sortBy": { - name: LNG.order_type, - accesskey: "o", - icon:"sort", - items:{ - "set_sort_name":{name:LNG.name,className:'menu_set_sort set_sort_name'}, - "set_sort_ext":{name:LNG.type,className:'menu_set_sort set_sort_ext'}, - "set_sort_size":{name:LNG.size,className:'menu_set_sort set_sort_size'}, - "set_sort_mtime":{name:LNG.modify_time,className:'menu_set_sort set_sort_mtime'}, - "set_sort_up":{name:LNG.sort_up,className:"set_sort_up",icon:"sort-up",className:'menu_set_desc set_sort_up'}, - "set_sort_down":{name:LNG.sort_down,className:"set_sort_down",icon:"sort-down",className:'menu_set_desc set_sort_down'} - } - }, - "sep2":"--------", - "app_install":{name:LNG.app_store,className:"app_install",icon:"tasks",accesskey: "a"}, - "app_create":{name:LNG.app_create,className:"app_create",icon:"puzzle-piece",accesskey: "k"}, - "sep3":"--------", - "newfolder":{name:LNG.newfolder,className:"newfolder",icon:"folder-close-alt",accesskey: "n"}, - "newfile":{name:LNG.newfile,className:"newfile",icon:"file-alt",accesskey: "j"}, - "newfileOther":{ - name:LNG.newothers, - items:{ - "newfile_html":{name:"html "+LNG.file}, - "newfile_php":{name:"php "+LNG.file}, - "newfile_js":{name:"js "+LNG.file}, - "newfile_css":{name:"css "+LNG.file} - } - }, - "sep3":"--------", - "info":{name:LNG.info,className:"info",icon:"info",accesskey: "i"} - } - }); - }; - var _bindSystem = function(){ - $.contextMenu({ - selector:'.menuDefault', - zIndex:9999, - items: {"open":{name:LNG.open,className:"open",icon:"external-link",accesskey: "o"}}, - callback: function(key, options) { - switch(key){ - case 'open':ui.path.open();break; - default:break; - } - } - }); - }; - var _bindBody_desktop = function(){ - $.contextMenu({ - selector: Config.BodyContent, - zIndex:9999, - callback: function(key, options) {_menuBody(key);}, - items: { - "refresh":{name:LNG.refresh,className:"refresh",icon:"refresh",accesskey: "e"}, - "sortBy": { - name: LNG.order_type, - accesskey: "o", - icon:"sort", - items:{ - "set_sort_name":{name:LNG.name,className:'menu_set_sort set_sort_name'}, - "set_sort_ext":{name:LNG.type,className:'menu_set_sort set_sort_ext'}, - "set_sort_size":{name:LNG.size,className:'menu_set_sort set_sort_size'}, - "set_sort_mtime":{name:LNG.modify_time,className:'menu_set_sort set_sort_mtime'}, - "set_sort_up":{name:LNG.sort_up,className:"set_sort_up",icon:"sort-up",className:'menu_set_desc set_sort_up'}, - "set_sort_down":{name:LNG.sort_down,className:"set_sort_down",icon:"sort-down",className:'menu_set_desc set_sort_down'} - } - }, - "sep1":"--------", - "upload":{name:LNG.upload,className:"upload",icon:"upload",accesskey: "u"}, - "past":{name:LNG.past,className:"past",icon:"paste",accesskey: "p"}, - "copy_see":{name:LNG.clipboard,className:"copy_see",icon:"eye",accesskey: "b"}, - "sep2":"--------", - "app_install":{name:LNG.app_store,className:"app_install",icon:"tasks",accesskey: "a"}, - "app_create":{name:LNG.app_create,className:"app_create",icon:"puzzle-piece",accesskey: "k"}, - "sep3":"--------", - "newfolder":{name:LNG.newfolder,className:"newfolder",icon:"folder-close-alt",accesskey: "n"}, - "newfile":{name:LNG.newfile,className:"newfile",icon:"file-alt",accesskey: "j"}, - "newfileOther":{ - name:LNG.newothers, - items:{ - "newfile_html":{name:"html "+LNG.file}, - "newfile_php":{name:"php "+LNG.file}, - "newfile_js":{name:"js "+LNG.file}, - "newfile_css":{name:"css "+LNG.file} - } - }, - "sep3":"--------", - "full":{name:LNG.full_screen,className:"full",icon:"fullscreen",accesskey: "m"}, - "setting_wall":{name:LNG.setting_wall,className:"setting_wall",icon:"picture",accesskey: "w"}, - "setting":{name:LNG.setting,className:"setting",icon:"cogs",accesskey: "s"} - } - }); - }; - var _bindFolder = function(){ - $('').appendTo('#rightMenu'); - $.contextMenu({ - zIndex:9999, - selector: folderMenuSelector, - className:folderMenuSelector, - callback: function(key, options) {_menuPath(key);}, - items: { - "open":{name:LNG.open,className:"open",icon:"folder-open-alt",accesskey: "o"}, - "open_ie":{name:LNG.open_ie,className:"open_ie",icon:"globe",accesskey: "b"}, - "sep1":"--------", - "copy":{name:LNG.copy,className:"copy",icon:"copy",accesskey: "c"}, - "cute":{name:LNG.cute,className:"cute",icon:"cut",accesskey: "k"}, - "remove":{name:LNG.remove,className:"remove",icon:"trash",accesskey: "d"}, - "rname":{name:LNG.rename,className:"rname",icon:"pencil",accesskey: "r"}, - "sep2":"--------", - "search":{name:LNG.search_in_path,className:"search",icon:"search",accesskey: "s"}, - "fav":{name:LNG.add_to_fav,className:"fav",icon:"star",accesskey: "f"}, - "zip":{name:LNG.zip,className:"zip",icon:"folder-close",accesskey: "z"}, - "sep3":"--------", - "info":{name:LNG.info,className:"info",icon:"info",accesskey: "i"} - } - }); - }; - var _bindFile = function(){ - $('').appendTo('#rightMenu'); - $.contextMenu({ - zIndex:9999, - selector: fileMenuSelector, - className:folderMenuSelector, - callback: function(key, options) {_menuPath(key);}, - items: { - "open":{name:LNG.open,className:"open",icon:"external-link",accesskey: "o"}, - "open_text":{name:LNG.edit,className:"open_text",icon:"edit",accesskey: "e"}, - "open_ie":{name:LNG.open_ie,className:"open_ie",icon:"globe",accesskey: "b"}, - "newfileOther":{ - name:LNG.open_with, - accesskey:'h', - items:{ - "open_text":{name:LNG.edit,className:"open_text",icon:"edit"}, - "open_kindedit":{name:LNG.others,className:"open_kindedit",icon:"edit"} - } - }, - "sep1":"--------", - "copy":{name:LNG.copy,className:"copy",icon:"copy",accesskey: "c"}, - "cute":{name:LNG.cute,className:"cute",icon:"cut",accesskey: "k"}, - "remove":{name:LNG.remove,className:"remove",icon:"trash",accesskey: "d"}, - "rname":{name:LNG.rename,className:"rname",icon:"pencil",accesskey: "r"}, - "sep2":"--------", - "zip":{name:LNG.zip,className:"zip",icon:"folder-close",accesskey: "z"}, - "unzip":{name:LNG.unzip,className:"unzip",icon:"folder-open-alt",accesskey: "u"}, - "down":{name:LNG.download,className:"down",icon:"download",accesskey: "x"}, - "sep3":"--------", - "info":{name:LNG.info,className:"info",icon:"info",accesskey: "i"} - } - }); - }; - var _bindApp = function(){ - $('').appendTo('#rightMenu'); - $.contextMenu({ - zIndex:9999, - selector: selectAppSelector, - className:folderMenuSelector, - callback: function(key, options) { - if(Config.pageApp == 'editor'){ - _menuTree(key); - }else{ - _menuPath(key); - } - }, - items: { - "open":{name:LNG.open,className:"open",icon:"external-link",accesskey: "o"}, - "app_edit":{name:LNG.app_edit,className:"app_edit",icon:"code",accesskey: "a"}, - "sep1":"--------", - "copy":{name:LNG.copy,className:"copy",icon:"copy",accesskey: "c"}, - "cute":{name:LNG.cute,className:"cute",icon:"cut",accesskey: "k"}, - "remove":{name:LNG.remove,className:"remove",icon:"trash",accesskey: "d"}, - "rname":{name:LNG.rename,className:"rname",icon:"pencil",accesskey: "r"}, - "sep2":"--------", - "info":{name:LNG.info,className:"info",icon:"info",accesskey: "i"} - } - }); - }; - var _bindSelectMore = function(){ - $('').appendTo('#rightMenu'); - $.contextMenu({ - zIndex:9999, - selector: selectMoreSelector, - className:folderMenuSelector, - callback: function(key, options) {_menuPath(key);}, - items: { - "copy":{name:LNG.copy,className:"copy",icon:"copy",accesskey: "c"}, - "clone":{name:LNG.clone,className:"clone",icon:"external-link",accesskey: "m"}, - "cute":{name:LNG.cute,className:"cute",icon:"cut",accesskey: "k"}, - "remove":{name:LNG.remove,className:"remove",icon:"trash",accesskey: "d"}, - "sep1":"--------", - "playmedia":{name:LNG.add_to_play,className:"playmedia",icon:"music",accesskey: "p"}, - "zip":{name:LNG.zip,className:"zip",icon:"folder-close",accesskey: "z"}, - "sep2":"--------", - "info":{name:LNG.info,className:"info",icon:"info",accesskey: "i"} - } - }); - } - - //___________________________________________________________________________________ - //桌面右键& 资源管理器右键动作 - var _menuBody = function(action) { - switch(action){ - case 'refresh':ui.f5(true,true);break; - case 'back':ui.path.back(); - case 'next':ui.path.next();break; - case 'seticon': ui.setListType('icon');break;//大图标显示 - case 'setlist':ui.setListType('list');break;//列表显示 - case 'set_sort_name':ui.setListSort('name',0);break;//排序方式,名称 - case 'set_sort_ext':ui.setListSort('ext',0);break;//排序方式,扩展名 - case 'set_sort_size':ui.setListSort('size',0);break;//排序方式,大小 - case 'set_sort_mtime':ui.setListSort('mtime',0);break;//排序方式,修改时间 - case 'set_sort_up':ui.setListSort(0,'up');break;//已有模式升序 - case 'set_sort_down':ui.setListSort(0,'down');break;//已有模式降序 - case 'upload':core.upload();break; - - case 'past':ui.path.past();break; //粘贴到当前文件夹 - case 'copy_see':ui.path.clipboard();break; //查看剪贴板 - case 'newfolder':ui.path.newFolder();break; //新建文件夹 - case 'newfile':ui.path.newFile();break;//新建文件 - case 'newfile_html':ui.path.newFile('html');break; - case 'newfile_php':ui.path.newFile('php');break; - case 'newfile_js':ui.path.newFile('js');break; - case 'newfile_css':ui.path.newFile('css');break; - case 'newfile_oexe':ui.path.newFile('oexe');break; - case 'info':ui.path.info();break;//当前文件夹熟悉 - - case 'open':ui.path.open();break; - case 'open_new':ui.path.open_new();break; - - case 'app_install':ui.path.appList();break; - case 'app_create':ui.path.appEdit(true);break; - - //桌面会用到 - case 'full':ui.fullScreen();break; - case 'setting':core.setting();break;//新建文件 - case 'setting_wall':core.setting('wall');break;//新建文件 - default:break; - } - }; - - //目录右键绑定(文件、文件夹) 树目录文件(夹) - var _menuPath = function(action) { - switch(action){ - case 'open':ui.path.open();break; - case 'down':ui.path.download();break; - case 'open_ie':ui.path.openIE();break; - case 'open_text':ui.path.openEditor();break; - case 'app_edit':ui.path.appEdit(); - case 'open_kindedit':break; - case 'playmedia':ui.path.play();break; - - case 'fav':ui.path.fav();break;//添加到收藏夹 - case 'search':ui.path.search();break; - - case 'copy':ui.path.copy();break; - case 'clone':ui.path.copyDrag(G.this_path,true);break; - case 'cute':ui.path.cute();break; - case 'remove':ui.path.remove();break; - case 'rname':ui.path.rname();break; - case 'zip':ui.path.zip();break; - case 'unzip':ui.path.unZip();break; - case 'info':ui.path.info();break; - default:break; - } - }; - - //=============================tree start============================= - //资源管理器tree 右键绑定 - var _bindTreeFav = function(){ - $('').appendTo('#rightMenu'); - $.contextMenu({ - zIndex:9999, - selector: selectTreeSelectorFav, - callback: function(key, options) {_menuTree(key);}, - items: { - "fav_page":{name:LNG.manage_fav,className:"fav_page",icon:"star",accesskey: "r"}, - "refresh_all":{name:LNG.refresh_tree,className:"refresh_all",icon:"refresh",accesskey: "e"}, - "sep1":"--------", - "quit":{name:LNG.close_menu,className:"quit",icon:"remove",accesskey: "q"} - } - }); - } - var _bindTreeRoot = function(){ - $('').appendTo('#rightMenu'); - $.contextMenu({ - zIndex:9999, - selector: selectTreeSelectorRoot, - callback: function(key, options) {_menuTree(key);}, - items: { - "explorer":{name:LNG.manage_folder,className:"explorer",icon:"laptop",accesskey: "v"}, - "refresh":{name:LNG.refresh_tree,className:"refresh",icon:"refresh",accesskey: "e"}, - "newfolder":{name:LNG.newfolder,className:"newfolder",icon:"folder-close-alt",accesskey: "n"}, - "newfile":{name:LNG.newfile,className:"newfile",icon:"file-alt",accesskey: "j"}, - "fav":{name:LNG.add_to_fav,className:"fav",icon:"star",accesskey: "f"}, - "search":{name:LNG.search_in_path,className:"search",icon:"search",accesskey: "s"}, - "sep1":"--------", - "past":{name:LNG.past,className:"past",icon:"paste",accesskey: "p"}, - "sep3":"--------", - "quit":{name:LNG.close_menu,className:"quit",icon:"remove",accesskey: "q"} - } - }); - } - var _bindTreeFolder = function(){ - $('').appendTo('#rightMenu'); - $.contextMenu({ - zIndex:9999, - selector: selectTreeSelectorFolder, - callback: function(key, options) {_menuTree(key);}, - items: { - "refresh":{name:LNG.refresh_tree,className:"refresh",icon:"refresh",accesskey: "e"}, - "newfolder":{name:LNG.newfolder,className:"newfolder",icon:"folder-close-alt",accesskey: "n"}, - "fav":{name:LNG.add_to_fav,className:"fav",icon:"star",accesskey: "f"}, - "search":{name:LNG.search_in_path,className:"search",icon:"search",accesskey: "s"}, - "sep1":"--------", - "copy":{name:LNG.copy,className:"copy",icon:"copy",accesskey: "c"}, - "cute":{name:LNG.cute,className:"cute",icon:"cut",accesskey: "k"}, - "past":{name:LNG.past,className:"past",icon:"paste",accesskey: "p"}, - "rname":{name:LNG.rename,className:"rname",icon:"pencil",accesskey: "r"}, - "sep2":"--------", - "remove":{name:LNG.remove,className:"remove",icon:"trash",accesskey: "d"}, - "info":{name:LNG.info,className:"info",icon:"info",accesskey: "i"} - } - }); - } - - var _bindTreeFolderEditor = function(){ - $('').appendTo('#rightMenu'); - $.contextMenu({ - zIndex:9999, - selector: selectTreeSelectorFolder, - callback: function(key, options) {_menuTree(key);}, - items: { - "explorer":{name:LNG.manage_folder,className:"explorer",icon:"laptop",accesskey: "v"}, - "refresh":{name:LNG.refresh_tree,className:"refresh",icon:"refresh",accesskey: "e"}, - "fav":{name:LNG.add_to_fav,className:"fav",icon:"star",accesskey: "f"}, - "search":{name:LNG.search_in_path,className:"search",icon:"search",accesskey: "s"}, - "sep3":"--------", - "newfolder":{name:LNG.newfolder,className:"newfolder",icon:"folder-close-alt",accesskey: "n"}, - "newfile":{name:LNG.newfile,className:"newfile",icon:"file-alt",accesskey: "j"}, - "sep2":"--------", - "copy":{name:LNG.copy,className:"copy",icon:"copy",accesskey: "c"}, - "cute":{name:LNG.cute,className:"cute",icon:"cut",accesskey: "k"}, - "past":{name:LNG.past,className:"past",icon:"paste",accesskey: "p"}, - "rname":{name:LNG.rename,className:"rname",icon:"pencil",accesskey: "r"}, - "sep4":"--------", - "remove":{name:LNG.remove,className:"remove",icon:"trash",accesskey: "d"}, - "info":{name:LNG.info,className:"info",icon:"info",accesskey: "i"}, - "sep5":"--------", - "quit":{name:LNG.close_menu,className:"quit",icon:"remove",accesskey: "q"} - } - }); - }; - var _bindEditorFile = function(){ - $('').appendTo('#rightMenu'); - $.contextMenu({ - zIndex:9999, - selector: selectTreeSelectorFile, - callback: function(key, options) {_menuTree(key);}, - items: { - "edit":{name:LNG.edit,className:"edit",icon:"edit",accesskey: "e"}, - "open":{name:LNG.open,className:"open",icon:"external-link",accesskey: "o"}, - "openIE":{name:LNG.open_ie,className:"openIE",icon:"globe",accesskey: "b"}, - "download":{name:LNG.download,className:"download",icon:"download",accesskey: "x"}, - "sep1":"--------", - "rname":{name:LNG.rename,className:"rname",icon:"pencil",accesskey: "r"}, - "copy":{name:LNG.copy,className:"copy",icon:"copy",accesskey: "c"}, - "cute":{name:LNG.cute,className:"cute",icon:"cut",accesskey: "k"}, - "remove":{name:LNG.remove,className:"remove",icon:"trash",accesskey: "d"}, - "sep2":"--------", - "info":{name:LNG.info,className:"info",icon:"info",accesskey: "i"}, - "quit":{name:LNG.close_menu,className:"quit",icon:"remove",accesskey: "q"} - } - }); - }; - - //绑定任务栏 程序标签 - var _bindTaskBar = function(){ - $('').appendTo('#rightMenu'); - $.contextMenu({ - zIndex:9999, - selector: '.taskBarMenu', - items: { - "quitOthers":{name:LNG.close_others,className:"quitOthers",icon:"remove-circle",accesskey: "o"}, - "quit":{name:LNG.close,className:"quit",icon:"remove",accesskey: "q"} - }, - callback: function(key, options) { - var id =options.$trigger.attr('id'); - var dialog = art.dialog.list[id]; - switch(key){ - case 'quitOthers': - $.each(art.dialog.list,function(index,dlg){ - if(id != index) dlg.close(); - }); - break; - case 'quit':dialog.close();break; - } - } - }); - }; - //绑定任务栏 - var _bindTask = function(){ - $.contextMenu({ - zIndex:9999, - selector: '.task_tab', - items: { - "closeAll":{name:LNG.dialog_close_all,icon:"remove-circle",accesskey: "o"}, - "showAll":{name:LNG.dialog_display_all,icon:"th-large",accesskey: "o"}, - "hideAll":{name:LNG.dialog_min_all,icon:"remove",accesskey: "q"} - }, - callback: function(key, options) { - var id =options.$trigger.attr('id'); - var dialog = art.dialog.list[id]; - switch(key){ - case 'showAll': - $.each(art.dialog.list,function(index,dlg){ - dlg.display(true); - }); - break; - case 'hideAll': - $.each(art.dialog.list,function(index,dlg){ - dlg.display(false); - }); - break; - case 'closeAll': - $.each(art.dialog.list,function(index,dlg){ - dlg.close(); - }); - break; - default:break; - } - } - }); - }; - - //绑定任务栏 - var _bindDialog = function(){ - $('').appendTo('#rightMenu'); - $.contextMenu({ - zIndex:9999, - selector: '.dialog_menu', - items: { - "quit":{name:LNG.close,icon:"remove",accesskey: "o"}, - "hide":{name:LNG.dialog_min,icon:"minus",accesskey: "o"}, - "refresh":{name:LNG.refresh,icon:"refresh",accesskey: "q"} - }, - callback: function(key, options) { - var id =options.$trigger.attr('id'); - var dialog = art.dialog.list[id]; - switch(key){ - case 'quit':dialog.close();break; - case 'hide':dialog.display(false);break; - case 'refresh':dialog.refresh();break; - default:break; - } - } - }); - }; - - - - var _menuTree = function(action) {//多选,右键操作 - switch(action){ - case 'app_edit':ui.tree.appEdit();break; - case 'edit':ui.tree.openEditor();break; - case 'open':ui.tree.open();break; - case 'refresh':ui.tree.refresh();break; - case 'copy':ui.tree.copy();break; - case 'cute':ui.tree.cute();break; - case 'past':ui.tree.past();break; - case 'rname':ui.tree.rname();break; - case 'remove':ui.tree.remove();break; - case 'info':ui.tree.info();break; - - case 'download':ui.tree.download();break; - case 'openIE':ui.tree.openIE();break; - case 'search':ui.tree.search();break; - - case 'newfolder':ui.tree.create('folder');break; - case 'newfile':ui.tree.create('file');break; - case 'explorer':ui.tree.explorer();break; - case 'fav_page':core.setting('fav');break; - case 'fav':ui.tree.fav();break;//添加当前到收藏夹 - case 'refresh_all':ui.tree.init();break; - case 'quit':;break; - default:break; - } - }; - //=============================tree end========================== - - return{ - initDesktop:_init_desktop, - initExplorer:_init_explorer, - initEditor:_init_editor, - show:function(select,left,top){ - if (!select) return; - rightMenu.hidden(); - $(select).contextMenu({x:left, y:top}); - }, - isDisplay:function(){//检测是否有右键菜单 - var display = false; - $('.context-menu-list').each(function(){ - if($(this).css("display") !="none"){ - display = true; - } - }); - return display; - }, - hidden:function(){ - $('.context-menu-list').filter(':visible').trigger('contextmenu:hide'); - } - } -}); \ No newline at end of file diff --git a/static/js/_dev/common/taskTap.js b/static/js/_dev/common/taskTap.js deleted file mode 100644 index ec060bf..0000000 --- a/static/js/_dev/common/taskTap.js +++ /dev/null @@ -1,220 +0,0 @@ -define(function(require, exports) { - var dialogs = {}; - var dialog_focus_id = ''; - var animate_time = 160; - var _bindTab = function(){ - $('.task_tab .tab').die('mouseenter').live('mouseenter',function (e) { - if (!$(this).hasClass('this')){ - $(this).addClass('hover'); - } - }).die('click').live('click',function(){ - var id = $(this).attr('id'); - var dialog = art.dialog.list[id]; - var dom = $('.'+id); - if (dom.css('visibility') == 'hidden'){ - dialog.display(true); - }else if(dom.hasClass('aui_state_focus')){ - dialog.display(false); - }else{ - dialog.zIndex(); - } - - }).die('mouseleave').live('mouseleave',function(){ - $(this).removeClass('hover'); - }).die('dblclick').live('dblclick',function(){ - //remove($(this).attr('id')); - }); - }; - - // 拖拽——移动 - var _bindDrag = function(){ - var $self,$tabs,$drag, - isDraging = false, - isDragInit= false, - first_left= 0, - box_left = 0, - tab_width = 0, - tab_margin= 0, - tab_parent_width= 0, - tab_parent_left = 0, - current_animate_id; //标签切换,当前动画所在的标签 - $('.task_tab .tab').die('mousedown').live('mousedown',function(e){ - $self = $(this); - isDraging = true; - //事件 在 window之外操作,继续保持。 - if(this.setCapture) this.setCapture(); - $(document).mousemove(function(e) {__dragMove(e);}); - $(document).one('mouseup',function(e) { - __dragEnd(e); - if(this.releaseCapture) {this.releaseCapture();} - stopPP(e);return false; - }); - }); - var __dragStart = function(e){ - isDragInit = true, - first_left = e.pageX; - $tab_parent = $('.task_tab'); - $tabs = $('.task_tab .tab'); - $(".tasktab-dragging").remove(); - $drag = $self.clone().addClass("tasktab-dragging").prependTo('body'); - - tab_margin= parseInt($tabs.css('margin-right')); - tab_parent_width = $tab_parent.width(); - tab_parent_left = $tab_parent.get(0).getBoundingClientRect().left; - tab_parent_left = tab_parent_left+$(window).scrollLeft(); - box_left = $self.get(0).getBoundingClientRect().left; - tab_width = parseInt($tabs.css('width')); - - var top = $self.get(0).getBoundingClientRect().top-parseInt($self.css('margin-top')); - var left = e.clientX - first_left + box_left; - - $('body').prepend("
    "); - $drag.css({'width':tab_width+'px','top':top,'left':left}); - $self.css('opacity',0); - }; - var __dragMove = function(e){ - if (!isDraging) return; - if(isDragInit==false){ - __dragStart(e); - } - - var left = e.clientX - first_left + box_left; - if (left < tab_parent_left - || left > tab_parent_left+tab_parent_width-tab_width){ - return;// 拖出边界则不处理 - } - $drag.css('left',left); - $tabs.each(function(i) { - var t_left = $(this).get(0).getBoundingClientRect().left; - if (left > t_left && left < t_left+tab_width/2+tab_margin){ - if ($self.attr('id') == $(this).attr('id')) { - return;//当前区域移动,没有超过左右过半 - } - __change($(this).attr('id'),'left'); - } - if (left > t_left-tab_width/2+tab_margin && left < t_left){ - if ($self.attr('id') == $(this).attr('id')) { - return;//当前区域移动,没有超过左右过半 - } - __change($(this).attr('id'),'right'); - } - }); - }; - // 标签交换位置 - var __change = function(id,change){ - //chrome标签类似动画,动画进行中,,且为当前标签动画则继续 - if ($self.is(":animated") - && current_animate_id == id){ - return; - } - //处理上次动画结束事物 - current_animate_id = id; - $self.stop(true,true); - $('.insertTemp').remove(); - $tabs = $('.task_tab .tab'); - - var temp,width = $self.width(); - var $move = $('.task_tab #'+id); - var $insert = $self.clone(true).insertAfter($self) - .css({'margin-right':'0px','border':'none'}).addClass('insertTemp'); - - if (change == 'left') { - $self.after($move).css('width','0px'); - }else{ - $self.before($move).css('width','0px'); - $move.before($insert); - } - $self.animate({'width':width+'px'},animate_time); - $insert.animate({'width':'0px'},animate_time,function(){ - $(this).remove(); - $tabs = $('.task_tab .tab'); - }); - }; - - var __dragEnd = function(e){ - //if (!isDraging) return false; - isDraging = false; - isDragInit= false; - startTime = 0; - $('.dragMaskView').remove(); - if ($drag == undefined) return; - box_left = $self.get(0).getBoundingClientRect().left; - $drag.animate({left:box_left+'px'},animate_time,function(){ - $self.css('opacity',1); - $(this).remove(); - }); - }; - }; - - var _resetWidth = function(action){ - var max_width = 110; - var reset_width = max_width; - var max_width_all = max_width+12; - var $tabs = $('.task_tab .tab'); - var full_width = $('.task_tab .tabs').width()-50; - var count = $tabs.length; - - //不用变化的个数 - var max_count = Math.floor(full_width/max_width_all); - if (count > max_count) { - reset_width = Math.floor(full_width/count)-12; - } - switch (action) { - case 'add': - $('.task_tab .tabs .this').css('width','0') - .animate({'width':reset_width+'px'},animate_time); - case 'close': - $tabs.animate({width:reset_width+'px'},animate_time); - break; - case 'resize': - $tabs.css('width',reset_width+'px'); - break; - default:break; - } - } - var _add = function(id,title){ - $('.task_tab').removeClass('hidden'); - var title_hover = title.replace(/<[^>]+>/g,""); - var html_tab = '
    '+title+'
    '; - $(html_tab).insertBefore('.task_tab .last'); - _resetWidth('add'); - dialogs[id] = {id:id,name:name}; - }; - //选中 - var _focus = function(selectID) { - //添加最初标签,或者标签不存在 - $('.task_tab .this').removeClass('this'); - $('.task_tab #'+selectID).addClass('this'); - dialog_focus_id = selectID; - }; - //删除 - var _close = function(selectID) { - delete dialogs[selectID]; - $('.task_tab #'+selectID).animate({width:0},animate_time,function(){ - $('.task_tab #'+selectID).remove(); - _resetWidth('close'); - if ($('.tabs .tab').length == 0) { - $('.task_tab').addClass('hidden'); - } - }); - }; - - //---------------------------------------- - //交互只能完成基本功能,如果同时调用对话框,会形成死循环。 - return { - add:_add, - focus:_focus, - close:_close, - init:function(){ - var html = - ''; - $(html).appendTo('body'); - $(window).bind("resize",function(){ - _resetWidth('resize'); - }); - _bindTab(); - _bindDrag(); - } - } -}); diff --git a/static/js/_dev/common/tree.js b/static/js/_dev/common/tree.js deleted file mode 100644 index 621aa7e..0000000 --- a/static/js/_dev/common/tree.js +++ /dev/null @@ -1,477 +0,0 @@ -define(function(require, exports) { - var pathOperate = require('./pathOperate'); - var pathOpen = require('./pathOpen'); - var successCallback; - var isUpdateRefresh = false;//上传连续更新树目录队列方式。没有处理完不做反应,处理完后sleep 2s; - ui.pathOpen = pathOpen; - var zTree; - - // 目录树操作 - var init=function(){ - $.ajax({ - url: Config.treeAjaxURL+"&type=init", - dataType:'json', - error:function(){ - $('#folderList').html('
    '+LNG.system_error+'
    '); - }, - success:function(data){ - if (!data.code){ - $('#folderList').html('
    '+LNG.system_error+'
    '); - return; - } - var tree_json = data.data; - $.fn.zTree.init($("#folderList"), setting,tree_json); - zTree = $.fn.zTree.getZTreeObj("folderList"); - } - }); - $('.ztree .switch').die('mouseenter').live('mouseenter',function(){ - $(this).addClass('switch_hover'); - }).die('mouseleave').live('mouseleave',function(){ - $(this).removeClass('switch_hover'); - }); - if (Config.pageApp == 'editor') { - Mousetrap.bind('up',function(e) { - keyAction(e,'up'); - }).bind('down',function(e) { - keyAction(e,'down'); - }).bind('left',function(e) { - keyAction(e,'left'); - }).bind('right',function(e) { - keyAction(e,'right'); - }); - - Mousetrap.bind('enter',function(e) { - tree.open(); - }).bind(['del','command+backspace'],function(e) { - tree.remove(); - }).bind('f2',function(e) { - stopPP(e); - tree.rname(); - }).bind(['ctrl+f','command+f'],function(e) { - stopPP(e); - tree.search(); - }).bind(['ctrl+c','command+c'],function(e) { - tree.copy(); - }).bind(['ctrl+x','command+x'],function(e) { - tree.cute(); - }).bind(['ctrl+v','command+v'],function(e) { - tree.past(); - }).bind('alt+m',function(e) { - tree.create('folder'); - }).bind('alt+n',function(e) { - tree.create('file'); - }); - } - }; - var keyAction = function(e,action){ - stopPP(e); - var treeNode = zTree.getSelectedNodes()[0]; - if (!treeNode) return; - switch(action){ - case 'up': - var node = treeNode.getPreNode(); - if (!node) { - node = treeNode.getParentNode(); - }else if(node.open && node.children.length>0) { - while(node.open && node.children && node.children.length>=1){ - node = node.children[node.children.length-1]; - } - //if (node.getParentNode().tId == treeNode.tId) node=treeNode; - } - zTree.selectNode(node); - break; - case 'down': - if (treeNode.open && treeNode.children.length>=1){ - node = treeNode.children[0]; - }else{ - var tempNode = treeNode, - node = tempNode.getNextNode()||tempNode.getParentNode().getNextNode(); - try{ - while(!node){ - tempNode = tempNode.getParentNode(); - node = tempNode.getNextNode()||tempNode.getParentNode().getNextNode(); - } - }catch(e){} - } - zTree.selectNode(node); - break; - case 'left': - if (!treeNode.isParent) { - zTree.selectNode(treeNode.getParentNode()); - }else{ - if (treeNode.open) { - zTree.expandNode(treeNode,false); - }else{ - zTree.selectNode(treeNode.getParentNode()); - } - } - break; - case 'right': - if (treeNode.open){ - zTree.selectNode(treeNode.children[0]); - }else{ - zTree.expandNode(treeNode,true); - } - break; - default:break; - } - }; - - var setting={ - async: { - enable: true, - dataType: "json", - url:Config.treeAjaxURL,//直接上次拿到的json变量。 - autoParam:["ajax_name=name","ajax_path=path","this_path"],//前面是value 后面是key - dataFilter: function(treeId,parentNode,responseData){ - if (!responseData.code) return null; - return responseData.data; - } - }, - edit: { - enable: true, - showRemoveBtn: false, - showRenameBtn: false, - drag:{ - isCopy:false,//暂时屏蔽拖拽方式移动 - isMove:false - // isCopy:true, - // isMove:true, - // prev:false, - // inner:true, - // next:false - } - }, - view: { - showLine: false, - selectedMulti: false, - dblClickExpand: false, - // dblClickExpand: function(treeId, treeNode) { - // return treeNode.level >= 0; - // },// 双击 展开&折叠 - addDiyDom: function(treeId, treeNode) { - var spaceWidth = Global.treeSpaceWide; - var switchObj = $("#" + treeNode.tId + "_switch"), - icoObj = $("#" + treeNode.tId + "_ico"); - switchObj.remove(); - icoObj.before(switchObj); - if(treeNode.type=='file'){//如果是文件则用自定义图标 - icoObj.removeClass('button ico_docu') - .addClass('file '+treeNode.ext) - } - if(treeNode.ext=='oexe'){//如果是文件则用自定义图标 - icoObj.removeClass('button ico_docu') - .addClass('file oexe') - .removeAttr('style');; - } - if (treeNode.level >= 1) { - var spaceStr = ""; - switchObj.before(spaceStr); - } - - //配置对应右键菜单 - var selector = ''; - if (Config.pageApp == 'explorer') { - if (treeNode.ext == '__fav__') selector ='menuTreeFav'; - if (treeNode.ext == '__root__') selector ='menuTreeRoot'; - if (treeNode.type == 'folder') selector ='menuTreeFolder'; - }else if (Config.pageApp == 'editor'){//对应收藏夹 文件&文件夹 - if (treeNode.ext == '__fav__') selector ='menuTreeFav'; - if (treeNode.ext == '__root__') selector ='menuTreeRoot'; - if (treeNode.type == 'file') selector ='menuTreeFile'; - if (treeNode.type == 'folder') selector ='menuTreeFolder'; - if (treeNode.ext == 'oexe') selector ='menuApp'; - } - - var title = LNG.name+':'+treeNode.name+"\n"+LNG.size+':'+treeNode.size_friendly+"\n" - +LNG.modify_time+':'+treeNode.mtime; - if (treeNode.type != 'file') { - title = treeNode.name; - } - switchObj.parent().addClass(selector).attr('title',title); - } - }, - callback: {//事件处理回调函数 - onClick: function(event,treeId,treeNode){ - zTree.selectNode(treeNode); - zTree.expandNode(treeNode); - if(treeNode.type=='folder' && Config.pageApp=='editor') return; - if (treeNode.level == 0) { - if (Config.pageApp=='explorer' && treeNode.ext != '__fav__'){ - ui.path.list(treeNode.this_path+'/');//更新文件列表 - } - return false; - } - - if (Config.pageApp=='editor'){ - ui.tree.openEditor();//编辑器优先打开文件 - }else if(Config.pageApp=='explorer'){ - ui.tree.open(); - } - }, - beforeRightClick:function(treeId, treeNode){ - zTree.selectNode(treeNode); - }, - beforeAsync:function(treeId, treeNode){ - treeNode.ajax_name= urlEncode(treeNode.name); - treeNode.ajax_path= urlEncode(treeNode.path); - }, - onAsyncSuccess:function(event, treeId, treeNode, msg){//更新成功后调用 - if (msg.data.length == 0){ - zTree.removeChildNodes(treeNode); - return; - } - if (typeof(successCallback) == 'function'){ - successCallback(); - successCallback = undefined; - } - }, - //新建文件夹、文件、重命名后回调(input blur时调用) - onRename:function(event, treeId,treeNode){ - var parent = treeNode.getParentNode(); - //已存在检测 - if(zTree.getNodesByParam('name',treeNode.name,parent).length>1){ - core.tips.tips(LNG.name_isexists,false); - zTree.removeNode(treeNode); - return; - } - - if (treeNode.create){//新建 - var path = treeNode.path+'/'+treeNode.name; - if (treeNode.type=='folder') { - pathOperate.newFolder(path,function(data){ - if (!data.code) return; - refresh(parent); - successCallback = function(){ - var sel = zTree.getNodesByParam('name',treeNode.name,parent)[0]; - zTree.selectNode(sel); - f5_refresh(); - } - }); - }else{//新建文件 - pathOperate.newFile(path,function(data){ - if (!data.code) return; - refresh(parent); - successCallback = function(){ - var sel = zTree.getNodesByParam('name',treeNode.name,parent)[0]; - zTree.selectNode(sel); - f5_refresh(); - } - }); - } - }else{//重命名 - var from = treeNode.path + treeNode.beforeName; - var to = treeNode.path + treeNode.name; - pathOperate.rname(from,to,function(data){ - if (!data.code) return; - refresh(parent); - successCallback = function(){ - var sel = zTree.getNodesByParam('name',treeNode.name,parent)[0]; - zTree.selectNode(sel); - f5_refresh(); - } - }); - } - } - // beforeDrag: function(treeId, treeNodes){ - // for (var i=0,l=treeNodes.length; i=1) return; - var p=_param(); - if (p.type == 'oexe'){ - p.path = p.node; - } - pathOpen.open(p.path,p.type); - }, - fav:function(){pathOperate.fav(_param().path);}, - search:function(){core.search('',_param().path);}, - appEdit:function(){ - var p=_param(); - var data = p.node;data.path = p.path; - pathOperate.appEdit(data,function(){ - refresh(p.node.getParentNode()); - });}, - - //operate - info:function(){pathOperate.info(_param(true));}, - copy:function(){pathOperate.copy(_param(true));}, - cute:function(){pathOperate.cute(_param(true));}, - past:function(){ - var param = _param(); - if (!param.node.isParent) param.node = param.node.getParentNode(); - pathOperate.past(param.path,function(){ - f5_refresh(); - refresh(param.node); - }); - }, - remove:function(){ - var param = _param(true); - var parent = param[0].node.getParentNode(); - pathOperate.remove(param,function(){ - f5_refresh(); - refresh(parent); - }); - }, - checkIfChange:function(explorer_path){ - if (isUpdateRefresh) return; - isUpdateRefresh = true; - if (!zTree) return; - zTree.getNodesByFilter(function(treeNode){ - var path; - if (treeNode.this_path){ - path = treeNode.this_path; - }else if (treeNode.path != ''){ - path = treeNode.path+treeNode.name; - } - if (path == explorer_path || - path+'/'==explorer_path|| - '/'+treeNode.name+'/'==explorer_path) { - refresh(treeNode); - return true; - } - return false; - },true); - setTimeout(function(){ - isUpdateRefresh = false; - },1000); - }, - explorer:function(){//管理文档 - var path = _param().path; - if (!path) path = G.this_path; - core.explorer(path); - }, - fileBox:function(type){//管理文档 - if (type = 'save_file') {};//没有则自动创建 - if (type = 'save_folder') {}; - if (type = 'select_') {}; - $('.header-left').css('width',110) - .next().css('left',150); - $('.frame-left').width("width",142) - - $.dialog.open('?/explorer&plague='+type,{ - resize:true, - fixed:true, - title:'另存为', - width:750,height:420 - }); - }, - // 创建节点 让元素进入编辑状态(编辑、新建)。保存动作在ztree的onRename回调函数中 - create:function(type){//type ='file' 'folder' - var sel = zTree.getSelectedNodes(); - if (sel.length<=0){//工具栏新建文件(夹) - var node = zTree.getNodeByParam("ext",'__root__', null); - zTree.selectNode(node); - } - - var param = _param(), - treeNode = param.node, - parent = treeNode.getParentNode(), - file="newfile",i=0, - folder=LNG.newfolder; - if (type=='folder') { - while(zTree.getNodesByParam('name',folder+'('+i+')',parent).length>0){ - i++; - } - newNode = {name:folder+'('+i+')','ext':'',type:'folder',create:true,path:param.path}; - }else if(type=='file'){ - while(zTree.getNodesByParam('name',file+'('+i+').txt',parent).length>0){ - i++; - } - newNode = {name:file+'('+i+').txt','ext':'txt',type:'file',create:true,path:param.path}; - } - - - if(treeNode.children != undefined){ - var treeNodeNew = zTree.addNodes(treeNode,newNode)[0]; - zTree.editName(treeNodeNew); - }else{ - if (treeNode.type != 'folder') treeNode = treeNode.getParentNode(); - var treeNodeNew = zTree.addNodes(treeNode,newNode)[0]; - zTree.editName(treeNodeNew); - } - }, - rname:function(){ - var treeNode = zTree.getSelectedNodes()[0],newNode; - zTree.editName(treeNode); - treeNode.beforeName = treeNode.name; - } - } -}); diff --git a/static/js/_dev/src/app/main.js b/static/js/_dev/src/app/main.js deleted file mode 100644 index 8e7e70a..0000000 --- a/static/js/_dev/src/app/main.js +++ /dev/null @@ -1,8 +0,0 @@ -define(function(require, exports, module) { - require('lib/jquery-lib'); - require('lib/util'); - require('lib/artDialog/jquery-artDialog'); - core= require('../../common/core'); - App = require('./page'); - App.init(); -}); diff --git a/static/js/_dev/src/app/page.js b/static/js/_dev/src/app/page.js deleted file mode 100644 index d91265f..0000000 --- a/static/js/_dev/src/app/page.js +++ /dev/null @@ -1,129 +0,0 @@ -define(function(require, exports) { - var page; - var bindEvent = function(){ - page = location.hash.split("#", 2)[1]; - if (!page) {page = 'all'} - change(page); - - $('ul.setting li').hover( - function(){ $(this).addClass('hover');}, - function(){ $(this).removeClass('hover');} - ).click(function(){ - page=$(this).attr('id'); - change(page); - }); - - //选择事件绑定 - $('.box .list').live( - 'hover', - function(){ $(this).addClass('listhover');}, - function(){ $(this).toggleClass('listhover');} - ).live('click',function(){ - //保存到服务器 - var geturl='index.php?setting/set&k='+type+'&v='+value; - $.ajax({ - url:geturl, - type:'json', - success:function(data){ - tips(data.data,data.code); - } - }); - }); - - $('a.create_app').bind('click',function(){ - FrameCall.father('ui.path.pathOperate.appEdit','"","","root_add"'); - }); - $('.app-list li .right a.button').live('click',function(){ - var data = json_decode($(this).parent().parent().attr('data')); - var action = $(this).attr('action'); - switch(action){ - case 'preview':core.openApp(data);break; - case 'add': - FrameCall.father('get','G.this_path'); - var path = share.data('create_app_path'); - var filename = urlEncode(path+data.name); - var url = './index.php?app/user_app&action=add&path='+filename; - $.ajax({ - url:url, - dataType:'json', - type:'POST', - data:'data='+urlEncode(json_encode(data)), - error:core.ajaxError, - success:function(data){ - tips(data.data,data.code); - if (!data.code) return; - FrameCall.father('ui.f5',''); - } - }); - break; - case 'edit':; - FrameCall.father('ui.path.pathOperate.appEdit', - "'"+json_encode(data)+"','','root_edit'"); - break; - case 'del': - $.ajax({ - url:'./index.php?app/del&name='+urlEncode(data.name), - dataType:'json', - error:core.ajaxError, - success:function(data){ - tips(data.data,data.code); - if (!data.code) return; - change(); - } - }); - break; - default:break; - } - }); - }; - var _html = function(data){ - var html = ''; - var root_action="编辑\ - 删除"; - if (!G.is_root) {root_action='';} - for (var i in data) { - var icon = data[i].icon; - if (icon.search(G.static_path)==-1 - && icon.substring(0,4) !='http') { - icon = G.static_path + 'images/app/' + icon; - } - html+="
  • \ - \ -

    "+data[i].name+"\ - "+data[i].desc+"

    \ -
    \ - 预览\ - 添加\ - "+root_action+"
    \ -
    \ -
  • "; - } - return html; - } - - var change = function(group){ - if (group == undefined || group =='') {group = page;} - window.location.href ='#'+group; - $('.selected').removeClass('selected'); - $('ul.setting li#'+group).addClass('selected'); - $('.main').find('.h1').html($('.selected').html()); - - var $content = $('.main .app-list'); - $.ajax({ - url:'./index.php?app/get&group='+group, - dataType:'json', - beforeSend:function (data){ - }, - success:function(data){ - $content.css('display','none') - .html(_html(data.data)).fadeIn('fast'); - } - }); - }; - - // 对外提供的函数 - return{ - reload:change, - init:bindEvent - }; -}); diff --git a/static/js/_dev/src/desktop/fileSelect.js b/static/js/_dev/src/desktop/fileSelect.js deleted file mode 100644 index 4f54038..0000000 --- a/static/js/_dev/src/desktop/fileSelect.js +++ /dev/null @@ -1,476 +0,0 @@ -define(function(require, exports) { - var isSelect = false; // 是否多选状态 - var isDraging = false; // 是否拖拽状态 - var isCtrlSelect = false; // 是否ctrl按住并选择 - - //初始化选择 - var _initSelect = function(){ - _bindDragEvent(); - _bindEvent(); - _bindSelectEvent(); - }; - var _bindEvent = function(){ - //phone - $(Config.FileBoxClass).die('touchstart').live('touchstart',function(event, phase, $target, data){ - if (!$(this).hasClass('select')){ - fileLight.clear(); - $(this).removeClass('select'); - $(this).addClass('select'); - fileLight.select(); - }else{ - ui.path.open(); - } - }); - - // 屏蔽对话框内操作 - $(Config.FileBoxClass).live('mouseenter',function (e) { - if (isDraging) {//hover,hover 到文件夹时则添加目标选择类 - if ($(this).hasClass(Config.TypeFolderClass) - && !$(this).hasClass(Config.SelectClassName)) { - $(this).addClass('selectDragTemp'); - } - } - if(!isSelect && !isDraging){//框选时,由于ctrl重选时会反选有hover - $(this).addClass(Config.HoverClassName); - } - - $(this).unbind("mousedown").mousedown(function(e){ - rightMenu.hidden(); - //已选中多个,点击可拖动以选中进行操作;点击未选中则清空 - if (!e.ctrlKey && !e.shiftKey && !$(this).hasClass(Config.SelectClassName)) { - fileLight.clear(); - $(this).addClass(Config.SelectClassName); - fileLight.select(); - } - //鼠标右键,有选中,且当前即为选中 - if(e.which==3 && !$(this).hasClass(Config.SelectClassName)){ - fileLight.clear(); - $(this).addClass(Config.SelectClassName); - fileLight.select(); - } - if(e.ctrlKey) {//ctrl 跳跃选择 - if ($(this).hasClass(Config.SelectClassName)) {//已经选定 设置标志位弹起时取消选择 - isCtrlSelect = true; - }else{ - fileLight.setMenu($(this)); - $(this).addClass(Config.SelectClassName); - } - fileLight.select(); - } - if(e.shiftKey){//shift 连选 - var current = parseInt($(this).attr(Config.FileOrderAttr)); - if (Global.fileListSelectNum == 0) { - _selectFromTo(0,current); - }else{//有选中,则当前元素序号对比选中的最左和最右, - var first = parseInt(Global.fileListSelect.first().attr(Config.FileOrderAttr)); - var last = parseInt(Global.fileListSelect.last().attr(Config.FileOrderAttr)); - if (current < first) { - //selectFromTo(current,last); - _selectFromTo(current,first); - }else if(current > last){ - //selectFromTo(first,current); - _selectFromTo(last,current); - }else if(current > first && current < last){ - _selectFromTo(first,current); - } - } - } - }); - }).die('mouseleave').live('mouseleave',function(){ - $(this).removeClass(Config.HoverClassName); - $(this).removeClass('selectDragTemp'); - }).die('click').live('click',function (e) { - stopPP(e);//再次绑定,防止冒泡到html的click事件 - if (!e.ctrlKey && !e.shiftKey) { - fileLight.clear(); - $(this).addClass(Config.SelectClassName); - fileLight.select(); - } - if(e.ctrlKey && isCtrlSelect) {//ctrl 跳跃选择 - isCtrlSelect = false; - fileLight.resumeMenu($(this));//恢复右键菜单id - $(this).removeClass(Config.SelectClassName); - fileLight.select(); - } - }); - //双击事件 - $(Config.FileBoxClass).unbind('dblclick').live('dblclick',function(e){//双击打开 - stopPP(e); - if (e.altKey){ - ui.path.pathInfo(); - }else { - ui.path.open(); - } - }); - $(Config.FileBoxTittleClass).unbind('dblclick').live('dblclick',function (e) { - ui.path.rname();//重命名 - stopPP(e);return false; - }); - }; - - // 拖拽——移动 select - var _bindDragEvent= function(){ - var delayTime = 100; - var leftOffset= 50; - var dragCopyOffset = 30; - var topOffset = 80-Global.topbar_height; - var $self; - var startTime = 0; - var hasStart = false; - var boxTop = 0; - var boxLeft = 0; - var screenHeight; - var screenWidth; - - $(Config.FileBoxClass).unbind('mousedown').live('mousedown',function(e){ - if (Global.shiftKey) return; - if (ui.isEdit()) return true; - if (e.which != 1 || isSelect) return true; - $self = $(this); - __dragStart(e); - //事件 在 window之外操作,继续保持。 - if(this.setCapture) this.setCapture(); - $(document).mousemove(function(e) {__dragMove(e);}); - $(document).one('mouseup',function(e) { - __dragEnd(e); - if(this.releaseCapture) {this.releaseCapture();} - stopPP(e);return false; - }); - }); - var __dragStart = function(e){ - rightMenu.hidden(); - isDraging = true; - startTime = $.now(); - boxTop = e.pageY; - boxLeft = e.pageX; - screenHeight = $(document).height(); - screenWidth = $(document).width(); - }; - var __dragMove = function(e){ - if (!isDraging) return true; - if (($.now() - startTime > delayTime) && !hasStart) { - __makeDragBox(); - } - var x = (e.clientX >= screenWidth-50 ? screenWidth-50 : e.clientX); - var y = (e.clientY >= screenHeight-50 ? screenHeight-50 : e.clientY); - x = (x <= 0 ? 0 : x); - y = (y <= 0 ? 0 : y); - x = x - leftOffset; - y = y - topOffset; - - $('.draggable-dragging').css('left',x); - $('.draggable-dragging').css('top',y); - if(Global.isIE){//ie 无法事件穿透则遍历对比鼠标位置 - $('.'+Config.TypeFolderClass).each(function() { - var mouseX = e.pageX; - var mouseY = e.pageY; - var offset = $(this).offset(); - var width = $(this).width(); - var height = $(this).height(); - if (mouseX > offset.left - && mouseX < offset.left+width - && mouseY > offset.top - && mouseY < offset.top+height){ - $(this).addClass('selectDragTemp'); - }else{ - $(this).removeClass('selectDragTemp'); - } - }); - } - }; - var __dragEnd = function(e){ - if (!isDraging) return false; - isDraging = false; - hasStart = false; - $('body').css('cursor','auto'); - $('.draggable-dragging').fadeOut(200,function(){ - $(this).remove(); - }); - - var dragTo = G.this_path; - var isDragCurrent = ($('.selectDragTemp').length == 0); - if (Global.ctrlKey) { - if (!isDragCurrent) { - dragTo = dragTo+fileLight.name($('.selectDragTemp')); - } - if (Math.abs(e.pageX-boxLeft) > dragCopyOffset || - Math.abs(e.pageY-boxTop) > dragCopyOffset) { - ui.path.copyDrag(dragTo,isDragCurrent); - } - }else if (!isDragCurrent){ - dragTo = dragTo+fileLight.name($('.selectDragTemp')); - ui.path.cuteDrag(dragTo); - } - }; - var __makeDragBox = function(){ - hasStart = true; - $('body').css('cursor','move'); - //移动时会挡住下面元素,导致hover不可用, - //webkit firfox下css属性 pointer-events: none;鼠标事件穿透可解决。 - var type = $self.find('.ico').attr('filetype'); - $('
    ' - +'
    '+Global.fileListSelectNum+'
    ' - +'
    ' - +'
    ').appendTo('body'); - }; - }; - - - // 框选 select - var _bindSelectEvent = function(){ - var startX = null; - var startY = null; - var $selectDiv = null; - $(Config.BodyContent).unbind('mousedown').live('mousedown',function(e){ - if (ui.isEdit()) return true; - if (isDraging || e.which != 1) return true; - __dragSelectInit(e); - if(this.setCapture){this.setCapture();} - $(document).unbind('mousemove').mousemove(function(e) {__dragSelecting(e);}); - $(document).one('mouseup',function(e) { - __dragSelectEnd(e); - Global.isDragSelect = true; - if(this.releaseCapture) {this.releaseCapture();} - }); - }) - //创建模拟 选择框,框选开始 - var __dragSelectInit = function(e) { - if ($(e.target).parent().hasClass(Config.FileBoxClassName) - || $(e.target).parent().parent().hasClass(Config.FileBoxClassName) - || $(e.target).hasClass('fix') - ) return; - - rightMenu.hidden(); - if (!(e.ctrlKey || e.shiftKey)) fileLight.clear(); - if ($(e.target).hasClass("ico")==false){// 编辑状态不可选 - if ($('#selContainer').length == 0) { - $('
    ').appendTo(Config.FileBoxSelector); - $selectDiv = $('#selContainer'); - } - startX = e.pageX; - startY = e.pageY-Global.topbar_height; - isSelect = true; - } - }; - //框选,鼠标移动中 - var __dragSelecting= function(e) { - if (!isSelect) return true; - if ($selectDiv.css('display') =="none" ){ - $selectDiv.css('display',''); - } - var mouseX = e.pageX; - var mouseY = e.pageY-Global.topbar_height; - $selectDiv.css({ - 'left' : Math.min(mouseX, startX), - 'top' : Math.min(mouseY, startY), - 'width' : Math.abs(mouseX - startX), - 'height': Math.abs(mouseY - startY) - }); - // ---------------- 框中选择关键算法 --------------------- - var _l = $selectDiv.offset().left; - var _t = $selectDiv.offset().top-Global.topbar_height; - var _w = $selectDiv.width(), _h = $selectDiv.height(); - var totalNum = Global.fileListNum; - - for ( var i = 0; i < totalNum; i++) { - var currentBox = Global.fileListAll[i]; - var $currentBox= $(Global.fileListAll[i]); - var sl = currentBox.offsetWidth + currentBox.offsetLeft; - var st = currentBox.offsetHeight + currentBox.offsetTop; - if (sl > _l && st > _t - && currentBox.offsetLeft < _l + _w - && currentBox.offsetTop < _t + _h) { - if (!$currentBox.hasClass("selectDragTemp")) { - if ($currentBox.hasClass("selectToggleClass")){ - continue; - } - if ($currentBox.hasClass(Config.SelectClassName)) { - $currentBox.removeClass(Config.SelectClassName).addClass("selectToggleClass"); - fileLight.resumeMenu($currentBox);//恢复右键选择 - continue; - } - $currentBox.addClass("selectDragTemp"); - } - }else { - $currentBox.removeClass("selectDragTemp"); - if ($currentBox.hasClass("selectToggleClass")) { - $currentBox.addClass(Config.SelectClassName).removeClass("selectToggleClass"); - } - } - } - }; - //框选结束 - var __dragSelectEnd = function(e) { - if (!isSelect) return false; - $selectDiv.css('display','none'); - $('.selectDragTemp').addClass(Config.SelectClassName).removeClass("selectDragTemp"); - $('.selectToggleClass').removeClass('selectToggleClass');//移除反选掉的div - - fileLight.select(); - isSelect = false; - startX = null; - startY = null; - }; - }; - - //获得选中文件【夹】相对位置的文件并返回 - var _getPosition = function(pose){ - var position = 0; //选择的位置,默认为第一个 - var $list = Global.fileListSelect;// - var listNum = Global.fileListSelectNum; - var totalNum = Global.fileListNum; //总数目 - - var __icon_position = function(){ - var rowNum = Global.fileRowNum; //一行的数目 - if (Global.fileListSelectNum == 1) {//只有一个为选中状态 - var thisNumber = parseInt($list.attr(Config.FileOrderAttr)); - switch(pose){ - case "up": - position = ((thisNumber <=0)? thisNumber:thisNumber - 1); - break; - case "left": - position = ((thisNumber < rowNum)? 0:thisNumber-rowNum); - break; - case "down": - position = ((thisNumber >=totalNum-1)? thisNumber:thisNumber + 1); - break; - case "right": - position = ((thisNumber+rowNum >=totalNum-1)? totalNum-1:thisNumber+rowNum); - break; - default:break; - } - }else if(Global.fileListSelectNum > 1){ //多个已选择的文件 - var firstNumber = parseInt($list.first().attr(Config.FileOrderAttr)); - var lastNumber = parseInt($list.last().attr(Config.FileOrderAttr)); - switch(pose){ - case "up": - position = position = ((firstNumber <=0)? firstNumber:firstNumber - 1); - break; - case "left":((firstNumber <=rowNum)? firstNumber:firstNumber-rowNum); - break; - case "down": - position = ((lastNumber >=totalNum)? lastNumber:lastNumber + 1); - break; - case "right": - position = ((lastNumber+rowNum >=totalNum)? lastNumber:lastNumber+rowNum); - break; - default:break; - } - } - } - __icon_position(); - return Global.fileListAll.eq(position); - }; - - //设置选中 - var _setSelectAt = function(pos){ - var $select; - switch (pos){ - case 'home':$select = Global.fileListAll.first();break; - case 'end': $select = Global.fileListAll.last(); break; - case 'left': - case 'up': - case 'right': - case 'down': - $select = _getPosition(pos); - break; - case 'all'://全选 - $select = Global.fileListAll;break; - default:break; - } - fileLight.clear(); - $select.addClass(Config.SelectClassName); - fileLight.select(); - }; - - //shift 选择,ctrl+上下左右选择 - var _selectFromTo = function(from,to){ - //console.log('from='+from+';to='+to); - fileLight.clear(); - for (var i = from; i <= to; i++) { - $(Global.fileListAll[i]).addClass(Config.SelectClassName); - } - fileLight.select(); - }; - - //设置选中相关函数=========================================== - var fileLight = { - init:function(){//初始化页面,缓存jquery所有文件对象 - var $listAll = $(Config.FileBoxClass); - $listAll.each(function(index){ - $(this).attr(Config.FileOrderAttr,index); - }); - Global.fileListSelect = ''; - Global.fileListAll = $listAll; - Global.fileListNum = $listAll.length; - Global.fileListSelectNum = 0; - }, - - //选择处理 - select:function(){ - var $list = $(Config.SelectClass); - Global.fileListSelect = $list; - Global.fileListSelectNum = $list.length; - if ($list.length > 1) { - fileLight.setMenu($list); - } - }, - setInView:function(){ - return;//desktop不处理 - }, - //获取文件&文件夹名字 - name:function($obj){ - return $obj.attr("data-name"); - }, - //获取文件&文件夹类型 folder为文件夹,其他为文件扩展名 - type:function($obj){ - return $obj.find(".ico").attr("filetype"); - }, - - //已有的情况下,选择则标记右键菜单标记 - setMenu:function($obj){ - $obj.removeClass("menufile menufolder menuApp menuDefault") - .addClass("menuMore"); - }, - //反选,或者框选已经选择的则恢复右键菜单标记 - resumeMenu:function($obj){ - var menu = {"fileApp":"menuApp","fileBox":"menufile", - "folderBox":"menufolder","systemBox":"menuDefault",}; - for(var key in menu){ - if ($obj.hasClass(key)) { - $obj.removeClass("menuMore").addClass(menu[key]); - } - } - }, - - //获取选中的文件名 - getAllName:function(){ - var arr_name = []; - if (Global.fileListSelectNum == 0) return; - var $list = Global.fileListSelect; - $list.each(function(i){ - arr_name.push(fileLight.name($(this))); - }); - return arr_name; - }, - - //清空选择,还原右键关联menu - clear:function(){ - if (Global.fileListSelectNum == 0) return; - var $list = Global.fileListSelect; - $list.removeClass(Config.SelectClassName); - $list.each(function(){ - fileLight.resumeMenu($(this)); - }); - Global.fileListSelect = ''; - Global.fileListSelectNum = 0; - } - } - - //对外提供调用方法 - return{ - init:_initSelect, - fileLight:fileLight, - selectPos:_setSelectAt - } -}); \ No newline at end of file diff --git a/static/js/_dev/src/desktop/main.js b/static/js/_dev/src/desktop/main.js deleted file mode 100644 index be0ce3c..0000000 --- a/static/js/_dev/src/desktop/main.js +++ /dev/null @@ -1,75 +0,0 @@ - define(function(require, exports, module) { - Config = { - BodyContent:".bodymain", // 框选事件起始的dom元素 - FileBoxSelector:'.fileContiner',// dd - FileBoxClass:".fileContiner .file", // 文件选择器 - FileBoxClassName:"file", // 文件选择器 - FileBoxTittleClass:".fileContiner .title",// 文件名选择器 - SelectClass:".fileContiner .select", // 选中文件选择器 - SelectClassName:"select", // 选中文件选择器名称 - TypeFolderClass:'folderBox',// 文件夹标记选择器 - TypeFileClass:'fileBox', // 文件标记选择器 - HoverClassName:"hover", // hover类名 - FileOrderAttr:"number", // 所有文件排序属性名 - - pageApp: "desktop", - navbar:'navbar', // 头部导航栏选择器 - AnimateTime:200 // 动画时间设定 - }; - Global = { - fileListAll:'', // 当前路径下文件对象集合,缓存起来便于全局使用 - fileListNum:0, // 文件&文件夹总个数 - fileRowNum:0, // 当前屏幕每行文件&文件夹个数 - frameLeftWidth:200, // 左边树目录宽度 - treeSpaceWide:10, // 树目录层级相差宽度 - topbar_height:40, // 头部高度 - ctrlKey:false, // 是否按下ctrl - shiftKey:false, // 是否按下shift - - fileListSelect:'', // 选s择的文件 - fileListSelectNum:'', // 选中的文件数。 - isIE:!-[1,], // 是否ie - isDragSelect:false, // 是否框选 - historyStatus:{back:1,next:0} // 是否可以前进后退操作状态 - }; - - require('lib/jquery-lib'); - require('lib/util'); - require('lib/webuploader/webuploader-min'); - require('lib/contextMenu/jquery-contextMenu'); - require('lib/artDialog/jquery-artDialog'); - require('lib/picasa/picasa'); - TaskTap = require('../../common/taskTap'); //任务栏 - core = require('../../common/core'); //公共方法及工具封装 - rightMenu = require('../../common/rightMenu'); //通用右键菜单配置 - fileSelect = require('./fileSelect'); - ui = require('./ui'); - ui.path = require('../explorer/path'); - fileLight = fileSelect.fileLight; - var uploader; - $(document).ready(function() { - ui.init(); - TaskTap.init(); - core.update(); - core.upload_init(); - fileSelect.init(); - rightMenu.initDesktop(); - $('.init_loading').fadeOut(450).addClass('pop_fadeout'); - - $(".bodymain").click(function () { - if ($("#menuwin").css("display")=='block') { - $("#menuwin").css("display", "none"); - } - }); - $(".start").click(function () { - if ($("#menuwin").css("display")=='block') { - $("#menuwin").css("display", "none"); - }else{ - $("#menuwin").css("display", "block"); - } - }); - $("#menuwin").click(function () { - $("#menuwin").css("display", "none"); - }); - }); -}); \ No newline at end of file diff --git a/static/js/_dev/src/desktop/ui.js b/static/js/_dev/src/desktop/ui.js deleted file mode 100644 index 16ba90c..0000000 --- a/static/js/_dev/src/desktop/ui.js +++ /dev/null @@ -1,369 +0,0 @@ -define(function(require, exports) { - //ajax后重置数据、重新绑定事件(f5或者list更换后重新绑定) - var MyPicasa = new Picasa(); - PicasaOpen = false;//全局变量,用于标记是否有幻灯片播放 - - var _ajaxLive = function(){ - fileLight.init(); - ui.setStyle(); - //幻灯片播放绑定 - PicasaOpen = false; - MyPicasa.initData(); - } - //json 排序 filed:(string)排序字段,orderby:升降序。升序为-1,降序为1 - var _sortBy = function(filed,orderby) { - var orderby = (orderby=='down')? -1 : 1; - return function (a, b) { - a = a[filed]; - b = b[filed]; - if (a < b) return orderby * -1; - if (a > b) return orderby * 1; - } - } - //列表排序操作。 - var _setListSort = function(field,order){ - //同步到右键菜单,如果传入0,则不修改 - if (field != 0) {//同步修改排序字段 - G.sort_field = field; - $('.menu_set_sort').removeClass('selected'); - $('.set_sort_'+field).addClass('selected'); - } - if (order != 0) {//修改排序方式,升序,降序 - G.sort_order = order; - $('.menu_set_desc').removeClass('selected'); - $('.set_sort_'+order).addClass('selected'); - } - _f5(false,true);//使用本地列表 - $.ajax({ - url:'index.php?setting/set&k=list_sort_field,list_sort_order&v=' - +G.sort_field+','+G.sort_order - }); - }; - var _bindHotKey = function(){ - var cmmand = 91; - Global.ctrlKey = false; - $(document).keydown(function (e){ - if ($('#PicasaView').css('display') != 'none') return true;//图片播放 - if (ui.isEdit()) return true;//编辑状态 - if (rightMenu.isDisplay()) return true; - var isStopPP = false;//是否向上拦截冒泡 - if (Global.ctrlKey || e.keyCode == cmmand || e.ctrlKey) { - //ctrl 组合键console.log(e.keyCode) - isStopPP = true; - Global.ctrlKey = true; - switch(e.keyCode){ - case 8:ui.path.remove();isStopPP=true;break;//ctrl+backspace remove - case 65:fileSelect.selectPos('all');break;//CTRL+A 全选 - case 67:ui.path.copy();break;//CTRL+C 复制 - case 88:ui.path.cute();break;//CTRL+X 剪切 - case 83:break; // 屏蔽CTRL+S - case 86:ui.path.past();break;//CTRL+V 粘贴 - case 70://CTRL+F 查找 - core.search($('.header-right input').val(),G.this_path); - break; - default:isStopPP=false;break; - } - }else if(e.shiftKey) { - Global.shiftKey = true; - //console.log("shiftKey+"+e.keyCode); - }else{ - switch (e.keyCode) { - case 8:isStopPP=true;break;//backspace - case 35:fileSelect.selectPos('end');break; - case 36:fileSelect.selectPos('home');break; - case 37:fileSelect.selectPos('left');isStopPP=true;break; - case 38:fileSelect.selectPos('up');break; - case 39:fileSelect.selectPos('right');isStopPP=true;break; - case 40:fileSelect.selectPos('down');break; - case 13:ui.path.open();isStopPP=false;break;//enter 打开文件==双击 - case 46:ui.path.remove();isStopPP=true;break; - case 113:ui.path.rname();isStopPP=true;break;//f2重命名 - default:isStopPP=false;break; - } - } - if (isStopPP) { - stopPP(e); - e.keyCode=0; - e.returnValue=false;//拦截向上消息冒泡 - } - return true; - }).keyup(function(e){ - if (e.shiftKey) Global.shiftKey = false; - if (e.keyCode == cmmand || !e.ctrlKey) Global.ctrlKey = false;//win=ctrl - }); - }; - var _ieCss = function(){ - if (!$.browser.msie && navigator.userAgent.indexOf("Firefox")<0) return; - var top = 10; - var left = 10; - var width = 80; - var height = 100; - var margin = 10; - - var w_height= $(document).height() - 60; - var col_num = Math.floor((w_height-top)/(height+margin)); - var row=0,col=0,x=0,y=0; - $('.fileContiner .file').css('position','absolute'); - $('.fileContiner .file').each(function(i){ - row = i%col_num; - col = Math.floor(i/col_num); - x = left + (width+margin)*col; - y = top + (height+margin)*row; - $(this).css({'left':x,'top':y}); - }); - } - //图标样式,文件夹模版填充 - this._getFolderBox = function(list){ - var html=""; - return html; - } - - //图标样式,文件模版填充 - this._getFileBox = function(list){ - var html = ''; - if (list['ext'] == 'oexe' && list['icon'] != undefined) { - var icon = list.icon; - if (list.icon.search(G.static_path)==-1 - && list.icon.substring(0,4) !='http') { - icon = G.static_path + 'images/app/' + list.icon; - } - var code = urlEncode(json_encode(list)); - var display = list.name.replace('.oexe',''); - html =""; - }else if (inArray(core.filetype['image'],list['ext'])) {//如果是图片,则显示缩略图 - var filePath = core.path2url(G.this_path+list['name']); - var thumbPath = 'index.php?explorer/image&path='+urlEncode(G.this_path+list['name']); - html+=""; - }else{ - html+=""; - } - return html; - } - //文件列表数据填充 - var _mainSetData = function(isFade){ - var html ="";//填充的数据 - var folderlist = G.json_data['folderlist']; - var filelist = G.json_data['filelist']; - //如果排序字段为size或ext时,文件夹排序方式按照文件名排序 - if (G.sort_field=='size' || G.sort_field=='ext' ){ - folderlist= folderlist.sort(_sortBy('name',G.sort_order)); - }else { - folderlist= folderlist.sort(_sortBy(G.sort_field,G.sort_order)); - } - filelist = filelist.sort(_sortBy(G.sort_field,G.sort_order)); - G.json_data['folderlist']=folderlist; - G.json_data['filelist']=filelist;//同步到页面数据 - var file_html='',folder_html=''; - for (var i in filelist){ - file_html += _getFileBox(filelist[i]); - } - for (var i in folderlist){ - folder_html += _getFolderBox(folderlist[i]); - } - //end排序方式重组json数据------ - //升序时,都是文件夹在上,文件在下,各自按照字段排序 - if (G.sort_order=='up'){ - html += folder_html+file_html; - }else{ - html += file_html+folder_html; - } - - var system = '';//系统应用 - $('.menuDefault').each(function(){ - system += $(this).get(0).outerHTML; - }); - html = system + html; - html += "
    "; - //填充到dom中----------------------------------- - if (isFade){//动画显示, - $(Config.FileBoxSelector) - .hide() - .html(html) - .fadeIn(Config.AnimateTime); - }else{ - $(Config.FileBoxSelector).html(html); - } - _ajaxLive(); - _ieCss(); - }; - var _f5 = function(is_data_server,is_animate,callback) { - if(is_data_server == undefined) is_data_server = true; //默认每次从服务器取数据 - if(is_animate == undefined) is_animate = false; //默认不用渐变动画 - if(!is_data_server){//采用当前数据刷新,用于显示模式更换 - var select_arr = fileLight.getAllName();//获取选中的文件名 - _mainSetData(is_animate); - ui.path.setSelectByFilename(select_arr);//不刷新数据的话,保持上次选中 - }else{//获取服务器数据 - $.ajax({ - url:'index.php?explorer/pathList&path='+G.this_path, - dataType:'json', - //async:false,//同步阻塞.阻塞其他线程,等待执行完成。//解决重命名后设置选中 - error:core.ajaxError, - success:function(data){ - if (!data.code) { - core.tips.tips(data); - $(Config.FileBoxSelector).html(''); - return false; - } - G.json_data = data.data; - _mainSetData(is_animate); - if (typeof(callback) == 'function'){ - callback(data); - } - } - }); - } - }; - var _f5_callback = function(callback){ - _f5(true,false,callback);//默认刷新数据,没有动画,成功后回调。 - }; - return{ - f5:_f5, - f5_callback:_f5_callback, - picasa:MyPicasa, - setListSort:_setListSort, - init:function(){ - _f5_callback(function(){ - - }); - //生成文件列表 - _bindHotKey(); - $(window).bind("resize",function(){ - ui.setStyle();//浏览器调整大小,文件列表区域调整高宽。 - if (PicasaOpen!=false) { - MyPicasa.setFrameResize(); - } - _ieCss(); - }); - $("html").die('click').live('click',function (e) { - rightMenu.hidden(); - if (Global.isIE && Global.isDragSelect) return; - }); - - Mousetrap.bind(['ctrl+s', 'command+s'],function(e) { - e.preventDefault(); - FrameCall.top('OpenopenEditor','Editor.save',''); - }); - - //绑定键盘定位文件名 选中文件,只只是首字母选择。 - var lastClickTime = 0; - var lastkeyCode = ''; - var keyTimeout; - var timeOffset = 200;//按键之间延迟,小于则认为是整体 - Mousetrap.bind( - ['1','2','3','4','5','6','7','8','9','0','`','~','!','@','#','$','%','^','&','*','(',')', - '-','_','=','+','[','{',']','}','|','/','?','.','>',',','<','a','b','c','d','e', - 'f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'],function(e){ - var code = String.fromCharCode(e.charCode); - if (lastClickTime == 0) {//新的一次键盘记录 - lastClickTime = time(); - lastkeyCode = code; - keyTimeout = setTimeout(function(){ - ui.path.setSelectByChar(lastkeyCode); - lastClickTime = 0; - },timeOffset);//延迟执行 - return; - } - if (code == lastkeyCode.substr(-1)) {//当前和之前一致 - ui.path.setSelectByChar(lastkeyCode); - lastClickTime = 0; - return; - } - - if (time() - lastClickTime < timeOffset) { - //定时之内没有输入则执行,有则追加,继续延时 - lastClickTime = time(); - lastkeyCode += code; - clearTimeout(keyTimeout); - keyTimeout = setTimeout(function(){ - ui.path.setSelectByChar(lastkeyCode); - lastClickTime = 0; - },timeOffset);//延迟执行。 - } - }); - - Mousetrap.bind(['alt+n', 'alt+n'],function(e){ - stopPP(e);ui.path.newFile(); - }); - Mousetrap.bind(['alt+m', 'alt+m'],function(e){ - stopPP(e);ui.path.newFolder(); - }); - - //如果为图片的话,"+LNG.double_click_rename+"被图片插件绑定, - PicasaOpen = false; - MyPicasa.init(".picasaImage"); - MyPicasa.initData(); - }, - setTheme:function(thistheme){ - core.setSkin(thistheme,'app_desktop.css'); - FrameCall.top('OpenopenEditor','Editor.setTheme','"'+thistheme+'"'); - FrameCall.top('Opensetting_mode','Setting.setThemeSelf','"'+thistheme+'"'); - FrameCall.father('ui.setTheme','"'+thistheme+'"'); - }, - setWall:function(img){ - $('.wallbackground') - .attr('src',img) - .one('load',function(){ - $('.desktop').css('background-image','url('+img+')'); - }); - }, - isEdit:function(){ - var focusTagName = $(document.activeElement).get(0).tagName; - if (focusTagName == 'INPUT' || focusTagName == 'TEXTAREA'){ - return true; - } - return false; - }, - setStyle:function(){//设置文件列表高宽。 - //main当前宽度所容纳每行文件个数。 - Global.fileRowNum = (function(){ - var main_width=$(Config.FileBoxSelector).width();//获取main主体的 - var file_width= - parseInt($(Config.FileBoxClass).css('width'))+ - parseInt($(Config.FileBoxClass).css('border-left-width'))+ - parseInt($(Config.FileBoxClass).css('border-right-width'))+ - parseInt($(Config.FileBoxClass).css('margin-right')); - return parseInt(main_width/file_width); - })(); - }, - fullScreen:function(){ - if ($('body').attr('fullScreen') == 'true') { - ui.exitfullScreen(); - } - $('body').attr('fullScreen','true'); - var docElm = document.documentElement; - if (docElm.requestFullscreen) { - docElm.requestFullscreen(); - }else if (docElm.mozRequestFullScreen) { - docElm.mozRequestFullScreen(); - } else if (docElm.webkitRequestFullScreen) { - docElm.webkitRequestFullScreen(); - } - }, - exitfullScreen:function(){ - $('body').attr('fullScreen','false'); - if (document.exitFullscreen) { - document.exitFullscreen(); - }else if(document.mozCancelFullScreen) { - document.mozCancelFullScreen(); - }else if(document.webkitCancelFullScreen) { - document.webkitCancelFullScreen(); - } - } - } -}); diff --git a/static/js/_dev/src/edit/edit.js b/static/js/_dev/src/edit/edit.js deleted file mode 100644 index eaa3bad..0000000 --- a/static/js/_dev/src/edit/edit.js +++ /dev/null @@ -1,410 +0,0 @@ -define(function(require, exports) { - var editConfig = { - theme:G.code_config.theme, - fontsize:G.code_config.font_size, - auto_complete:parseInt(G.code_config.auto_complete), - wrap:parseInt(G.code_config.auto_wrap),//自适应宽度换行 - display:parseInt(G.code_config.display_char)//是否显示特殊字符 - }; - var editors = {}; - var focusID = undefined; - var Mode = require('./mode'); - ace.require("ace/ext/language_tools"); - - // 通过属性查找。 - var editorFind = function(key,value){ - if (value==undefined || key==undefined || editors.length<1) return ''; - for (var obj in editors){ - if (editors[obj]['kod'][key] == value){ - return editors[obj]['kod'].uuid; - } - } - return ''; - }; - - var initFirst=function(){ - //code; - $('#fontsize li').removeClass('this'); - $('#fontsize li').each(function(){ - if(editConfig.fontsize == $(this).html()){ - $(this).addClass('this'); - } - }); - $('#codetheme li').removeClass('this'); - $('#codetheme li').each(function(){ - if(editConfig.theme == $(this).attr('theme')){ - $(this).addClass('this'); - } - }); - if (editConfig.wrap==1) { - $('a[action=wordbreak]').addClass('select'); - } - if (editConfig.display==1) { - $('a[action=display]').addClass('select'); - } - if (editConfig.auto_complete==1) { - $('a[action=auto_complete]').addClass('select'); - } - }; - initFirst(); - - - var initAdd = function(filename){ - var initData; - var uuid = 'id_'+ UUID(); - if (filename == undefined) { - initData = { - uuid: uuid, - name: 'newfile.txt', - charset: 'utf-8', - filename: '', - mode: Mode.get('txt'), - }; - initEditor(initData); - initAce(initData); - $('.edit_body .this').removeClass('this'); - $('.edit_body pre#'+uuid).addClass('this'); - return; - } - //打开文件 - initData = { - charset: 'utf-8', - uuid: uuid, - name: core.pathThis(urlDecode(urlDecode(filename))), - filename: filename, - mode: Mode.get(core.pathExt(urlDecode(filename))), - }; - initEditor(initData,true); - var load = art.dialog({title:false,content:LNG.getting,icon:'warning'}); - $.ajax({ - dataType:'json', - url:'./index.php?editor/fileGet&filename='+filename, - error:function(XMLHttpRequest, textStatus, errorThrown) { - load.close(); - _removeData(initData.uuid); - core.ajaxError(XMLHttpRequest, textStatus, errorThrown); - }, - success: function(result) { - load.close(); - if (!result.code){ - Tips.tips(result); - _removeData(initData.uuid); - return; - } - var data = result.data; - editors[uuid] = undefined; - $('pre#'+uuid).text(data.content); - initAce(initData); - $('.edit_body .this').removeClass('this'); - $('.edit_body pre#'+uuid).addClass('this'); - var current = editors[uuid]; - current.kod.charset = data.charset; - current.navigateTo(0); - current.moveCursorTo(0,0); - } - }); - }; - var initEditor = function(initData,no_animate){ - var html_tab = - '
    '+ - '
    '+initData.name+'
    '+ - ' '+ - '
    '+ - '
    '; - $(html_tab).insertBefore('.edit_tab .add'); - var html_body = '
    ';
    -        $('.edit_body .tabs').append(html_body);
    -        _select(initData.uuid);
    -
    -        if (no_animate) {
    -            var temp_time=animate_time;animate_time = 1;
    -            Tap.resetWidth('add');
    -            animate_time = temp_time;
    -        }else{
    -            Tap.resetWidth('add');
    -        }
    -    };
    -    var initAce = function(initData){
    -        var this_editor = ace.edit(initData.uuid);
    -        this_editor.setTheme("ace/theme/"+editConfig.theme);
    -        if (initData.mode != undefined) {
    -            this_editor.getSession().setMode("ace/mode/"+initData.mode);
    -        }        
    -        this_editor.getSession().setTabSize(4);
    -        this_editor.getSession().setUseSoftTabs(true);
    -        this_editor.getSession().setUseWrapMode(editConfig.wrap);
    -        this_editor.setShowPrintMargin(false);//显示固定宽度
    -        this_editor.setDragDelay(100);
    -        this_editor.setShowInvisibles(editConfig.display);
    -        this_editor.setFontSize(editConfig.fontsize);
    -        this_editor.setOptions({
    -            enableBasicAutocompletion:true,
    -            enableSnippets: true,
    -            enableLiveAutocompletion:editConfig.auto_complete
    -        });
    -        this_editor.on("change", function(e){//ace_selected
    -            setChanged(this_editor,true);
    -        });
    -        this_editor.commands.addCommand({
    -            name: 'editSave',
    -            bindKey: {win: 'Ctrl-S',  mac: 'Command-S',sender: 'editor|cli'},
    -            exec: function(editor,args, request) {
    -                save(editor.kod.uuid);
    -            }
    -        });
    -        this_editor.commands.addCommand({
    -            name: 'preview',
    -            bindKey: {win: 'Ctrl-Shift-S',  mac: 'Command-Shift-S'},
    -            exec: function(editor) {
    -                preview.open();
    -                Toolbar.doAction('preview');
    -            }
    -        });
    -
    -        //数据存储;以对象的方式存储在ace实例中
    -        this_editor.kod = {
    -            'uuid':initData.uuid,
    -            'name':initData.name,
    -            'charset':'ansii',
    -            'filename':initData.filename
    -        }
    -        editors[initData.uuid]=this_editor;
    -        focusID = initData.uuid;
    -        editors[focusID].focus();
    -    }
    -
    -    var _select = function(uuid,exist){
    -        $('.edit_tab .this').removeClass('this');
    -        $('.edit_tab .tab_'+uuid).addClass('this');
    -        focusID = uuid;
    -        if (editors[uuid] != undefined){
    -            editors[uuid].focus();
    -        }
    -        if (exist == true) {
    -            $('.edit_tab .this')
    -                .stop(true,true)
    -                .animate({"opacity":0.3},100)
    -                .animate({"opacity":0.8},100)
    -                .animate({"opacity":0.5},40)
    -                .animate({"opacity":1},40,function(){
    -                    editors[uuid].focus();
    -                });
    -        }
    -    }
    -    //选中 分次封装
    -    var select = function(uuid,exist) {
    -        if(uuid == undefined || uuid =='') return;
    -        _select(uuid,exist);
    -        $('.edit_body .this').removeClass('this');
    -        $('.edit_body pre#'+uuid).addClass('this');
    -    };
    -
    -    var config = function(key,value,uuid){
    -        var box = editors;
    -        if (uuid != undefined){
    -            box={};box[uuid]=editors[uuid];
    -        }
    -
    -        var save_data=undefined;
    -        for(var obj in box){
    -            var edit = box[obj];
    -            switch(key){
    -                case 'resize':edit.resize();break;
    -                case 'theme':
    -                    editConfig[key] = value;
    -                    edit.setTheme("ace/theme/"+value);
    -                    G.code_config.theme = value;
    -                    save_data = {'k':'theme','v':value};
    -                    break;
    -                case 'fontsize':
    -                    editConfig[key] = value;
    -                    edit.setFontSize(value);
    -                    G.code_config.font_size = value;
    -                    save_data = {'k':'font_size','v':value};
    -                    break;
    -                case 'wrap':
    -                    editConfig[key] = !edit.getSession().getUseWrapMode();
    -                    edit.getSession().setUseWrapMode(editConfig[key]);
    -                    G.code_config.auto_wrap = editConfig[key];
    -                    var the_value = editConfig[key]?1:0;
    -                    save_data = {'k':'auto_wrap','v':the_value};
    -                    break;
    -                case 'display':
    -                    editConfig[key] = !edit.getShowInvisibles()
    -                    edit.setShowInvisibles(editConfig[key]);
    -                    G.code_config.display_char = editConfig[key];
    -                    var the_value = editConfig[key]?1:0;
    -                    save_data = {'k':'display_char','v':the_value};
    -                    break;//自动换行 true/false
    -                case 'setting':edit.commands.exec('showSettingsMenu',edit);break;//自动换行 true/false 
    -                //case 'mode':edit.getSession().setMode("ace/mode/"+value);break;
    -                //case 'table_size':edit.getSession().setTabSize(value);;break;//自动换行 true/false
    -                //case 'show_line':edit.setShowPrintMargin(value);break;//显示固定宽度线设置
    -                case 'auto_complete':
    -                    editConfig[key] = !edit.$enableBasicAutocompletion;
    -                    edit.setOptions({enableLiveAutocompletion:editConfig[key]});
    -                    edit.$enableBasicAutocompletion = editConfig[key];
    -                    G.code_config.auto_complete = editConfig[key];
    -                    var the_value = editConfig[key]?1:0;
    -                    save_data = {'k':'auto_complete','v':the_value};
    -                    break;
    -                default:break;
    -            }
    -        }
    -        if (save_data) {//配置保存到服务器
    -            $.ajax({
    -                url:'./index.php?editor/setConfig&k='+save_data.k+'&v='+save_data.v,
    -                dataType:'json',
    -                success:function(data){
    -                    //tips(data);
    -                }
    -            });
    -        }
    -    };
    -    var setChanged = function(theEditor,type){
    -        if (type == theEditor.hasChanged) return;
    -        theEditor.hasChanged = type;//true(change) or false(nochange)
    -        $('.edit_tab .tabs .tab_'+theEditor.kod.uuid).toggleClass('edit_changed');
    -    };
    -
    -    // 编辑保存,如果是新建标签则新建文件,询问保存路径。
    -    var save = function(uuid,isDelete){
    -        if (focusID == undefined) return;
    -        if (uuid == undefined) uuid = focusID;
    -        if (isDelete == undefined) isDelete = false;
    -
    -        var edit_this = editors[uuid];
    -        if(!edit_this.hasChanged) return;
    -        if(edit_this == undefined || edit_this == '') {
    -            tips(LNG.data_error,'warning');return;
    -        }
    -
    -        current().focus();
    -        var html = urlEncode2(edit_this.getValue());
    -        var filename = edit_this.kod.filename;
    -        if (filename == '') {
    -                        
    -        }
    -        $.ajax({
    -            type:'POST',
    -            async:false,
    -            dataType:'json',
    -            url:'./index.php?editor/fileSave',
    -            data:'path='+filename+'&charset='+edit_this.kod.charset+'&filestr='+html,
    -            beforeSend: function(){
    -                Tips.loading(LNG.sending);
    -            },
    -            error:core.ajaxError,
    -            success:function(data){
    -                Tips.close(data);
    -                if (!data.code) return;
    -                // 保存成功 记录上次保存时的修改时间。
    -                setChanged(edit_this,false);
    -                if (isDelete) {
    -                    _removeData(uuid);
    -                }
    -            }
    -        });
    -    }
    -    var saveall = function(){
    -        for (var obj in editors){
    -            save(obj);
    -        }
    -    };
    -    
    -    //安全删除标签,先检测该文档是否修改。
    -    var removeSafe = function(uuid) {
    -        if (uuid == undefined) uuid = focusID;
    -        if (editors[uuid] == undefined) return;
    -        var edit_this = editors[uuid];
    -        if (edit_this.hasChanged) {
    -            $.dialog({
    -                title:LNG.warning,
    -                resize:false,
    -                background: '#fff',
    -                opacity: 0.4,
    -                lock:true,
    -                icon: 'question',
    -                content:edit_this.kod.name+'
    '+LNG.if_save_file, - padding:30, - button:[ - {name:LNG.button_save,focus:true,callback:function(){ - save(uuid,true); - }}, - {name:LNG.button_not_save,callback:function(){ - _removeData(uuid); - }}, - {name:LNG.button_cancle,callback:function(){ - current().focus(); - }} - ] - }); - }else{ - _removeData(uuid); - } - } - - - //删除 - var _removeData = function(uuid) { - delete editors[uuid]; - var changeID = ''; - var $tabs = $('.edit_tab .tab'); - var $that = $('.edit_tab .tab_'+uuid); - var $editor = $('.edit_body pre#'+uuid); - if ($that.hasClass('this')){ - if ($tabs.length > 1) { - if ($($tabs[0]).attr('uuid') == uuid) { - changeID = $($tabs[1]).attr('uuid'); - }else{ - $tabs.each(function(i){ - var temp_id = $(this).attr('uuid'); - if (temp_id == uuid){return false;}//跳出该循环。 - changeID = temp_id; - }); - } - } - if(changeID !=''){//先显示下一个body,避免闪烁 - $('.edit_body pre#'+changeID).addClass('this'); - } - $editor.remove(); - Tap.resetWidth('remove',$that,changeID); - }else{ - $editor.remove(); - Tap.resetWidth('remove',$that); - } - }; - var hasFileSave = function(){ - for (var obj in editors){ - if (editors[obj].hasChanged) return true; - } - return false; - }; - var setTheme = function(thistheme){ - core.setSkin(thistheme,'app_code_edit.css'); - }; - var current = function(){ - if (!focusID || !editors[focusID]) return false; - return editors[focusID]; - }; - //---------------------------------------- - return { - current:current, - hasFileSave:hasFileSave, - config:config, - setTheme:setTheme, - select:select, - remove:removeSafe, - save:save, - saveall:saveall, - add:function(filename){ - var id = editorFind('filename',filename); - if (id != ''){//已存在 - select(id,true); - }else{ - initAdd(filename); - } - } - }; -}); \ No newline at end of file diff --git a/static/js/_dev/src/edit/main.js b/static/js/_dev/src/edit/main.js deleted file mode 100644 index e18dfac..0000000 --- a/static/js/_dev/src/edit/main.js +++ /dev/null @@ -1,33 +0,0 @@ -var animate_time = 160;//关闭动画 -define(function(require, exports, module) { - require('lib/jquery-lib'); - require('lib/util'); - require('lib/contextMenu/jquery-contextMenu'); - require('lib/artDialog/jquery-artDialog'); - Tap = require('./taskTap'); //任务栏 - Toolbar = require('./toolbar'); //任务栏 - Editor = require('./edit'); //任务栏 - core = require('../../common/core'); //公共方法及工具封装 - rightMenu = Tap.rightMenu; - preview = Toolbar.preview; - - Global = { - topbar_height:40, // 头部高度 - isIE:!-[1,], // 是否ie - }; - - $(document).ready(function() { - Tap.init(); - Toolbar.init(); - if (G.frist_file != '') { - Editor.add(G.frist_file); - } - window.onbeforeunload = function(){//关闭窗口编辑器保存提示 - if (Editor.hasFileSave()) { - return LNG.if_save_file; - }else{ - return undefined; - } - } - }); -}); \ No newline at end of file diff --git a/static/js/_dev/src/edit/mode.js b/static/js/_dev/src/edit/mode.js deleted file mode 100644 index 5a3b14e..0000000 --- a/static/js/_dev/src/edit/mode.js +++ /dev/null @@ -1,123 +0,0 @@ -define(function(require, exports, module) { - var modes = {}; - var supportedModes = { - abap: ["abap"], - actionscript: ["as"], - ada: ["ada","adb"], - apache_conf: ["htaccess","htgroups","htpasswd","conf","htaccess","htgroups","htpasswd"], - asciidoc: ["asciidoc"], - assembly_x86: ["asm"], - autohotkey: ["ahk"], - batchfile: ["bat","cmd"], - c9search: ["c9search_results"], - c_cpp: ["cpp","c","cc","cxx","h","hh","hpp"], - clojure: ["clj"], - cobol: ["cbl","cob"], - coffee: ["coffee","cf","cson","cakefile"], - coldfusion: ["cfm"], - csharp: ["cs"], - css: ["css"], - curly: ["curly"], - d: ["d","di"], - dart: ["dart"], - diff: ["diff","patch"], - dot: ["dot"], - erlang: ["erl","hrl"], - ejs: ["ejs"], - forth: ["frt","fs","ldr"], - ftl: ["ftl"], - glsl: ["glsl","frag","vert"], - golang: ["go"], - groovy: ["groovy"], - haml: ["haml"], - handlebars: ["hbs","handlebars","tpl","mustache"], - haskell: ["hs"], - haxe: ["hx"], - html: ["html","htm","xhtml","cshtml"], - html_ruby: ["erb","rhtml"], - ini: ["ini","conf","cfg","prefs"], - jack: ["jack"], - jade: ["jade"], - java: ["java"], - javascript: ["js","jsm"], - json: ["json","oexe"], - jsoniq: ["jq"], - jsp: ["jsp"], - jsx: ["jsx"], - julia: ["jl"], - latex: ["tex","latex","ltx","bib"], - less: ["less"], - liquid: ["liquid"], - lisp: ["lisp"], - livescript: ["ls"], - logiql: ["logic","lql"], - lsl: ["lsl"], - lua: ["lua"], - luapage: ["lp"], - lucene: ["lucene"], - makefile: ["makefile","gnumakefile","makefile","ocamlmakefile","make"], - matlab: ["matlab"], - markdown: ["md","markdown"], - mel: ["mel"], - mysql: ["mysql"], - mushcode: ["mc","mush"], - nix: ["nix"], - objectivec: ["m","mm"], - ocaml: ["ml","mli"], - pascal: ["pas","p"], - perl: ["pl","pm"], - pgsql: ["pgsql"], - php: ["php","phtml"], - powershell: ["ps1"], - prolog: ["plg","prolog"], - properties: ["properties"], - protobuf: ["proto"], - python: ["py"], - r: ["r"], - rdoc: ["rd"], - rhtml: ["rhtml"], - ruby: ["rb","ru","gemspec","rake","guardfile","rakefile","gemfile"], - rust: ["rs"], - sass: ["sass"], - scad: ["scad"], - scala: ["scala"], - scheme: ["scm","rkt"], - scss: ["scss"], - sh: ["sh","bash",".bashrc"], - sjs: ["sjs"], - space: ["space"], - snippets: ["snippets"], - soy_template: ["soy"], - sql: ["sql"], - stylus: ["styl","stylus"], - svg: ["svg"], - tcl: ["tcl"], - tex: ["tex"], - text: ["txt",'ini','log'], - textile: ["textile"], - toml: ["toml"], - twig: ["twig"], - typescript: ["ts","typescript","str"], - vbscript: ["vbs"], - velocity: ["vm"], - verilog: ["v","vh","sv","svh"], - xml: ["xml","rdf","rss","wsdl","xslt","atom","mathml","mml","xul","xbl"], - xquery: ["xq"], - yaml: ["yaml","yml"] - }; - function initMode() { - for (var lng in supportedModes) { - for (var i = 0; i < supportedModes[lng].length; i++) { - modes[supportedModes[lng][i]] = lng; - } - } - } - function get(ext){// get the mode by file extences; - return modes[ext]; - } - initMode(); - return{ - get:get, - modes:modes - } -}); diff --git a/static/js/_dev/src/edit/taskTap.js b/static/js/_dev/src/edit/taskTap.js deleted file mode 100644 index b71b853..0000000 --- a/static/js/_dev/src/edit/taskTap.js +++ /dev/null @@ -1,258 +0,0 @@ -define(function(require, exports) { - var _bindTab = function(){ - $('.edit_tab .tab').live('mouseenter',function (e) { - if (!$(this).hasClass('this')){ - $(this).addClass('hover'); - } - $(this).unbind("mousedown").mousedown(function(e){ - if (!$(this).hasClass('this') && !$.nodeName(e.target,'A')){ - $(this).removeClass('hover').addClass('this'); - Editor.select($(this).attr('uuid')); - //return false; - } - }); - }).die('mouseleave').live('mouseleave',function(){ - $(this).removeClass('hover'); - }).die('dblclick').live('dblclick',function(e){ - //双击关闭标签 - Editor.remove($(this).attr('uuid')); - stopPP(e); - }); - $('.edit_tab').die('dblclick').live('dblclick',function(e){ - Editor.add();stopPP(e); - }); - $('.edit_tab .tab .close').live('click',function (e) { - var id = $(this).parent().attr('uuid'); - Editor.remove(id); - }); - }; - var _menu_hidden = function(){ - $('.context-menu-list').filter(':visible').trigger('contextmenu:hide'); - }; - var _bind_menu = function(){//右键绑定 - $('body').click(_menu_hidden).contextmenu(_menu_hidden); - $.contextMenu({ - zIndex:9999, - selector: '.edit_tab_menu', - items: { - "close":{name:LNG.close,icon:"remove",accesskey: "d"}, - "close_right":{name:LNG.close_right,icon:"remove-sign",accesskey: "r"}, - "close_others":{name:LNG.close_others,icon:"remove-circle",accesskey: "o"}, - "sep1":"--------", - "create":{name:LNG.newfile,icon:"plus",accesskey: "n"}, - "preview":{name:LNG.preview,icon:"globe",accesskey: "p"}, - }, - callback: function(key, options) { - var $item =options.$trigger; - var id = $item.attr('uuid'); - switch(key){ - case 'close':Editor.remove();break; - case 'close_right': - var index = $('.edit_tab .tabs .tab').index($item); - $('.edit_tab .tabs .tab:gt('+index+')').each(function(){ - Editor.remove($(this).attr('uuid')); - }); - break; - case 'close_others': - $('.edit_tab .tabs .tab').each(function(){ - var uuid = $(this).attr('uuid'); - if (uuid != id) { - Editor.remove(uuid); - } - }); - break; - case 'create':Editor.add();break; - case 'preview':Toolbar.doAction('preview');break; - default:break; - } - } - }); - $('.context-menu-root').addClass('fadein'); - }; - - // 拖拽——移动 - var _bindDrag = function(){ - var $self,$tabs,$drag, - isDraging = false, - isDragInit= false, - first_left= 0, - box_left = 0, - tab_width = 0, - tab_margin= 0, - tab_parent_width= 0, - tab_parent_left = 0, - current_animate_id; //标签切换,当前动画所在的标签 - $('.edit_tab .tab').die('mousedown').live('mousedown',function(e){ - if ($.nodeName(e.target,'A')) { - return ; - }else if($.nodeName(e.target,'SPAN')) { - $self = $(e.target).parent(); - }else { - $self = $(this); - } - isDraging = true; - //事件 在 window之外操作,继续保持。 - if(this.setCapture) this.setCapture(); - $(document).mousemove(function(e) {__dragMove(e);}); - $(document).one('mouseup',function(e) { - __dragEnd(e); - if(this.releaseCapture) {this.releaseCapture();} - stopPP(e);return false; - }); - }); - var __dragStart = function(e){ - isDragInit = true, - first_left = e.pageX; - $tab_parent = $('.edit_tab'); - $tabs = $('.edit_tab .tab'); - $(".draggable-dragging").remove(); - $drag = $self.clone().addClass("draggable-dragging").prependTo('body'); - - tab_margin= parseInt($tabs.css('margin-right')); - tab_parent_width = $tab_parent.width(); - tab_parent_left = $tab_parent.get(0).getBoundingClientRect().left; - tab_parent_left = tab_parent_left+$(window).scrollLeft(); - box_left = $self.get(0).getBoundingClientRect().left; - tab_width = parseInt($tabs.css('width')); - - var top = $self.get(0).getBoundingClientRect().top-parseInt($self.css('margin-top')); - var left = e.clientX - first_left + box_left; - - $('body').prepend("
    "); - $drag.css({'width':tab_width+'px','top':top,'left':left}); - $self.css('opacity',0); - }; - var __dragMove = function(e){ - if (!isDraging) return; - if(isDragInit==false){ - __dragStart(e); - } - - var left = e.clientX - first_left + box_left; - if (left < tab_parent_left - || left > tab_parent_left+tab_parent_width-tab_width){ - return;// 拖出边界则不处理 - } - $drag.css('left',left); - $tabs.each(function(i) { - var t_left = $(this).get(0).getBoundingClientRect().left; - if (left > t_left && left < t_left+tab_width/2+tab_margin){ - if ($self.attr('uuid') == $(this).attr('uuid')) { - return;//当前区域移动,没有超过左右过半 - } - __change($(this).attr('uuid'),'left'); - } - if (left > t_left-tab_width/2+tab_margin && left < t_left){ - if ($self.attr('uuid') == $(this).attr('uuid')) { - return;//当前区域移动,没有超过左右过半 - } - __change($(this).attr('uuid'),'right'); - } - }); - }; - // 标签交换位置 - var __change = function(id,change){ - //chrome标签类似动画,动画进行中,,且为当前标签动画则继续 - if ($self.is(":animated") - && current_animate_id == id){ - return; - } - //处理上次动画结束事物 - current_animate_id = id; - $self.stop(true,true); - $('.insertTemp').remove(); - $tabs = $('.edit_tab .tab'); - - var temp,width = $self.width(); - var $move = $('.edit_tab .tab_'+id); - var $insert = $self.clone(true).insertAfter($self) - .css({'margin-right':'0px','border':'none'}).addClass('insertTemp'); - - if (change == 'left') { - $self.after($move).css('width','0px'); - }else{ - $self.before($move).css('width','0px'); - $move.before($insert); - } - $self.animate({'width':width+'px'},animate_time); - $insert.animate({'width':'0px'},animate_time,function(){ - $(this).remove(); - $tabs = $('.edit_tab .tab'); - }); - }; - - var __dragEnd = function(e){ - //if (!isDraging) return false; - isDraging = false; - isDragInit= false; - startTime = 0; - $('.dragMaskView').remove(); - - // 点击事件回调会影响两个事件:选择,和拖拽弹起, - //此处后执行,设置需要再次设置焦点 - //Editor.current().focus(); - if ($drag == undefined) return; - - box_left = $self.get(0).getBoundingClientRect().left; - $drag.animate({left:box_left+'px'},animate_time,function(){ - $self.css('opacity',1); - $(this).remove(); - }); - }; - }; - - var resetWidth = function(action,dom,selectID){ - var time = animate_time*1.5; - var max_width = 122; - var reset_width = max_width; - var $tabs = $('.edit_tab .tab'); - var full_width = $('.edit_tab .tabs').width()-4; - var margin = parseInt($tabs.css('margin-right')) + parseInt($tabs.css('border-right')); - var add_width = parseInt($('.edit_tab .add').outerWidth())+margin*2; - var count = $tabs.length; - //不用变化的个数 - var max_count = Math.floor((full_width-add_width)/(max_width+margin)); - if (count > max_count) { - reset_width = Math.floor((full_width - add_width)/count) - margin; - } - switch (action) { - case 'add': - $('.edit_tab .tabs .this').css({'margin-top':'30px','width':reset_width}) - .animate({'margin-top':'0px'},time); - $tabs.animate({width:reset_width+'px'},time); - break; - case 'remove': - if (selectID!=undefined) Editor.select(selectID); - dom.animate({'width':'0','margin-top':'+=30'},time,function(){ - dom.remove(); - }); - $tabs.animate({width:reset_width+'px'},time); - break; - case 'resize': - $tabs.css('width',reset_width+'px'); - break; - default:break; - } - } - - return { - rightMenu:{ - hidden:_menu_hidden - }, - resetWidth:resetWidth, - init:function(){ - $('body').live("resize",function(){ - resetWidth('resize'); - }); - _bindTab(); - _bindDrag(); - _bind_menu(); - - //ctrl s bind - Mousetrap.bind(['ctrl+s', 'command+s'],function(e) { - e.preventDefault();e.returnvalue = false; - Editor.save(); - }); - } - }; -}); diff --git a/static/js/_dev/src/edit/toolbar.js b/static/js/_dev/src/edit/toolbar.js deleted file mode 100644 index e538a8a..0000000 --- a/static/js/_dev/src/edit/toolbar.js +++ /dev/null @@ -1,202 +0,0 @@ -define(function(require, exports) { - var bindEvent = function(){ - $(window).bind("resize",function(){ - preview.resize(); - }); - $("#fontsize li").mouseenter(function () { - $(this).addClass("lihover"); - $(this).unbind('click').click(function(){//点击选中 - var val=$(this).text(); - $('a.font span').text(val); - Editor.config('fontsize',val); - $('.dropbox').css("display","none"); - - $("#fontsize li.this").removeClass('this'); - $(this).addClass('this'); - Editor.current() && Editor.current().focus(); - }); - }).mouseleave(function (){ - $(this).toggleClass("lihover"); - }); - - $('.tools a[action=wordbreak],.tools a[action=display],.tools a[action=auto_complete]') - .bind('click',function(){ - $(this).toggleClass('select'); - }); - $('.tools a').bind('click',function(e){ - var action = $(this).attr('action'); - doAction(action); - Editor.current() && Editor.current().focus(); - }); - - //主题修改 - $("#codetheme li").mouseenter(function () { - $(this).addClass("lihover"); - $(this).unbind('click').click(function(){//点击选中 - var val=$(this).attr('theme'); - Editor.config('theme',val); - $('a[action=codetheme] span').text($(this).html()); - $('.dropbox').css("display","none"); - $("#codetheme li.this").removeClass('this'); - $(this).addClass('this'); - }); - }).mouseleave(function (){ - $(this).toggleClass("lihover"); - }); - - $('.tools .left a').tooltip({placement:'bottom'}); - }; - - var doAction = function(action){ - switch (action) {//普通动作 - case 'max':FrameCall.father('core.editorFull',"''");break; - default:break; - } - //必须有编辑器的动作 - if (!Editor.current()) return; - switch (action) { - case 'save':Editor.save();break; - case 'saveall':Editor.saveall();break; - case 'pre' :Editor.current().undo();break; - case 'next' :Editor.current().redo();break; - case 'find' :Editor.current().execCommand('find');break; - case 'gotoline': - Editor.current().commands.exec('gotoline',Editor.current()); - break; - case 'font': - if ($('#fontsize').css('display')=='block') { - $('#fontsize').fadeOut(100); - }else{ - $('#fontsize').fadeIn(100); - } - break; - case 'codetheme': - if ($('#codetheme').css('display')=='block') { - $('#codetheme').fadeOut(100); - }else{ - $('#codetheme').fadeIn(100); - } - break; - case 'wordbreak':Editor.config('wrap');break; - case 'display':Editor.config('display');break; - case 'setting':Editor.config('setting');break; - case 'auto_complete':Editor.config('auto_complete');break; - case 'preview': - var url = urlDecode(urlDecode(Editor.current().kod.filename)); - url = core.path2url(url); - preview.open(url); - break; - case 'close':Editor.remove();break; - default:break; - } - } - - //文件预览 - var bindPreviewResize= function(){ - $('.frame_right input').keyEnter(preview.refresh); - var isDraging = false; - var mouseFirst = 0; - var leftwidthFirst = 0; - var min_width = 0;//最小宽度 - $drag = $('.frame_right .resize'); - $box_left = $('.frame_left'); - $box = $drag.parent(); - - $drag.die('mousedown').live('mousedown',function(e){ - if (e.which != 1) return true; - __dragStart(e); - //事件 在 window之外操作,继续保持。 - if(this.setCapture) this.setCapture(); - $(document).mousemove(function(e) {__dragMove(e);}); - $(document).one('mouseup',function(e) { - __dragEnd(e); - if(this.releaseCapture) {this.releaseCapture();} - return false; - }); - }); - var __dragStart = function(e){ - isDraging = true; - mouseFirst = e.pageX; - leftwidthFirst = $box.width(); - $drag.addClass('resize_active'); - $("body").css("cursor","col-resize"); - $box.append('
    '); - }; - var __dragMove = function(e){ - if (!isDraging) return true; - var mouseOffset = e.pageX - mouseFirst; - var offset = leftwidthFirst-mouseOffset; - var w_width = $(window).width(); - if (offset >= w_width-50) offset= w_width-50;//最宽 - if (offset <= 100 ) offset = 100;//最窄 - - $box_left.css('width',w_width-offset) - .find('.edit_body').css('width',w_width-offset); - $box.width(offset); - Tap.resetWidth('resize'); - Editor.config('resize'); - }; - var __dragEnd = function(e){ - if (!isDraging) return false; - isDraging = false; - $drag.removeClass('resize_active'); - $("body").css("cursor","default"); - $box.find('.mask_view').remove(); - }; - }; - var preview = (function(){ - var $box = $('.frame_right'), - $box_left = $('.frame_left'), - $address = $box.find('input'), - width = 400; - return { - open:function(url){ - if ($box.css('display') != 'block') { - $box.css('display','block').css('width',width); - var left_width = $(window).width() - width; - $('.frame_left').css('width',left_width) - .find('.edit_body').css('width',left_width); - } - $address.val(url); - $box.find('.open_ie').attr('href',url); - $box.find('iframe').attr('src',url); - preview.resize(); - }, - resize:function () {//调整frame宽度时 自动调整宽度 - if ($box.css('display') == 'block') {//有预览则更新对应宽度 - var offset = $box.width(); - var w_width = $(window).width(); - if (offset >= w_width-50) offset= w_width-50;//最宽 - if (offset <= 100 ) offset = 100;//最窄 - $box.width(offset); - $box_left.css('width',w_width-offset) - .find('.edit_body').css('width',w_width-offset); - } - Tap.resetWidth('resize'); - Editor.config('resize'); - }, - close:function(){ - $box.css('display','none'); - $address.val(''); - $box.find('iframe').attr('src',''); - $('.frame_left').css('width','100%') - .find('.edit_body').css('width','100%'); - Tap.resetWidth('resize'); - Editor.config('resize'); - }, - refresh:function(){ - var url = $address.attr('value'); - $box.find('.open_ie').attr('href',url); - $box.find('iframe').attr('src',url); - } - }; - })(); - return{ - preview:preview, - doAction:doAction, - init:function(){ - bindEvent(); - bindPreviewResize(); - } - }; -}); \ No newline at end of file diff --git a/static/js/_dev/src/editor/main.js b/static/js/_dev/src/editor/main.js deleted file mode 100644 index 86d3d5e..0000000 --- a/static/js/_dev/src/editor/main.js +++ /dev/null @@ -1,32 +0,0 @@ -define(function(require, exports, module) { - Config = { - TreeId:"folderList", // 目录树对象 - AnimateTime:200, // 动画时间设定 - pageApp : "editor", - treeAjaxURL : "index.php?explorer/treeList&app=editor",//树目录请求 - }; - Global = { - topbar_height:40, // 头部高度 - frameLeftWidth:200, // 左边树目录宽度 - treeSpaceWide:15, // 树目录层级相差宽度 - isIE:!-[1,], // 是否ie - }; - require('lib/jquery-lib'); - require('lib/util'); - require('lib/ztree/js/ztree'); - require('lib/contextMenu/jquery-contextMenu'); - require('lib/artDialog/jquery-artDialog'); - TaskTap = require('../../common/taskTap'); //任务栏 - core = require('../../common/core'); //公共方法及工具封装 - rightMenu = require('../../common/rightMenu'); //通用右键菜单配置 - ui = require('./ui'); - tree = require('../../common/tree'); - ui.tree = tree; - $(document).ready(function() { - ui.init(); - TaskTap.init(); - core.update(); - rightMenu.initEditor(); - $('.init_loading').fadeOut(450).addClass('pop_fadeout'); - }); -}); diff --git a/static/js/_dev/src/editor/ui.js b/static/js/_dev/src/editor/ui.js deleted file mode 100644 index e3f2603..0000000 --- a/static/js/_dev/src/editor/ui.js +++ /dev/null @@ -1,88 +0,0 @@ -define(function(require, exports, module) { - var _bindFrameSizeEvent= function(){ - var isDraging = false; - var mouseFirst = 0; - var leftwidthFirst = 0; - var min_width = 0;//最小宽度 - - var $left = $('.frame-left'); - var $drag = $('.frame-resize'); - var $right= $('.frame-right'); - - $drag.die('mousedown').live('mousedown',function(e){ - if (e.which != 1) return true; - __dragStart(e); - //事件 在 window之外操作,继续保持。 - if(this.setCapture) this.setCapture(); - $(document).mousemove(function(e) {__dragMove(e);}); - $(document).one('mouseup',function(e) { - __dragEnd(e); - if(this.releaseCapture) {this.releaseCapture();} - stopPP(e);return false; - }); - }); - var __dragStart = function(e){ - isDraging = true; - mouseFirst = e.pageX; - leftwidthFirst = $('.frame-left').width(); - $drag.addClass('active'); - $('.resizeMask').css('display','block'); - }; - var __dragMove = function(e){ - if (!isDraging) return true; - var mouseOffset = e.pageX - mouseFirst; - var offset = leftwidthFirst+mouseOffset; - if (offset < min_width) offset = min_width; - if (offset > $(document).width()-200) offset = $(document).width()-200; - - $left.css('width',offset); - $drag.css('left',offset-5); - $right.css('left',offset+1); - }; - var __dragEnd = function(e){ - if (!isDraging) return false; - isDraging = false; - $drag.removeClass('active'); - Global.frameLeftWidth = $('.frame-left').width(); - $('.resizeMask').css('display','none'); - }; - }; - var _bindToolbar = function(){ - $('.tools-left a').click(function(e){ - var action = $(this).attr('class'); - switch(action){ - case 'home':tree.init();break; - case 'view':tree.explorer();break; - case 'folder':tree.create('folder');break; - case 'file':tree.create('file');break; - case 'refresh':tree.init();break; - default:break; - } - }); - }; - return{ - init:function(){ - _bindFrameSizeEvent(); - _bindToolbar(); - tree.init(); - $("html").die('click').live('click',function (e) { - rightMenu.hidden(); - if (Global.isIE && Global.isDragSelect) return; - }); - - Mousetrap.bind(['ctrl+s', 'command+s'],function(e) { - e.preventDefault();e.returnvalue = false; - FrameCall.top('OpenopenEditor','Editor.save',''); - }); - }, - setTheme:function(thistheme){ - core.setSkin(thistheme,'app_editor.css'); - FrameCall.top('OpenopenEditor','Editor.setTheme','"'+thistheme+'"'); - }, - //编辑器全屏 - editorFull:function(){ - var $frame = $('iframe[name=OpenopenEditor]'); - $frame.toggleClass('frame_fullscreen'); - } - } -}); diff --git a/static/js/_dev/src/explorer/fileSelect.js b/static/js/_dev/src/explorer/fileSelect.js deleted file mode 100644 index cc415bc..0000000 --- a/static/js/_dev/src/explorer/fileSelect.js +++ /dev/null @@ -1,553 +0,0 @@ -define(function(require, exports) { - var isSelect = false; // 是否多选状态 - var isDraging = false; // 是否拖拽状态 - var isCtrlSelect = false; // 是否ctrl按住并选择 - - //初始化选择 - var _initSelect = function(){ - _bindDragEvent(); - _bindEvent(); - _bindSelectEvent(); - }; - var _bindEvent = function(){ - //phone - $(Config.FileBoxClass).die('touchstart').live('touchstart',function(event, phase, $target, data){ - if (!$(this).hasClass('select')){ - fileLight.clear(); - $(this).removeClass('select'); - $(this).addClass('select'); - fileLight.select(); - }else{ - ui.path.open(); - } - }); - - // 屏蔽对话框内操作 - $(Config.FileBoxClass).live('mouseenter',function (e) { - if (isDraging) {//hover,hover 到文件夹时则添加目标选择类 - if ($(this).hasClass(Config.TypeFolderClass) - && !$(this).hasClass(Config.SelectClassName)) { - $(this).addClass('selectDragTemp'); - } - } - if(!isSelect && !isDraging){//框选时,由于ctrl重选时会反选有hover - $(this).addClass(Config.HoverClassName); - } - - $(this).unbind("mousedown").mousedown(function(e){ - rightMenu.hidden(); - //已选中多个,点击可拖动以选中进行操作;点击未选中则清空 - if (!e.ctrlKey && !e.shiftKey && !$(this).hasClass(Config.SelectClassName)) { - fileLight.clear(); - $(this).addClass(Config.SelectClassName); - fileLight.select(); - } - //鼠标右键,有选中,且当前即为选中 - if(e.which==3 && !$(this).hasClass(Config.SelectClassName)){ - fileLight.clear(); - $(this).addClass(Config.SelectClassName); - fileLight.select(); - } - if(e.ctrlKey) {//ctrl 跳跃选择 - if ($(this).hasClass(Config.SelectClassName)) {//已经选定 设置标志位弹起时取消选择 - isCtrlSelect = true; - }else{ - fileLight.setMenu($(this)); - $(this).addClass(Config.SelectClassName); - } - fileLight.select(); - } - if(e.shiftKey){//shift 连选 - var current = parseInt($(this).attr(Config.FileOrderAttr)); - if (Global.fileListSelectNum == 0) { - _selectFromTo(0,current); - }else{//有选中,则当前元素序号对比选中的最左和最右, - var first = parseInt(Global.fileListSelect.first().attr(Config.FileOrderAttr)); - var last = parseInt(Global.fileListSelect.last().attr(Config.FileOrderAttr)); - if (current < first) { - //selectFromTo(current,last); - _selectFromTo(current,first); - }else if(current > last){ - //selectFromTo(first,current); - _selectFromTo(last,current); - }else if(current > first && current < last){ - _selectFromTo(first,current); - } - } - } - }); - }).die('mouseleave').live('mouseleave',function(){ - $(this).removeClass(Config.HoverClassName); - $(this).removeClass('selectDragTemp'); - }).die('click').live('click',function (e) { - stopPP(e);//再次绑定,防止冒泡到html的click事件 - if (!e.ctrlKey && !e.shiftKey) { - fileLight.clear(); - $(this).addClass(Config.SelectClassName); - fileLight.select(); - } - if(e.ctrlKey && isCtrlSelect) {//ctrl 跳跃选择 - isCtrlSelect = false; - fileLight.resumeMenu($(this));//恢复右键菜单id - $(this).removeClass(Config.SelectClassName); - fileLight.select(); - } - }); - //双击事件 - $(Config.FileBoxClass).die('dblclick').live('dblclick',function(e){//双击打开 - stopPP(e); - - if (e.altKey){ - ui.path.info(); - }else { - ui.path.open(); - } - }); - $(Config.FileBoxTittleClass).die('dblclick').live('dblclick',function (e) { - ui.path.rname();//重命名 - stopPP(e);return false; - }); - }; - - // 拖拽——移动 select - var _bindDragEvent= function(){ - var delayTime = 100; - var leftOffset= 50; - var dragCopyOffset = 30; - var topOffset = 80-Global.topbar_height; - var $self; - var startTime = 0; - var hasStart = false; - var boxTop = 0; - var boxLeft = 0; - var screenHeight; - var screenWidth; - - $(Config.FileBoxClass).die('mousedown').live('mousedown',function(e){ - if (Global.shiftKey) return; - if (ui.isEdit()) return true; - if (e.which != 1 || isSelect) return true; - $self = $(this); - __dragStart(e); - //事件 在 window之外操作,继续保持。 - if(this.setCapture) this.setCapture(); - $(document).mousemove(function(e) {__dragMove(e);}); - $(document).one('mouseup',function(e) { - __dragEnd(e); - if(this.releaseCapture) {this.releaseCapture();} - stopPP(e);return false; - }); - }); - var __dragStart = function(e){ - rightMenu.hidden(); - isDraging = true; - startTime = $.now(); - boxTop = e.pageY; - boxLeft = e.pageX; - screenHeight = $(document).height(); - screenWidth = $(document).width(); - }; - var __dragMove = function(e){ - if (!isDraging) return true; - if (($.now() - startTime > delayTime) && !hasStart) { - __makeDragBox(); - } - var x = (e.clientX >= screenWidth-50 ? screenWidth-50 : e.clientX); - var y = (e.clientY >= screenHeight-50 ? screenHeight-50 : e.clientY); - x = (x <= 0 ? 0 : x); - y = (y <= 0 ? 0 : y); - x = x - leftOffset; - y = y - topOffset; - - $('.draggable-dragging').css('left',x); - $('.draggable-dragging').css('top',y); - if(Global.isIE){//ie 无法事件穿透则遍历对比鼠标位置 - $('.'+Config.TypeFolderClass).each(function() { - var mouseX = e.pageX; - var mouseY = e.pageY; - var offset = $(this).offset(); - var width = $(this).width(); - var height = $(this).height(); - if (mouseX > offset.left - && mouseX < offset.left+width - && mouseY > offset.top - && mouseY < offset.top+height){ - $(this).addClass('selectDragTemp'); - }else{ - $(this).removeClass('selectDragTemp'); - } - }); - } - }; - var __dragEnd = function(e){ - if (!isDraging) return false; - isDraging = false; - hasStart = false; - $('body').css('cursor','auto'); - $('.draggable-dragging').fadeOut(200,function(){ - $(this).remove(); - }); - - var dragTo = G.this_path; - var isDragCurrent = ($('.selectDragTemp').length == 0); - if (Global.ctrlKey) { - if (!isDragCurrent) { - dragTo = dragTo+fileLight.name($('.selectDragTemp')); - } - if (Math.abs(e.pageX-boxLeft) > dragCopyOffset || - Math.abs(e.pageY-boxTop) > dragCopyOffset) { - ui.path.copyDrag(dragTo,isDragCurrent); - } - }else if (!isDragCurrent){ - dragTo = dragTo+fileLight.name($('.selectDragTemp')); - ui.path.cuteDrag(dragTo); - } - }; - var __makeDragBox = function(){ - hasStart = true; - $('body').css('cursor','move'); - //移动时会挡住下面元素,导致hover不可用, - //webkit firfox下css属性 pointer-events: none;鼠标事件穿透可解决。 - var type = $self.find('.ico').attr('filetype'); - $('
    ' - +'
    '+Global.fileListSelectNum+'
    ' - +'
    ' - +'
    ').appendTo('body'); - }; - }; - - - // 框选 select - var _bindSelectEvent = function(){ - var startX = null; - var startY = null; - var $selectDiv = null; - var offset_top = 85+Global.topbar_height; - var mainScrollTop = 0; //初始滚动条位置 - var mainOffsetTop = 0; - - $(Config.BodyContent).die('mousedown').live('mousedown',function(e){ - if ($(e.target).hasClass('bodymain') && - ($(document).width() - e.pageX<20)) { - return;// 屏蔽滚动条上的消息 - } - - if (ui.isEdit()) return true; - if (e.which != 1 || isDraging) return true; - __dragSelectInit(e); - if(this.setCapture){this.setCapture();} - $(document).unbind('mousemove').mousemove(function(e) {__dragSelecting(e);}); - $(document).one('mouseup',function(e) { - __dragSelectEnd(e); - Global.isDragSelect = true; - if(this.releaseCapture) {this.releaseCapture();} - }); - }) - - //创建模拟 选择框,框选开始 - var __dragSelectInit = function(e) { - mainScrollTop = $(Config.BodyContent).scrollTop(); - mainOffsetTop = offset_top - mainScrollTop; - if ($(e.target).parent().hasClass(Config.FileBoxClassName) - || $(e.target).parent().parent().hasClass(Config.FileBoxClassName) - || $(e.target).hasClass('fix') - ) return; - - rightMenu.hidden(); - if (!(e.ctrlKey || e.shiftKey)) fileLight.clear(); - if ($(e.target).hasClass("ico")==false){// 编辑状态不可选 - if ($('#selContainer').length == 0) { - $('
    ').appendTo(Config.FileBoxSelector); - $selectDiv = $('#selContainer'); - } - //$selectDiv = $('
    ').appendTo(Config.FileBoxSelector); - startX = e.pageX - Global.frameLeftWidth; - startY = e.pageY + $(Config.BodyContent).scrollTop() - offset_top; - isSelect = true; - } - }; - //框选,鼠标移动中 - var __dragSelecting= function(e) { - if (!isSelect) return true; - if ($selectDiv.css('display') =="none" ){ - $selectDiv.css('display',''); - } - var scroll_cute = $(Config.BodyContent).scrollTop() - mainScrollTop; - var mouseX = e.pageX- Global.frameLeftWidth; - var mouseY = e.pageY- mainOffsetTop + scroll_cute; - - $selectDiv.css({ - 'left' : Math.min(mouseX, startX), - 'top' : Math.min(mouseY, startY), - 'width' : Math.abs(mouseX - startX), - 'height': Math.abs(mouseY - startY) - }); - // ---------------- 框中选择关键算法 --------------------- - var _l = $selectDiv.offset().left - Global.frameLeftWidth; - var _t = $selectDiv.offset().top - mainOffsetTop + scroll_cute; - var _w = $selectDiv.width(); - var _h = $selectDiv.height() + Math.abs(scroll_cute); - var totalNum = Global.fileListNum; - - for ( var i = 0; i < totalNum; i++) { - var currentBox = Global.fileListAll[i]; - var $currentBox= $(Global.fileListAll[i]); - var sl = currentBox.offsetWidth + currentBox.offsetLeft; - var st = currentBox.offsetHeight + currentBox.offsetTop; - if (sl > _l && st > _t - && currentBox.offsetLeft < _l + _w - && currentBox.offsetTop < _t + _h) { - if (!$currentBox.hasClass("selectDragTemp")) { - if ($currentBox.hasClass("selectToggleClass")){ - continue; - } - if ($currentBox.hasClass(Config.SelectClassName)) { - $currentBox.removeClass(Config.SelectClassName).addClass("selectToggleClass"); - fileLight.resumeMenu($currentBox);//恢复右键选择 - continue; - } - $currentBox.addClass("selectDragTemp"); - } - }else { - $currentBox.removeClass("selectDragTemp"); - if ($currentBox.hasClass("selectToggleClass")) { - $currentBox.addClass(Config.SelectClassName).removeClass("selectToggleClass"); - } - } - } - }; - //框选结束 - var __dragSelectEnd = function(e) { - if (!isSelect) return false; - $selectDiv.css('display','none'); - $('.selectDragTemp').addClass(Config.SelectClassName).removeClass("selectDragTemp"); - $('.selectToggleClass').removeClass('selectToggleClass');//移除反选掉的div - - fileLight.select(); - isSelect = false; - startX = null; - startY = null; - }; - }; - - //获得选中文件【夹】相对位置的文件并返回 - var _getPosition = function(pose){ - var position = 0; //选择的位置,默认为第一个 - var $list = Global.fileListSelect;// - var listNum = Global.fileListSelectNum; - var totalNum = Global.fileListNum; //总数目 - - // get position list - var __list_position = function(){ - if (Global.fileListSelectNum == 1) {//只有一个为选中状态 - var thisNumber = parseInt($list.attr(Config.FileOrderAttr)); - switch(pose){ - case "up": - case "left": - position = ((thisNumber <=0)? thisNumber:thisNumber - 1); - break; - case "down": - case "right": - position = ((thisNumber >=totalNum-1)? thisNumber:thisNumber + 1); - break; - default:break; - } - }else if(Global.fileListSelectNum > 1){ //多个已选择的文件 - var firstNumber = parseInt($list.first().attr(Config.FileOrderAttr)); - var lastNumber = parseInt($list.last().attr(Config.FileOrderAttr)); - switch(pose){ - case "up": - case "left":position = ((firstNumber <=0)? firstNumber:firstNumber - 1); - break; - case "down": - case "right": - position = ((lastNumber >=totalNum)? lastNumber:lastNumber + 1); - break; - default:break; - } - } - } - var __icon_position = function(){ - var rowNum = Global.fileRowNum; //一行的数目 - if (Global.fileListSelectNum == 1) {//只有一个为选中状态 - var thisNumber = parseInt($list.attr(Config.FileOrderAttr)); - switch(pose){ - case "up": - position = ((thisNumber < rowNum)? 0:thisNumber-rowNum); - break; - case "left": - position = ((thisNumber <=0)? thisNumber:thisNumber - 1); - break; - case "down": - position = ((thisNumber+rowNum >=totalNum-1)? totalNum-1:thisNumber+rowNum); - break; - case "right": - position = ((thisNumber >=totalNum-1)? thisNumber:thisNumber + 1); - break; - default:break; - } - }else if(Global.fileListSelectNum > 1){ //多个已选择的文件 - var firstNumber = parseInt($list.first().attr(Config.FileOrderAttr)); - var lastNumber = parseInt($list.last().attr(Config.FileOrderAttr)); - switch(pose){ - case "up": - position = ((firstNumber <=rowNum)? firstNumber:firstNumber-rowNum); - break; - case "left":position = ((firstNumber <=0)? firstNumber:firstNumber - 1); - break; - case "down": - position = ((lastNumber+rowNum >=totalNum)? lastNumber:lastNumber+rowNum); - break; - case "right": - position = ((lastNumber >=totalNum)? lastNumber:lastNumber + 1); - break; - default:break; - } - } - } - if (G.list_type=='list') { - __list_position(); - }else{ - __icon_position(); - } - return Global.fileListAll.eq(position); - }; - - //设置选中 - var _setSelectAt = function(pos){ - var $select; - switch (pos){ - case 'home':$select = Global.fileListAll.first();break; - case 'end': $select = Global.fileListAll.last(); break; - case 'left': - case 'up': - case 'right': - case 'down': - $select = _getPosition(pos); - break; - case 'all'://全选 - $select = Global.fileListAll;break; - default:break; - } - fileLight.clear(); - $select.addClass(Config.SelectClassName); - fileLight.select(); - fileLight.setInView(); - }; - - //shift 选择,ctrl+上下左右选择 - var _selectFromTo = function(from,to){ - fileLight.clear(); - for (var i = from; i <= to; i++) { - $(Global.fileListAll[i]).addClass(Config.SelectClassName); - } - fileLight.select(); - }; - - //设置选中相关函数=========================================== - var fileLight = { - init:function(){//初始化页面,缓存jquery所有文件对象 - var $listAll = $(Config.FileBoxClass); - $listAll.each(function(index){ - $(this).attr(Config.FileOrderAttr,index); - }); - Global.fileListSelect = ''; - Global.fileListAll = $listAll; - Global.fileListNum = $listAll.length; - Global.fileListSelectNum = 0; - fileLight.menuAction('clear'); - }, - - //选择处理 - select:function(){ - var $list = $(Config.SelectClass); - Global.fileListSelect = $list; - Global.fileListSelectNum = $list.length; - if ($list.length > 1) { - fileLight.setMenu($list); - } - fileLight.menuAction('menufile'); - }, - setInView:function(){ - var $list = Global.fileListSelect; - if ($list && $list.length >= 1) { - var $con = $('.bodymain'); - var $last = $($list[$list.length-1]); - $con.scrollTop($last.offset().top - - $con.offset().top - - $con.height()/2 - + $con.scrollTop() - ); - } - }, - //获取文件&文件夹名字 - name:function($obj){ - return $obj.attr("data-name"); - }, - //获取文件&文件夹类型 folder为文件夹,其他为文件扩展名 - type:function($obj){ - return $obj.find(".ico").attr("filetype"); - }, - //已有的情况下,选择则标记右键菜单标记 - setMenu:function($obj){ - $obj.removeClass("menufile menufolder menuApp") - .addClass("menuMore"); - fileLight.menuAction(); - }, - //反选,或者框选已经选择的则恢复右键菜单标记 - resumeMenu:function($obj){ - var menu = {"fileApp":"menuApp","fileBox":"menufile","folderBox":"menufolder"}; - for(var key in menu){ - if ($obj.hasClass(key)) { - $obj.removeClass("menuMore").addClass(menu[key]); - } - } - fileLight.menuAction(); - }, - - //获取选中的文件名 - getAllName:function(){ - var arr_name = []; - if (Global.fileListSelectNum == 0) return; - var $list = Global.fileListSelect; - $list.each(function(i){ - arr_name[i] = fileLight.name($(this)); - }); - return arr_name; - }, - - //清空选择,还原右键关联menu - clear:function(){ - if (Global.fileListSelectNum == 0) return; - var $list = Global.fileListSelect; - $list.removeClass(Config.SelectClassName); - $list.each(function(){ - fileLight.resumeMenu($(this)); - }); - Global.fileListSelect = ''; - Global.fileListSelectNum = 0; - fileLight.menuAction(); - }, - menuAction:function(){ - if (Global.fileListSelectNum == 0) { - $('.drop-menu-action li').addClass('disabled'); - $('.drop-menu-action #past').removeClass('disabled'); - $('.drop-menu-action #info').removeClass('disabled'); - }else if (Global.fileListSelectNum > 1) { - $('.drop-menu-action li').removeClass('disabled'); - $('.drop-menu-action #open').addClass('disabled'); - $('.drop-menu-action #rname').addClass('disabled'); - $('.drop-menu-action #past').addClass('disabled'); - }else{ - $('.drop-menu-action li').removeClass('disabled'); - $('.drop-menu-action #past').addClass('disabled'); - } - } - }; - //对外接口 - return { - init:_initSelect, - selectPos:_setSelectAt, - fileLight:fileLight - } -}); \ No newline at end of file diff --git a/static/js/_dev/src/explorer/main.js b/static/js/_dev/src/explorer/main.js deleted file mode 100644 index 5c09610..0000000 --- a/static/js/_dev/src/explorer/main.js +++ /dev/null @@ -1,70 +0,0 @@ -define(function(require, exports, module) { - Config = { - BodyContent:".bodymain", // 框选事件起始的dom元素 - FileBoxSelector:'.fileContiner',// dd - FileBoxClass:".fileContiner .file", // 文件选择器 - FileBoxClassName:"file", // 文件选择器 - FileBoxTittleClass:".fileContiner .title",// 文件名选择器 - SelectClass:".fileContiner .select", // 选中文件选择器 - SelectClassName:"select", // 选中文件选择器名称 - TypeFolderClass:'folderBox',// 文件夹标记选择器 - TypeFileClass:'fileBox', // 文件标记选择器 - HoverClassName:"hover", // hover类名 - FileOrderAttr:"number", // 所有文件排序属性名 - TreeId:"folderList", // 目录树对象 - - pageApp : "explorer", - treeAjaxURL : "index.php?explorer/treeList&app=explorer",//树目录请求 - AnimateTime:200 // 动画时间设定 - }; - Global = { - fileListAll:'', // 当前路径下文件对象集合,缓存起来便于全局使用 - fileListNum:0, // 文件&文件夹总个数 - fileRowNum:0, // 当前屏幕每行文件&文件夹个数 - frameLeftWidth:200, // 左边树目录宽度 - treeSpaceWide:10, // 树目录层级相差宽度 - topbar_height:40, // 头部高度 - ctrlKey:false, // 是否按下ctrl - shiftKey:false, // 是否按下shift - - fileListSelect:'', // 选s择的文件 - fileListSelectNum:'', // 选中的文件数。 - isIE:!-[1,], // 是否ie - isDragSelect:false, // 是否框选 - historyStatus:{back:1,next:0} // 是否可以前进后退操作状态 - }; - - require('lib/jquery-lib'); - require('lib/util'); - require('lib/webuploader/webuploader-min');// - require('lib/ztree/js/ztree'); - require('lib/contextMenu/jquery-contextMenu'); - require('lib/artDialog/jquery-artDialog'); - require('lib/picasa/picasa'); - ui= require('./ui'); - TaskTap = require('../../common/taskTap'); //任务栏 - core = require('../../common/core'); //公共方法及工具封装 - rightMenu = require('../../common/rightMenu'); //通用右键菜单配置 - ui.tree = require('../../common/tree'); - ui.path = require('./path'); - fileSelect = require('./fileSelect'); - fileLight = fileSelect.fileLight; - var uploader; - - $(document).ready(function() { - if ($('.topbar').css('display') == 'none') { - Global.topbar_height = 0; - }else{ - Global.topbar_height = $('.topbar').height(); - } - - ui.init(); - ui.tree.init(); - TaskTap.init(); - core.update(); - core.upload_init(); - fileSelect.init(); - rightMenu.initExplorer(); - $('.init_loading').fadeOut(450).addClass('pop_fadeout'); - }); -}); \ No newline at end of file diff --git a/static/js/_dev/src/explorer/path.js b/static/js/_dev/src/explorer/path.js deleted file mode 100644 index d8f9dee..0000000 --- a/static/js/_dev/src/explorer/path.js +++ /dev/null @@ -1,554 +0,0 @@ -//对文件打开,文件操作的封装 -define(function(require, exports) { - var pathOperate = require('../../common/pathOperate'); - var pathOpen = require('../../common/pathOpen'); - var selectByChar = undefined;//键盘选择记录 - ui.pathOpen = pathOpen; - - //得到json中,获取新建文件名 dom节点的位置。 - //新建文件(保持排序队形不变) - var _getCreatePos = function(str,type){ - var list = "",i,j,offset=0, - folderlist =G.json_data['folderlist'], - filelist =G.json_data['filelist']; - - if (Config.pageApp == 'desktop') { - offset = $('.menuDefault').length; - } - if (type=='folder'){ - for (i=0;i=str) break; - } - if (G.sort_order == 'up') return i+offset; - return filelist.length+i+offset; - }else if(type=='file'){ - for (j=0;j=str) break; - } - if (G.sort_order == 'down') return j+offset; - return folderlist.length+j+offset; - } - return -1; - }; - - //设置某个文件[夹]选中。传入字符串或数组 - var _setSelectByFilename = function(name) { - if (name == undefined) return; - if (typeof(name) == 'string') { - name = [name]; - } - fileLight.clear(); - $('.fileContiner .file').each(function(key,value){ - var current_name = fileLight.name($(this)); - if ($.inArray(current_name,name) !=-1){ - $(Global.fileListAll).eq(key).addClass(Config.SelectClassName); - } - }); - fileLight.select(); - fileLight.setInView(); - }; - - //设置某个文件[夹]选中。传入字符串或数组 - var _setSelectByChar = function(ch) { - if (ch == '') return; - //初始化数据 - ch = ch.toLowerCase(); - if (selectByChar == undefined - || G.this_path != selectByChar.path - || ch != selectByChar.key ) { - var arr = []; - $('.fileContiner .file').each(function(){ - var current_name = fileLight.name($(this)); - if (!current_name) return; - if (ch == current_name.substring(0,ch.length).toLowerCase()){ - arr.push(current_name); - } - }); - selectByChar = {key:ch,path:G.this_path,index:0,list:arr}; - } - - if (selectByChar.list.length == 0) return;//没有匹配项 - //自动从匹配结果中查找 - _setSelectByFilename(selectByChar.list[selectByChar.index++]); - if (selectByChar.index == selectByChar.list.length) { - selectByChar.index = 0; - } - }; - - //搜索当前文件夹 含有字母 - var _setSearchByStr = function(ch) { - if (ch == ''){ - fileLight.clear(); - return; - } - fileLight.clear(); - $('.fileContiner .file').each(function(key,value){ - var current_name = fileLight.name($(this)); - if (current_name.toLowerCase().indexOf(ch) != -1){ - $(Global.fileListAll).eq(key).addClass(Config.SelectClassName); - } - }); - fileLight.select(); - fileLight.setInView(); - }; - - //查找json中,文件名所在的数组位置。 - var _arrayFind = function(data,key,str){ - var m=data.length; - for(i=0;i\ -
    \ -
    \ - \ -
    \ - \ - \ -
    \ -
    \ -
    \ -
    '; - if (pos==-1){ - $(Config.FileBoxSelector).html(listhtml+$(Config.FileBoxSelector).html()); - }else { - $(listhtml).insertAfter(Config.FileBoxSelector+" .file:eq("+pos+")"); - } - // dom - var $textarea = $(".newfile"); - var textarea = $textarea.get(0); - // 处理选中文件名部分 - var selectlen=newname.length-newname_ext.length-1; - if(Global.isIE){//IE - var range = textarea.createTextRange(); - range.moveEnd('character', -textarea.value.length); - range.moveEnd('character', selectlen); - range.moveStart('character', 0); - range.select(); - }else{//firfox chrome ... - textarea.setSelectionRange(0,selectlen); - } - - $textarea.focus(); - $textarea.unbind('keydown').keydown(function(event) { - if (event.keyCode == 13 || event.keyCode == 27){ - //捕获键盘事件 enter esc - stopPP(event); - event.preventDefault();//阻止编辑器回车 - filename=$textarea.attr('value');//获取编辑器值 - if(_fileExist(filename)){ - $("#makefile").remove(); - core.tips.tips(LNG.path_exists,'warning'); - }else{ - pathOperate.newFile(G.this_path+filename,function(){ - ui.f5_callback(function() { - _setSelectByFilename(filename); - }); - }); - } - } - return true; - }); - $textarea.unbind('blur').blur(function(){ - filename=$textarea.attr('value');//获取编辑器值 - if(_fileExist(filename)){ - $("#makefile").remove(); - core.tips.tips(LNG.path_exists,'warning'); - _newFile(newname_ext); - }else{ - pathOperate.newFile(G.this_path+filename,function(){ - ui.f5_callback(function() { - _setSelectByFilename(filename); - }); - }); - } - }); - }; - //新建文件夹 - var newFolder = function() { - fileLight.clear(); - var newname=LNG.newfolder; - var is_exist=0; - var newname=_getName(newname);//如果重复,则自动追加字符 - var pos=_getCreatePos(newname,'folder'); - pos=(pos==0)?-1:(pos-1); - - var listhtml=''; - - if (pos==-1){//空目录时 - $(Config.FileBoxSelector).html(listhtml+$(Config.FileBoxSelector).html()); - }else { - $(listhtml).insertAfter(Config.FileBoxSelector+" .file:eq("+pos+")"); - } - $('.newfile').select(); - $('.newfile').focus(); - $('.newfile').unbind('keydown').keydown(function(event) { - if (event.keyCode == 13 || event.keyCode == 27) { - stopPP(event); - event.preventDefault();//阻止编辑器回车 - var filename=$('.newfile').attr('value');//获取编辑器值 - if(_fileExist(filename)){ - $("#makefile").remove(); - core.tips.tips(LNG.path_exists,'warning'); - }else{ - pathOperate.newFolder(G.this_path+filename,function(){ - if (Config.pageApp == 'explorer') { - ui.tree.checkIfChange(G.this_path); - } - ui.f5_callback(function() { - _setSelectByFilename(filename); - }); - }); - } - } - }); - $('.newfile').unbind('blur').blur(function(){//编辑框事件处理 - filename=$('.newfile').attr('value');//获取编辑器值 - if(_fileExist(filename)){ - $("#makefile").remove(); - core.tips.tips(LNG.path_exists,'warning'); - _newFolder(); - }else{ - pathOperate.newFolder(G.this_path+filename,function(){ - if (Config.pageApp == 'explorer') { - ui.tree.checkIfChange(G.this_path); - } - ui.f5_callback(function() { - _setSelectByFilename(filename); - }); - }); - } - }); - }; - - //重命名 - var rname = function() { - var rname_to = ""; - var path = ""; - var selectname = "";//成功后选中的名称 - var selectObj = Global.fileListSelect; - var selectid = fileLight.name(selectObj); - var selecttype = fileLight.type(selectObj); - selecttype = (selecttype=='folder'?'folder':selecttype); - $(selectObj).find(".title").html("
    "); - - var $textarea = $("#pathRenameTextarea"); - var textarea = $textarea.get(0); - if (selecttype=='folder') { - $textarea.select(); - }else{//若为文件,则只选中名称部分 - var selectlen=selectid.length-selecttype.length-1; - if(Global.isIE){//IE - var range = textarea.createTextRange(); - range.moveEnd('character', -textarea.value.length); - range.moveEnd('character', selectlen); - range.moveStart('character', 0); - range.select(); - }else{//firfox chrome ... - textarea.setSelectionRange(0,selectlen); - } - } - $textarea.unbind('focus').focus(); - $textarea.keydown(function(event) { - if (event.keyCode == 13) { - event.preventDefault();//阻止编辑器回车 - stopPP(event); - rname_to=$textarea.attr('value');//获取编辑器值 - if (selecttype == 'oexe') rname_to+='.oexe'; - var select_name = rname_to;//重命名后选中文件。 - if (rname_to!=selectid){ - path =urlEncode(G.this_path+selectid); - rname_to=urlEncode(G.this_path+rname_to); - pathOperate.rname(path,rname_to,function(){ - if (Config.pageApp == 'explorer') { - ui.tree.checkIfChange(G.this_path); - } - ui.f5_callback(function() { - _setSelectByFilename(select_name); - }); - }); - }else{ - if (selecttype == 'oexe') selectid =selectid.replace('.oexe',''); - $(selectObj).find(".title").html(selectid); - } - } - if ( event.keyCode == 27){ - if (selecttype == 'oexe') selectid =selectid.replace('.oexe',''); - $(selectObj).find(".title").html(selectid); - } - }); - $textarea.unbind('blur').blur(function(){ - rname_to=$('#pathRenameTextarea').attr('value');//获取编辑器值 - if (selecttype == 'oexe') rname_to+='.oexe'; - var select_name = rname_to;//重命名后选中文件。 - if (rname_to!=selectid){ - path =urlEncode(G.this_path+selectid); - rname_to=urlEncode(G.this_path+rname_to); - pathOperate.rname(path,rname_to,function(){ - if (Config.pageApp == 'explorer') { - ui.tree.checkIfChange(G.this_path); - } - ui.f5_callback(function() { - _setSelectByFilename(select_name); - }); - }); - }else{ - if (selecttype == 'oexe') selectid =selectid.replace('.oexe',''); - $(selectObj).find(".title").html(selectid); - } - }); - }; - var refreshCallback=function(){//当前目录文件变化,刷新目录 - ui.f5(); - if (Config.pageApp == 'explorer') { - ui.tree.checkIfChange(G.this_path); - } - }; - return { - //app - appEdit:function(create){ - if (create) { - pathOperate.appEdit(0,0,'user_add'); - }else{ - var code = Global.fileListSelect.attr('data-app'); - var data = json_decode(urlDecode(code)); - data.path = G.this_path+fileLight.name(Global.fileListSelect); - pathOperate.appEdit(data); - } - }, - appList:function(){pathOperate.appList(_param().path);}, - appInstall:function(){pathOperate.appInstall(_param().path);}, - - //open - openEditor :function(){pathOpen.openEditor(_param().path);}, - openIE :function(){pathOpen.openIE(_param().path);}, - download :function(){pathOpen.download(_param().path);}, - open:function(path){ - if (path != undefined) {pathOpen.open(path);return;}; - var param = _param(); - var selectObj= Global.fileListSelect; - if (inArray(core.filetype['image'],param.type) ) { - if (G.list_type=='icon' || Config.pageApp == 'desktop') { - ui.picasa.play($(selectObj).find('.ico')); - }else{ - ui.picasa.play($(selectObj)); - } - return; - } - //oexe 的打开 - if (param.type == 'oexe') { - var code = selectObj.attr('data-app'); - param.path = json_decode(urlDecode(code)); - } - pathOpen.open(param.path,param.type); - }, - play:function(){ - if (Global.fileListSelectNum <1) return; - var list = [];//选中单个&多个都可以播放 - Global.fileListSelect.each(function(index){ - var pathtype = fileLight.type($(this)); - if (inArray(core.filetype['music'],pathtype) - || inArray(core.filetype['movie'],pathtype)) { - var url = core.path2url(G.this_path+fileLight.name($(this))); - list.push(url); - } - }); - pathOpen.play(list,'music'); - }, - - //operate - pathOperate:pathOperate, - search :function(){core.search('',_param().path);}, - fav :function(){pathOperate.fav(_param().path);}, - remove :function(){pathOperate.remove(_param(true),refreshCallback);fileLight.clear();}, - copy :function(){pathOperate.copy(_param(true));}, - cute :function(){pathOperate.cute(_param(true),ui.f5);}, - zip :function(){pathOperate.zip(_param(true),refreshCallback);}, - unZip :function(){pathOperate.unZip(_param().path,ui.f5);}, - cuteDrag:function(dragTo){pathOperate.cuteDrag(_param(true),dragTo,refreshCallback);}, - copyDrag:function(dragTo,isDragCurrent){ - pathOperate.copyDrag(_param(true),dragTo,function(list){ - fileLight.clear(); - if (Config.pageApp == 'explorer'){ - ui.tree.checkIfChange(G.this_path); - } - ui.f5_callback(function() { - if (isDragCurrent && list['data']){ - _setSelectByFilename(list.data); - } - }); - }); - }, - info:function(){pathOperate.info(_param(true));}, - past:function(){ - fileLight.clear(); - pathOperate.past(G.this_path,function(list){ - if (Config.pageApp == 'explorer') { - ui.tree.checkIfChange(G.this_path); - } - ui.f5_callback(function() { - _setSelectByFilename(list.data); - }); - }); - }, - //前进后退 - back:back, - next:next, - //内部特有的 - list:list, - newFile:newFile, - newFolder:newFolder, - rname:rname, - setSearchByStr:_setSearchByStr, - setSelectByChar:_setSelectByChar, - setSelectByFilename:_setSelectByFilename, - clipboard:pathOperate.clipboard - } -}); \ No newline at end of file diff --git a/static/js/_dev/src/explorer/ui.js b/static/js/_dev/src/explorer/ui.js deleted file mode 100644 index c1b02be..0000000 --- a/static/js/_dev/src/explorer/ui.js +++ /dev/null @@ -1,753 +0,0 @@ -define(function(require, exports) { - //ajax后重置数据、重新绑定事件(f5或者list更换后重新绑定) - var fileSelect = require('./fileSelect'); - var fileLight = fileSelect.fileLight; - var MyPicasa = new Picasa(); - PicasaOpen = false;//全局变量,用于标记是否有幻灯片播放 - - var _ajaxLive = function(){ - fileLight.init(); - ui.setStyle(); - //幻灯片播放绑定 - PicasaOpen = false; - MyPicasa.initData(); - - //图片缩略图懒加载 桌面不做处理 - $(".fileContiner .picture img").lazyload({ - //effect : "fadeIn", - //placeholder:G.static_path + 'images/loading_tree.gif', - container: $(".bodymain") - }); - } - //文件列表 列表模式和图标模式切换, - var _initListType = function(thistype){ - $('.tools-right button').removeClass('active'); - $('#set_'+thistype).addClass('active'); - if (thistype=='list') { - $(Config.FileBoxSelector).removeClass('fileList_icon').addClass('fileList_list'); - $('#list_type_list').html( - '
    '+ - '
    '+LNG.name+'
    '+ - '
    '+LNG.type+'
    '+ - '
    '+LNG.size+'
    '+ - '
    '+LNG.modify_time+'
    '+ - '
    '+ - '
    ' - ); - $(Config.FileBoxSelector+' textarea').autoTextarea({minHeight:19,padding:4}); - }else{ - $(Config.FileBoxSelector).removeClass('fileList_list').addClass('fileList_icon'); - $('#list_type_list').html(''); - $(Config.FileBoxSelector+' textarea').autoTextarea({minHeight:32,padding:4}); - } - //同步到右键菜单 - $('.menu_seticon').removeClass('selected'); - $('.set_set'+G.list_type).addClass('selected'); - } - //修改显示方式,图标&列表方式;动态加载css,本页面json刷新。 - var _setListType = function (thistype,firstRun){ - G.list_type = thistype; - if (firstRun == undefined){ - $.ajax({ - url:'index.php?setting/set&k=list_type&v='+thistype, - dataType:'json', - success:function(data){ - _initListType(thistype); - _f5(false,false); - } - }); - }else{ - _initListType(thistype); - _f5(false,true); - } - }; - - //json 排序 filed:(string)排序字段,orderby:升降序。升序为-1,降序为1 - var _sortBy = function(filed,orderby) { - var orderby = (orderby=='down')? -1 : 1; - return function (a, b) { - a = a[filed]; - b = b[filed]; - if (a < b) return orderby * -1; - if (a > b) return orderby * 1; - } - } - //列表排序操作。 - var _setListSort = function(field,order){ - //同步到右键菜单,如果传入0,则不修改 - if (field != 0) {//同步修改排序字段 - G.sort_field = field; - $('.menu_set_sort').removeClass('selected'); - $('.set_sort_'+field).addClass('selected'); - } - if (order != 0) {//修改排序方式,升序,降序 - G.sort_order = order; - $('.menu_set_desc').removeClass('selected'); - $('.set_sort_'+order).addClass('selected'); - } - _f5(false,true);//使用本地列表 - $.ajax({ - url:'index.php?setting/set&k=list_sort_field,list_sort_order&v=' - +G.sort_field+','+G.sort_order - }); - }; - //针对排序方式更新标题栏显示 - var _jsonSortTitle = function(){ - var up=''; - var down=''; - $('#main_title .this') - .toggleClass('this') - .attr('id','') - .find('span') - .html(""); - $('#main_title div[field='+G.sort_field+']') - .addClass('this') - .attr('id',G.sort_order) - .find('span') - .html(eval(G.sort_order)); - }; - - //标题栏排序方式点击 - var _bindEventSort = function(){ - $('#main_title div').die('click').live('click',function(){ - if ($(this).attr('id')=='up'){ - $(this).attr('id','down'); - }else $(this).attr('id','up'); - _setListSort($(this).attr('field'),$(this).attr('id')); - }); - }; - var _bindEventTools = function(){ - $('.tools a,.tools button').bind('click',function(){ - var todo = $(this).attr('id'); - _toolsAction(todo); - }); - }; - var _bindEventTheme = function(){//主题切换 - $('.dropdown-menu-theme li').click(function(){//点击选中 - var theme=$(this).attr("theme"); - $.ajax({ - url:'index.php?setting/set&k=theme&v='+theme, - dataType:'json', - success: function(data) { - ui.setTheme(theme); - } - }); - $('.dropdown-menu li').removeClass('this'); - $(this).addClass('this'); - }); - }; - - var _bindFrameSizeEvent= function(){ - var isDraging = false; - var mouseFirst = 0; - var leftwidthFirst = 0; - var min_width = 0;//最小宽度 - - var $left = $('.frame-left'); - var $drag = $('.frame-resize'); - var $right= $('.frame-right'); - $drag.die('mousedown').live('mousedown',function(e){ - if (e.which != 1) return true; - __dragStart(e); - //事件 在 window之外操作,继续保持。 - if(this.setCapture) this.setCapture(); - $(document).mousemove(function(e) {__dragMove(e);}); - $(document).one('mouseup',function(e) { - __dragEnd(e); - if(this.releaseCapture) {this.releaseCapture();} - stopPP(e);return false; - }); - }); - var __dragStart = function(e){ - isDraging = true; - mouseFirst = e.pageX; - leftwidthFirst = $('.frame-left').width(); - $drag.addClass('active'); - }; - var __dragMove = function(e){ - if (!isDraging) return true; - - var mouseOffset = e.pageX - mouseFirst; - var offset = leftwidthFirst+mouseOffset; - if (offset < min_width) offset = min_width; - if (offset > $(document).width()-200) offset = $(document).width()-200; - - $left.css('width',offset); - $drag.css('left',offset-5); - $right.css('left',offset+1); - ui.setStyle(); - }; - var __dragEnd = function(e){ - if (!isDraging) return false; - isDraging = false; - $drag.removeClass('active'); - Global.frameLeftWidth = $('.frame-left').width(); - }; - }; - var _bindHotKey = function(){ - var cmmand = 91; - Global.ctrlKey = false; - $(document).keydown(function (e){ - if ($('#PicasaView').css('display') != 'none') return true;//图片播放 - if (ui.isEdit()) return true;//编辑状态 - if (rightMenu.isDisplay()) return true; - - var isStopPP = false;//是否向上拦截冒泡 - if (Global.ctrlKey || e.keyCode == cmmand || e.ctrlKey) { - //ctrl 组合键console.log(e.keyCode) - isStopPP = true; - Global.ctrlKey = true; - switch(e.keyCode){ - case 8:ui.path.remove();isStopPP=true;break;//ctrl+backspace remove - case 65:fileSelect.selectPos('all');break;//CTRL+A 全选 - case 8:ui.path.next();isStopPP=true;break;//前进 - case 67:ui.path.copy();break;//CTRL+C 复制 - case 88:ui.path.cute();break;//CTRL+X 剪切 - case 83:break; // 屏蔽CTRL+S - case 86:ui.path.past();break;//CTRL+V 粘贴 - case 70://CTRL+F 查找 - core.search($('.header-right input').val(),G.this_path); - break; - default:isStopPP=false;break; - } - }else if(e.shiftKey) { - Global.shiftKey = true; - //console.log("shiftKey+"+e.keyCode); - }else{ - switch (e.keyCode) { - case 8:ui.path.back();isStopPP=true;break; - case 35:fileSelect.selectPos('end');break; - case 36:fileSelect.selectPos('home');break; - case 37:fileSelect.selectPos('left');isStopPP=true;break; - case 38:fileSelect.selectPos('up');isStopPP=true;break; - case 39:fileSelect.selectPos('right');isStopPP=true;break; - case 40:fileSelect.selectPos('down');isStopPP=true;break; - case 13:ui.path.open();isStopPP=false;break;//enter 打开文件==双击 - case 46:ui.path.remove();isStopPP=true;break; - case 113:ui.path.rname();isStopPP=true;break;//f2重命名 - default:isStopPP=false;break; - } - } - if (isStopPP) { - stopPP(e); - e.keyCode=0; - e.returnValue=false;//拦截向上消息冒泡 - } - return true; - }).keyup(function(e){ - if (!e.shiftKey) Global.shiftKey = false; - if (e.keyCode == cmmand || !e.ctrlKey) Global.ctrlKey = false;//win=ctrl - }); - }; - - //下拉菜单展开操作 - var _menuActionBind = function(){ - $('.drop-menu-action li').bind('click',function(){ - if ($(this).hasClass('disabled'))return; - var action = $(this).attr('id'); - switch(action){ - case 'open':ui.path.open();break; - case 'copy':ui.path.copy();break; - case 'rname':ui.path.rname();break; - case 'cute':ui.path.cute();break; - case 'clone':ui.path.copyDrag(G.this_path,true);break; - case 'past':ui.path.past();break; - case 'remove':ui.path.remove();break; - case 'zip':ui.path.zip();break; - case 'download':ui.path.download();break; - case 'info':ui.path.info();break; - default:break; - } - }); - }; - //图标样式,文件夹模版填充 - this._getFolderBox = function(list){ - var html=""; - html+=""; - return html; - } - //图标样式,文件模版填充 - this._getFileBox = function(list){ - var html=""; - if (list['ext'] == 'oexe' && list['icon'] != undefined) { - var icon = list.icon; - if (list.icon.search(G.static_path)==-1 - && list.icon.substring(0,4) !='http') { - icon = G.static_path + 'images/app/' + list.icon; - } - var code = urlEncode(json_encode(list)); - var display = list.name.replace('.oexe',''); - html =""; - }else if (inArray(core.filetype['image'],list['ext'])) {//如果是图片,则显示缩略图 - var filePath = core.path2url(G.this_path+list['name']); - var thumbPath = 'index.php?explorer/image&path='+urlEncode(G.this_path+list['name']); - html+=""; - }else{ - html+=""; - } - return html; - } - - //--------------------------------------- - //列表样式,文件夹模版填充 - this._getFolderBoxList = function(list){ - var html=""; - html+=""; - return html; - } - //列表样式,文件模版填充 - this._getFileBoxList = function(list){ - var html=""; - if (list['ext'] == 'oexe') { - var code = urlEncode(json_encode(list)); - html ="