信呼OA版本v2.3.8
This commit is contained in:
113
webmain/system/sysfile/rock_sysfile.php
Normal file
113
webmain/system/sysfile/rock_sysfile.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php if(!defined('HOST'))die('not access');?>
|
||||
<script >
|
||||
$(document).ready(function(){
|
||||
var a = $('#veiw_{rand}').bootstable({
|
||||
checked:false,method:'get',
|
||||
url:js.getajaxurl('getdata','{mode}','{dir}'),
|
||||
columns:[{
|
||||
text:'名称',dataIndex:'name',align:'left',renderer:function(v,d){
|
||||
return '<span title="'+jm.base64decode(d.path)+'"><i class="icon-'+d.type+'"></i> '+v+'</span>';
|
||||
}
|
||||
},{
|
||||
text:'说明',dataIndex:'explain'
|
||||
},{
|
||||
text:'大小',dataIndex:'filesize'
|
||||
},{
|
||||
text:'创建时间',dataIndex:'createdt'
|
||||
},{
|
||||
text:'最后修改',dataIndex:'lastdt'
|
||||
},{
|
||||
text:'',dataIndex:'isaz',align:'left',renderer:function(v,d){
|
||||
var str = '';
|
||||
if(d.lei==0){
|
||||
str='<a href="javascript:;" onclick="openfile{rand}('+d.lei+',\''+d.path+'\')">打开</a>';
|
||||
}else{
|
||||
if(d.isedit==1)str='<a href="javascript:;" onclick="openfile{rand}(2,\''+d.path+'\')">查看</a>';
|
||||
if(js.isimg(d.fileext))str='<a href="javascript:;" onclick="$.imgview({url:\''+jm.base64decode(d.path)+'\'})">预览</a>';
|
||||
}
|
||||
if(d.isdel==1)str+=' <a href="javascript:;" onclick="openfile{rand}(3,\''+d.path+'\')">删</a>';
|
||||
return str;
|
||||
}
|
||||
}],
|
||||
load:function(d){
|
||||
$('#sviepath').html('文件不要随意删除');
|
||||
nowpath = d.nowpath;
|
||||
var str='',i,ad2,s1='';
|
||||
ad2=d.nowpath.split('/');
|
||||
for(i=0;i<ad2.length;i++){
|
||||
if(i>0){
|
||||
str+=' <font color="#cccccc">></font> ';
|
||||
s1+='/';
|
||||
}
|
||||
s1+=''+ad2[i]+'';
|
||||
str+='<a href="javascript:;" onclick="openfile{rand}(0,\''+jm.base64encode(s1)+'\')">'+ad2[i]+'</a>';
|
||||
}
|
||||
$('#nowpath').html(str);
|
||||
},
|
||||
itemdblclick:function(d){
|
||||
if(d.lei==0)openfile{rand}(0,d.path);
|
||||
}
|
||||
});
|
||||
|
||||
var c = {
|
||||
reload:function(){
|
||||
a.reload();
|
||||
},
|
||||
clearlogs:function(){
|
||||
js.confirm('确定要全部删除<?=UPDIR?>/logs下的文件嘛?', function(jg){if(jg=='yes')c.clearlogss();});
|
||||
},
|
||||
clearlogss:function(){
|
||||
js.loading('清理中...');
|
||||
js.ajax(js.getajaxurl('clearlogs','{mode}','{dir}'),false,function(tss){
|
||||
js.msgok(tss);
|
||||
});
|
||||
},
|
||||
delfile:function(pts){
|
||||
js.confirm('确定要删除'+jm.base64decode(pts)+'吗?', function(jg){if(jg=='yes')c.delfiles(pts);});
|
||||
},
|
||||
delfiles:function(pts){
|
||||
js.loading('删除中...');
|
||||
js.ajax(js.getajaxurl('delfile','{mode}','{dir}'),{path:pts},function(tss){
|
||||
js.msgok(tss);
|
||||
a.reload();
|
||||
});
|
||||
},
|
||||
svnupdate:function(){
|
||||
js.loading('发送中...');
|
||||
js.ajax(js.getajaxurl('svnupdate','{mode}','{dir}'),false,function(tss){
|
||||
js.msgok(tss);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
openfile{rand}=function(lx,pts){
|
||||
if(lx==0)a.setparams({path:pts},true);
|
||||
if(lx==2)window.open('?m=sysfile&d=system&a=edit&path='+pts+'');
|
||||
if(lx==3)c.delfile(pts);
|
||||
}
|
||||
|
||||
js.initbtn(c);
|
||||
});
|
||||
</script>
|
||||
|
||||
<div>
|
||||
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td nowrap align="left">
|
||||
<button class="btn btn-default" click="reload" type="button">刷新</button>
|
||||
</td>
|
||||
<td align="left" width="100%" style="padding:0px 10px;">
|
||||
路径:<a href="javascript:;" onclick="openfile{rand}(0,'')"><?=ROOT_PATH?></a> <font color="#cccccc">></font> <span id="nowpath"></span>
|
||||
</td>
|
||||
<td align="right" nowrap>
|
||||
<?php
|
||||
if(getconfig('svnpath'))echo '<button class="btn btn-default" click="svnupdate" type="button">SVN更新系统</button>';
|
||||
?>
|
||||
<button class="btn btn-default" click="clearlogs" type="button">一键清除<?=UPDIR?>/logs下日志文件</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="blank10"></div>
|
||||
<div id="veiw_{rand}"></div>
|
||||
179
webmain/system/sysfile/sysfileAction.php
Normal file
179
webmain/system/sysfile/sysfileAction.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
class sysfileClassAction extends Action
|
||||
{
|
||||
public function initAction()
|
||||
{
|
||||
$this->isdelmu = array(''.UPDIR.'/logs', ''.UPDIR.'/sqllog',''.UPDIR.'/cache', ''.UPDIR.'/data/'.(date('Y')-1).'');
|
||||
}
|
||||
|
||||
public function getdataAjax()
|
||||
{
|
||||
$notedit = ',exe,dll,zip,rar,gz,ocx,png,gif,jpg,ico,mp4,wmv,frx,psd,';
|
||||
$this->notedit = $notedit;
|
||||
$rows = array();
|
||||
$path = '';
|
||||
$isope= getconfig('sysfileview');
|
||||
if($this->adminid!=1 || getconfig('system')=='demo' || !$isope){
|
||||
if($this->adminid!=1)$rows[]=array('name'=>'非admin管理员不能查看');
|
||||
if(getconfig('system')=='demo')$rows[]=array('name'=>'演示不能查看');
|
||||
if(!$isope)$rows[]=array('name'=>'系统配置文件没有打开sysfileview选项,不能查看,可配置加上\'sysfileview\'=>true,即可');
|
||||
}else{
|
||||
$path = $this->jm->base64decode($this->get('path'));
|
||||
$rows = $this->getfilelist($path);
|
||||
}
|
||||
|
||||
$total = count($rows);
|
||||
return array(
|
||||
'rows' => $rows,
|
||||
'totalCount'=> $total,
|
||||
'success' => true,
|
||||
'nowpath' => $path
|
||||
);
|
||||
}
|
||||
private function getfilelist($path)
|
||||
{
|
||||
$chk = c('check');
|
||||
$php5= version_compare(PHP_VERSION, '7.0.0','<');
|
||||
$dir_arr = @scandir(ROOT_PATH.'/'.$path);
|
||||
$darr1= $rows = array();
|
||||
foreach($dir_arr as $key=>$val){
|
||||
if($val == '.' || $val == '..'){
|
||||
}else{
|
||||
if($php5 && $chk->isincn($val))$val = iconv('gb2312','utf-8', $val);
|
||||
$mulu = $path.'/'.$val.'';
|
||||
if(!$path)$mulu = $val;
|
||||
if(is_dir($mulu)){
|
||||
$isdel = 0;
|
||||
foreach($this->isdelmu as $sdif)if(strpos($mulu, $sdif)===0)$isdel=1;
|
||||
$rows[] = array(
|
||||
'name' => $val,
|
||||
'type'=>'folder-close-alt',
|
||||
'lei'=>0,
|
||||
'isdel'=>$isdel,
|
||||
'path'=> $this->jm->base64encode($mulu)
|
||||
);
|
||||
}else{
|
||||
$suhs = $this->getfilew($val, $mulu,'',0);
|
||||
if($suhs)$darr1[] = $suhs;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($darr1 as $k=>$rs)$rows[] = $rs;
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
private function getfilew($val,$mulu,$sm='',$isdel=0)
|
||||
{
|
||||
if(!file_exists($mulu))return false;
|
||||
$fileext = strtolower(substr($val,strripos($val,'.')+1));
|
||||
$isedit = 1;
|
||||
if(contain($this->notedit,','.$fileext.','))$isedit = 0;
|
||||
foreach($this->isdelmu as $sdif)if(strpos($mulu, $sdif)===0)$isdel=1;
|
||||
return array(
|
||||
'name' => $val,
|
||||
'type' => 'file',
|
||||
'lei'=>1,
|
||||
'filesize' => $this->rock->formatsize(filesize($mulu)),
|
||||
'createdt' => date('Y-m-d H:i:s',filectime($mulu)),
|
||||
'lastdt' => date('Y-m-d H:i:s',filemtime($mulu)),
|
||||
'path' => $this->jm->base64encode($mulu),
|
||||
'fileext' => $fileext,
|
||||
'isedit' => $isedit,
|
||||
'isdel' => $isdel,
|
||||
'explain' => $sm
|
||||
);
|
||||
}
|
||||
private function iscaozuo()
|
||||
{
|
||||
if($this->adminid!=1 || getconfig('system')=='demo' || !getconfig('sysfileview'))return '禁止操作';
|
||||
return '';
|
||||
}
|
||||
|
||||
public function editAction()
|
||||
{
|
||||
if($str=$this->iscaozuo())return $str;
|
||||
$path = $this->jm->base64decode($this->get('path'));
|
||||
if(isempt($path))return '无效路径';
|
||||
if(!file_exists($path))return '文件不存在';
|
||||
$pathinfo=pathinfo($path);
|
||||
|
||||
$filename = $pathinfo['basename'];
|
||||
$filesize = filesize($path);
|
||||
$content = file_get_contents($path);
|
||||
$encode = mb_detect_encoding($content, array('ASCII','UTF-8','GB2312','GBK','BIG5'));
|
||||
|
||||
if($encode && $encode != "UTF-8"){
|
||||
$content = iconv($encode,'utf-8',$content);
|
||||
}
|
||||
|
||||
$this->smartydata['filename'] = $filename;
|
||||
$fileext = strtolower(substr($path,strripos($path,'.')+1));
|
||||
$this->smartydata['fileext'] = $fileext;
|
||||
$this->smartydata['content'] = $content;
|
||||
$this->smartydata['filepath'] = $this->jm->base64encode($path);
|
||||
$this->smartydata['filesize'] = $this->rock->formatsize($filesize);
|
||||
}
|
||||
|
||||
private function delfolder($path)
|
||||
{
|
||||
$this->fileall = array();
|
||||
$this->folderall = array();
|
||||
$this->getallfile($path);
|
||||
$total = count($this->fileall);
|
||||
if($this->fileall)foreach($this->fileall as $file)unlink($file);
|
||||
if($this->folderall)foreach($this->folderall as $file)rmdir($file);
|
||||
if(is_dir($path))rmdir($path);
|
||||
return '共删除'.$total.'个文件';
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理
|
||||
*/
|
||||
public function clearlogsAjax()
|
||||
{
|
||||
if($str=$this->iscaozuo())return $str;
|
||||
$path = ''.UPDIR.'/logs';
|
||||
return $this->delfolder($path);
|
||||
}
|
||||
private function getallfile($path)
|
||||
{
|
||||
$dir_arr = @scandir($path);
|
||||
$darr1= $rows = array();
|
||||
if($dir_arr)foreach($dir_arr as $key=>$val){
|
||||
if($val == '.' || $val == '..'){
|
||||
}else{
|
||||
$mulu = $path.'/'.$val.'';
|
||||
if(is_dir($mulu)){
|
||||
$this->getallfile($mulu);
|
||||
$this->folderall[] = $mulu;
|
||||
}else{
|
||||
$this->fileall[] = $mulu;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*/
|
||||
public function delfileAjax()
|
||||
{
|
||||
if($str=$this->iscaozuo())return $str;
|
||||
$path = $this->jm->base64decode($this->get('path'));
|
||||
if(isempt($path))return '无效文件';
|
||||
$isdel = 0;
|
||||
foreach($this->isdelmu as $sdif)if(strpos($path, $sdif)===0)$isdel=1;
|
||||
if($isdel==0)return '此文件禁止删除';
|
||||
if(is_dir($path))return $this->delfolder($path);
|
||||
unlink($path);
|
||||
return '删除成功';
|
||||
}
|
||||
|
||||
public function svnupdateAjax()
|
||||
{
|
||||
$cmd = '"'.getconfig('svnpath').'" /command:update /closeonend:1 /path:"'.ROOT_PATH.'"';
|
||||
c('socket')->udpsend($cmd);
|
||||
return '已发送svn更新';
|
||||
}
|
||||
}
|
||||
137
webmain/system/sysfile/tpl_sysfile_edit.html
Normal file
137
webmain/system/sysfile/tpl_sysfile_edit.html
Normal file
@@ -0,0 +1,137 @@
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title><?=$da['filename']?></title>
|
||||
<script type="text/javascript" src="js/jquery.js"></script>
|
||||
<script type="text/javascript" src="js/js.js"></script>
|
||||
<link rel="shortcut icon" href="favicon.ico" />
|
||||
<style>
|
||||
|
||||
</style>
|
||||
<script>
|
||||
var fileext = '<?=$da['fileext']?>';
|
||||
function save(o1){
|
||||
var cont = get('content').innerText;
|
||||
js.setmsg('保存中...');
|
||||
o1.disabled = true;
|
||||
js.ajax({
|
||||
type:'post',
|
||||
url:'?m=sysfile&a=savefile&path=<?=$da['filepath']?>',
|
||||
data:{content:cont},
|
||||
success:function(res){
|
||||
if(res=='ok'){
|
||||
js.setmsg('保存成功,可修改继续保存','green');
|
||||
o1.disabled=false;
|
||||
}else{
|
||||
js.setmsg(res);
|
||||
o1.disabled=false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
function initbody(){
|
||||
var hei = winHb()-40;
|
||||
|
||||
$('#lineheihtss').css('height',''+hei+'px');
|
||||
$('#content').scroll(scrollss);
|
||||
|
||||
$('#content').css('height',''+(hei-10)+'px');
|
||||
$('#content').css('width',''+(winWb()-62)+'px');
|
||||
|
||||
var cont = get('content').innerHTML;
|
||||
var arr = cont.split("\n"),i,s1='';
|
||||
for(i=0;i<arr.length;i++){
|
||||
if(i>0)s1+='<br>';
|
||||
s1+=''+(i+1)+'';
|
||||
}
|
||||
$('#lineheiht').html(s1+'<br> ');
|
||||
|
||||
var sphe = ',php,js,java,';
|
||||
|
||||
|
||||
if(sphe.indexOf(','+fileext+',')>-1){
|
||||
//var rNote = /(?:^|\n|\r)\s*\/\/.*(?:\r|\n|$)|(\/\*(.|\s)*?\*\/)/g;
|
||||
var rNote = /(\/\*(.|\s)*?\*\/)/g;
|
||||
var emu = cont.match(rNote),st1;
|
||||
if(emu != null){
|
||||
for(i=0;i<emu.length; i++){
|
||||
st1=emu[i];
|
||||
cont = cont.replace(st1,'<span>'+st1+'</span>');
|
||||
}
|
||||
}
|
||||
get('content').innerHTML=phpjcq(cont,fileext);
|
||||
}
|
||||
if(fileext=='conf')confini(cont,'#');
|
||||
if(fileext=='ini')confini(cont,';');
|
||||
}
|
||||
|
||||
function phpjcq(cont, lx){
|
||||
if(lx=='php'){
|
||||
var jcz = 'include_once,$_GET,isset,unset,explode,foreach,isempt,if,else,extends,require,public,function,protected,array,return,echo,private,exit,is_numeric,property_exists,this'.split(','),i,reg;
|
||||
for(i=0;i<jcz.length;i++){
|
||||
reg = new RegExp(jcz[i], 'g');
|
||||
cont = cont.replace(reg,'<font>'+jcz[i]+'</font>');
|
||||
}
|
||||
}
|
||||
if(cont.indexOf('\/\/')==-1)return cont;
|
||||
var arr = cont.split("\n"),i,s1='',xu,s2;
|
||||
for(i=0;i<arr.length;i++){
|
||||
if(i>0)s1+='\n';
|
||||
s2 = arr[i]
|
||||
xu = s2.indexOf('\/\/');
|
||||
if(xu>-1 && s2.indexOf(':\/\/')==-1){
|
||||
s1+=s2.substr(0, xu)+'<span>'+s2.substr(xu)+'</span>';
|
||||
}else{
|
||||
s1+=s2;
|
||||
}
|
||||
}
|
||||
return s1;
|
||||
}
|
||||
function confini(cont, lx){
|
||||
var arr = cont.split("\n"),i,s1='';
|
||||
for(i=0;i<arr.length;i++){
|
||||
if(i>0)s1+='\n';
|
||||
if(arr[i].indexOf(lx)==0 || arr[i].indexOf(' '+lx)==0){
|
||||
s1+='<span>'+arr[i]+'</span>';
|
||||
}else{
|
||||
s1+=arr[i];
|
||||
}
|
||||
}
|
||||
get('content').innerHTML=s1;
|
||||
}
|
||||
|
||||
function scrollss(){
|
||||
get('lineheihtss').scrollTop=get('content').scrollTop;
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
pre span{color:#999999}
|
||||
pre font{color:blue}
|
||||
table {
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body style="background:white;padding:0px;margin:0px;overflow:hidden">
|
||||
<table style="width:100%;height:100%" border=0><tr>
|
||||
<td valign="top" style="background:#e4e4e4;"><div id="lineheihtss" style="width:50px;height:300px;overflow:hidden"><div style="line-height:20px;padding-top:5px;text-align:right;padding-right:3px;font-size:14px" id="lineheiht">1<br>2<br></div></div></td>
|
||||
<td valign="top" style="width:100%;height:100%;padding:0px">
|
||||
<div id="contentdiv" style="overflow:hidden;background:#caeccb;">
|
||||
<pre id="content" contenteditable="plaintext-only" style="height:100%;width:100%;border:0px #aaaaaa solid;background:none;line-height:20px;font-size:14px;overflow:auto;padding:5px;margin:0px;outline:none"><?=htmlspecialchars($da['content'])?></pre></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td style="height:40px;overflow:hidden">
|
||||
|
||||
<div ><span id="msgview">大小:<?=$da['filesize']?>,查找请用Ctrl+F</span>,文件:<?=$rock->jm->base64decode($da['filepath'])?></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user