Adobe Support Forums
Firefox-Hilfe
php.netphp.ini settings: magic_quotes_gpc = On
When magic_quotes are on, all ' (single-quote), " (double quote), \ (backslash) and NUL's are escaped with a backslash automatically.
array_walk — Apply a user function to every member of an array
FileZillaFileZilla Client is a fast and reliable cross-platform FTP, FTPS and SFTP client with lots of useful features and an intuitive graphical user interface.
PHP 5 & Dreamweaver template logfile to FileZilla XML FTP queue file
When you make changes on your Dreamweaver template file, Dreamweaver updates automatically all files based on the template. But the files are not updated on the ftp server.
For updating all changed files, you have to use the synchronization, wich scannes the whole site for newer files. That takes a lot of time.
The solution is to make a ftp queue xml file for FileZilla based on the logfile from the template changes.
Dreamweaver template logfile:
Paste your Dreamweaver logfile in the text-area above.PHP Code:
<?php
//*** Convert Dreamweaver Logfiles to FileZilla ftp queue files
//*** autor: roman pantring
//*** http://flashdictionary.filomatic.de
function remotepath_format(&$item,$key){
if($item == ""){
$item = "";
}else{
$item = ' '.strlen($item).' '.$item;
}
}
if (isset($_POST['logfile']) && $_POST['logfile']!="" ) {
$logfile = stripslashes($_POST['logfile']);
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->xmlStandalone = true;
$xml->formatOutput = true;
$roo = $xml->createElement('FileZilla3');
$xml->appendChild($roo);
$queue = $xml->createElement('Queue');
$roo->appendChild($queue);
$server = $xml->createElement('Server');
$queue->appendChild($server);
$host = $xml->createElement('Host',$_POST['host']);
$server->appendChild($host);
$port = $xml->createElement('Port',$_POST['port']);
$server->appendChild($port);
$protocol = $xml->createElement('Protocol',0);
$server->appendChild($protocol );
$type = $xml->createElement('Type',0);
$server->appendChild($type);
$user = $xml->createElement('User',$_POST['user']);
$server->appendChild($user);
$pass = $xml->createElement('Pass',$_POST['password']);
$server->appendChild($pass);
$logontype = $xml->createElement('Logontype',1);
$server->appendChild($logontype);
$timezoneoffset = $xml->createElement('TimezoneOffset',0);
$server->appendChild($timezoneoffset);
$pasvmode = $xml->createElement('PasvMode','MODE_DEFAULT');
$server->appendChild($pasvmode);
$maximummultipleconnections = $xml->createElement('MaximumMultipleConnections',0);
$server->appendChild($maximummultipleconnections);
$encodingtype = $xml->createElement('EncodingType','Auto');
$server->appendChild($encodingtype);
$bypassproxy = $xml->createElement('BypassProxy',0);
$server->appendChild($bypassproxy);
$name = $xml->createElement('Name',$_POST['host']);
$server->appendChild($name);
$logfile_array = array();
$logfile_array = explode("\r\n",$logfile);
$lastkey = array_search('Done.', $logfile_array);
foreach($logfile_array as $key => $value){
if($key==0){
$Localpath = substr($value,9);
}
if($key>0 && $key<$lastkey){
$file = $xml->createElement('File');
$server->appendChild($file);
$localfile = $xml->createElement('LocalFile',$Localpath.substr($value,8));
$file->appendChild($localfile);
$remotefile_str = substr($value,8);
$remotefile_array = explode("\\",$remotefile_str);
$remotefile_str = $remotefile_array[count($remotefile_array)-1];
$remotefile = $xml->createElement('RemoteFile',$remotefile_str);
$file->appendChild($remotefile);
$remotepathFormat = str_replace("/",'\\',$_POST['remotepath']);
$remotepath_str = $remotepathFormat.'\\'.substr($value,8,(strlen($remotefile_str)*-1)-1);
$remotepath_array = explode("\\",$remotepath_str);
array_walk($remotepath_array,'remotepath_format');
$remotepath_str = '1 0'.join("",$remotepath_array);
$remotepath = $xml->createElement('RemotePath',$remotepath_str);
$file->appendChild($remotepath);
$download = $xml->createElement('Download',0);
$file->appendChild($download);
$size = $xml->createElement('Size');
$file->appendChild($size);
$transfermode = $xml->createElement('TransferMode',0);
$file->appendChild($transfermode);
}
}
$xmlfile = $xml->saveXML() ;
echo htmlentities($xmlfile);
} else {
echo('Paste your Dreamweaver logfile in the text-area above.');
}
?>
Updating G:\saves\projekte\flashdictionary\www\flashdictionary\ updated html.php updated impressum.php updated JavaScript\jquery\slideToggle.php Done. files examined: 3 files updated: 3 files which could not be updated: 0 total time: (0:00:01)
Dreamweaver template logfile in FileZilla XML ftp queue file
PHP Code:
<?php
//*** Convert Dreamweaver Logfiles to FileZilla ftp queue files
//*** autor: roman pantring
//*** http://flashdictionary.filomatic.de
function remotepath_format_01(&$item,$key){
if($item == ""){
$item = "";
}else{
$item = ' '.strlen($item).' '.$item;
}
}
if (file_exists('dreamweaver_logfile.txt')) {
$filename = "dreamweaver_logfile.txt";
$handle = fopen($filename, "r");
$logfile = fread($handle, filesize($filename));
fclose($handle);
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->xmlStandalone = true;
$xml->formatOutput = true;
$roo = $xml->createElement('FileZilla3');
$xml->appendChild($roo);
$queue = $xml->createElement('Queue');
$roo->appendChild($queue);
$server = $xml->createElement('Server');
$queue->appendChild($server);
$host = $xml->createElement('Host',$_POST['host']);
$server->appendChild($host);
$port = $xml->createElement('Port',$_POST['port']);
$server->appendChild($port);
$protocol = $xml->createElement('Protocol',0);
$server->appendChild($protocol );
$type = $xml->createElement('Type',0);
$server->appendChild($type);
$user = $xml->createElement('User',$_POST['user']);
$server->appendChild($user);
$pass = $xml->createElement('Pass',$_POST['password']);
$server->appendChild($pass);
$logontype = $xml->createElement('Logontype',1);
$server->appendChild($logontype);
$timezoneoffset = $xml->createElement('TimezoneOffset',0);
$server->appendChild($timezoneoffset);
$pasvmode = $xml->createElement('PasvMode','MODE_DEFAULT');
$server->appendChild($pasvmode);
$maximummultipleconnections = $xml->createElement('MaximumMultipleConnections',0);
$server->appendChild($maximummultipleconnections);
$encodingtype = $xml->createElement('EncodingType','Auto');
$server->appendChild($encodingtype);
$bypassproxy = $xml->createElement('BypassProxy',0);
$server->appendChild($bypassproxy);
$name = $xml->createElement('Name',$_POST['host']);
$server->appendChild($name);
$logfile_array = array();
$logfile_array = explode("\r\n",$logfile);
$lastkey = array_search('Done.', $logfile_array);
foreach($logfile_array as $key => $value){
if($key==0){
$Localpath = substr($value,9);
}
if($key>0 && $key<$lastkey){
$file = $xml->createElement('File');
$server->appendChild($file);
$localfile = $xml->createElement('LocalFile',$Localpath.substr($value,8));
$file->appendChild($localfile);
$remotefile_str = substr($value,8);
$remotefile_array = explode("\\",$remotefile_str);
$remotefile_str = $remotefile_array[count($remotefile_array)-1];
$remotefile = $xml->createElement('RemoteFile',$remotefile_str);
$file->appendChild($remotefile);
$remotepathFormat = str_replace("/",'\\',$_POST['remotepath']);
$remotepath_str = $remotepathFormat.'\\'.substr($value,8,(strlen($remotefile_str)*-1)-1);
$remotepath_array = explode("\\",$remotepath_str);
array_walk($remotepath_array,'remotepath_format_01');
$remotepath_str = '1 0'.join("",$remotepath_array);
$remotepath = $xml->createElement('RemotePath',$remotepath_str);
$file->appendChild($remotepath);
$download = $xml->createElement('Download',0);
$file->appendChild($download);
$size = $xml->createElement('Size');
$file->appendChild($size);
$transfermode = $xml->createElement('TransferMode',0);
$file->appendChild($transfermode);
}
}
$xml->save('FileZilla_queue.xml');
} else {
echo('Paste your Dreamweaver logfile in the text-area above.');
}
?>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FileZilla3>
<Queue>
<Server>
<Host></Host>
<Port></Port>
<Protocol>0</Protocol>
<Type>0</Type>
<User></User>
<Pass></Pass>
<Logontype>1</Logontype>
<TimezoneOffset>0</TimezoneOffset>
<PasvMode>MODE_DEFAULT</PasvMode>
<MaximumMultipleConnections>0</MaximumMultipleConnections>
<EncodingType>Auto</EncodingType>
<BypassProxy>0</BypassProxy>
<Name></Name>
<File>
<LocalFile>G:\saves\projekte\flashdictionary\www\flashdictionary\html.php</LocalFile>
<RemoteFile>html.php</RemoteFile>
<RemotePath>1 0</RemotePath>
<Download>0</Download>
<Size/>
<TransferMode>0</TransferMode>
</File>
<File>
<LocalFile>G:\saves\projekte\flashdictionary\www\flashdictionary\impressum.php</LocalFile>
<RemoteFile>impressum.php</RemoteFile>
<RemotePath>1 0</RemotePath>
<Download>0</Download>
<Size/>
<TransferMode>0</TransferMode>
</File>
<File>
<LocalFile>G:\saves\projekte\flashdictionary\www\flashdictionary\JavaScript\jquery\slideToggle.php</LocalFile>
<RemoteFile>slideToggle.php</RemoteFile>
<RemotePath>1 0 10 JavaScript 6 jquery</RemotePath>
<Download>0</Download>
<Size/>
<TransferMode>0</TransferMode>
</File>
</Server>
</Queue>
</FileZilla3>
PHP docs: file_exists simplexml_load_file count children() DOMDocument