$sql=$this->db->quoteInto("select * from g6ftpusers where name=?",$user->username);
$u=$this->db->fetchRow($sql);
if(empty($u))
{
$sql=$this->db->quoteInto("insert into g6ftpusers (domainid,name) values(1,?)",$user->username);
$this->db->query($sql);
$sql=$this->db->quoteInto("select id from g6ftpusers where domainid=1 and name=?",$user->username);
$a=$this->db->fetchRow($sql);
$userid=$a['id'];
/*这部分功能已经放在数据库中实现
$sql="insert into g6ftpusersettings (userid,configname,configvalue) (select ".$userid." as userid,configname,configvalue from g6ftpusersettings where userid=".$this->westdcid.")";
$this->db->query($sql);
*/
}else$userid=$u['id'];//g6ftp中的用户ID,非系统的用户ID
$this->pwd=$user->password;//初始化
$this->time=$user->time;
//判断用户密码是否失效,或用户一次下载数据已经达到上限
$sql=$this->db->quoteInto("select * from ftpuser where userid=?",$user->id);
$u=$this->db->fetchRow($sql);
if(empty($u)){
$sql=$this->db->quoteInto("update g6ftpusersettings set configvalue=? where configname='Password' and userid=".$userid,strtoupper('MD5:'.md5($user->password)));
$this->db->query($sql);
$this->getwestdcpath();
$sql=$this->db->quoteInto("update g6ftpusersettings set configvalue=? where configname='AccessList' and userid=".$userid,$this->getuserpath($user->path));
$this->db->query($sql);
//插入ftpuser信息
$sql="insert into ftpuser (userid,pwd,ts_created,ts_invalid,datacount) values(?,?,now(),?,1)";
$sql=$this->db->quoteInto("update g6ftpusersettings set configvalue=? where configname='Password' and userid=".$userid,strtoupper('MD5:'.md5($user->password)));
$this->db->query($sql);
$this->getwestdcpath();
$sql=$this->db->quoteInto("update g6ftpusersettings set configvalue=? where configname='AccessList' and userid=".$userid,$this->getuserpath($user->path));
$this->db->query($sql);
$sql="update ftpuser set pwd=?,ts_created=now(),ts_invalid=?,datacount=1 where userid=?";
$sql=$this->db->quoteInto("update g6ftpusersettings set configvalue=configvalue||'\n'||? where configname='AccessList' and userid=".$userid,$this->getuserpath1($user->path));