修正proftp类并实现实时FTP用户控制
This commit is contained in:
parent
5195b58268
commit
56f317030e
|
@ -370,8 +370,8 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
$rs=$this->db->fetchAll($sql,array($finish));
|
||||
$has_ftp1=false;
|
||||
foreach($rs as $data) {
|
||||
if ($data['host']=='ftp1.westgis.ac.cn')
|
||||
$has_ftp1=true;
|
||||
if ($data['host']=='ftp1.westgis.ac.cn')
|
||||
$has_ftp1=true;
|
||||
// deal with ftp.westgis.ac.cn, use g6 to add path
|
||||
// todo ...
|
||||
}
|
||||
|
@ -381,7 +381,9 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
"username"=>"westdc_".$row['userid'],
|
||||
"password"=>md5('westdc'.$row['userid'].rand(1000,9999)),
|
||||
"time"=>date('Y-m-d H:i:s', strtotime('+2 week')),
|
||||
//"path"=>$path,
|
||||
//"path"=>$path,
|
||||
"param"=>"offlineappid=".$finish,
|
||||
"host"=>'ftp1.westgis.ac.cn',
|
||||
"maxdata"=>$this->view->config->download->max,
|
||||
"datacount"=>1 //represent one offline application
|
||||
);
|
||||
|
|
|
@ -7,7 +7,29 @@ class Proftp
|
|||
function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
// deal with online & offline user
|
||||
// online user, $user->param is 'onlineappid=xx', xx is number
|
||||
// offline user, $user->param is 'offlineid=xx', xx is number
|
||||
function createuser($user)
|
||||
{
|
||||
$this->insert_user($user);
|
||||
//处理FTP用户目录
|
||||
if (!empty($user->host))
|
||||
{
|
||||
//vist $user->host web
|
||||
$page=file_get_contents('http://'.$user->host.'/proftp.php?'.$user->param);
|
||||
if (!empty($page) die($page);//there are errors in visit ftp page
|
||||
}
|
||||
return $this->update_pwd($user);
|
||||
}
|
||||
|
||||
/*
|
||||
* insert user into pureftp table
|
||||
* param $user: username,
|
||||
* return null
|
||||
*/
|
||||
private function insert_user($user)
|
||||
{
|
||||
//只插入到users表中
|
||||
$sql=$this->db->quoteInto("select * from proftpusers where userid=?",$user->username);
|
||||
|
@ -19,6 +41,14 @@ class Proftp
|
|||
$sql="insert into proftpusers (userid,passwd,uid,gid,homedir) values('".$user->username."','".$user->password."',109,1002,'".'/home/ftp/'.$user->username."')";
|
||||
$this->db->query($sql);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
//判断用户密码是否失效,或用户一次下载数据已经达到上限
|
||||
|
@ -49,7 +79,7 @@ class Proftp
|
|||
$this->time=$u['ts_invalid'];
|
||||
return true;
|
||||
} else //同时下载数据数超过限制
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue