Adobe Support Forums

Firefox-Hilfe

php.net

php.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

FileZilla

FileZilla Client is a fast and reliable cross-platform FTP, FTPS and SFTP client with lots of useful features and an intuitive graphical user interface.

Tortoise SVN

Tortoise SVN

My Delicious Tortoise feed Delicious rss icon

»»

Tags:

PHP 5 & Tortoise logfile to FileZilla XML FTP queue file

This script helps you uploading changes from the SVN repository via FTP with FileZilla.

Menu: TortoiseSVN - Show log
Revision Log Dialog:
Choose Copy to clipboard, to copy the log messages to clipboard.

Tortoise logfile:


Paste your Tortoise logfile in the text-area above.
PHP Code:
<?php
//*** Convert Tortoise 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);
    
$startkey array_search('----'$logfile_array);
    
$lastkey count($logfile_array);
    
$Localpath stripslashes($_POST['localpath']);
        
    foreach(
$logfile_array as $key  => $value){        
        if(
$key>$startkey && $key<$lastkey && $value!=""){ 
            
$file $xml->createElement('File');
            
            
$value_array explode(" : ",$value);
            
$localfile_str str_replace("/","\\",$value_array[1]);
            
$localfile $xml->createElement('LocalFile',$Localpath.substr($localfile_str,1));            

            
$remotefile_str substr($localfile_str,1);
            
$remotefile_array explode("\\",$remotefile_str);
            
$remotefile_str $remotefile_array[count($remotefile_array)-1];
            
$remotefile $xml->createElement('RemoteFile',$remotefile_str);        
            
            
$remotepathFormat str_replace("/",'\\',$_POST['remotepath']);
            
$remotepath_str $remotepathFormat.'\\'.substr($localfile_str,1,(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);            
            
            
$download $xml->createElement('Download',0);            
            
$size $xml->createElement('Size');
            
$transfermode $xml->createElement('TransferMode',0);
            
            if(
$value_array[0]!="Deleted"){
            
$server->appendChild($file);
            
$file->appendChild($localfile);
            
$file->appendChild($remotefile);
            
$file->appendChild($remotepath);
            
$file->appendChild($download);
            
$file->appendChild($size);
            
$file->appendChild($transfermode);
            }
        }        
    }    
    
$xmlfile $xml->saveXML() ;
    echo 
htmlentities($xmlfile);     
    } else {
   echo(
'Paste your Tortoise logfile in the text-area above.');
}
?>
Tortoise logfile: Example
Revision: 87
Author: Roman
Date: 14:11:54, Freitag, 7. Januar 2011
Message:
html code fixed
----
Modified : /flashdictionary/css/css_php_jquery_-_fontcomputer.php
Deleted : /flashdictionary/dreamweaver/img/Blog_template_mysql_advanced_filtered_recordset_article.gif
Added : /flashdictionary/dreamweaver/img/Blog_files.jpg

Tortoise logfile in FileZilla XML ftp queue file

PHP Code:
<?php
//*** Convert Tortoise 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('Tortoise_logfile.txt')) {
    
$filename "Tortoise_logfile.txt";
    
$handle fopen($filename"r");
    
$logfile fread($handlefilesize($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);
    
$startkey array_search('----'$logfile_array);
    
$lastkey count($logfile_array);
    
$Localpath stripslashes($_POST['localpath']);
        
    foreach(
$logfile_array as $key  => $value){        
        if(
$key>$startkey && $key<$lastkey && $value!=""){ 
            
$file $xml->createElement('File');
            
            
$value_array explode(" : ",$value);
            
$localfile_str str_replace("/","\\",$value_array[1]);
            
$localfile $xml->createElement('LocalFile',$Localpath.substr($localfile_str,1));            

            
$remotefile_str substr($localfile_str,1);
            
$remotefile_array explode("\\",$remotefile_str);
            
$remotefile_str $remotefile_array[count($remotefile_array)-1];
            
$remotefile $xml->createElement('RemoteFile',$remotefile_str);        
            
            
$remotepathFormat str_replace("/",'\\',$_POST['remotepath']);
            
$remotepath_str $remotepathFormat.'\\'.substr($localfile_str,1,(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);            
            
            
$download $xml->createElement('Download',0);            
            
$size $xml->createElement('Size');
            
$transfermode $xml->createElement('TransferMode',0);
            
            if(
$value_array[0]!="Deleted"){
            
$server->appendChild($file);
            
$file->appendChild($localfile);
            
$file->appendChild($remotefile);
            
$file->appendChild($remotepath);
            
$file->appendChild($download);
            
$file->appendChild($size);
            
$file->appendChild($transfermode);
            }
        }        
    }
    
$xml->save('FileZilla_Tortoise_queue.xml');
        
    } else {
   echo(
'Paste your Tortoise logfile in the text-area above.');
}
?>
FileZilla_Tortoise_queue.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FileZilla3>
  <Queue>
    <Server>
      <Host>domain.com</Host>
      <Port>21</Port>
      <Protocol>0</Protocol>
      <Type>0</Type>
      <User>User</User>
      <Pass>Password</Pass>
      <Logontype>1</Logontype>
      <TimezoneOffset>0</TimezoneOffset>
      <PasvMode>MODE_DEFAULT</PasvMode>
      <MaximumMultipleConnections>0</MaximumMultipleConnections>
      <EncodingType>Auto</EncodingType>
      <BypassProxy>0</BypassProxy>
      <Name>domain.com</Name>
      <File>
        <LocalFile>C:\flashdictionary\css\css_php_jquery_-_fontcomputer.php</LocalFile>
        <RemoteFile>css_php_jquery_-_fontcomputer.php</RemoteFile>
        <RemotePath>1 0 8 httpdocs 15 flashdictionary 3 css</RemotePath>
        <Download>0</Download>
        <Size/>
        <TransferMode>0</TransferMode>
      </File>
      <File>
        <LocalFile>C:\flashdictionary\dreamweaver\img\Blog_files.jpg</LocalFile>
        <RemoteFile>Blog_files.jpg</RemoteFile>
        <RemotePath>1 0 8 httpdocs 15 flashdictionary 11 dreamweaver 3 img</RemotePath>
        <Download>0</Download>
        <Size/>
        <TransferMode>0</TransferMode>
      </File>
    </Server>
  </Queue>
</FileZilla3>

PHP docs: file_exists simplexml_load_file count children() DOMDocument

Quelle: dr.web.de - PHP und XML: Einfach einfach!