merge sanjiangyuan-sub branch r4872 - r4922 into sjy-conservation
This commit is contained in:
commit
78a88ffcaf
|
@ -2693,7 +2693,129 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
return;
|
||||
}
|
||||
|
||||
public function ftpAction()
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$uuid = $this->_getParam('uuid');
|
||||
|
||||
$this->view->uuid = $uuid;
|
||||
$submd=$this->view->config->sub->metadata;
|
||||
|
||||
if(empty($uuid) || !preg_match("/^[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{4}-[0-9A-Za-z]{12}$/",$uuid))
|
||||
{
|
||||
$data = array(
|
||||
'error'=>"参数错误"
|
||||
);
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
//安全检查: uuid必须是当前子平台数据
|
||||
$sql="select * from $submd where uuid=?";
|
||||
$sth=$this->db->prepare($sql);
|
||||
$sth->execute(array($uuid));
|
||||
$row=$sth->fetch();
|
||||
if (empty($row))
|
||||
{
|
||||
$data = array(
|
||||
'error'=>"参数错误"
|
||||
);
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
|
||||
//ftp admin 用户名
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$uid=$auth->getIdentity()->id;
|
||||
$uname = $submd.'admin'.$uid;
|
||||
|
||||
//ftp路径
|
||||
$homedir = "/data/upload/".$uuid."/";
|
||||
//ftp用户表
|
||||
$ftptable=' pureftp ';//ftp2.westgis.ac.cn
|
||||
$uid = 1002;
|
||||
$gid = 1002;
|
||||
|
||||
$sql = "SELECT * FROM $ftptable WHERE userid='$uname' ORDER BY pkid DESC";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute();
|
||||
$row = $sth->fetch();
|
||||
|
||||
//create directory for upload
|
||||
//server is not localhost, so we need a trick
|
||||
//$old=umask(0);
|
||||
//@mkdir($homedir,0777);
|
||||
//umask($old);
|
||||
$page=file_get_contents('http://ftp.sanjiangyuan.org.cn/proftp_upload.php?uuid='.$uuid);
|
||||
if (!empty($page)) die($page);//there are errors in visit ftp page
|
||||
|
||||
|
||||
if(!empty($row['pkid']))
|
||||
{
|
||||
if(preg_match("/.*".$uuid.".*/",$row['homedir']))
|
||||
{
|
||||
$data = array(
|
||||
'statu'=>1,
|
||||
'user'=>$row['userid'],
|
||||
'passwd'=>$row['passwd']
|
||||
);
|
||||
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
|
||||
}else{
|
||||
$passwd = $this->genRandomString(16);
|
||||
//$sql = "UPDATE proftpusers SET passwd=?,uid=?,gid=?,homedir=? WHERE userid=?";
|
||||
//$sth = $this->db->prepare($sql);
|
||||
//$rs = $sth->execute(array($passwd,$uid,$gid,$homedir,$uname));
|
||||
$sql="update ".$ftptable." SET passwd='".$passwd."',uid=".$uid.",gid=".$gid.",homedir='".$homedir."' WHERE userid='".$uname."'";
|
||||
$rs=$this->db->query($sql);
|
||||
if($rs)
|
||||
{
|
||||
$data = array(
|
||||
'statu'=>1,
|
||||
'user'=>$uname,
|
||||
'passwd'=>$passwd
|
||||
);
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}else{
|
||||
$data = array(
|
||||
'error'=>"FTP信息更新失败,请重试"
|
||||
);
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
$passwd = $this->genRandomString(16);
|
||||
|
||||
//$sql = "INSERT INTO proftpusers (userid,passwd,uid,gid,homedir) VALUES (?,?,?,?,?)";
|
||||
//$sth = $this->db->prepare($sql);
|
||||
//$rs = $sth->execute(array($uname,$passwd,$uid,$gid,$homedir));
|
||||
$sql="insert into ".$ftptable." (userid,passwd,uid,gid,homedir) values('".$uname."','".$passwd."',".$uid.",".$gid.",'".$homedir."')";
|
||||
$rs=$this->db->query($sql);
|
||||
if($rs)
|
||||
{
|
||||
$data = array(
|
||||
'statu'=>1,
|
||||
'user'=>$uname,
|
||||
'passwd'=>$passwd
|
||||
);
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}else{
|
||||
$data = array(
|
||||
'error'=>"FTP信息更新失败,请重试"
|
||||
);
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}//end if
|
||||
}
|
||||
|
||||
/*
|
||||
获得单个文件的信息
|
||||
|
@ -2718,4 +2840,26 @@ class Admin_DataController extends Zend_Controller_Action
|
|||
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(json_encode($data,JSON_NUMERIC_CHECK));
|
||||
return true;
|
||||
}//jsonexit() 退出并返回json数据
|
||||
|
||||
private function genRandomString($len)
|
||||
{
|
||||
$chars = array(
|
||||
"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", "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", "0", "1", "2",
|
||||
"3", "4", "5", "6", "7", "8", "9"
|
||||
);
|
||||
$charsLen = count($chars) - 1;
|
||||
|
||||
shuffle($chars); // 将数组打乱
|
||||
|
||||
$output = "";
|
||||
for ($i=0; $i<$len; $i++)
|
||||
{
|
||||
$output .= $chars[mt_rand(0, $charsLen)];
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,10 @@
|
|||
<li class="nav-header"><h4>数据管理</h4></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="/admin/data/md">元数据管理</a></li>
|
||||
<li><a href="/admin/data/newdata">新建元数据</a></li>
|
||||
<li><a href="/admin/data/author">数据作者管理</a></li>
|
||||
<li><a href="/admin/data/version">数据版本管理</a></li>
|
||||
<li><a href="/admin/data/comment">数据反馈管理</a></li>
|
||||
<li><a href="/admin/data/attachments">数据附件管理</a></li>
|
||||
<li><a href="/admin/data/fund">支持项目</a></li>
|
||||
<li><a href="/admin/data/visual">可视化数据</a></li>
|
||||
</ul>
|
||||
</div>
|
|
@ -73,7 +73,8 @@
|
|||
<?php endif;?>
|
||||
<a href="/admin/down/sendmail/uuid/<?php echo $item['uuid'];?>" title="向数据下载者发送通知邮件">邮件通知</a> |
|
||||
<a href="/admin/data/fund/uuid/<?php echo $item['uuid'];?>">支持项目</a> |
|
||||
<a href="/admin/data/visual/uuid/<?php echo $item['uuid'];?>">数据可视化</a>
|
||||
<a href="/admin/data/visual/uuid/<?php echo $item['uuid'];?>">数据可视化</a> |
|
||||
<a href="javascript:void(0);" onclick="getFtp('<?= $item['uuid'] ?>')">FTP数据管理</a>
|
||||
</p>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
|
@ -89,4 +90,36 @@ $(".inline").colorbox({inline:true, width:"50%"});
|
|||
function Alert(html){
|
||||
$.colorbox({'innerWidth':'50%','html':'<h4 style="font-size:16px;font-weight:bold;">'+html+'</h4>'});
|
||||
}
|
||||
function getFtp(uuid){
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':'/admin/data/ftp/uuid/'+uuid,
|
||||
'data':'',
|
||||
'success':function(data){
|
||||
if (typeof(data)=='object')
|
||||
{
|
||||
if(typeof(data.error)!='undefined')
|
||||
{Alert(data.error);return false;}
|
||||
if(typeof(data.statu)!='undefined')
|
||||
{
|
||||
if(data.statu > 0)
|
||||
{
|
||||
var html = '<p>临时FTP帐号信息<b>(此帐号仅对应当前数据集!)</b></p><p>ftp://ftp.sanjiangyuan.org.cn/</p>'+
|
||||
'<p>用户名:'+data.user+
|
||||
'</p><p>密码:'+data.passwd+'</p>'
|
||||
+'<p><a href="ftp://'+data.user+':'+data.passwd+'@ftp.sanjiangyuan.org.cn/">或直接点击此链接</a></p>';
|
||||
Alert(html);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
Alert('出现错误,请稍候再试</h4>');
|
||||
}
|
||||
},
|
||||
'timeout': 30000,
|
||||
'error': function(){
|
||||
Alert('处理中出现错误,请刷新页面后重试</h4>');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
|
@ -34,13 +34,13 @@ $this->headLink()->appendStylesheet('/css/news.css');
|
|||
</div>
|
||||
</div>
|
||||
<div class="span9" id="archive_body">
|
||||
<h3 class="text-center"><?php echo $this->infos['title'];?></h3>
|
||||
<div class="text-center">[<?php echo date("Y-m-d",strtotime($this->infos['ts_published']));?>] 来源 : <?php echo $this->infos['source'];?></div>
|
||||
<h3 class="text-center" style="font-family:'微软雅黑', '宋体'; color:#08c"><?php echo $this->infos['title'];?></h3>
|
||||
<div class="text-center" style="font-size:11px; color:#BCBCBC"> 发布时间 : <span style="font-size:11px; color:#08c"><?php echo date("Y-m-d",strtotime($this->infos['ts_published']));?></span> 来源 : <span style="font-size:11px; color:#08c"><?php echo $this->infos['source'];?></span></div>
|
||||
<?php if(!empty($this->mdinfo)){?>
|
||||
<?php foreach($this->mdinfo as $v){ ?>
|
||||
<div class="info">相关数据:《<a href="/data/<?= $v['uuid']?>"><?= $v['title']?></a>》</div>
|
||||
<?php } } ?>
|
||||
<div class="media">
|
||||
<div class="media" style="font-family:'微软雅黑','宋体';font-size:18px; line-height:200%">
|
||||
<div class="pull-left">
|
||||
<?php echo $this->infos['body'];?>
|
||||
</div>
|
||||
|
|
|
@ -154,9 +154,13 @@ class Order
|
|||
$uid = view::User('id');
|
||||
}
|
||||
|
||||
$sql = "select count(*) as cnt from dataorder where status=1 and uuid in (select uuid from $this->config->sub->metadata) and userid=".$uid;
|
||||
$row=$this->db->FetchRow($sql);
|
||||
if ($row['cnt']>=$this->config->download->max) return "一次申请不能大于5条数据!请移除部分数据。";
|
||||
|
||||
if($id == -1)
|
||||
{
|
||||
$sql = $this->db->quoteInto("update dataorder set status=2 where status=1 and userid=?",$uid);
|
||||
$sql = $this->db->quoteInto("update dataorder set status=2 where status=1 and uuid in (select uuid from $this->config->sub->metadata) and userid=?",$uid);
|
||||
if($this->db->exec($sql))
|
||||
{
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue