<?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"
	>

<channel>
	<title>Jayesh Blog</title>
	<atom:link href="http://blog.jayesh.com.np/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jayesh.com.np</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Thu, 20 Nov 2008 10:12:55 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Getting Child</title>
		<link>http://blog.jayesh.com.np/2008/11/get-child-tree/</link>
		<comments>http://blog.jayesh.com.np/2008/11/get-child-tree/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 09:26:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Cipher]]></category>

		<category><![CDATA[PHP pabulum]]></category>

		<category><![CDATA[child]]></category>

		<category><![CDATA[tree]]></category>

		<guid isPermaLink="false">http://blog.jayesh.com.np/?p=19</guid>
		<description><![CDATA[During my project, I need a code to show the items and it&#8217;s corresponding child, of certain category. So, finally I come up with this code. If you are also in sort of such problem and wondering how to get the child of its parent (tree),then this piece of code may acts as your helper.
This [...]]]></description>
			<content:encoded><![CDATA[<p>During my project, I need a code to show the items and it&#8217;s corresponding child, of certain category. So, finally I come up with this code. If you are also in sort of such problem and wondering how to get the child of its parent (tree),then this piece of code may acts as your helper.<br />
This is very simple example of showing in tree structure but hopefully a good one to use. </p>
<p>[Source code]</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
</pre></td><td class="code"><pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> display_children<span style="color: #009900;">&#40;</span><span style="color: #000033;">$parent</span><span style="color: #339933;">,</span> <span style="color: #000033;">$level</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//db connection</span>
        <span style="color: #000033;">$dbcon</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;root&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cant connect to db&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000033;">$select_db</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;db_name&quot;</span><span style="color: #339933;">,</span><span style="color: #000033;">$dbcon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000033;">$select_db</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	   <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cannot access database:&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">mysql_error</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: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// retrieve all children of $parent</span>
	<span style="color: #000033;">$query</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM table_name WHERE parent_id='$parent'&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000033;">$result</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$query</span><span style="color: #339933;">,</span><span style="color: #000033;">$dbcon</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// display each child</span>
	<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000033;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// indent and display the title of this child</span>
		<span style="color: #990000;">echo</span> <span style="color: #990000;">str_repeat</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-&gt;'</span><span style="color: #339933;">,</span><span style="color: #000033;">$level</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000033;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'child_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
		display_children<span style="color: #009900;">&#40;</span><span style="color: #000033;">$row</span><span style="color: #009900;">&#91;</span>child_id<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000033;">$level</span><span style="color: #cc66cc;">+1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//end of function</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.jayesh.com.np/2008/11/get-child-tree/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Accessory in file upload</title>
		<link>http://blog.jayesh.com.np/2008/07/accessory-in-file-upload/</link>
		<comments>http://blog.jayesh.com.np/2008/07/accessory-in-file-upload/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 07:33:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Cipher]]></category>

		<category><![CDATA[PHP pabulum]]></category>

		<category><![CDATA[accessory]]></category>

		<category><![CDATA[extension]]></category>

		<category><![CDATA[file]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://blog.jayesh.com.np/?p=18</guid>
		<description><![CDATA[Before allowing to upload file, you make like your users to check and secure the file.You may like to check extension and allow particular file (eg.image file only), check size, and others.So, I am listing some accessory which you may wish to have. 
[ function checking extension of the file  ]
You can check the [...]]]></description>
			<content:encoded><![CDATA[<p>Before allowing to upload file, you make like your users to check and secure the file.You may like to check extension and allow particular file (eg.image file only), check size, and others.So, I am listing some accessory which you may wish to have. </p>
<p>[ <strong>function checking extension of the file </strong> ]</p>
<p>You can check the mime-type and file extension and only allow certain types to be uploaded.</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
</pre></td><td class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//returns the extension of the file </span>
<span style="color: #666666; font-style: italic;">//Usage :: if index.HTML then returns .HTML</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_extension<span style="color: #009900;">&#40;</span><span style="color: #000033;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000033;">$i</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strrpos</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$str</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;.&quot;</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: #000033;">$i</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	     <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000033;">$l</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$str</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000033;">$i</span><span style="color: #339933;">;</span>
	<span style="color: #000033;">$ext</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$str</span><span style="color: #339933;">,</span><span style="color: #000033;">$i</span><span style="color: #cc66cc;">+1</span><span style="color: #339933;">,</span><span style="color: #000033;">$l</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000033;">$ext</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//end of function get Extension</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Now using this function you can check file extension before uploading file.<br />
In case of picture file</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"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$extension</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;jpg&quot;</span><span style="color: #009900;">&#41;</span>  <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000033;">$extension</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;jpeg&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000033;">$extension</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;png&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000033;">$extension</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;gif&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>	
<span style="color: #009900;">&#123;</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: #339933;">...</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>[ <strong>Disabling executing of these files could give us an extra layer of protection</strong> ]</p>
<p>Further if you are allowing your users only photos or pictures, you can restrict other files by placing the following code your your .htaccess file.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre>&nbsp;
&lt;Files ^(*.jpeg<PIPE>*.jpg<PIPE>*.png<PIPE>*.gif)&gt;
order deny,allow
deny from all
&lt;/Files&gt;</pre></td></tr></table></div>

<p>[ <strong>Black listing the extension you don't like to allow</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">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> black_list<span style="color: #009900;">&#40;</span><span style="color: #000033;">$blacklist</span><span style="color: #339933;">,</span><span style="color: #000033;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//$blacklist = array(&quot;php&quot;, &quot;phtml&quot;, &quot;doc&quot;, &quot;txt&quot;, &quot;js&quot;, &quot;shtml&quot;, &quot;pl&quot; ,&quot;py&quot;);</span>
	<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000033;">$blacklist</span> <span style="color: #b1b100;">as</span> <span style="color: #000033;">$file</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;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/$file<span style="color: #000099; font-weight: bold;">\$</span>/i&quot;</span><span style="color: #339933;">,</span> <span style="color: #000033;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	     <span style="color: #009900;">&#123;</span>
		<span style="color: #000033;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ERROR :: Uploading executable files Not Allowed<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000033;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'msg'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>[ <strong>Disable Script Execution with .htaccess</strong> ]</p>
<p>Just create .htaccess file with contents below and place it on the uploads folder to disable running malicious scripts.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre>AddHandler cgi-script .php .php3 .php4 .phtml .pl .py .jsp .asp .htm .shtml .sh .cgi
Options -ExecCGI</pre></td></tr></table></div>

<p>[ <strong>Other part of security</strong> ]</p>
<p>The best way of handling file uploads securely is rather than giving writable permissions to users, is to allow the writable permission to apache itself. In this way the apache server has writable permission rather than the user. Just chown the writable folder to apache or nobody and assign 770 permission.</p>
<p>In this way the public has no access to read or write or execute permissions in the uploads folder. You will notice that apache has rwx and so as the owner. You can safely place the upload folder inside www folder without any concern.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre>chown -R apache uploads
chmod -R 770 uploads</pre></td></tr></table></div>

<p>If anybody tries to access the uploads folder, through URL you will see forbidden.Because apache is the grou owner you will have no problem in displaying the images or photos to the browser.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre>&lt;img src=&quot;uploads/file02929.gif&quot;&gt;</pre></td></tr></table></div>

<p>Note :: This method works best if you have your own dedicated or vps plan with root permissions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayesh.com.np/2008/07/accessory-in-file-upload/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to limit file size during file uploading using PHP?</title>
		<link>http://blog.jayesh.com.np/2008/07/how-to-limit-file-size-during-file-uploading-using-php/</link>
		<comments>http://blog.jayesh.com.np/2008/07/how-to-limit-file-size-during-file-uploading-using-php/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 11:39:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Cipher]]></category>

		<category><![CDATA[PHP pabulum]]></category>

		<category><![CDATA[file]]></category>

		<category><![CDATA[size]]></category>

		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://blog.jayesh.com.np/?p=17</guid>
		<description><![CDATA[I expect that the previous post regarding to the file upload becomes beneficial to you. Now let us become more specific. You may like to restrict user in  many circumstances. So, today I am going to deal with the restriction made to the file size during the file uploads. There may be many solutions. [...]]]></description>
			<content:encoded><![CDATA[<p>I expect that the previous post regarding to the file upload becomes beneficial to you. Now let us become more specific. You may like to restrict user in  many circumstances. So, today I am going to deal with the restriction made to the file size during the file uploads. There may be many solutions.  Let me share - some of them.</p>
<p><strong>Method 1.</strong></p>
<p>You can place hidden field as</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre>&nbsp;
&lt;input type=&quot;hidden&quot; name=&quot;MAX_FILE_SIZE&quot; value=&quot;2000000&quot; /&gt;</pre></td></tr></table></div>

<p><strong>Note</strong> :: Well, some web browsers actually pick up on this field and will not allow the user to upload a file bigger than this number (in bytes). You should set this value to coincide with the maximum upload size that is set in your php.ini file. It is set with the upload_max_filesize directive and the default is 2MB. But it still cannot ensure that your script won&#8217;t be handed a file of a larger size. The danger is that an attacker will try to send you several large files in one request and fill up the file system in which PHP stores the decoded files. Set the post_max_size directive in your php.ini file to the maximum size that you want (must be greater than upload_max_filesize). The default is 10MB. This directive controls the maximum size of all the POST data allowed in a single request. Also make sure that file_uploads inside your php.ini file is set to On.</p>
<p><strong>Method 2.</strong> </p>
<p>On the other hand, You may define and validate the file size before uploading , as—</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
</pre></td><td class="code"><pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">//check for valid file size in bytes</span>
<span style="color: #000000; font-weight: bold;">function</span> validate_file_size<span style="color: #009900;">&#40;</span><span style="color: #000033;">$file_name</span><span style="color: #339933;">,</span> <span style="color: #000033;">$max_file_size</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000033;">$size</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$file_name</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: #000033;">$size</span> <span style="color: #339933;">&gt;</span> <span style="color: #000033;">$max_file_size</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	   <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</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: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//end of function validate_file_size</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>Method 3.</strong></p>
<p>There is another way which is quite simple one.The superglobal $_FILES array containing information about the file; namely $_FILES["userfile"]["size"] gives you the size of the uploaded file in bytes. So by cheking the size you may restrict user during file uploading.<br />
Example:</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">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;MAX_SIZE&quot;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2000000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;userfile&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;size&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> MAX_SIZE<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">move_uploaded_file</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userfile'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tmp_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000033;">$target_path</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;The file has been uploaded&quot;</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: #990000;">echo</span> <span style="color: #0000ff;">&quot;There was an error uploading the file, please try again!&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;There was an error uploading the file, please try again!&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.jayesh.com.np/2008/07/how-to-limit-file-size-during-file-uploading-using-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Uploading the files using PHP</title>
		<link>http://blog.jayesh.com.np/2008/07/uploading-the-files-using-php/</link>
		<comments>http://blog.jayesh.com.np/2008/07/uploading-the-files-using-php/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 11:00:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Cipher]]></category>

		<category><![CDATA[PHP pabulum]]></category>

		<category><![CDATA[file]]></category>

		<category><![CDATA[source]]></category>

		<category><![CDATA[upload]]></category>

		<guid isPermaLink="false">http://blog.jayesh.com.np/2008/07/uploading-the-files-using-php/</guid>
		<description><![CDATA[I think you have got a lot of tutorial regarding to the file upload. Uploading a file in PHP is not a great deal. If you are still confound and searching for the uploading stuff then let me help you. Do not worry, it’s simple. You may just copy and paste to use it.
Firstly you [...]]]></description>
			<content:encoded><![CDATA[<p>I think you have got a lot of tutorial regarding to the file upload. Uploading a file in PHP is not a great deal. If you are still confound and searching for the uploading stuff then let me help you. Do not worry, it’s simple. You may just copy and paste to use it.<br />
Firstly you need to create a simple HTML form to let user select a file to upload. So lets create it.</p>
<p>[upload_form.html]</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>&nbsp;
&lt;form action=&quot;upload.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; name=&quot;upload&quot; &gt;
&lt;div align=&quot;center&quot; style=&quot;line-height: 1.9em<SEMI>&quot;&gt;
Choose file to upload
&lt;br /&gt;
&lt;input name=&quot;userfile&quot; type=&quot;file&quot;&gt;&lt;br /&gt;
&lt;input name=&quot;upload&quot; type=&quot;submit&quot; value=&quot;Upload&quot; /&gt; 
&lt;/div&gt;
&lt;/form&gt;</pre></td></tr></table></div>

<p>Secondly, you need to create PHP script that is going to handle our uploads. This PHP file should make a key decision with all uploads: keep the file or throw it away. A file might be thrown away from many reasons, including: </p>
<ul>
<li>The file is too large and you do not want to have it on your server.</li>
<li>You want to restrict that the file must be image (.jpeg, jpg, bmp etc) file and not other.</li>
<li>Others</li>
</ul>
<p>[upload.php]</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
</pre></td><td class="code"><pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##################################</span>
<span style="color: #666666; font-style: italic;">#Copyright 2008, Jayesh Shrestha</span>
<span style="color: #666666; font-style: italic;">#You may use, modify and distribute  </span>
<span style="color: #666666; font-style: italic;">#this code as long as this copyright</span>
<span style="color: #666666; font-style: italic;"># notice is preserved.</span>
<span style="color: #666666; font-style: italic;">##################################</span>
&nbsp;
<span style="color: #000033;">$target_path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;upload/&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// define the path where the files are to be kept</span>
&nbsp;
<span style="color: #000033;">$target_path</span> <span style="color: #339933;">=</span> <span style="color: #000033;">$target_path</span> <span style="color: #339933;">.</span> <span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span> <span style="color: #000033;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userfile'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">move_uploaded_file</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'userfile'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'tmp_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000033;">$target_path</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;The file has been uploaded&quot;</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: #990000;">echo</span> <span style="color: #0000ff;">&quot;There was an error uploading the file, please try again!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Note :: You may use copy() function as well. This makes a copy of the file source to destination. Returns TRUE on success or FALSE on failure</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayesh.com.np/2008/07/uploading-the-files-using-php/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Counting the file that has been downloaded</title>
		<link>http://blog.jayesh.com.np/2008/07/counting-the-file-that-has-been-downloaded/</link>
		<comments>http://blog.jayesh.com.np/2008/07/counting-the-file-that-has-been-downloaded/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 06:58:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Cipher]]></category>

		<category><![CDATA[PHP pabulum]]></category>

		<category><![CDATA[count]]></category>

		<category><![CDATA[counter]]></category>

		<category><![CDATA[download]]></category>

		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://blog.jayesh.com.np/?p=12</guid>
		<description><![CDATA[In former post related to the download, I have tried showing how can we let our files to get downloaded by clients. Now next thing is, you may also want to count the numbers of files that have been downloaded. So my main motive to place this post is to help you count you files [...]]]></description>
			<content:encoded><![CDATA[<p>In former post related to the <a href="http://blog.jayesh.com.np/2008/07/how-can-i-let-download-my-file/">download</a>, I have tried showing how can we let our files to get downloaded by clients. Now next thing is, you may also want to <strong>count the numbers of files that have been downloaded</strong>. So my main motive to place this post is to help you count you files that have been downloaded. You can embed (copy and paste) it in your code. I hope this code will be beneficial one. Check it out.</p>
<p>NOTE :: [<code>Create counter.txt file and embed this code</code>]</p>
<p>[source code]</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
</pre></td><td class="code"><pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">##################################</span>
<span style="color: #666666; font-style: italic;">#Copyright 2008, Jayesh Shrestha</span>
<span style="color: #666666; font-style: italic;">#You may use, modify and distribute  </span>
<span style="color: #666666; font-style: italic;">#this code as long as this copyright</span>
<span style="color: #666666; font-style: italic;"># notice is preserved.</span>
<span style="color: #666666; font-style: italic;">##################################</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* counter for file downloaded  */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//checking that you have created counter.txt file or not</span>
&nbsp;
 <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'counter.txt'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	 <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Please create counter.txt file first&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000033;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;counter.txt&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;r+&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000033;">$count</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fread</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$file</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: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// closes file</span>
&nbsp;
<span style="color: #000033;">$count</span><span style="color: #339933;">++;</span>
&nbsp;
<span style="color: #000033;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'counter.txt'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'w'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// opens file again with 'w'-parameter</span>
<span style="color: #990000;">fwrite</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$file</span><span style="color: #339933;">,</span> <span style="color: #000033;">$count</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">fclose</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.jayesh.com.np/2008/07/counting-the-file-that-has-been-downloaded/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Some beliefs on Politics and its terms</title>
		<link>http://blog.jayesh.com.np/2008/07/some-believes-on-politics-and-its-terms/</link>
		<comments>http://blog.jayesh.com.np/2008/07/some-believes-on-politics-and-its-terms/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 09:48:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Potpourri]]></category>

		<category><![CDATA[communism]]></category>

		<category><![CDATA[democracy]]></category>

		<category><![CDATA[politics]]></category>

		<category><![CDATA[socialism]]></category>

		<category><![CDATA[terms]]></category>

		<guid isPermaLink="false">http://blog.jayesh.com.np/?p=10</guid>
		<description><![CDATA[Each people belong to one country by birth and each country is ruled under Politics jumble. The word politics comes from the Greek word &#8220;polis&#8221;, meaning the state or community as a whole. So, each people have rights to know, in which principles, their nation is under. Some says “Politics is dirty game”; some argues [...]]]></description>
			<content:encoded><![CDATA[<p>Each people belong to one country by birth and each country is ruled under Politics jumble. The word politics comes from the Greek word &#8220;polis&#8221;, meaning the state or community as a whole. So, each people have rights to know, in which principles, their nation is under. Some says “Politics is dirty game”; some argues on other. Whatever, but thing I am listing here may define what political terms exactly are? It may say what your nation is following.</p>
<blockquote><p><strong>Feudalism</strong>: You have two cows. Your owner takes some of the milk.</p>
<p><strong>Pure Socialism</strong>: You have two cows. The government takes them and puts them in a barn with everyone else&#8217;s cows. You have to take care of all of the cows. The government gives you as much milk as you need.</p>
<p><strong>Bureaucratic Socialism</strong>: You have two cows. The government takes them and put them in a barn with everyone else&#8217;s cows. They are cared for by ex-chicken farmers. You have to take care of the chickens the government took from the chicken farmers. The government gives you as much milk and eggs as the regulations say you need.</p>
<p><strong>Fascism</strong>: You have two cows. The government takes both, hires you to take care of them and sells you the milk.</p>
<p><strong>Pure Communism</strong>: You have two cows. Your neighbors help you take care of them, and you all share the milk.</p>
<p><strong>Communism</strong>: You have two cows. You have to take care of them, but the government takes all the milk.</p>
<p><strong>Cambodian Communism</strong>: You have two cows. The government takes both of them and shoots you.</p>
<p><strong>Dictatorship</strong>: You have two cows. The government takes both and drafts you.</p>
<p><strong>Pure Democracy</strong>: You have two cows. Your neighbors decide who gets the milk.</p>
<p><strong>Representative Democracy</strong>: You have two cows. Your neighbors pick someone to tell you who get the milk.</p>
<p><strong>Bureaucracy</strong>: You have two cows. At first the government regulates what you can feed them and when you can milk them. Then it pays you not to milk them. Then it takes both, shoots one, milks the other and pours the milk down the drain. Then it requires you to fill out forms accounting for the missing cows.</p>
<p><strong>Pure Anarchy</strong>: You have two cows. Either you sell the milk at a fair price or your neighbors try to take the cows and kill you.</p>
<p><strong>Libertarian/Anarcho-Capitalism</strong>: You have two cows. You sell one and buy a bull.</p>
<p><strong>Surrealism</strong>: You have two cows. The government requires you to take harmonica lessons.
</p></blockquote>
<p>Do you know what politics is?</p>
<p><strong>What is politics?</strong></p>
<p>A little boy goes to his dad and asks, &#8220;What is politics?&#8221;</p>
<p>Dad says, &#8220;Well son, let me try to explain it this way: I&#8217;m the breadwinner of the family, so let&#8217;s call me capitalism. Your Mom, she&#8217;s the administrator of the money, so we&#8217;ll call her the Government. We&#8217;re here to take care of your needs, so we&#8217;ll call you the people. The nanny, we&#8217;ll consider her the Working Class. And your baby brother, we&#8217;ll call him the Future. Now, think about that and see if that makes sense,&#8221;</p>
<p>So the little boy goes off to bed thinking about what dad had said.</p>
<p>Later that night, he hears his baby brother crying, so he gets up to check on him. He finds that the baby has severely soiled his diaper. So the little boy goes to his parents&#8217; room and finds his mother sound asleep. Not wanting to wake her, he goes to the nanny&#8217;s room. Finding the door locked, he peeks in the keyhole and sees his father in bed with the nanny. He gives up and goes back to bed. The next morning, the little boy says to his father, &#8220;Dad, I think I understand the concept of politics now.&#8221;</p>
<p>The father says, &#8220;Good son, tell me in your own words what you think politics is all about.&#8221;</p>
<p>The little boy replies, &#8220;Well, while Capitalism is screwing the Working Class, the Government is sound asleep, the People are being ignored and the Future is in deep&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayesh.com.np/2008/07/some-believes-on-politics-and-its-terms/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How can I let download my file ?</title>
		<link>http://blog.jayesh.com.np/2008/07/how-can-i-let-download-my-file/</link>
		<comments>http://blog.jayesh.com.np/2008/07/how-can-i-let-download-my-file/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 06:57:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Cipher]]></category>

		<category><![CDATA[PHP pabulum]]></category>

		<category><![CDATA[download]]></category>

		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://blog.jayesh.com.np/?p=9</guid>
		<description><![CDATA[Normally, Downloading  is the process of taking a file from a computer on the Internet and saving that file on your computer. Are you searching for the PHP source code for downloading the file? Then, you are at the right place. Here is a simple PHP code, that let the file to download; you [...]]]></description>
			<content:encoded><![CDATA[<p>Normally, <strong>Downloading</strong>  is the process of taking a file from a computer on the Internet and saving that file on your computer. Are you searching for the <code>PHP source code</code> for <strong>downloading </strong>the file? Then, you are at the right place. Here is a simple PHP code, that let the file to download; you have uploaded. So, without delaying a second lets start to do our work.</p>
<p>&#8212;&#8212;&#8211;<br />
Firstly, create the download form that allows one to download the file.<br />
&#8212;&#8212;&#8211;<br />
[download_form.php]</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">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##################################</span>
<span style="color: #666666; font-style: italic;">#Copyright 2008, Jayesh Shrestha</span>
<span style="color: #666666; font-style: italic;">#You may use, modify and distribute  </span>
<span style="color: #666666; font-style: italic;">#this code as long as this copyright</span>
<span style="color: #666666; font-style: italic;"># notice is preserved.</span>
<span style="color: #666666; font-style: italic;">##################################</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre>&nbsp;
&lt;!-- form for download --&gt;
&nbsp;
&lt;form name=&quot;download&quot; action=&quot;download.php&quot; method=&quot;post&quot;&gt;</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> 
&nbsp;
<span style="color: #000033;">$safeFilename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/^<span style="color: #000099; font-weight: bold;">\w</span>+<span style="color: #000099; font-weight: bold;">\.</span><span style="color: #000099; font-weight: bold;">\w</span>+$/'</span><span style="color: #339933;">;</span> 
<span style="color: #000033;">$downloads</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;download-dir/&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre>&lt;select name=&quot;filename&quot;&gt;</pre></td></tr></table></div>


<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">  <span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
  <span style="color: #000033;">$dir</span> <span style="color: #339933;">=</span> <span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$downloads</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: #000033;">$dir</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Bad downloads setting&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// List only files with a safe filename</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">preg_match</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$safeFilename</span><span style="color: #339933;">,</span> <span style="color: #000033;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre>  &lt;option value=&quot;&lt;?php echo $file?&gt;&quot;&gt;&lt;?php echo $file?&gt;&lt;/option&gt;</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php">  <span style="color: #000000; font-weight: bold;">&lt;?php</span>
   <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #990000;">closedir</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$dir</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>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre>&lt;/select&gt;
&lt;input type=&quot;submit&quot; name=&quot;download&quot; value=&quot;Download&quot;&gt;
&lt;/form&gt;</pre></td></tr></table></div>

<p>&#8212;&#8212;&#8211;<br />
NOTE :: Place the files in the directory named (download_dir).<br />
&#8212;&#8212;&#8211;</p>
<p>[download.php]</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
</pre></td><td class="code"><pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">##################################</span>
<span style="color: #666666; font-style: italic;">#Copyright 2008, Jayesh Shrestha</span>
<span style="color: #666666; font-style: italic;">#You may use, modify and distribute  </span>
<span style="color: #666666; font-style: italic;">#this code as long as this copyright</span>
<span style="color: #666666; font-style: italic;"># notice is preserved.</span>
<span style="color: #666666; font-style: italic;">##################################</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'download'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000033;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #000033;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filename'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000033;">$downloads</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;download-dir/$filename&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Now make sure the file actually exists</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;$downloads&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot;&lt;h1&gt;File does not exist&lt;/h1&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//end of if 1.1</span>
  <span style="color: #b1b100;">else</span>
  <span style="color: #009900;">&#123;</span>
	  <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-disposition: attachment; filename=$filename&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: application/octet-stream&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #990000;">readfile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;$downloads&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	  <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
  <span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//end of else</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//end of if 1</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>To download a file, one generally needs to select file and click Download button , which automatically starts the download process. After starting the download, a dialog box will prompt the user to choose a place to download the file. This download location can be on the user’s hard-drive or a floppy disk. After choosing a location and clicking OK, the file will begin to download. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayesh.com.np/2008/07/how-can-i-let-download-my-file/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Some mathematics tricks for ease</title>
		<link>http://blog.jayesh.com.np/2008/07/some-mathematics-tricks-for-ease/</link>
		<comments>http://blog.jayesh.com.np/2008/07/some-mathematics-tricks-for-ease/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 12:07:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Trigger tricks]]></category>

		<category><![CDATA[math]]></category>

		<category><![CDATA[solutions]]></category>

		<category><![CDATA[trick]]></category>

		<guid isPermaLink="false">http://blog.jayesh.com.np/?p=8</guid>
		<description><![CDATA[If you are suffering pain using calculator for simple mathematics solutions. Then I hope tricks, I am listing here, really help you. 
Check it out >>> 
Multiply by Eleven(11)
The eleven times table has always been very easy to learn up to nine[(1 to 9) * 11]. Here&#8217;s a way of multiplying large numbers by 11 [...]]]></description>
			<content:encoded><![CDATA[<p><code>If you are suffering pain using calculator for simple mathematics solutions. Then I hope tricks, I am listing here, really help you. </code></p>
<p><strong>Check it out >>> </strong></p>
<p><strong>Multiply by Eleven(11)</strong><br />
<code>The eleven times table has always been very easy to learn up to nine[(1 to 9) * 11]. Here&#8217;s a way of multiplying large numbers by 11 too:</code></p>
<blockquote><p><code> Example:<br />
    Q. What is 123 x 11 ?<br />
<em>Trick</em><br />
    Sol. Write down the first digit &#8230;&#8230;&#8230;&#8230;	  = 1<br />
    &#8230;&#8230;.Add the first and second digits &#8230; 1 + 2  = 3<br />
    &#8230;&#8230;.Add the second and third digits &#8230; 2 + 3 = 5<br />
    &#8230;&#8230;.Write down the last digit &#8230;&#8230;&#8230; 	          = 3<br />
    The answer is 1353.</code><br />
 </code></p></blockquote>
<p><code> Try it for other numbers</code></p>
<p><strong>How to &#8220;Square&#8221; quickly?</strong><br />
<code>Did you know that there is a quick way of squaring a two digit number which ends in 5?<br />
Just multiply the first digit by that number plus one.... stick a 25 after your product and there's your answer .... simple ?<br />
</code></p>
<blockquote><p><code> Example:<br />
     Q. What is 25 squared?<br />
<em>Trick</em><br />
      Sol.<br />
     Here,<br />
	First number	    = First digit is     = 2<br />
	Second number	 = First digit+1     = 3<br />
	So,<br />
	      2&#215;3 = 6</p>
<p>    &#8230;..<code>now stick on the 25</code><br />
    &#8230;&#8230;&#8230;..<code>The answer is 625</code><br />
 </code></p></blockquote>
<p><code> Try it for other numbers</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jayesh.com.np/2008/07/some-mathematics-tricks-for-ease/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to generate CAPTCHA?</title>
		<link>http://blog.jayesh.com.np/2008/06/what-why-and-how-to-add-captcha/</link>
		<comments>http://blog.jayesh.com.np/2008/06/what-why-and-how-to-add-captcha/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 10:35:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Cipher]]></category>

		<category><![CDATA[PHP pabulum]]></category>

		<category><![CDATA[captcha]]></category>

		<category><![CDATA[example]]></category>

		<category><![CDATA[generate captcha]]></category>

		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://blog.jayesh.com.np/?p=7</guid>
		<description><![CDATA[CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) is a simple test to determine if a user is a computer or a human. It&#8217;s is a type of challenge-response test used in computing to ensure that the response is not generated by a computer.
CAPTCHA helps to prevent spam abuse on the [...]]]></description>
			<content:encoded><![CDATA[<p>CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) is a simple test to determine if a user is a computer or a human. It&#8217;s is a type of challenge-response test used in computing to ensure that the response is not generated by a computer.</p>
<p>CAPTCHA helps to prevent spam abuse on the websites. So if you use CAPTCHA on your web site forms, this can help in stopping some bots and making life harder for other bots in accessing or using your forms. In brief the CAPTCHA protection works by generating a random string, writing it to an image, then storing the string inside of a session or by some other method. This is then checked when the form is submitted.</p>
<p>Here is the full code demonstrating how to make your own simple CAPTCHA protection using PHP.</p>
<p>class.captcha.php [source-code]</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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
</pre></td><td class="code"><pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> captcha
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000033;">$charArray</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: #000000; font-weight: bold;">function</span> captcha<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> make_seed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
   		<span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$usec</span><span style="color: #339933;">,</span> <span style="color: #000033;">$sec</span><span style="color: #009900;">&#41;</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: #009900;">&#40;</span>float<span style="color: #009900;">&#41;</span> <span style="color: #000033;">$sec</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>float<span style="color: #009900;">&#41;</span> <span style="color: #000033;">$usec</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">100000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> generateCaptcha<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//$captcha = array();</span>
		<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000033;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span><span style="color: #000033;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000033;">$p</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</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: #000033;">$p</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">charArray</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">65</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</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: #000033;">$p</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">charArray</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">97</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">122</span><span style="color: #009900;">&#41;</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: #000033;">$p</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">charArray</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">48</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">57</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000033;">$tempStr</span> <span style="color: #339933;">.=</span> <span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">charArray</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000033;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'captcha'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$tempStr</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: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">charArray</span><span style="color: #339933;">;;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> randomCharsGenerator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000033;">$ranCharArray</span> <span style="color: #339933;">=</span> 
&nbsp;
<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;A&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;B&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;C&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;D&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;E&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;F&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;G&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;H&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;I&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;J&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;K&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;L&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;M&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;N&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;O&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;P&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Q&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;R&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;S&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;T&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;U&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;V&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;W&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;X&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Y&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Z&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;a&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;b&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;c&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;d&quot;</span>
&nbsp;
<span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;e&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;f&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;g&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;h&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;i&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;j&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;k&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;l&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;m&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;o&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;p&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;q&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;r&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;s&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;t&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;u&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;v&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;w&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;x&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;y&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;z&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;1&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;2&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;3&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;4&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;5&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;6&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;7&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;8&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;9&quot;</span><span style="color: #339933;">,</span>
&nbsp;
<span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000033;">$sizeOfArray</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$ranCharArray</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000033;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span> <span style="color: #000033;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">srand</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">make_seed</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: #666666; font-style: italic;">//$ascii = rand(64,90);</span>
			<span style="color: #666666; font-style: italic;">//$this-&gt;charArray[$i] = chr($ascii);</span>
			<span style="color: #000033;">$temp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000033;">$sizeOfArray</span><span style="color: #cc66cc;">-1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">charArray</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000033;">$ranCharArray</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$temp</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000033;">$tempStr</span> <span style="color: #339933;">.=</span> <span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">charArray</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000033;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'captcha'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$tempStr</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: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">charArray</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> randomDirtGenerator<span style="color: #009900;">&#40;</span><span style="color: #000033;">$dirt</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000033;">$ranDirtArray</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;:&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;~&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;`&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;_&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000033;">$dirtArray</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>
		<span style="color: #000033;">$sizeOfArray</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$ranDirtArray</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000033;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #000033;">$dirt</span><span style="color: #339933;">;</span> <span style="color: #000033;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">srand</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">make_seed</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: #000033;">$temp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000033;">$sizeOfArray</span><span style="color: #cc66cc;">-1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000033;">$dirtArray</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000033;">$ranDirtArray</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$temp</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000033;">$dirtArray</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> getValue<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: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">charArray</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> captchaMaker<span style="color: #009900;">&#40;</span><span style="color: #000033;">$width</span><span style="color: #339933;">,</span> <span style="color: #000033;">$height</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000033;">$canvas</span> <span style="color: #339933;">=</span> ImageCreate<span style="color: #009900;">&#40;</span><span style="color: #000033;">$width</span><span style="color: #339933;">,</span> <span style="color: #000033;">$height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000033;">$red</span> <span style="color: #339933;">=</span> ImageColorAllocate<span style="color: #009900;">&#40;</span><span style="color: #000033;">$canvas</span><span style="color: #339933;">,</span>0xe4<span style="color: #339933;">,</span>0x2e<span style="color: #339933;">,</span>0x2e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000033;">$white</span> <span style="color: #339933;">=</span> ImageColorAllocate<span style="color: #009900;">&#40;</span><span style="color: #000033;">$canvas</span><span style="color: #339933;">,</span>0xff<span style="color: #339933;">,</span>0xff<span style="color: #339933;">,</span>0xff<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000033;">$gray</span> <span style="color: #339933;">=</span> ImageColorAllocate<span style="color: #009900;">&#40;</span><span style="color: #000033;">$canvas</span><span style="color: #339933;">,</span>0x80<span style="color: #339933;">,</span>0x80<span style="color: #339933;">,</span>0x80<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000033;">$blue</span> <span style="color: #339933;">=</span> ImageColorAllocate<span style="color: #009900;">&#40;</span><span style="color: #000033;">$canvas</span><span style="color: #339933;">,</span>0x33<span style="color: #339933;">,</span>0x66<span style="color: #339933;">,</span>0x99<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000033;">$black</span> <span style="color: #339933;">=</span> ImageColorAllocate<span style="color: #009900;">&#40;</span><span style="color: #000033;">$canvas</span><span style="color: #339933;">,</span>0x00<span style="color: #339933;">,</span>0x00<span style="color: #339933;">,</span>0x00<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		ImageFilledRectangle<span style="color: #009900;">&#40;</span><span style="color: #000033;">$canvas</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #000033;">$width</span><span style="color: #cc66cc;">-2</span><span style="color: #339933;">,</span><span style="color: #000033;">$height</span><span style="color: #cc66cc;">-2</span><span style="color: #339933;">,</span><span style="color: #000033;">$white</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//$ranChars = $this-&gt;randomCharsGenerator();</span>
		<span style="color: #000033;">$ranChars</span> <span style="color: #339933;">=</span> <span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">generateCaptcha</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000033;">$ranDirts</span> <span style="color: #339933;">=</span> <span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">randomDirtGenerator</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000033;">$boundaryX</span> <span style="color: #339933;">=</span> <span style="color: #990000;">abs</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$width</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000033;">$boundaryY</span> <span style="color: #339933;">=</span> <span style="color: #000033;">$height</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//$font = array(&quot;times&quot;,&quot;arial&quot;,&quot;comic&quot;);</span>
&nbsp;
		<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000033;">$i</span><span style="color: #339933;">&lt;</span>sizeof<span style="color: #009900;">&#40;</span><span style="color: #000033;">$ranChars</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000033;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">srand</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">make_seed</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: #000033;">$ranAngle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">-45</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">45</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000033;">$ranX</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$i</span><span style="color: #339933;">*</span><span style="color: #000033;">$boundaryX</span><span style="color: #009900;">&#41;</span><span style="color: #cc66cc;">+30</span><span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$i</span><span style="color: #cc66cc;">+1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #000033;">$boundaryX</span><span style="color: #009900;">&#41;</span><span style="color: #cc66cc;">-30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000033;">$ranY</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span> <span style="color: #000033;">$boundaryY</span><span style="color: #cc66cc;">-30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000033;">$ranFont</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$font</span><span style="color: #009900;">&#41;</span><span style="color: #cc66cc;">-1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			ImageTTFText<span style="color: #009900;">&#40;</span><span style="color: #000033;">$canvas</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">20</span><span style="color: #339933;">,</span><span style="color: #000033;">$ranAngle</span><span style="color: #339933;">,</span><span style="color: #000033;">$ranX</span><span style="color: #339933;">,</span><span style="color: #000033;">$ranY</span><span style="color: #339933;">,</span><span style="color: #000033;">$black</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;arial.ttf&quot;</span><span style="color: #339933;">,</span><span style="color: #000033;">$ranChars</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000033;">$color</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;$red&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;$blue&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;$gray&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;$black&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000033;">$fontSize</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">9</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000033;">$i</span><span style="color: #339933;">&lt;</span>sizeof<span style="color: #009900;">&#40;</span><span style="color: #000033;">$ranDirts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000033;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000033;">$ranAngle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">-60</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000033;">$ranX</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #000033;">$width</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000033;">$ranY</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #000033;">$height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">srand</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">make_seed</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: #000033;">$ranColor</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$color</span><span style="color: #009900;">&#41;</span><span style="color: #cc66cc;">-1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000033;">$ranFontSize</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #990000;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$fontSize</span><span style="color: #009900;">&#41;</span><span style="color: #cc66cc;">-1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
ImageTTFText<span style="color: #009900;">&#40;</span><span style="color: #000033;">$canvas</span><span style="color: #339933;">,</span><span style="color: #000033;">$fontSize</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$ranFontSize</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000033;">$ranAngle</span><span style="color: #339933;">,</span><span style="color: #000033;">$ranX</span><span style="color: #339933;">,</span><span style="color: #000033;">$ranY</span><span style="color: #339933;">,</span><span style="color: #000033;">$color</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$ranColor</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;arial.ttf&quot;</span><span style="color: #339933;">,</span><span style="color: #000033;">$ranDirts</span><span style="color: #009900;">&#91;</span><span style="color: #000033;">$i</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;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Expires: Wed, 1 Jan 1990 00:00:00 GMT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Last-Modified: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">gmdate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D, d M Y H:i:s&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; GMT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-Control: no-store, no-cache, must-revalidate&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-Control: post-check=0, pre-check=0&quot;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Pragma: no-cache&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-type: image/jpeg'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ImageJPEG<span style="color: #009900;">&#40;</span><span style="color: #000033;">$canvas</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		<span style="color: #666666; font-style: italic;">//return $canvas;	</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000033;">$a</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> captcha<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000033;">$canvas</span><span style="color: #339933;">=</span><span style="color: #000033;">$a</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">captchaMaker</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">350</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.jayesh.com.np/2008/06/what-why-and-how-to-add-captcha/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How can I embed &#8220;Google Search&#8221; box in my web-site?</title>
		<link>http://blog.jayesh.com.np/2008/06/how-can-i-embed-google-search-box-in-my-web-site/</link>
		<comments>http://blog.jayesh.com.np/2008/06/how-can-i-embed-google-search-box-in-my-web-site/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 06:10:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Google ground]]></category>

		<category><![CDATA[google]]></category>

		<category><![CDATA[html]]></category>

		<category><![CDATA[search]]></category>

		<category><![CDATA[search box]]></category>

		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://blog.jayesh.com.np/?p=6</guid>
		<description><![CDATA[Dear friends, you may be wandering how to embed &#8220;Google Search&#8221; box in your website. Do not worry it&#8217;s so simple to add it.Google itself actually provides you a nice page along with HTML code. Just what you need to do is copy and paste it onto your web page.
NOTE :: Layout can be changed, [...]]]></description>
			<content:encoded><![CDATA[<p>Dear friends, you may be wandering how to embed &#8220;Google Search&#8221; box in your website. Do not worry it&#8217;s so simple to add it.Google itself actually provides you a nice page along with HTML code. Just what you need to do is copy and paste it onto your web page.<br />
NOTE :: Layout can be changed, it all depends upto you.</p>
<p>Google provides mainly three &#8220;Google Free Web Search&#8221;.</p>
<p>*** First one is simple version of the Google Search box.It works as you copy and paste it into your HTML content.</p>
<p>CODE</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
</pre></td><td class="code"><pre>&nbsp;
&lt;!-- Search Google --&gt;
&lt;center&gt;
&lt;FORM method=GET action=&quot;http://www.google.com/search&quot;&gt;
&lt;input type=hidden name=ie value=UTF-8&gt;
&lt;input type=hidden name=oe value=UTF-8&gt;
&lt;TABLE bgcolor=&quot;#FFFFFF&quot;&gt;&lt;tr&gt;&lt;td&gt;
&lt;A HREF=&quot;http://www.google.com/&quot;&gt;
&lt;IMG SRC=&quot;http://www.google.com/logos/Logo_40wht.gif&quot;
border=&quot;0&quot; ALT=&quot;Google&quot; align=&quot;absmiddle&quot;&gt;&lt;/A&gt;
&lt;INPUT TYPE=text name=q size=25 maxlength=255 value=&quot;&quot;&gt;
&lt;INPUT type=submit name=btnG VALUE=&quot;Google Search&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/TABLE&gt;
&lt;/FORM&gt;
&lt;/center&gt;
&lt;!-- Search Google --&gt;</pre></td></tr></table></div>

<p>*** Next one is &#8220;Google Free SafeSearch&#8221;, that represents a safe version of the Google Search box, because it will return only sites without adult or explicit sexual content. You can add it to you website by copying the text below and pasting it into your HTML code.</p>
<p>CODE</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
</pre></td><td class="code"><pre>&nbsp;
&lt;!-- Google SafeSearch --&gt;
&lt;center&gt;
&lt;FORM method=GET action=&quot;http://www.google.com/search&quot;&gt;
&lt;input type=hidden name=ie value=UTF-8&gt;
&lt;input type=hidden name=oe value=UTF-8&gt;
&lt;TABLE bgcolor=&quot;#FFFFFF&quot;&gt;&lt;tr&gt;&lt;td&gt;
&lt;A HREF=&quot;http://www.google.com/search?safe=vss&quot;&gt;
&lt;IMG SRC=&quot;http://www.google.com/logos/Google_Safe.gif&quot;
border=&quot;0&quot; ALT=&quot;Google&quot; width=&quot;115&quot; height=&quot;45&quot; align=&quot;absmiddle&quot;&gt;&lt;/A&gt;
&lt;INPUT TYPE=text name=q size=25 maxlength=255 value=&quot;&quot;&gt;
&lt;INPUT type=hidden name=safe value=strict&gt;
&lt;INPUT type=submit name=sa value=&quot;Google Search&quot;&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/TABLE&gt;
&lt;/FORM&gt;
&lt;/center&gt;
&lt;!-- Google SafeSearch --&gt;</pre></td></tr></table></div>

<p>*** The last and the most complex search box is Google Free web search with site search that will allow users to search the Internet or search your website, an action that will offer a better navigation and quick access to your menus.</p>
<p>CODE</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
</pre></td><td class="code"><pre>&nbsp;
&lt;!-- SiteSearch Google --&gt;
&lt;FORM method=GET action=&quot;http://www.google.com/search&quot;&gt;
&lt;input type=hidden name=ie value=UTF-8&gt;
&lt;input type=hidden name=oe value=UTF-8&gt;
&lt;TABLE bgcolor=&quot;#FFFFFF&quot; align=&quot;center&quot;&gt;&lt;tr&gt;&lt;td&gt;
&lt;A HREF=&quot;http://www.google.com/&quot;&gt;
&lt;IMG SRC=&quot;http://www.google.com/logos/Logo_40wht.gif&quot;
border=&quot;0&quot; ALT=&quot;Google&quot;&gt;&lt;/A&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;INPUT TYPE=text name=q size=31 maxlength=255 value=&quot;&quot;&gt;
&lt;INPUT type=submit name=btnG VALUE=&quot;Google Search&quot;&gt;
&lt;font size=-1&gt;
&lt;input type=hidden name=domains value=&quot;YOUR DOMAIN NAME&quot;&gt;&lt;br&gt;&lt;input type=radio
&nbsp;
name=sitesearch value=&quot;&quot;&gt; Web Search &lt;input type=radio name=sitesearch value=&quot;YOUR DOMAIN
&nbsp;
NAME&quot; checked&gt; Site Search &lt;br&gt;
&lt;/font&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/TABLE&gt;
&lt;/FORM&gt;
&lt;!-- SiteSearch Google --&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.jayesh.com.np/2008/06/how-can-i-embed-google-search-box-in-my-web-site/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
