From 10bef61f5660717dd77e723e4861ef70f2f558e9 Mon Sep 17 00:00:00 2001 From: wlx Date: Mon, 8 Nov 2010 02:08:31 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BA=86SQL=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/models/Proftp.php | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/application/models/Proftp.php b/application/models/Proftp.php index 3fc9e043..6908e12a 100644 --- a/application/models/Proftp.php +++ b/application/models/Proftp.php @@ -14,12 +14,11 @@ class Proftp $u=$this->db->fetchRow($sql); if (empty($u)) { - $sql=$this->db->quoteInto("insert into proftpusers (userid,passwd,uid,gid,homedir) values(?,?,109,1002,?)",$user->username,$user->userpass,'/home/ftp/'.$user->username); - $this->db->query($sql); - $sql=$this->db->quoteInto("select pkid from proftpusers where userid=?",$user->username); - $a=$this->db->fetchRow($sql); - $userid = $a['pkid']; - } else $userid=$u['id'];//g6ftp中的用户ID,非系统的用户ID + //$sql="insert into proftpusers (userid,passwd,uid,gid,homedir) values(?,?,109,1002,?)"; + //$this->db->query($sql,array($user->username,$user->password,'/home/ftp/'.$user->username)); + $sql="insert into proftpusers (userid,passwd,uid,gid,homedir) values('".$user->username."','".$user->password."',109,1002,'".'/home/ftp/'.$user->username."')"; + $this->db->query($sql); + } $this->pwd=$user->password;//初始化 $this->time=$user->time; //判断用户密码是否失效,或用户一次下载数据已经达到上限 @@ -29,23 +28,20 @@ class Proftp //插入ftpuser信息 $sql="insert into ftpuser (userid,pwd,ts_created,ts_invalid,datacount) values(?,?,now(),?,1)"; $this->db->query($sql,array($user->id,$user->password,$user->time)); - //todo: create users home directory return true; } elseif (strtotime($u['ts_invalid'])<=time() or $u['datacount']<1) { - //更新用户密码、数据地址和数据计数 - //数据地址覆盖原来的信息 - //todo: 重置用户目录下的可用文件/目录。 - $sql=$this->db->quoteInto("update proftpusers set passwd=? where userid=?",$user->password,$user->username); + //更新用户密码和数据计数 + $sql="update proftpusers set passwd='".$user->password."' where userid='".$user->username."'"; + //$this->db->query($sql,array($user->password,$user->username)); $this->db->query($sql); $sql="update ftpuser set pwd=?,ts_created=now(),ts_invalid=?,datacount=1 where userid=?"; $this->db->query($sql,array($user->password,$user->time,$user->id)); return true; } elseif (strtotime($u['ts_invalid'])>time() && $u['datacount']<$user->maxdata) { - //更新数据地址和数据计数 - //数据地址要追加在原来的后面 - //需要判断数据是否已经在下载进程中 - $sql="update ftpuser set ts_invalid=?,datacount=? where userid=?"; - $this->db->query($sql,array($user->time,$user->datacount+1,$user->id)); + //更新数据计数 + //use the old password + $sql="update ftpuser set ts_invalid=?,datacount=datacount+? where userid=?"; + $this->db->query($sql,array($user->time,$user->datacount,$user->id)); $sql="select pwd,ts_invalid from ftpuser where userid=?"; $u=$this->db->fetchRow($sql,array($user->id)); $this->pwd=$u['pwd'];