<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Webmaster Sucks &#187; another server</title>
	<atom:link href="http://www.webmastersucks.com/tags/another-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webmastersucks.com</link>
	<description>Here I share stuff I used to suck at as a novice webmaster..</description>
	<lastBuildDate>Tue, 11 May 2010 10:56:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Copy a Directory to Another Server</title>
		<link>http://www.webmastersucks.com/copy-a-directory-to-another-server/</link>
		<comments>http://www.webmastersucks.com/copy-a-directory-to-another-server/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 11:09:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[another server]]></category>
		<category><![CDATA[copy directory]]></category>
		<category><![CDATA[copy server to server]]></category>
		<category><![CDATA[directory list script]]></category>
		<category><![CDATA[move server]]></category>

		<guid isPermaLink="false">http://www.webmastersucks.com/?p=228</guid>
		<description><![CDATA[
			
				
			
		
I need a script to my directory to another servers. Firstly, i tried to download from my site and upload another site but it is not so fast. Because there is lots of files in that directory. I wrote a little php script for this. I hope you will enjoy..
P.S.: This code is only copy [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.webmastersucks.com%2Fcopy-a-directory-to-another-server%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.webmastersucks.com%2Fcopy-a-directory-to-another-server%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I need a script to my directory to another servers. Firstly, i tried to download from my site and upload another site but it is not so fast. Because there is lots of files in that directory. I wrote a little php script for this. I hope you will enjoy..<br />
P.S.: This code is only copy files in that  directory, if there is another directories this script didnt copy them..</p>
<pre class="brush: php;">
&lt;?
$ftp_server = www.mysite.com;
$ftp_username = &quot;myuser&quot;;
$ftp_password = &quot;mypass&quot;;

$source_directory = &quot;/home/mywebsite/public_html/test/&quot;;
$destination_directory = &quot;public_html/test/&quot;;

$ftp_connection = ftp_connect($ftp_server);
$connection_result = ftp_login($ftp_connection, $ftp_username, $ftp_password);

if ((!$ftp_connection) || (!$connection_result)) {
        echo(&quot;&lt;font color=red&gt;Connection Error!...&lt;/font&gt;&lt;br&gt;&quot;);
        echo(&quot;&lt;font color=red&gt;$ftp_username user can't connect to $ftp_server ...&lt;/font&gt;&lt;br&gt;&quot;);
        exit;
    } else {
        echo(&quot;&lt;font color=green&gt;$ftp_username connected to $ftp_server ...&lt;/br&gt;&quot;);
    }
$copied_directory = opendir($source_directory);

while($my_file = readdir($copied_directory))
{
 if($my_file != &quot;.&quot; &amp;&amp; $my_file != &quot;..&quot;)
 {
  $source_my_file = $source_directory.$my_file;
  $target_my_file = $destination_directory.$my_file;
  
  $upload = ftp_put($ftp_connection, $target_my_file, $source_my_file, FTP_BINARY);
  
  if (!$upload)
  {
   echo &quot;&lt;font color=red&gt;Can't connect...&lt;/font&gt;&quot;;
  }
  else
  {
   echo &quot;&lt;font color=green&gt; $my_file is copied to $ftp_server ...&lt;/font&gt;&lt;br&gt;&quot;;
  }
 }
}

ftp_close($ftp_connection);
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.webmastersucks.com/copy-a-directory-to-another-server/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
