FileZilla 3b ftp settings
----------
usage:
1. rename this file from .txt to .php
2. make a backup of your old settings in FZ2 and 3, just in case ;-)
3. run this script either in windows commandline or in Linux terminal/console:
php fzc-2-3.php [optional path/name of FZ2 settings file]
if settings file can't be opened, then script will try opening FileZilla.xml in it's own directory
if that fails,too, program will exit with usage description
------------
acks:
botg, Timothy and guru_glenn - for password decryption idea
*/
function fz_decrypt($ret)
{
$m_key = "FILEZILLA1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$str = '';
$retlength = strlen($ret);
if (($retlength % 3) != 0) { print "not a valid encrypted key length\n";
exit;
}
$m_key_length = strlen($m_key);
$length = $retlength / 3;
$pos = $length % $m_key_length;
for ($i=0 ; $i < $length; $i++) {
$str .= chr(( 0 + substr( $ret, 3 * $i, 3 ) )^ ord(substr( $m_key, ($i+$pos)%$m_key_length, 1)));
}
return $str;
}
$file_in1=fopen($argv[1],'r');
if ($file_in1=='')
$file_in1=fopen('FileZilla.xml','r');
if ($file_in1==''){
print "\nThere's no FileZilla.xml file in script's directory.\n\n";
print "Usage:\n";
print "php fzc-2-3.php [optional path/name of FZ2 settings file]\n\n";
print "If you don't specify any name/path, then script will try to open FileZilla.xml in this directory";
exit;
}
$line=0;
$output_serv='';
$output_sett='';
$status=0;
while(!feof($file_in1)){
$line++;
$input=trim(fgets($file_in1));
if ($status==2){
//if it is Settings section
//last server
if (strpos($input,'Last Server')!==false){
$output_sett.="\n";
do {
$lsstr=substr($input,24,strpos($input,'')-24);
if (strpos($lsstr,'Host')!==false)
$output_sett.="".(substr($lsstr,20))."\n";
if (strpos($lsstr,'Port')!==false)
$output_sett.="".(substr($lsstr,21))."\n";
if (strpos($lsstr,'User')!==false)
$output_sett.="".(substr($lsstr,20))."\n";
if (strpos($lsstr,'Pass')!==false)
$output_sett.="".(fz_decrypt(substr($lsstr,20)))."\n";
$input=trim(fgets($file_in1));
}while ((strpos($input,'Last Server')!==false)||(strpos($input,'Last server')!==false));
$output_sett.="\n";
}
}
if ($status==3){
//if it is Sites section
if (strpos($input,'".$foldname."\n";
} //end of check for folders
elseif (strpos($input,'\n";
} //end of check for folder ending tag
elseif (strpos($input,'\n";
$output_serv.="".$input_host."\n";
$output_serv.="".$input_port."\n";
$output_serv.="".$input_logontype."\n";
$output_serv.="".$input_user."\n";
$output_serv.="".$input_pass."\n";
$output_serv.="".$input_localdir."\n";
$output_serv.="".$input_remotedir."\n";
$output_serv.=$input_site."\n";
$output_serv.="\n";
} //end of check for site tag
} //end of Sites section
if ((strpos($input,'\n\n\n";
} //strpos(input,sites)
if ((strpos($input,'\n\n";
} //strpos(input,/sites)
if ((strpos($input,'\n\n\n";
} //strpos(input,sites)
if ((strpos($input,'\n\n";
} //strpos(input,/sites)
} //end while(!feof)
print "read ".$line." lines\n";
print "preparing to write...\n";
//write sites settings
print "1. writing filezillaXXXXXX.xml...\n";
$filename='filezilla'.date('his').'.xml';
$file_out_sett = fopen($filename,'w+');
fwrite($file_out_sett,$output_sett);
fclose($file_out_sett);
print "2. writing sitemanagerXXXXXX.xml...\n";
$filename='sitemanager'.date('his').'.xml';
$file_out_serv = fopen($filename,'w+');
fwrite($file_out_serv,$output_serv);
fclose($file_out_serv);
print "conversion complete! :-)\n";
fclose($file_in1);
?>