จะลบ delete user ใน filezilla server โดยใช้ preg_replace

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: จะลบ delete user ใน filezilla server โดยใช้ preg_replace

Re: จะลบ delete user ใน filezilla server โดยใช้ preg_replace

by 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 :&nbsp;
<input type="text" name="username" />

<input type="submit" value="DEL"></p>
</form>

Re: จะลบ delete user ใน filezilla server โดยใช้ preg_replace

by samyuranun » 16/08/2008 12:08 am

ช่วยกันดูกันหน่อย

จะลบ delete user ใน filezilla server โดยใช้ preg_replace

by samyuranun » 08/08/2008 12:13 am

preg_replace ให้ ข้างหน้าเป็น#

มีอังกอแค่เนีย

$regex = strpos($data,'#\\<User Name="' . $username . '"' $regex .= "(.*?)";
$regex .= "\\</User\\>#si";
$config = preg_replace($regex, '', $config);


ทดสอบ
<?php
ksort($patterns);
ksort($replacements);
echo preg_replace($patterns, $replacements, $string);
?>

ปล.
Windos 2003 server str ,apache,php

Top