将黑河上传的服务器切换为ftp1服务器
This commit is contained in:
parent
f00639b9d2
commit
93e4f1859b
|
@ -508,72 +508,11 @@ class HeiheController extends DataController
|
|||
// 2. 保存变化记录 save changelog & userid for the latest version
|
||||
$sql = "UPDATE mdversion SET changelog=?,userid=? WHERE id in (select id from mdversion where uuid=? order by ts_created desc limit 1)";
|
||||
$this->db->query($sql,array($changelog,$u_id,$row['uuid']));
|
||||
|
||||
// 处理文件权限和数据信息
|
||||
$ftp_user = "heihe".$u_id."upload";
|
||||
$sql = "SELECT * FROM pureftp WHERE userid=? AND homedir LIKE ?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($ftp_user,'%'.$uuid.'%'));
|
||||
$row1 = $sth->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if(!empty($row1['passwd']))
|
||||
{
|
||||
$old=umask(0);
|
||||
//$this->chmodr($row1['homedir'],1444);
|
||||
umask($old);
|
||||
}
|
||||
|
||||
//$path = $row1['homedir'];
|
||||
$path = '/var/www/westdc.westgis.ac.cn/data/heihe_upload/'.$uuid.'/';
|
||||
|
||||
//delete dataset & datafile records
|
||||
$sql="delete from dataset where uuid=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array($uuid));
|
||||
file_get_contents("http://ftp1.westgis.ac.cn/proftp_upload.php?uuid=".$row['uuid']."&filelist=1");
|
||||
//自动添加数据分类为黑河
|
||||
$sql="insert into datasource (uuid,sourceid) values(?,1)";
|
||||
$sth=$this->db->prepare($sql);
|
||||
try{$sth->execute(array($uuid));}catch(Exception $e) {}
|
||||
|
||||
$sql = "INSERT INTO dataset (uuid,path) VALUES (?,?) RETURNING id";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$rs = $sth->execute(array($uuid,$path));
|
||||
|
||||
if(!$rs)
|
||||
{
|
||||
$messages[] = "元数据信息写入失败";
|
||||
/*
|
||||
$data = array("error"=>'元数据信息写入失败');
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
|
||||
$temp = $sth->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$dsid = $temp['id'];
|
||||
|
||||
$dir = new mydir();
|
||||
$files=$dir->recursive($path);
|
||||
|
||||
foreach ($files as $k=>$v)
|
||||
{
|
||||
//$pathinfo = pathinfo($path.$v);
|
||||
$filename = mb_substr($v,mb_strlen($path)+1);
|
||||
$filesize = filesize($v);
|
||||
$isdir=is_dir($v)?1:0;
|
||||
$depth=substr_count($filename,"/")+1;
|
||||
if (substr($filename,-1,1)=='/') $depth--;
|
||||
//$this->chmodr($path.$v,0444);
|
||||
$sql = "INSERT INTO datafile (dsid,filename,filesize,isdir,depth) VALUES (?,?,?,?,?)";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$rs = $sth->execute(array($dsid,$filename,$filesize,$isdir,$depth));
|
||||
if(!$rs)
|
||||
{
|
||||
$messages[] = "数据文件".$filename.'写入失败';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 3. 保存数据评审状态
|
||||
//导入元数据
|
||||
|
@ -637,7 +576,7 @@ class HeiheController extends DataController
|
|||
}//unsubmit
|
||||
|
||||
//FTP
|
||||
if($ac == "ftp")
|
||||
else if($ac == "ftp")
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
@ -666,22 +605,27 @@ class HeiheController extends DataController
|
|||
);
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//ftp 用户名
|
||||
$uname = 'heihe'.$u_id.'upload';
|
||||
$uname = 'westdc'.$u_id.'upload';
|
||||
|
||||
//ftp路径
|
||||
$homedir = "/var/www/westdc.westgis.ac.cn/data/heihe_upload/".$uuid."/";
|
||||
$homedir = "/disk1/WestDC/upload/".$uuid."/";
|
||||
|
||||
$sql = "SELECT * FROM pureftp WHERE userid='$uname' ORDER BY pkid DESC";
|
||||
$sql = "SELECT * FROM proftpusers WHERE userid='$uname' ORDER BY pkid DESC";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute();
|
||||
$row = $sth->fetch();
|
||||
|
||||
$old=umask(0);
|
||||
@mkdir($homedir,0777);
|
||||
umask($old);
|
||||
|
||||
//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://ftp1.westgis.ac.cn/proftp_upload.php?uuid='.$uuid);
|
||||
if (!empty($page)) die($page);//there are errors in visit ftp page
|
||||
|
||||
|
||||
if(!empty($row['pkid']))
|
||||
{
|
||||
|
@ -697,13 +641,15 @@ class HeiheController extends DataController
|
|||
return true;
|
||||
|
||||
}else{
|
||||
$uid = 1001;
|
||||
$gid = 1001;
|
||||
$uid = 109;
|
||||
$gid = 1002;
|
||||
|
||||
$passwd = $this->genRandomString(16);
|
||||
$sql = "UPDATE pureftp SET passwd=?,uid=?,gid=?,homedir=? WHERE userid=?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$rs = $sth->execute(array($passwd,$uid,$gid,$homedir,$uname));
|
||||
//$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 proftpusers SET passwd='".$passwd."',uid=".$uid.",gid=".$gid.",homedir='".$homedir."' WHERE userid='".$uname."'";
|
||||
$rs=$this->db->query($sql);
|
||||
if($rs)
|
||||
{
|
||||
$data = array(
|
||||
|
@ -724,13 +670,15 @@ class HeiheController extends DataController
|
|||
}
|
||||
|
||||
else{
|
||||
$uid = 1001;
|
||||
$gid = 1001;
|
||||
$uid = 109;
|
||||
$gid = 1002;
|
||||
$passwd = $this->genRandomString(16);
|
||||
|
||||
$sql = "INSERT INTO pureftp (userid,passwd,uid,gid,homedir) VALUES (?,?,?,?,?)";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$rs = $sth->execute(array($uname,$passwd,$uid,$gid,$homedir));
|
||||
//$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 proftpusers (userid,passwd,uid,gid,homedir) values('".$uname."','".$passwd."',109,1002,'".$homedir."')";
|
||||
$rs=$this->db->query($sql);
|
||||
if($rs)
|
||||
{
|
||||
$data = array(
|
||||
|
|
|
@ -99,7 +99,7 @@ function getFtp(uuid){
|
|||
{
|
||||
if(data.statu > 0)
|
||||
{
|
||||
var html = '<p>临时FTP帐号信息<b>(此帐号仅对应当前数据集!)</b></p><p>ftp://westdc.westgis.ac.cn/</p>'+
|
||||
var html = '<p>临时FTP帐号信息<b>(此帐号仅对应当前数据集!)</b></p><p>ftp://ftp1.westgis.ac.cn/</p>'+
|
||||
'<p>用户名:'+data.user+
|
||||
'</p><p>密码:'+data.passwd+'</p>'
|
||||
+'<p><a href="ftp://'+data.user+':'+data.passwd+'@westdc.westgis.ac.cn/">或直接点击此链接</a></p>';
|
||||
|
|
Loading…
Reference in New Issue