修正proftp类并实现实时FTP用户控制
This commit is contained in:
parent
5195b58268
commit
56f317030e
|
@ -382,6 +382,8 @@ class Admin_DownController extends Zend_Controller_Action
|
|||
"password"=>md5('westdc'.$row['userid'].rand(1000,9999)),
|
||||
"time"=>date('Y-m-d H:i:s', strtotime('+2 week')),
|
||||
//"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;
|
||||
//判断用户密码是否失效,或用户一次下载数据已经达到上限
|
||||
|
|
Loading…
Reference in New Issue