โดย samyuranun » 16/08/2008 12:09 am
$username = $_REQUEST["username"];
function removeUserFTP($username){
$userDir = "C:\\AppServ\\www\\Project\\".$part."";
$fileloc = "C:\\Program Files\\FileZilla Server\\";
$filelocfile = ($fileloc."FileZilla Server.xml");
echo "Path : " . $filelocfile . "\n";
//$data = fread($fp,filesize($filelocfile));
//$regex = "#\\<User Name=\"" . preg_quote($username) . "\"\\>";
//$regex = strpos($data,'#\\<User Name="' . $username . '"');//find user name
//$regex = "#\\<User Name=\"" . preg_quote($username) . "\"\\>";
$config = file_get_contents($fileloc.'FileZilla Server.xml');
//$regex = "#\\<User Name=\"" . preg_quote($username) . "\"\\>";
//$regex .= "(.*?)";
//$regex .= "\\</User\\>#si";
$regex = "\\<User Name=\"" . preg_quote($username) . "\"\\>";
$regex .= "(.*?)";
$regex .= "\\</User\\>#si";
$nullText = "";
$filelocfile = preg_replace($regex,$nullText,$filelocfile);
$fp = fopen($filelocfile,"w");
fwrite($fp, $config);
fclose($fp);
system('"' . $fileloc.'FileZilla server.exe' . '"' . '/reload-config');
echo "remove userFTP OK";//did not add user, user name already used
return(true);
////////////////
// end add filezilla user
////////////////
}
if($username!="")
{
echo "<br>Username : ".$username;
if(removeUserFTP($username))
{
echo("<br>[FTP] User added succesfully <br><center>สำเร็จ</center><hr><br>");
} else
{
echo("<br>[FTP]Username taken <br><center>ไม่สำเร็จ</center><hr><hr>");
}
}
?>
<form method="POST" action="">
<p>
username :
<input type="text" name="username" />
<input type="submit" value="DEL"></p>
</form>
$username = $_REQUEST["username"];
function removeUserFTP($username){
$userDir = "C:\\AppServ\\www\\Project\\".$part."";
$fileloc = "C:\\Program Files\\FileZilla Server\\";
$filelocfile = ($fileloc."FileZilla Server.xml");
echo "Path : " . $filelocfile . "\n";
//$data = fread($fp,filesize($filelocfile));
//$regex = "#\\<User Name=\"" . preg_quote($username) . "\"\\>";
//$regex = strpos($data,'#\\<User Name="' . $username . '"');//find user name
//$regex = "#\\<User Name=\"" . preg_quote($username) . "\"\\>";
$config = file_get_contents($fileloc.'FileZilla Server.xml');
//$regex = "#\\<User Name=\"" . preg_quote($username) . "\"\\>";
//$regex .= "(.*?)";
//$regex .= "\\</User\\>#si";
$regex = "\\<User Name=\"" . preg_quote($username) . "\"\\>";
$regex .= "(.*?)";
$regex .= "\\</User\\>#si";
$nullText = "";
$filelocfile = preg_replace($regex,$nullText,$filelocfile);
$fp = fopen($filelocfile,"w");
fwrite($fp, $config);
fclose($fp);
system('"' . $fileloc.'FileZilla server.exe' . '"' . '/reload-config');
echo "remove userFTP OK";//did not add user, user name already used
return(true);
////////////////
// end add filezilla user
////////////////
}
if($username!="")
{
echo "<br>Username : ".$username;
if(removeUserFTP($username))
{
echo("<br>[FTP] User added succesfully <br><center>สำเร็จ</center><hr><br>");
} else
{
echo("<br>[FTP]Username taken <br><center>ไม่สำเร็จ</center><hr><hr>");
}
}
?>
<form method="POST" action="">
<p>
username :
<input type="text" name="username" />
<input type="submit" value="DEL"></p>
</form>