实现pureftp离线数据支持
This commit is contained in:
parent
be977393de
commit
77fc6f0b4c
|
@ -52,7 +52,7 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
$mail->addTo($row['email']);
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->setFrom($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->send();
|
||||
|
||||
$sql="select pdflink from offlineapp where id=?";
|
||||
|
@ -82,12 +82,12 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
unset($mail);
|
||||
$mail = new WestdcMailer($this->view->config->smtp);
|
||||
$mailtp=new EmailText($this->db,'offline-start-subject',array('user'=>$username,'datalist'=>$data,'source'=>$source));
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->setFrom($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
$mail_addrs=explode(",",substr($tmp_email,1,-1));
|
||||
$mail->addTo($mail_addrs);
|
||||
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addCc($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||
$mail->send();
|
||||
$data="";
|
||||
|
@ -97,7 +97,7 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
$source=$row['sourcetitle'];
|
||||
}
|
||||
$data.=" 数据名称:".$row['title']."\n";
|
||||
$data.=" \t数据地址:http://westdc.westgis.ac.cn/data/".$row['uuid']."\n\n";
|
||||
$data.=" \t数据地址:http://deep.qherc.org/data/".$row['uuid']."\n\n";
|
||||
$uuid_done.="'".$row['uuid']."',";
|
||||
}
|
||||
//发送最后一封邮件
|
||||
|
@ -106,12 +106,12 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
unset($mail);
|
||||
$mail = new WestdcMailer($this->view->config->smtp);
|
||||
$mailtp=new EmailText($this->db,'offline-start-author',array('user'=>$username,'datalist'=>$data,'source'=>$source));
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->setFrom($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
$mail_addrs=explode(",",substr($tmp_email,1,-1));
|
||||
$mail->addTo($mail_addrs);
|
||||
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addCc($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||
$mail->send();
|
||||
}
|
||||
|
@ -135,11 +135,11 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
unset($mail);
|
||||
$mail = new WestdcMailer($this->view->config->smtp);
|
||||
$mailtp=new EmailText($this->db,'offline-start-author',array('user'=>$username,'datalist'=>$data));
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->setFrom($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
$mail->addTo($tmp_email);
|
||||
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addCc($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||
$mail->send();
|
||||
$data="";
|
||||
|
@ -147,9 +147,9 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
$tmp_email=$row['email'];
|
||||
}
|
||||
$data.=" 数据名称:".$row['title']."\n";
|
||||
$data.=" \t数据地址:http://westdc.westgis.ac.cn/data/".$row['uuid']."\n";
|
||||
$data.=" \t数据地址:http://deep.qherc.org/data/".$row['uuid']."\n";
|
||||
$data.=" \t如您不想收到此类数据申请审核的邮件,您可以将该数据委托给数据中心代为审核,委托后您也可以随时撤销此委托以便继续自行管理。\n";
|
||||
$data.=" \t如想委托给数据中心,请访问此网址:http://westdc.westgis.ac.cn/author/delegate/uuid/".$row['uuid']."\n";
|
||||
$data.=" \t如想委托给数据中心,请访问此网址:http://deep.qherc.org/author/delegate/uuid/".$row['uuid']."\n";
|
||||
$data.=" \t撤销委托方法:进入数据中心->数据作者->我的数据,在该数据条上撤销委托。\n\n";
|
||||
$uuid_done.="'".$row['uuid']."',";
|
||||
}
|
||||
|
@ -159,11 +159,11 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
unset($mail);
|
||||
$mail = new WestdcMailer($this->view->config->smtp);
|
||||
$mailtp=new EmailText($this->db,'offline-start-author',array('user'=>$username,'datalist'=>$data));
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->setFrom($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
$mail->addTo($tmp_email);
|
||||
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addCc($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||
$mail->send();
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
foreach($rows as $row)
|
||||
{
|
||||
$data.=" 数据名称:".$row['title']."\n";
|
||||
$data.=" \t数据地址:http://westdc.westgis.ac.cn/data/".$row['uuid']."\n\n";
|
||||
$data.=" \t数据地址:http://deep.qherc.org/data/".$row['uuid']."\n\n";
|
||||
$uuid_done.="'".$row['uuid']."',";
|
||||
}
|
||||
if (!empty($data))
|
||||
|
@ -187,15 +187,13 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
unset($mail);
|
||||
$mail = new WestdcMailer($this->view->config->smtp);
|
||||
$mailtp=new EmailText($this->db,'offline-start-dcadmin',array('user'=>$username,'datalist'=>$data));
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->setFrom($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
$addrs=array();
|
||||
$addrs[] = 'nztong@lzb.ac.cn';
|
||||
$addrs[] = 'wjian@lzb.ac.cn';
|
||||
$addrs[] = 'lixin@lzb.ac.cn';
|
||||
$addrs[] = 'wangliangxu@lzb.ac.cn';
|
||||
$mail->addTo($addrs);
|
||||
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addCc($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||
$mail->send();
|
||||
}
|
||||
|
@ -315,11 +313,11 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
unset($mail);
|
||||
$mail = new WestdcMailer($this->view->config->smtp);
|
||||
$mailtp=new EmailText($this->db,'offline-start-mdadmin',array('user'=>$username,'datalist'=>$data));
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->setFrom($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
$mail->addTo($tmp_email);
|
||||
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addCc($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||
$mail->send();
|
||||
$data='';
|
||||
|
@ -327,7 +325,7 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
$tmp_email=$row;
|
||||
}
|
||||
$data.=" 数据名称:".$newmd['title'][$k]."\n";
|
||||
$data.=" \t数据地址:http://westdc.westgis.ac.cn/data/".$newmd['uuid'][$k]."\n";
|
||||
$data.=" \t数据地址:http://deep.qherc.org/data/".$newmd['uuid'][$k]."\n";
|
||||
$data.=" \t如您不想收到此类数据申请审核的邮件,您可以在按如下操作办法进行处理:1. 申请成为该数据作者;2. 将该数据委托给数据中心代为审核,委托后您也可以随时撤销此委托以便继续自行管理。\n";
|
||||
$data.=" \t如要申请成为该数据作者:进入数据中心->数据作者->数据认证,查找到对应的数据后,在其下方点击申请认证即可。\n\n";
|
||||
}
|
||||
|
@ -336,11 +334,11 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
unset($mail);
|
||||
$mail = new WestdcMailer($this->view->config->smtp);
|
||||
$mailtp=new EmailText($this->db,'offline-start-mdadmin',array('user'=>$username,'datalist'=>$data));
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->setFrom($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
$mail->addTo($tmp_email);
|
||||
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addCc($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->createAttachment($filecontent,'application/octet-stream',Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, 'offlineapp.pdf');
|
||||
$mail->send();
|
||||
}
|
||||
|
@ -369,25 +367,27 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
$sql="select * from dataorder left join dataset on dataset.uuid=dataorder.uuid where dataorder.offlineappid=?";
|
||||
$rs=$this->db->fetchAll($sql,array($finish));
|
||||
$has_ftp1=false;
|
||||
$path=array();
|
||||
foreach($rs as $data) {
|
||||
if ($data['host']=='ftp1.westgis.ac.cn')
|
||||
if ($data['host']=='deep.qherc.org')
|
||||
{
|
||||
$has_ftp1=true;
|
||||
// deal with ftp.westgis.ac.cn, use g6 to add path
|
||||
// todo ...
|
||||
$path[]=$data['path'];
|
||||
}
|
||||
//deal with ftp1 account
|
||||
}
|
||||
//deal with ftp account
|
||||
if ($has_ftp1) {
|
||||
$user=(object)array("id"=>$row['userid'],
|
||||
"username"=>"westdc_".$row['userid'],
|
||||
"password"=>md5('westdc'.$row['userid'].rand(1000,9999)),
|
||||
"username"=>"qherc".$row['userid'],
|
||||
"password"=>md5('qherc'.$row['userid'].rand(1000,9999)),
|
||||
"time"=>date('Y-m-d H:i:s', strtotime('+2 week')),
|
||||
//"path"=>$path,
|
||||
"path"=>$path,
|
||||
"maxdata"=>$this->view->config->download->max,
|
||||
"datacount"=>1 //represent one offline application
|
||||
);
|
||||
$proftp=new Proftp();
|
||||
$proftp=new Purerftp();
|
||||
$proftp->db=$this->db;
|
||||
if ($proftp->createuser($user))
|
||||
if (!$proftp->createuser($user))
|
||||
{
|
||||
$user->datacount=0; //force this offline to be true
|
||||
$proftp->createuser($user);
|
||||
|
@ -400,9 +400,9 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
array('user'=>$row['username'],'datalist'=>str_replace(";","\n",$row['datalist']),
|
||||
'ftpuser'=>$user->username,'ftppwd'=>$proftp->pwd,'ftptime'=>$proftp->time));
|
||||
$mail->setBodyText($mailtp->getBody());
|
||||
$mail->setFrom($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->setFrom($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->addTo($row['email']);
|
||||
$mail->addCc($this->view->config->service->email,'西部数据中心服务组');
|
||||
$mail->addCc($this->view->config->service->email,$this->view->config->service->poster);
|
||||
$mail->setSubject($mailtp->getSubject());
|
||||
$mail->send();
|
||||
} //ftp1 deal
|
||||
|
|
|
@ -4,10 +4,36 @@ class Pureftp
|
|||
public $db;
|
||||
public $pwd;
|
||||
public $time;
|
||||
public $data_path='/home/wlx/qhhdata';
|
||||
|
||||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
// deal with online & offline user
|
||||
// online user, the $user->path is a string, which is a path omit the $data_path (e.g., /test/data means the physical path is $data_path/test/data)
|
||||
// offline user, the $user->path is an array of string
|
||||
function createuser($user)
|
||||
{
|
||||
insert_user($user);
|
||||
// add system link directory
|
||||
if (is_array($user->path))
|
||||
{
|
||||
foreach ($user->path as $path)
|
||||
symlink($path,'/home/ftp/'.$user->username.'/'.str_replace('/','-',substr($path,strlen($this->data_path)+1)));
|
||||
} else {
|
||||
//online path, only one path
|
||||
symlink($this->data_path.$user->path,'/home/ftp/'.$user->username.'/'.str_replace('/','-',substr($user->path,1)));
|
||||
}
|
||||
return update_pwd($user);
|
||||
}
|
||||
|
||||
/*
|
||||
* insert user into pureftp table
|
||||
* param $user: username,
|
||||
* return null
|
||||
*/
|
||||
private function insert_user($user)
|
||||
{
|
||||
//插入到pureftp表中
|
||||
$sql=$this->db->quoteInto("select * from pureftp where userid=?",$user->username);
|
||||
|
@ -19,9 +45,15 @@ class Pureftp
|
|||
//create user home dir
|
||||
mkdir('/home/ftp/'.$user->username);
|
||||
}
|
||||
// add system link directory
|
||||
symlink('/home/wlx/qhhdata'.$user->path,'/home/ftp/'.$user->username.'/'.str_replace('/','-',substr($user->path,1)));
|
||||
}
|
||||
|
||||
/*
|
||||
* update password in the table used by pureftp
|
||||
* param $user: password,id,time,username
|
||||
* return: bool
|
||||
*/
|
||||
private function update_pwd($user)
|
||||
{
|
||||
$this->pwd=$user->password;//初始化
|
||||
$this->time=$user->time;
|
||||
//判断用户密码是否失效,或用户一次下载数据已经达到上限
|
||||
|
|
Loading…
Reference in New Issue