use umask to confirm upload directory could be writed in mkdir

This commit is contained in:
wlx 2012-09-17 03:55:22 +00:00
parent 3061660318
commit 1fe581f808
1 changed files with 6 additions and 5 deletions

View File

@ -487,7 +487,11 @@ class SubmitController extends Zend_Controller_Action
$sql = "SELECT * FROM pureftp WHERE userid='$uname' ORDER BY pkid DESC";
$sth = $this->db->prepare($sql);
$sth->execute();
$row = $sth->fetch();
$row = $sth->fetch();
$homedir = "/home/wlx/qhhdata/upload/".$uuid."/";
$old=umask(0);
@mkdir($homedir,0777);
umask($old);
if(!empty($row['pkid']))
{
@ -505,13 +509,11 @@ class SubmitController extends Zend_Controller_Action
}else{
$uid = 1001;
$gid = 1001;
$homedir = "/home/wlx/qhhdata/upload/".$uuid."/";
$passwd = $this->genRandomString(16);
$passwd = $this->genRandomString(16);
$sql = "UPDATE pureftp SET passwd=?,uid=?,gid=?,homedir=? WHERE userid=?";
$sth = $this->db->prepare($sql);
$rs = $sth->execute(array($passwd,$uid,$gid,$homedir,$uname));
@mkdir($homedir,0644);
if($rs)
{
$data = array(
@ -532,7 +534,6 @@ class SubmitController extends Zend_Controller_Action
}else{
$uid = 1001;
$gid = 1001;
$homedir = "/home/wlx/qhhdata/upload/".$uuid."/";
$passwd = $this->genRandomString(16);
$sql = "INSERT INTO pureftp (userid,passwd,uid,gid,homedir) VALUES (?,?,?,?,?)";