php change password "FileZilla Server.exe" /reload-config
Posted: 2009-04-08 11:15
I created a php page through a form that updates the user's password.
The file "FileZilla server.xml " is written with the updated password, but the FileZilla server does not reload the new configuration
I searched in this forum a way to refresh the configuration file "FileZilla Server.xml"
http://forum.filezilla-project.org/sear ... mit=Search
from the prompt the command work
"FileZilla Server.exe" /reload-config
but through a php page the command not work.
passthru('"C:\Programmi\FileZilla server\FileZilla Server.exe" /reload-config');
system('"C:\Programmi\FileZilla server\FileZilla Server.exe" /reload-config');
someone has a solution??
I am sorry for my bad English.
but the code is international
below my code
note:
the web user and the computer user are not the same,
for update the "FileZilla Server.xml" the web user must have write permission on the xml file.
if you want to use this code
update the value for $xmlfile="C:\..path...\FileZilla Server.xml"
and the path for passthru or system function.
ciao
Mario
The file "FileZilla server.xml " is written with the updated password, but the FileZilla server does not reload the new configuration
I searched in this forum a way to refresh the configuration file "FileZilla Server.xml"
http://forum.filezilla-project.org/sear ... mit=Search
from the prompt the command work
"FileZilla Server.exe" /reload-config
but through a php page the command not work.
passthru('"C:\Programmi\FileZilla server\FileZilla Server.exe" /reload-config');
system('"C:\Programmi\FileZilla server\FileZilla Server.exe" /reload-config');
someone has a solution??
I am sorry for my bad English.
but the code is international
below my code
note:
the web user and the computer user are not the same,
for update the "FileZilla Server.xml" the web user must have write permission on the xml file.
Code: Select all
<div name="" align="center">
<form name="form_FileZillaServer_change_user_pass" onload="clean_form()">
<table border="0" width="300" cellpadding="5" cellspacing="5">
<tr>
<td width="100%" colspan="2" align="center">cambia la tua password</td>
</tr>
<tr>
<td width="50%">nome utente</td>
<td width="50%"><input type="text" name="username" size="20" value="" onfocus="form.username.value=''";></td>
</tr>
<tr>
<td width="50%">password corrente</td>
<td width="50%"><input type="password" name="password" size="20" value=""></td>
</tr>
<tr>
<td width="50%">nuova password</td>
<td width="50%"><input type="password" name="new_password" size="20" value=""></td>
</tr>
<tr>
<td width="50%">riscrivi la nuova password</td>
<td width="50%"><input type="password" name="ceck_new_password" size="20" value=""></td>
</tr>
<tr>
<td width="100%" colspan="2" align="center">
<input type="button" value="Invia" name="" onclick="ceck_form();"> - <input type="button" value="Reimposta" name="" onclick="clean_form();"></td>
</tr>
</table>
</form>
<script>
form=document.form_FileZillaServer_change_user_pass;
function ceck_form(){
if(form.username.value == '' ){
alert('inserisci il nome utente');
form.username.focus();
return;
}
if(form.password.value == ''){
alert('inserisci la tua password');
form.password.focus();
return;
}
if(form.new_password.value == '' ){
alert('inserisci la nuova password');
form.new_password.focus();
return;
}
if(form.ceck_new_password.value == ''){
alert('riscrivi la nuova password');
form.ceck_new_password.focus();
return;
}
if(form.ceck_new_password.value != form.new_password.value){
alert('controllo della nuova password fallito\n\nreinserisci i valori');
form.ceck_new_password.value = '';
form.new_password.value = '';
form.new_password.focus();
return;
}
if(form.ceck_new_password.value == form.new_password.value && form.password.value == form.new_password.value){
alert('la password che desideri modificare e\' uguale alla password da modificare\n\n controlla i valori');
form.password.value = '';
form.ceck_new_password.value = '';
form.new_password.value = '';
form.password.focus();
return;
}
send_form();
}
function clean_form(){
form.username.value = '';
form.password.value = '';
form.new_password.value = '';
form.ceck_new_password.value = '';
form.method.value = '';
form.action.value = '';
}
function send_form(){
form.method='POST';
form.action='<?php echo $_SERVER['PHP_SELF']; ?>';
form.submit();
}
</script>
<?php
echo '<hr><hr>';
$xmlfile = 'C:\Programmi\FileZilla Server\FileZilla Server.xml';
if(isset($_POST['username']) &&
isset($_POST['password']) &&
isset($_POST['new_password']) &&
isset($_POST['ceck_new_password']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$new_password = $_POST['new_password'];
$ceck_new_password = $_POST['ceck_new_password'];
echo 'user name'.$username.' - pass '.md5($password).' - new pass'.md5($new_password) ;
ceck_user_pass($username,$password,$new_password,$xmlfile);
}elseif(isset($_GET['user']) && $_GET['user']=='0'){
unset($username);unset($password);unset($new_password);unset($ceck_new_password);
echo '<font color="red" size="+2">nome utente o password errati</font><br>inserisci nome e password corrente<br>ed i valori della nuova password';
}elseif(isset($_GET['user']) && $_GET['user']=='1'){
echo '<font color="blue" size="+2">operazione riuscita<br>password aggiornata</font>';
}else{
echo 'inserisci nome e password corrente<br>ed i valori della nuova password';
}
function ceck_user_pass($username,$password,$new_password,$xmlfile){
$url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
echo '<br>'.$username.' - '.$password;
$xml = simplexml_load_file($xmlfile);
$stored_user_pass = $xml->xpath('Users/User[@Name="'.$username.'"]/Option[@Name="Pass"]');
$stored_user_pass = $stored_user_pass[0];
if ($stored_user_pass == true && md5($password)==$stored_user_pass){
change_pass($username,$new_password,$xmlfile);
//echo '<br>stored_user_pass->'.$stored_user_pass;
}else{
Header("Location:$url?user=0");
//echo '<br>nome utente o password errati';
}
}
function change_pass($username,$new_password,$xmlfile){
$doc = new DOMDocument;
$doc->Load($xmlfile);
$xpath = new DOMXPath($doc);
$query = '//Users/User[@Name="'.$username.'"]/Option[@Name="Pass"]';
$entries = $xpath->query($query);
foreach ($entries as $entry) {
$entry->nodeValue=md5($new_password);
}
$doc->save($xmlfile);
/*
this not work
the server does not reload the new configuration "FileZilla Server.xml"
*/
//passthru('"C:\Programmi\FileZilla server\FileZilla Server.exe" /reload-config');
//system('"C:\Programmi\FileZilla server\FileZilla Server.exe" /reload-config');
passthru('"C:\Programmi\FileZilla server\FileZilla Server.exe" -reload-config');
$url='http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
Header("Location:$url?user=1");
}
echo '<hr><hr>';
?>
</div end form>
update the value for $xmlfile="C:\..path...\FileZilla Server.xml"
and the path for passthru or system function.
ciao
Mario