<?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>DOC776.org &#187; PHP</title>
	<atom:link href="http://www.doc776.org/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.doc776.org</link>
	<description>This is the era of information.</description>
	<lastBuildDate>Mon, 02 Jan 2012 00:05:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Getting Directory Tree &#8211; Recursive VS Non-Recursive</title>
		<link>http://www.doc776.org/2009/07/getting-directory-tree-recursive-vs-non-recursive/</link>
		<comments>http://www.doc776.org/2009/07/getting-directory-tree-recursive-vs-non-recursive/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 22:33:48 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Fact]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[info]]></category>
		<category><![CDATA[recursion]]></category>
		<category><![CDATA[recursive]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=162</guid>
		<description><![CDATA[I took some time to examine between the performance of using a recursive and non recursive method of retrieving a directory tree. Of-course retrieving a directory tree is possible with out using any functions and still be able to get the full tree with unlimited depth possibilities. I made the non recursive piece of code [...]]]></description>
			<content:encoded><![CDATA[<p>I took some time to examine between the performance of using a recursive and non recursive method of retrieving a directory tree. Of-course retrieving a directory tree is possible with out using any functions and still be able to get the full tree with unlimited depth possibilities. I made the non recursive piece of code that outputs an array of each file and folder/subfolder of a given directory and a recursive function that calls it self on each new folder found. And then before an after I took a memory usage survey and time lapse of code execution. The folder that i used for testnig had some random folders and files and a freshly downloaded codeigniter frame work. So there were about 360 items in the generated array of files and folders.</p>
<p><strong>Non-Recursive Code:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$tree</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'folder/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$folders_to_do</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'folder/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$current_folder</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folders_to_do</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$key_of_current_folder</span> <span style="color: #339933;">=</span> <span style="color: #990000;">key</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folders_to_do</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$current_folder</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$folders_to_do</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key_of_current_folder</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$folder</span> <span style="color: #339933;">=</span> <span style="color: #990000;">scandir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_folder</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folder</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> and <span style="color: #000088;">$item</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'.'</span> and <span style="color: #000088;">$item</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'..'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$folders_to_do</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$current_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$tree</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$current_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$tree</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$current_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folders_to_do</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key_of_current_folder</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tree</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The way it works is very simple. It runs only on 2 loops (while &#038; foreach), 1 array (folders_to_do) and 1 string variable (current_folder) to control what we are scanning. The outer loop will always loop it self as long as it has something to scan, that means if the to-do array is not empty it will loop again. Now inside the while loop we have the regular scandir() function and foreach loop. in the foreach loop when a file is found it is added to the main tree array but if a folder is found then it is not only added to the tree array but is also added to the to-do list. Since the to-do list has something new to scan, the while loop will not brake. At the end when there is no more directories to scan the tree array will contain every folder and file found in the initial directory passed. All that is left to do is to sort the array and you get a neat list of each files and folders of a passed directory.</p>
<p><strong>Recursive:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$tree2</span> <span style="color: #339933;">=</span> recursive<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'folder/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> recursive<span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_folder</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	static <span style="color: #000088;">$tree</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$folder</span> <span style="color: #339933;">=</span> <span style="color: #990000;">scandir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_folder</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folder</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> and <span style="color: #000088;">$item</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'.'</span> and <span style="color: #000088;">$item</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'..'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$tree</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$current_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span>
			recursive<span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">is_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$tree</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$current_folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$tree</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This method is also straight forward. It uses a static array inside the function to hold the tree, optionally you can keep passing the tree as an argument if you do not wish to use a static array or if you simple going to use the function multiple times on the same script. The function it self takes in only 1 string variable which is the folder it is going to process. The foreach loop does same thing basically; if it is a file it only adds to the tree array and if it is a folder it adds to the tree array and calls the function with the folder path as teh argument. The recursion concept is no different then any other. It was only simplified ridiculously.</p>
<p><strong>Result Array:</strong></p>
<pre>
Array
(
    [0] => folder/
    [1] => folder/another folder/
    [2] => folder/another folder/bar file
    [3] => folder/another folder/dddddd/
    [4] => folder/another folder/dddddd/lost track/
    [5] => folder/another folder/dddddd/lost track/last file
    [6] => folder/another folder/hhh/
    [7] => folder/another omg folder/
    [8] => folder/codeigniter omg/
    [9] => folder/codeigniter omg/index.php
...
</pre>
<p>Both of those codes will produce exactly the same thing but using different amount of memory. Above you can see a steddy array with each folder and file name with full paths.</p>
<p><strong>Performance:</strong><br />
AS I said earlier I had about 360 files and folder combined for testing.</p>
<p>The time in milliseconds took to execute was the same on average of those methods. I refreshed many times and it was always either same or one or the other had few more milliseconds.</p>
<p>The memory usage for the non recursive was 82,512 and for the recursive method it was 116,112. I used the memory_get_usage() function to find those numbers. For each method I took memory usage before the code and after the code. So the results are (after_code &#8211; before_code) for first and second methods, just to clarify so no one has questions to how I have come to my conclusion.</p>
<p>82,512 / 116,112 = 0.71 ratio!</p>
<p>All testing was done here: http://www.sandbox.doc776.org/recursion/script.php</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/07/getting-directory-tree-recursive-vs-non-recursive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Framework CodeIgniter or CodeLighter</title>
		<link>http://www.doc776.org/2009/06/php-framework-codeigniter-or-codelighter/</link>
		<comments>http://www.doc776.org/2009/06/php-framework-codeigniter-or-codelighter/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 18:41:13 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Text]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[info]]></category>
		<category><![CDATA[structure]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=159</guid>
		<description><![CDATA[I been putting up a fuss lately between choosing to use CodeIgniter or Codelighter. For those that do not know what CodeIgniter is, it is a very small but powerful MVC based PHP framework for developing web applications. And for those who not sure what CodeLighter is, it is mini version of CodeIgniter, it follows [...]]]></description>
			<content:encoded><![CDATA[<p>I been putting up a fuss lately between choosing to use CodeIgniter or Codelighter. </p>
<p>For those that do not know what CodeIgniter is, it is a very small but powerful MVC based PHP framework for developing web applications. And for those who not sure what CodeLighter is, it is mini version of CodeIgniter, it follows the same syntax in general but the actual framework is minimized to the core.</p>
<p>Some nice things of CodeIgniter is that it has a separate documentation and lots of useful helpers and functions. This is a full framework so everything in it is separated from each part for the code like routes, hooks, core classes and so on.</p>
<p>CodeLighter has every core class like dispatcher controller loader and such placed in one single file. If you are the type that likes simplicity then this is good for you. Even thought it is in one file it is all very well commented and there is no need for documentation separately. It is very easy to go through the code and understand what each thing does and makes it easy to edit to your likes. CodeLighter of course supports the full MVC but more compact on the configuration end. Separate models, helpers, views and controllers. the whole code it self has only 5 directories and 3 files. One is the index that starts the code the actual CodeLighter core classes and MySQL class, everything else is for you to make.</p>
<p>I tried using both of those frameworks to try them out. The first thing to look at is the page render time. I had both frameworks installed on same server and had them only connect to the database and that is it. The render time of each page has a huge difference. CodeIgniter scored on average of 0.07 seconds at all times and CodeLighter Scored 0.005 seconds on average. The difference in loading times is all there and at the end before choosing what you want to use think about what you need it for. The CodeIgniter woulb be good for something heavy that has lots of pages and lots of features. CodeLighter would still be fine but would be better for smaller websites. It is like, what is the point of using a framework if it actually slower then the original code.</p>
<p>Notes:<br />
CodeIgniter is good for beginners that wish to learn MVC structure. Which stands for Module View Controller.<br />
CodeLighter is good for those who are going in depth and wish to know the full mechanics and use a more plain and dynamic MVC framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/06/php-framework-codeigniter-or-codelighter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get File Extension</title>
		<link>http://www.doc776.org/2009/06/get-file-extension/</link>
		<comments>http://www.doc776.org/2009/06/get-file-extension/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 07:09:02 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[useful]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=152</guid>
		<description><![CDATA[Very handy PHP function to get the file extension of a file name like something.jpg Method 1: (best way) 1 2 3 4 5 6 7 8 9 10 11 // get_file_extension ( string [the file name] , boolean [lower case] ) function get_file_extension&#40;$str,$low = true&#41;&#123; $i = strrpos&#40;$str,'.'&#41;; if &#40;!$i&#41; return ''; $l = [...]]]></description>
			<content:encoded><![CDATA[<p>Very handy PHP function to get the file extension of a file name like something.jpg</p>
<p><strong>Method 1:  (best way)</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// get_file_extension ( string [the file name] , boolean [lower case] )</span>
<span style="color: #000000; font-weight: bold;">function</span> get_file_extension<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span><span style="color: #000088;">$low</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strrpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$l</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$i</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$ext</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span><span style="color: #000088;">$i</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #000088;">$l</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$low</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000088;">$ext</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ext</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$ext</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Method 2:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// get_file_extension ( string [the file name] , boolean [lower case] )</span>
<span style="color: #000000; font-weight: bold;">function</span> get_file_extension<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span><span style="color: #000088;">$low</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$ar</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ar</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$ar</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_reverse</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ar</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$low</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000088;">$ext</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ar</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$ext</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Both functions produce the same output but one uses the string functions and the other uses array function. If you think about it, to manipulate and create arrays take more memory then manipulating regular text. (internally arrays are created using those same string manipulation methods) So method one is better because it uses most simple way to get what you need.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/06/get-file-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make Code</title>
		<link>http://www.doc776.org/2009/06/make-code/</link>
		<comments>http://www.doc776.org/2009/06/make-code/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 07:03:03 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[useful]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=149</guid>
		<description><![CDATA[Very simple handy little function to generate a random code of number and lower and upper case letters. Straight forward stuff&#8230; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 function makecode($chars = 6) { for($i=0; $i&#60;=($chars-1); $i++) { $r0 = rand(0,1); $r1 = rand(0,2); // frequency of lower [...]]]></description>
			<content:encoded><![CDATA[<p>Very simple handy little function to generate a random code of number and lower and upper case letters.</p>
<p>Straight forward stuff&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="language" style="font-family:monospace;">function makecode($chars = 6)
{
	for($i=0; $i&lt;=($chars-1); $i++)
	{
		$r0 = rand(0,1);
		$r1 = rand(0,2); // frequency of lower case
		if($r0==0)
			$r .= chr(rand(ord('A'),ord('Z')));
		elseif($r0==1)
			$r .= rand(0,9);
		if($r1==0)
			$r = strtolower($r);
	}
	return $r;
}</pre></td></tr></table></div>

<p>$r0 controls if the next digit is a number or a letter<br />
$1 controls if teh letter will be upper or lower. Set it to 0 if you want it to always be lower or change the range to what ever suits you.<br />
Also a number maybe passed to the function to change how many digits in the code to make.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/06/make-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting Bytes To Better Format</title>
		<link>http://www.doc776.org/2009/06/converting-bytes-to-better-format/</link>
		<comments>http://www.doc776.org/2009/06/converting-bytes-to-better-format/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 06:42:18 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=143</guid>
		<description><![CDATA[Every now and then we need a simple function that could take any number in bytes taken from filesize() or other source and convert it for better reading. Here are some functions that do the exact same thing but with different methods. Method 1: Very simple straight forward stuff. Can be customized to different sizes [...]]]></description>
			<content:encoded><![CDATA[<p>Every now and then we need a simple function that could take any number in bytes taken from filesize() or other source and convert it for better reading. Here are some functions that do the exact same thing but with different methods.</p>
<p><strong>Method 1:</strong>  Very simple straight forward stuff. Can be customized to different sizes with different limits.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> convert_size<span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">1073741824</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$num</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">1073741824</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">' gb'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">1048576</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$num</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">1048576</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">' mb'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$num</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$num</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">1024</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">' kb'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #000088;">$num</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' b'</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$num</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>Method 2:  (best way)</strong>  More advance using a loop to count size depth. Very small and compact all the way to YB. Unlike method 1 it runs by a single constant.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> convert_size<span style="color: #009900;">&#40;</span><span style="color: #000088;">$size</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$iec</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; B&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; KB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; MB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; GB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; TB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; PB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; EB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; ZB&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot; YB&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$size</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$size</span><span style="color: #339933;">=</span><span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$size</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">1024</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$size</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$size</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$iec</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>As you see if you wish to have a large range conversion using the first method then you will have lots of IF statements unlike method two. Iif you are using method one you have more simple flexibility to have different off-sets for sizes.</p>
<p>Method two uses a single while loop to take the size to its lowest by every 1024 and each time it loops it reduces a single multiple of 1024 and counts how many times it reduces it, and at the end shows the corresponding unit size from the array using that count. The array must have the unit sizes in correct order. Good thing about this is if you give it a number that is like 7^20 (that&#8217;s 20 zeroes), then it still works just fine as long as the array has that many unit sizes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/06/converting-bytes-to-better-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Displaying Page Load Time</title>
		<link>http://www.doc776.org/2009/06/displaying-page-load-time/</link>
		<comments>http://www.doc776.org/2009/06/displaying-page-load-time/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 06:18:30 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[info]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=139</guid>
		<description><![CDATA[How to display page load time at end of the HTML page using PHP.]]></description>
			<content:encoded><![CDATA[<p>It is very simple to show page load times in PHP.</p>
<p><strong>Method 1:</strong><br />
Place this at the very begin of your PHP code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'STARTING_MICROTIME'</span><span style="color: #339933;">,</span> get_microtime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Depending on how you like to organize your code have those functions some where, they are pretty straight forward:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> execution_time<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%01.4f</span>&quot;</span><span style="color: #339933;">,</span> get_microtime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> STARTING_MICROTIME<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> get_microtime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">doubleval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$time</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$time</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And finally just use the execution_time() function to show the total time elapsed since the script started.</p>
<p><strong>Method 2:</strong><br />
Place this at very beginning of your code.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'PAGE_LOAD_START'</span><span style="color: #339933;">,</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And this where you want to display the render time.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> PAGE_LOAD_START<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>This way is easier IMO. Using constants is not necessary, it just avoids problems in namespaces if your code is OOP like.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/06/displaying-page-load-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Easy Image Class</title>
		<link>http://www.doc776.org/2009/06/easy-image-class/</link>
		<comments>http://www.doc776.org/2009/06/easy-image-class/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 03:22:27 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Class]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[thumbnail]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=127</guid>
		<description><![CDATA[I needed something simple to grab images from MySQL database and display them. Slowly it grew into a very handy class. This class can be used to manipulate images stored in files or in a MySQL database. It can read images from files and store them in a MySQL database table, and vice-versa. The class [...]]]></description>
			<content:encoded><![CDATA[<p>I needed something simple to grab images from MySQL database and display them. Slowly it grew into a very handy class.</p>
<p>This class can be used to manipulate images stored in files or in a MySQL database. It can read images from files and store them in a MySQL database table, and vice-versa. The class can also convert images between GIF, JPEG and PNG formats, as well resize the images to create thumbnails.</p>
<p>Documentation:<br />
Coming Soon&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/06/easy-image-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Thumbnail / Resize Function</title>
		<link>http://www.doc776.org/2009/06/image-thumbnail-resize-function/</link>
		<comments>http://www.doc776.org/2009/06/image-thumbnail-resize-function/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 19:45:02 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[gd]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[thumbnail]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=104</guid>
		<description><![CDATA[Log time ago I wrote this function for my friend&#8217;s gallery website. The function is straight forward and uses the GD library of PHP. You may resize the image by giving it the maximum width and height you want the thumbnail to have. The function acts as an extension of the GD library so to [...]]]></description>
			<content:encoded><![CDATA[<p>Log time ago I wrote this function for my friend&#8217;s gallery website. The function is straight forward and uses the GD library of PHP. You may resize the image by giving it the maximum width and height you want the thumbnail to have. The function acts as an extension of the GD library so to speak, so you have to pass the image resource. An additional argument may be passed stating if you want the thumbnail to be square or not, by default it is false. If it is true the width:height ratio will not be change, it only fills the empty space with black color and places the thumbnail image in the center of the square.</p>
<p>imagethumb(image resource, max width, max height, fill to make square)<br />
1 &#8211; (GD image resource) Straight forward teh image resource loaded by GD library.<br />
2 &#8211; (int) maximum width of thumbnail<br />
3 &#8211; (int) maximum width of thumbnail<br />
4 &#8211; (true/false) make thumbnail square</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> imagethumb<span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit_w</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit_h</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span> <span style="color: #000088;">$fill</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//get original dimensions</span>
	<span style="color: #000088;">$old_w</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesx</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$old_h</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagesy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_im</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//first resize by width if overflow else set old to new</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_w</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$limit_w</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//get reduction percent</span>
		<span style="color: #000088;">$reduce_percent</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit_w</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$old_w</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//set new w and h</span>
		<span style="color: #000088;">$new_w</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_w</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$reduce_percent</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$new_h</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$old_h</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$reduce_percent</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//set as the old dimensions</span>
		<span style="color: #000088;">$new_w</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$old_w</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$new_h</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$old_h</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//second resize by height if still overflows</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_h</span> <span style="color: #339933;">&gt;</span> <span style="color: #000088;">$limit_h</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//get reduction percent</span>
		<span style="color: #000088;">$reduce_percent</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit_h</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$new_h</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">//set new w and h</span>
		<span style="color: #000088;">$new_w</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_w</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$reduce_percent</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$new_h</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_h</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #000088;">$reduce_percent</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fill</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//height offset picture, to keep centered</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_h</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$limit_h</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$h_offset</span> <span style="color: #339933;">=</span> <span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit_h</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$new_h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #000088;">$h_offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//width offset picture, to keep centered</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_w</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$limit_w</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$w_offset</span> <span style="color: #339933;">=</span> <span style="color: #990000;">floor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit_w</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$new_w</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
			<span style="color: #000088;">$w_offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//make new image and copy to it</span>
		<span style="color: #000088;">$new_im</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatetruecolor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$limit_w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limit_h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
		<span style="color: #000088;">$new_im</span> <span style="color: #339933;">=</span> <span style="color: #990000;">imagecreatetruecolor</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$new_h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">imagecopyresampled</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_im</span><span style="color: #339933;">,</span> <span style="color: #000088;">$w_offset</span><span style="color: #339933;">,</span> <span style="color: #000088;">$h_offset</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$new_w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$new_h</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_h</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$new_im</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/06/image-thumbnail-resize-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Pagination Simple Mechanics</title>
		<link>http://www.doc776.org/2009/04/php-pagination-simple-mechanics/</link>
		<comments>http://www.doc776.org/2009/04/php-pagination-simple-mechanics/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 00:49:48 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[structure]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=67</guid>
		<description><![CDATA[It is actually very simple. All you need to know is what page you are on and how many items there is to list in total. Here is an out line: Step one, get those values: total_items items_per_page current_page Step two, calculate total pages: total_pages = ( total_items / items_per_page ) Step three, calculate limit [...]]]></description>
			<content:encoded><![CDATA[<p>It is actually very simple. All you need to know is what page you are on and how many items there is to list in total. Here is an out line:</p>
<p>Step one, get those values:<br />
total_items<br />
items_per_page<br />
current_page</p>
<p>Step two, calculate total pages:<br />
total_pages = ( total_items / items_per_page ) </p>
<p>Step three, calculate limit offset for database query:<br />
start_item = current_page * items_per_page<br />
end_item = if on last page then ( total_pages &#8211; start_item ) else ( items_per_page )  &#8220;asuming your database works like mysql&#8221;</p>
<p>Be mindful that arrays and databases start from 0 not from 1.</p>
<p>And from there just make your PHP code and add on nifty features of your own.</p>
<p>Check out my previous guide for a nice pagination script with demo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/04/php-pagination-simple-mechanics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Website To Website File Transfer</title>
		<link>http://www.doc776.org/2009/01/php-website-to-website-file-transfer/</link>
		<comments>http://www.doc776.org/2009/01/php-website-to-website-file-transfer/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 01:24:16 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.doc776.org/?p=55</guid>
		<description><![CDATA[My internet provider is not one of the best for one damn reason: It has bandwidth limit. So there I was wondering how am I going to transfer my 15gb website from old location to this shiny new one, knowing I have only 1GB on my monthly bandwidth left and it resets about 10 days [...]]]></description>
			<content:encoded><![CDATA[<p>My internet provider is not one of the best for one damn reason: It has bandwidth limit. So there I was wondering how am I going to transfer my 15gb website from old location to this shiny new one, knowing I have only 1GB on my monthly bandwidth left and it resets about 10 days from now. First attempt is to use one of those web ftp websites i found, well they all got their own bandwidth or they just freeze. I tried connecting to the old website using my own ftp script but it failed, and so did the remade scripts I tried using. The conclusion is that the old website does not allow direct ftp or special access, but my new one is liek a free world, do what you want sorta thing. Problem solved! I made mini script for teh old website that shows all files and folders in an orderly fashion in a big list. Then I made a simple file_get_content() and file_put_content() script on my new site. It was perfect, thought the rapid request rate shuts down the only connection between my two websites. Added a sleep(1) right after each download and flush() right after it is echo &#8216;file copied&#8217; and it was done. Just sit back and relax as my new site copied all the files nice and fast.<span id="more-55"></span></p>
<p>For this script you would need to ahve PHP5. If you on PHP4 then you got to use fopen, fget, fput and fclose, classic style. You would also need to be able to modify your php ini variables with ini_set().</p>
<p>The other script that you will need to put at the source from where you copying is basically scandir() and echo all the files will full path with a separator like <br /> or anything that is uncommon.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//depends on what si teh biggest fiel that would be copied</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;memory_limit&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;256M&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//you can let it run for hours on end till its copied</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;max_execution_time&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;60000&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//list of files to be copied from source website, get them here</span>
<span style="color: #000088;">$files</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;br&gt;'</span><span style="color: #339933;">,</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http:///source.website.com/list.php'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*on the listing i just printed each file with a new line tag at end, so the last line 
also got the tag, when exploded results in the last slot of the array to be empty*/</span>
<span style="color: #666666; font-style: italic;">//remove that last empty value in the array</span>
<span style="color: #990000;">array_pop</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$files</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//total files to be copied</span>
<span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$maps</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//copied count</span>
<span style="color: #000088;">$cop</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//you can stop this script and re run it again, so you get files that already exist on new location</span>
<span style="color: #666666; font-style: italic;">//previously copied count</span>
<span style="color: #000088;">$ext</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//start teh big loop</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$files</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$m</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//display that we starting to copy this</span>
 <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Copying '</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$k</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$total</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">.</span><span style="color: #000088;">$m</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' ... '</span><span style="color: #339933;">;</span>
 <span style="color: #990000;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//if its not copied previously</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_file</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'path/to/new/place/here/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$m</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//get the file from source or show that we cant</span>
	<span style="color: #000088;">$f</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">file_get_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://source.website.com/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$m</span><span style="color: #009900;">&#41;</span> or er<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//if get works fire away</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$f</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//put it on our server now</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">file_put_contents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'path/to/new/place/here/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$m</span><span style="color: #339933;">,</span> <span style="color: #000088;">$f</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//show that we done copying</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Done!&lt;br&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$cop</span><span style="color: #339933;">++;</span>
			<span style="color: #990000;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//wait haf a second or 1 second not to flame your source website</span>
			<span style="color: #990000;">usleep</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//500000 = 0.5 seconds / 1000000 = seconds</span>
			<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Cannot put file.&lt;br&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Cannot get file.&lt;br&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//show if already exists</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Already exists.&lt;br&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$ext</span><span style="color: #339933;">++;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//litle info</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Copied '</span><span style="color: #339933;">.</span><span style="color: #000088;">$cop</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' and '</span><span style="color: #339933;">.</span><span style="color: #000088;">$ext</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' existed of '</span><span style="color: #339933;">.</span><span style="color: #000088;">$total</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'. Failed: '</span><span style="color: #339933;">.</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$total</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$ext</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$cop</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The flush() just shows current generated content to use.</p>
<blockquote><p><strong>Note:</strong><br />
I have noticed that if you pass URLs that have spaces in them, it will return as error also. I tried encoding teh URL and same thing happand. My solutioin: I used a curl version of file_get_content(). Here is the script, it will not return error on URLs with spaces:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> curl_get_file_contents<span style="color: #009900;">&#40;</span><span style="color: #000088;">$URL</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_setopt</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000088;">$URL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$contents</span> <span style="color: #339933;">=</span> <span style="color: #990000;">curl_exec</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">curl_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$c</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$contents</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$contents</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

</blockquote>
<p>The mini script that generates the list of files to copy on the source end of this deal is easy if you only copying folder by folder.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;copy/this/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;..&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$file</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>There is no limit to how much you can automate the procedure. Remember that.</p>
<p>Output from when I was using it:</p>
<pre>Copying 6868/8593 6a8f9cbcaa6e54ad6032250c359bd233.png ... Done!
Copying 6869/8593 2997daad502d72d34ddb1e68499ebe08.png ... Done!
Copying 6870/8593 382c4d6be6670d61d2cc3c074f1a15bb.png ... Done!
Copying 6871/8593 72790f18f902f42d35a648cc32f69571.png ... Done!
Copying 6872/8593 66f037fb5bfb7aed444617dfcd071e95.png ... Done!
Copying 6873/8593 96544d7d415904d2b5443738713f5ab1.png ... Done!</pre>
<p>Yeah I was copying directly one folder, my resources (don&#8217;t ask why there is 8000 of them, that&#8217;s just half of it). It finished it in around 2 hours. I just left the page on and minimized it as i was doing some other work. If you accidentally stop it, just refresh it. It will skip thought all the existing files in seconds and continue copying the rest. Saves you time relay, unlike with big back up and upload scripts here the only error that can happen if you are requesting too fast and it will skip that file, to fix that just refresh the page to get all those skipped ones, fast and easy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.doc776.org/2009/01/php-website-to-website-file-transfer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

