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

<channel>
	<title>Public Mindphp</title>
	<atom:link href="http://publicmind.in/blog/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://publicmind.in/blog</link>
	<description>Simple and Sophisticated</description>
	<lastBuildDate>Thu, 13 May 2010 23:32:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PHP: Encoding a URL before accessing it</title>
		<link>http://publicmind.in/blog/url-encoding/</link>
		<comments>http://publicmind.in/blog/url-encoding/#comments</comments>
		<pubDate>Sat, 08 May 2010 16:56:34 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=605</guid>
		<description><![CDATA[I discussed a little about URL encoding in my recent post Facebook: Bug with URL encoding, although it seems like the bug still exists. In this post I will discuss &#8220;how to encode a given URL before accessing it using CURL or fsockopen&#8221;. The problem with URLs is that they might contain certain disallowed characters [...]]]></description>
			<content:encoded><![CDATA[<p>I discussed a little about URL encoding in my recent post <a title="Facebook: Bug with URL encoding" href="http://publicmind.in/blog/facebook-bug-with-url-encoding/">Facebook: Bug with URL encoding</a>, although it seems like the bug still exists. In this post I will discuss &#8220;how to encode a given URL before accessing it using CURL or fsockopen&#8221;. The problem with URLs is that they might contain certain disallowed characters like spaces, according to RFC 3986. Our aim is to convert these invalid characters to their <a href="http://en.wikipedia.org/wiki/Percent-encoding" target="_blank">percentage encoded values</a> in a given URL , so that we can access the URL using our regular HTTP request methods. For example the URL [http://example.com/space space] should be converted to [http://example.com/space%20space] before we can access it using CURL. However, the URL [http://example.com/percents%25percent] is perfectly valid as it doesn&#8217;t contains any of the disallowed characters.<br />
<span id="more-605"></span><br />
The given URL can only contain characters which are allowed by RFC 3986 which includes alpha-numeric characters along with reserved characters and delimiters  (<strong>:</strong> | <strong>/</strong> | <strong>?</strong> | <strong>#</strong> | <strong>[</strong> | <strong>]</strong> | <strong>@ </strong>| <strong>!</strong> | <strong>$</strong> | <strong>&amp;</strong> | <strong>&#8216; </strong>| <strong>(</strong> | <strong>)</strong> | <strong>*</strong> | <strong>+</strong> | <strong>,</strong> | <strong>;</strong> | <strong>=</strong> | <strong>%</strong>).  The following piece of code changes the disallowed characters in the URL to their corresponding percentage encoded values. The characters and delimiters which are allowed are left untouched.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:700px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009933; font-style: italic;">/**<br />
* @param $url<br />
* &nbsp; &nbsp; The URL to encode<br />
*<br />
* @return<br />
* &nbsp; &nbsp; A string containing the encoded URL with disallowed<br />
* &nbsp; &nbsp; characters converted to their percentage encodings.<br />
*/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> encode_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$reserved</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
<span style="color: #0000ff;">&quot;:&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%3A!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%2F!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;?&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%3F!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;#&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%23!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;[&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%5B!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;]&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%5D!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;@&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%40!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;!&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%21!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;$&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%24!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;&amp;amp;&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%26!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;'&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%27!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;(&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%28!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;)&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%29!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;*&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%2A!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;+&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%2B!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;,&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%2C!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;;&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%3B!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;=&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%3D!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #0000ff;">&quot;%&quot;</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000ff;">'!%25!ui'</span><span style="color: #339933;">,</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/rawurlencode"><span style="color: #990000;">rawurlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/array_values"><span style="color: #990000;">array_values</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$reserved</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array_keys"><span style="color: #990000;">array_keys</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$reserved</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>One thing to notice here is that the &#8216;%&#8217; character must be the last in the <em>$reserved</em> array. This makes sure that the already encoded values are not lost or encoded again.</p>
<p><strong>Note</strong>: This might not be the best solution but well, it works. If you are using something better, let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/url-encoding/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>&#8220;What is Drupal?&#8221;, for newbies</title>
		<link>http://publicmind.in/blog/what-is-drupal-for-newbies/</link>
		<comments>http://publicmind.in/blog/what-is-drupal-for-newbies/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 22:55:16 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=432</guid>
		<description><![CDATA[I often come across this question from my friends and peers and most of the time I deflect it by saying &#8220;it lets you create your website easily, why don&#8217;t you look up on Wikipedia?&#8221;. Few days ago, one of my friends pointed me that most of the articles start with &#8220;Drupal is a Content Management [...]]]></description>
			<content:encoded><![CDATA[<p>I often come across this question from my friends and peers and most of the time I deflect it by saying &#8220;it lets you create your website easily, why don&#8217;t you look up on Wikipedia?&#8221;. Few days ago, one of my friends pointed me that most of the articles start with &#8220;Drupal is a Content Management System(CMS) &#8230;&#8221; which becomes pretty much confusing when one has no idea about what a CMS is. In this post, I have tried to explain what a CMS is and why we need it and how Drupal stands out among various other available CMSs.</p>
<p>Let us say you need to create a webpage for your website. Ideally, it would mean you create HTML content that will be delivered to someone who requests it through their web browser. Eventually you grow big and decide to add 100 more pages to your website and therefore create 100 more HTML pages. But then you realize that there is a lot of duplicate content. The footer which contains the copyright information is essentially the same on all pages, therefore if you ever need to edit it then it would mean to edit these 101 pages. This will be a lot of redundant work.<br />
<span id="more-432"></span><br />
The main problem with the HTML pages is that they are static, they can not be changed based on what user requests. Thats why we need to have two different pages, even if they are almost similar and just differ by a single line. But then we also need to send the HTML content to the web browsers. That is where scripting languages such as PHP, ASP, JSP come as a savior. These languages are capable of creating dynamic content. The data is usually stored in the database and whenever a request comes for a page, HTML content will be created from this data on-the-fly and will be sent back to the requesting user. Now, you just need to store that copyright information just once, hence changing it becomes much easier.</p>
<p>Now, you also want to control which users have permission to access certain portion of the website and you create a login page for that part of the website, store cookies and write other code to maintain the session for the user. You might also want to publish a webpage on the fly, i.e.  save content to the database right from the user browser. You need some kind of access control mechanism and believe me it will be a hell lot of work to do.</p>
<p>That is where web-based Content Management System come into picture. They take out all the programming part from the publishing part of your website. You just need to write the content that has to be published on your website, make some settings on how it will be displayed, whether anyone or only authenticated users can see that content and you are done (of course, this is overly simplified but believe me once you know this everything will look so obvious to you).</p>
<p>With a CMS, one can easily create a website which :</p>
<ol>
<li>allows large number of people to contribute and share data.</li>
<li>easily manages user access control lists.</li>
<li>have reduced duplicate content.</li>
</ol>
<p>Drupal is one of the several available CMS is the market which is written in PHP and uses MySQL or PostgreSQL as database to store the website content. Drupal is released under GNU General Public License.</p>
<p><strong>What can you achieve with Drupal?</strong></p>
<p>You can easily create and manage,</p>
<ul>
<li>personal homepage</li>
<li>company website</li>
<li>blog</li>
<li>shopping websites (just like Ebay or Amazon)</li>
<li>Social networking sites like Twitter or Facebook</li>
</ul>
<p>With Drupal, you can create any kind of website, Imagination is the limit. Just FYI, White House uses Drupal to manage its official website: <a href="http://whitehouse.gov">whitehouse.gov</a></p>
<p>As with every other product, there are several other alternatives to Drupal such as Joomla, TYPO3, Nucleus, WordPress, etc. You can find the whole list of available CMS here: <a href="http://en.wikipedia.org/wiki/List_of_content_management_systems" target="_blank">List of Content Management Systems</a>. But what makes Drupal stand out is :</p>
<ol>
<li>its ease of use</li>
<li>a large community of developers which keeps everything secure and up to date.</li>
<li>a large pool of modules and themes. A module in Drupal lets you do things which aren&#8217;t supported by default in Drupal.</li>
</ol>
<p>Here is a small 1 minute video on &#8220;What is Drupal&#8221;, this video has already won six Telly awards:</p>
<p><object width="425" height="349"><param name="movie" value="http://www.youtube.com/v/rF1X12PE6PY&#038;rel=0&#038;border=1&#038;color1=0x3a3a3a&#038;color2=0x999999&#038;hl=en_US&#038;feature=player_embedded&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/rF1X12PE6PY&#038;rel=0&#038;border=1&#038;color1=0x3a3a3a&#038;color2=0x999999&#038;hl=en_US&#038;feature=player_embedded&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="425" height="349"></embed></object></p>
<p><strong>Drupal Website Hosting</strong></p>
<p><strong></strong>There are a lot of web hosting providers in the market and I know you will research well before buying anything. Most of them provide a one-click Drupal installation which saves you a lot of trouble while installing Drupal. I recommend you to look for such a web host, well all is up to you anyway.</p>
<p>You are now ready to eat up the Wikipedia article on Drupal. You can visit official Drupal website to look for great tutorials and downloads. Here are a few important links:</p>
<p>Official Drupal website: <a href="http://drupal.org">http://drupal.org</a><br />
Modules Resource: <a href="http://drupal.org/project/modules">http://drupal.org/project/modules</a><br />
Themes Resource: <a href="http://drupal.org/project/themes">http://drupal.org/project/themes</a><br />
Wikipedia article: <a href="http://en.wikipedia.org/wiki/Drupal">http://en.wikipedia.org/wiki/Drupal</a></p>
<p>Do not forget to vote for this post on DZone or Digg if you liked it, or you can leave a comment or two.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/what-is-drupal-for-newbies/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WordPress: WP ShareThisPost</title>
		<link>http://publicmind.in/blog/wordpress-sharethispost/</link>
		<comments>http://publicmind.in/blog/wordpress-sharethispost/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 22:12:31 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[bookmarking]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[sharing]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=386</guid>
		<description><![CDATA[Although the third party bookmarking and sharing tools are quite useful to analyze the sharing trends on your blog, they do slow down the whole process of sharing. Also, as mentioned in my Sharing and Bookmarking Tools post, I was not comfortable with the small icons available with Bookmarkify and Socialable. WP ShareThisPost is a [...]]]></description>
			<content:encoded><![CDATA[<p>Although the third party bookmarking and sharing tools are quite useful to analyze the sharing trends on your blog, they do slow down the whole process of sharing. Also, as mentioned in my <a title="Sharing and Bookmarking Tools" href="http://publicmind.in/blog/share-bookmark-tools/">Sharing and Bookmarking Tools</a> post, I was not comfortable with the small icons available with Bookmarkify and Socialable. <strong>WP ShareThisPost</strong> is a small custom wordpress plugin which provides large icons along with the flexibility to add your favorite sharing and bookmarking sites (if not included by default).</p>
<p><strong>WP ShareThisPost</strong> includes the following sharing and bookmarking sites, by default:</p>
<ul>
<li>del.icio.us</li>
<li>Digg</li>
<li>Google Bookmarks</li>
<li>StumbleUpon</li>
<li>Facebook</li>
<li>Twitter</li>
<li>Technorati</li>
</ul>
<p><span id="more-386"></span><br />
Go through the readme.txt file to know how you can customize <strong>WP ShareThisPost</strong> to include more of your favorite sharing and bookmarking sites.</p>
<p><strong>WP ShareThisPost</strong>, by default, only adds the sharing and bookmarking links at the end of posts. You can see the readme.txt file to see how you can change that to include pages, archives, feeds, etc.</p>
<p><a href='https://sourceforge.net/projects/wpsharethispost/' title='WP ShareThisPost'><img src='http://publicmind.in/blog/wp-content/uploads/downloadbutton.gif' alt='Download' /></a></p>
<h2><strong>Installation</strong></h2>
<p>Upload the unzipped folder into the plugins folder of your wordpress installation (usually /wp-content/plugins), activate it and you are ready to go. You will see the desired links below each of your posts:</p>
<p style="text-align: center;">
<div id="attachment_388" class="wp-caption aligncenter" style="width: 478px"><a href="http://publicmind.in/blog/wp-content/uploads/2010/01/wp_sharethispost.jpg"><img class="size-full wp-image-388 " title="WP ShareThisPost" src="http://publicmind.in/blog/wp-content/uploads/2010/01/wp_sharethispost.jpg" alt="WP ShareThisPost" width="468" height="91" /></a><p class="wp-caption-text">WP ShareThisPost</p></div>
<h2>Styling</h2>
<p>I use this CSS to style my WP ShareThisPost, adapt as you wish of course by changing the wp_sharethispost.css file:</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:500px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #cc00cc;">#content</span> <span style="color: #6666ff;">.wp_sharethispost</span> ul <span style="color: #00AA00;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span> !important<span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> !important<span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #cc00cc;">#content</span> <span style="color: #6666ff;">.wp_sharethispost</span> ul li <span style="color: #00AA00;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span> !important<span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #933;">15px</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #cc00cc;">#content</span> <span style="color: #6666ff;">.wp_sharethispost</span> li<span style="color: #3333ff;">:before </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span><br />
<span style="color: #cc00cc;">#content</span> <span style="color: #6666ff;">.wp_sharethispost</span> img <span style="color: #00AA00;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">48px</span><span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">48px</span><span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span><br />
<span style="color: #cc00cc;">#content</span> <span style="color: #6666ff;">.wp_sharethispost</span> <span style="color: #6666ff;">.wp_sharethispost_tagline</span> <span style="color: #00AA00;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.5em</span><span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#486472</span><span style="color: #00AA00;">;</span><br />
<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/wordpress-sharethispost/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Select HTML elements with more than one css class using XPath</title>
		<link>http://publicmind.in/blog/html-elements-with-more-than-one-css-class/</link>
		<comments>http://publicmind.in/blog/html-elements-with-more-than-one-css-class/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 22:39:43 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[xpath]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=309</guid>
		<description><![CDATA[Recently, while working on my project FeedAPI ImageGrabber I came across the issue where I had to select HTML elements by a given css class. The HTML element can have a single CSS class: 1&#60;div class=&#34;foo&#34;&#62;&#60;/div&#62; or multiple CSS classes associated with it. 1&#60;div class=&#34;foo exp tar&#34;&#62;&#60;/div&#62; Now if you want to select the HTML [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, while working on my project <a href="http://publicmind.in/blog/feedapi-imagegrabber">FeedAPI ImageGrabber</a> I came across the issue where I had to select HTML elements by a given css class. The HTML element can have a single CSS class:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>or multiple CSS classes associated with it.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span>div <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;foo exp tar&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>Now if you want to select the HTML elements with class &#8220;foo&#8221;, this div element would be one of them.<br />
<span id="more-309"></span><br />
As, I do not have much experience with XPath, I started to search for a solution. After a lot of search and discussion on Drupal development mailing lists, I arrived at the following XPath :</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #666666; font-style: italic;">//*[@class and contains(concat(' ',normalize-space(@class),' '),' $classname ')]</span></div></td></tr></tbody></table></div>
<p>The <strong>normalize-space</strong> function replaces all continuous tabs and whitespaces with a single whitespace character. Then, we concatenate the resulting string with two white-spaces, one in the start and other at the last. At last, we search for</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">' '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$classname</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' '</span></div></td></tr></tbody></table></div>
<p>in the final string.</p>
<p>I hope it helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/html-elements-with-more-than-one-css-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MYSQL: Get the Auto-Increment Values after Insert Statement</title>
		<link>http://publicmind.in/blog/mysql-auto-increment-values/</link>
		<comments>http://publicmind.in/blog/mysql-auto-increment-values/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 12:24:32 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[Intern]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=218</guid>
		<description><![CDATA[Until sometime back, I was unaware of how I could get the value of an auto-incremented field after an Insert Statement. But recently I needed it for two of my projects simultaneously, so I explored the possibilities. As one of my project is in Java and other is in PHP, we will go through both [...]]]></description>
			<content:encoded><![CDATA[<p>Until sometime back, I was unaware of how I could get the value of an auto-incremented field after an Insert Statement. But recently I needed it for two of my projects simultaneously, so I explored the possibilities. As one of my project is in Java and other is in PHP, we will go through both of them. </p>
<p>So, here is the problem. In general, the PRIMARY KEY field is the AUTO_INCREMENT field. Now wen you insert a row, a new key is generated and you can&#8217;t get it through usual way as this row can be accessed only using the primary key.</p>
<p>So here is how it can be done:<br />
<span id="more-218"></span><br />
<strong>In JAVA: </strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">/*Insert a row into the desired table that generates <br />
an auto increment field*/</span><br />
<br />
stmt.<span style="color: #006633;">executeUpdate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Insert into tableName (col1, col2) values (val1, val2)&quot;</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astatement+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Statement</span></a>.<span style="color: #006633;">RETURN_GENERATED_KEYS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aresultset+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ResultSet</span></a> rs <span style="color: #339933;">=</span> stmt.<span style="color: #006633;">getGeneratedKeys</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">int</span> autoIncValue <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>rs.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;autoIncValue <span style="color: #339933;">=</span> rs.<span style="color: #006633;">getInt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">/*You can get more generated keys if they are generated in your code*/</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>In PHP</strong>:</p>
<p>The mysql_insert_id() function in PHP returns the AUTO_INCREMENT ID generated from the previous INSERT operation.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<span style="color: #000088;">$con</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_connect"><span style="color: #990000;">mysql_connect</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hostname&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error while connecting: '</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000088;">$db_selected</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_select_db"><span style="color: #990000;">mysql_select_db</span></a><span style="color: #009900;">&#40;</span>database_name<span style="color: #339933;">,</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO tablename VALUES (val1,val2)&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #339933;">,</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;ID of last inserted record is: &quot;</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mysql_insert_id"><span style="color: #990000;">mysql_insert_id</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<a href="http://www.php.net/mysql_close"><span style="color: #990000;">mysql_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$con</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>Note: Be sure to call mysql_insert_id() immediately after a query to get the correct value. The function returns 0 if the previous query does not generate an AUTO_INCREMENT value, or FALSE if no MySQL connection was established. </p>
<p>Enjoy!!</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/mysql-auto-increment-values/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sharing and Bookmarking Tools</title>
		<link>http://publicmind.in/blog/share-bookmark-tools/</link>
		<comments>http://publicmind.in/blog/share-bookmark-tools/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 08:33:07 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=89</guid>
		<description><![CDATA[It takes me quite a lot of time to write a post here, mainly because I have very less going on in my life at the moment. But if you were following this blog closely (I know you weren&#8217;t ), you might have noticed that I kept playing with the SHARING and BOOKMARKING tools. I [...]]]></description>
			<content:encoded><![CDATA[<p>It takes me quite a lot of time to write a post here, mainly because I have very less going on in my life at the moment. But if you were following this blog closely (I know you weren&#8217;t <img src='http://publicmind.in/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ), you might have noticed that I kept playing with the SHARING and BOOKMARKING tools. I started off with the <strong>bookmarkify</strong>, then tried <strong>addthis</strong> and then finally settled for <strong>tellafriend</strong>.  Although, I am still thinking of shifting back to <strong>Bookmarkify</strong>, right now I am sticking with <strong>TellaFriend</strong>. As far as the features are concerned, they all almost provide the same kind of features. All of them provide access to over 50 Bookmarking sites, not to forget the &#8220;Email this&#8221; option. Here is a short review on the following Bookmarking tools.<br />
<span id="more-89"></span></p>
<ol>
<li><strong>Bookmarkify:</strong> This WordPress plugin lets you insert social bookmarking links in your posts and other pages. The most important advantage Bookmarkify has is that it put direct links to the bookmarking and sharing websites on your pages/posts. This saves you from depending on another website (as in both of the next two tools) for bookmarking your pages. Visit the official plugin page for more of its features.  So, why I am not using it? The one and only reason I am not using it is because of the tiny icons it places on your post.
<div id="attachment_158" class="wp-caption aligncenter" style="width: 502px"><img class="size-full wp-image-158" title="bookmarkify" src="http://publicmind.in/blog/wp-content/uploads/2009/04/screenshot-2.png" alt="Small Images by Bookmarkify" width="492" height="116" /><p class="wp-caption-text">Small Images by Bookmarkify</p></div><br />
May be, I will modify it to use large icons in near future.</li>
<li><strong>AddThis</strong>: The next two plugins are almost similar. They both place a javascript on your posts/pages, which opens the list of available sharing options. The major difference between these two and Bookmarkify is that, rather than putting a direct link to the bookmarking sites, they put a link to their site which redirects to the Bookmarking or Sharing site. So, how is this advantageous? Well!! you can keep track of the visitors who digged your websites, how many times its already digged/shared and if it gets highly shared, get prepared for the high traffic. These tools also offer powerful analytics so you can learn how and where your visitors are sharing your content.
<p><div id="attachment_161" class="wp-caption aligncenter" style="width: 487px"><img class="size-full wp-image-161" title="addthis" src="http://publicmind.in/blog/wp-content/uploads/2009/04/screenshot-2.gif" alt="mouseover the bookmarking button" width="477" height="269" /><p class="wp-caption-text">mouseover the bookmarking button</p></div></li>
<li><strong>TellaFriend</strong>: Although this tool differs from the last one ideologically, it is quite similar to Addthis. TellaFriend is made for the &#8220;word of mouth&#8221; kind of sharing. For this, it integrates the most famous email-service providers (Gmail, Yahoo, Hotmail), so that they can get your address book to you and you can share it to your friends without even having to remember their email addresses. It also integrates the famous IM (Gtalk, Yahoo messenger,) and Blogging (WordPress, Blogger, ) services for promoting the same idea.
<p><div id="attachment_162" class="wp-caption aligncenter" style="width: 419px"><img class="size-full wp-image-162" title="tellafriend" src="http://publicmind.in/blog/wp-content/uploads/2009/04/untitled.jpeg" alt="Mouseover the TellaFriend Button." width="409" height="176" /><p class="wp-caption-text">Mouseover the tellafriend button</p></div>
<p>It also provides the feature of adding the title and description for the Bookamrking site right there on your website. Although, its not such a great feature but still it scores +1 for it.</p>
<div id="attachment_163" class="wp-caption aligncenter" style="width: 495px"><img class="size-full wp-image-163" title="morebox" src="http://publicmind.in/blog/wp-content/uploads/2009/04/untitled1.jpeg" alt="Add the title &amp; description and hit &quot;BookMark&quot;" width="485" height="454" /><p class="wp-caption-text">Enter the title &amp; description and hit &quot;Bookmark&quot;</p></div>
<p>One more but less important thing in which it scores over Addthis is its redirecting page. Compare the following two redirect pages, you know what I am talking about!!</p>
<p><img class="aligncenter size-full wp-image-170" title="addthis-tellafriend" src="http://publicmind.in/blog/wp-content/uploads/2009/04/untitled31.jpeg" alt="addthis-tellafriend" width="526" height="155" /><br />
So,  Decide for yourself which one of them you want. If you are using something else, do leave a comment. and remember <strong>Sharing is Good</strong>.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/share-bookmark-tools/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Drupal: FeedAPI Imagegrabber</title>
		<link>http://publicmind.in/blog/feedapi-imagegrabber/</link>
		<comments>http://publicmind.in/blog/feedapi-imagegrabber/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 07:08:10 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Drupal]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Intern]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://publicmind.in/blog/?p=105</guid>
		<description><![CDATA[Feeds Image Grabber (FIG) was released on 3rd March 2010, to support the Feeds module. Introduction FeedAPI Imagegrabber is a add-on module for FeedAPI. It consists of a parser which visits the original URL of a new feed item, and retrieves the main image from the post. Once the main image has been retrieved, it [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Digg Digg Disabled -->
<div class="download"><a href="http://publicmind.in/blog/drupal-feeds-image-grabber">Feeds Image Grabber</a> (FIG) was released on 3rd March 2010, to support the <a href="http://drupal.org/project/feeds">Feeds</a> module.
</div>
<p><strong>Introduction</strong></p>
<p><a href="http://drupal.org/project/feedapi_imagegrabber" target="_blank">FeedAPI Imagegrabber</a> is a add-on module for <a href="http://drupal.org/project/feedapi" target="_blank">FeedAPI</a>. It consists of a parser which visits the original URL of a new feed item, and retrieves the main image from the post. Once the main image has been retrieved, it is then converted into a thumbnail using the <a href="http://drupal.org/project/imagecache" target="_blank">ImageCache</a> module, and stored in the node created by FeedAPI, inside a CCK field.</p>
<p>The purpose of FeedAPI Imagegrabber is to make the feed more informative as well as interesting for the user. As, we all know that &#8220;comics are much better than novels&#8221;, this module appends the feed-item with an appropriate image from its content URL. The goal of the module is to mimic the thumbnail display of websites such as digg.com. This goal is acheived by using FeedAPI to turn RSS feed-items into nodes, and then using FeedAPI Imagegrabber to append these nodes with an appropriate image from the feed-item&#8217;s webpage.<br />
<span id="more-105"></span><br />
<strong>How it works</strong></p>
<p>A classic method of mimicking the behavior of FeedAPI Imagegrabber will be to do the same thing manually. Let us go through the procedure if you were to do it manually:</p>
<ol>
<li>Refresh the feed.</li>
<li>For each feed-item, go to their respective original URL and save the image to display.</li>
<li>Crop the image, convert it into a thumbnail and then upload it in an CCK Image field.</li>
</ol>
<p>FeedAPI Imagegrabber automates the last 2 steps of the three step process described. It uses cURL to download the images and then crop them using Imagecache. Then the image is stored into the CCK Imagefield. The most difficult part which only humans can do is to select the image,  for which I am constantly improving on the heuristics.</p>
<p><strong>Download and Install</strong></p>
<p>Visit the project page : <a href="http://drupal.org/project/feedapi_imagegrabber" target="_blank">FeedAPI Imagegrabber</a></p>
<p><strong>Features and Future Releases</strong></p>
<p>Visit the project page : <a href="http://drupal.org/project/feedapi_imagegrabber" target="_blank">FeedAPI Imagegrabber</a></p>
<p><strong>History</strong></p>
<p>I understand history is boring, but it is only for those who think the other way round. I started working on this module during December 2008.  At the time, when I started working on this module, I had a little or say<em><strong> no idea</strong></em> about Drupal or its API. It took me quite some time to get used to it and start working on the module. In the Initial release, I thought of very simple heuristics and decided to select the largest image available on the web-page. I completed the module in about 1 month and was very happy with my performance, and then a big blow came which delayed the release of FeedAPI Imagegrabber by 2 months. I had to include an external BSD licensed script for converting relative URL&#8217;s to absolute URL&#8217;s but Drupal denied to accept this. They said they allow only GPL licensed code and I started to convince them that both licenses are compatible. Unfortunately, I was unable to convince them and I had to create an external link to that BSD script on sourceforge. And now, the module is released with the hope to enhance the visitor-experience on several websites around the globe.</p>
<p>You may find these posts useful:</p>
<p><a rel="bookmark" href="http://publicmind.in/blog/tutorial-for-feedapi-imagegrabber">Tutorial for FeedAPI ImageGrabber</a><br />
<a class="title" rel="bookmark" href="http://publicmind.in/blog/urltoabsolute/">PHP: Relative URL to Absolute URL</a><br />
<a rel="bookmark" href="http://magicalsilverdrop.blogspot.com/2009/02/open-source-software-and-licenses.html">Open Source Software and Licenses</a></p>
<p>Do Leave your comments to let me know what you think.</p>
<p><strong>Note: </strong>Support queries and requests should be made through the <a href="http://drupal.org/project/feedapi_imagegrabber" target="_blank">FeedAPI Imagegrabber Forum</a>. I may not be able to answer them here. <img src='http://publicmind.in/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<div class="download">
<p><strong>Updates:</strong></p>
<ul>
<li>The first stable version of the module was released on 7th April, 2009. Check it out now <a href="http://drupal.org/project/feedapi_imagegrabber" target="_blank">here</a>!!</li>
<li>RC1 release for Imagegrabber is now available for download on Project page. It is compatible with the RC1 release of Imagefield. (17 Apr, 2009)</li>
<li>Demonstration Website is up, and is available <a href="http://publicmind.in/feedapi_imagegrabber/demonstration">here</a>. (20 Aug, 2009)</li>
<li>FeedAPI ImageGrabber v1.8 released. Download it from the project website <a href="http://drupal.org/project/feedapi_imagegrabber" target="_blank">here</a>. (20 September 2009)</li>
<li><a href="http://publicmind.in/blog/tutorial-for-feedapi-imagegrabber">Tutorial for FeedAPI ImageGrabber</a> published. (20 September 2009)</li>
<li>FeedAPI ImageGrabber v1.9 released. Download it from the project website <a href="http://drupal.org/project/feedapi_imagegrabber" target="_blank">here</a>. (26 October 2009)</li>
<li>FeedAPI ImageGrabber now supports <a href="http://drupal.org/project/filefield_paths">Filefield Paths</a> module. Download the development snapshot, its stable for use on production site.</li>
<li>As of 02 Dec 2009, Development of FeedAPI ImageGrabber has been halted. You can look out for the <a href="http://drupal.org/project/feeds_imagegrabber" target="_blank">Feeds Image Grabber</a> module which supports <a href="http://drupal.org/project/feeds" target="_blank">Feeds</a> module,  successor of FeedAPI, with the same functionality.</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/feedapi-imagegrabber/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>PHP: Archive files for Backup on Server</title>
		<link>http://publicmind.in/blog/php-archive-files-backup/</link>
		<comments>http://publicmind.in/blog/php-archive-files-backup/#comments</comments>
		<pubDate>Wed, 11 Mar 2009 05:25:50 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Nitin's Blog]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.publicmind.in/?p=59</guid>
		<description><![CDATA[As Currently I am hosting this website on a free host, my web host imposes several limitations on me. One of them is not providing the feature to download the whole folder. This makes taking backup really hard as you have download each and every file yourself. Although it is a matter of days when [...]]]></description>
			<content:encoded><![CDATA[<p>As Currently I am hosting this website on a free host, my web host imposes several limitations on me. One of them is not providing the feature to download the whole folder. This makes taking backup really hard as you have download each and every file yourself.  Although it is a matter of days when I shift this website to a new server, I wrote the following PHP script which automatically archives the files in a folder and then the zip files can be easily downloaded with a single click. The script is crude in nature as I did not handle much exceptions but it works fine for me. You might need to change certain parameters to run it with your PHP resource limits. The code is pretty self explanatory although if you find difficulty understanding some part or find a bug or want to suggest any improvement, do leave a comment.<br />
<span id="more-59"></span></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&lt;</span> ?<br />
<span style="color: #009933; font-style: italic;">/**<br />
* Copyright (c) 2009, Nitin Kumar Gupta, http://publicmind.in.<br />
* All rights reserved.<br />
*<br />
* Redistribution and use in source and binary forms, with or without<br />
* modification, are permitted provided that the following conditions<br />
* are met:<br />
*<br />
* &nbsp; * Redistributions of source code must retain the above copyright<br />
* &nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<br />
*<br />
* &nbsp; * Redistributions in binary form must reproduce the above<br />
* &nbsp; &nbsp; copyright notice, this list of conditions and the following<br />
* &nbsp; &nbsp; disclaimer in the documentation and/or other materials provided<br />
* &nbsp; &nbsp; with the distribution.<br />
*<br />
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS<br />
* &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT<br />
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS<br />
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE<br />
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,<br />
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,<br />
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;<br />
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER<br />
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br />
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY<br />
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY<br />
* OF SUCH DAMAGE.<br />
*/</span><br />
<br />
<span style="color: #666666; font-style: italic;">/*<br />
* This is a BSD License approved by the Open Source Initiative (OSI).<br />
* See: &nbsp;http://www.opensource.org/licenses/bsd-license.php<br />
*/</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
* Directory to archive.<br />
* example: '.' - root directory<br />
* &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'folder/sub-folder/sub-folder' - for an internal folder.<br />
*<br />
* Note: Do not use trailing slashes.<br />
*/</span><br />
<span style="color: #000088;">$directory</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'.'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// File name for the backup along with timestamp. If the filename exists,</span><br />
<span style="color: #666666; font-style: italic;">// They are numbered as backup_1, backup_2,...</span><br />
<span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;d_m_y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;;</span><br />
<span style="color: #000088;">$zipname</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'backup_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$time</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000088;">$maxFiles</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">500</span><span style="color: #339933;">;</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">//Number of files to be added to each archive.</span><br />
<span style="color: #666666; font-style: italic;">//Varies with your PHP Memory limit and execution time.</span><br />
<span style="color: #666666; font-style: italic;">//After a certain limit, the zipArchive is unable to archive.</span><br />
<br />
<span style="color: #000088;">$fileNums</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$filenames</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
parse<span style="color: #009900;">&#40;</span><span style="color: #000088;">$directory</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
zipFiles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Done&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
* &nbsp;Archives the files present in the global $filename array.<br />
*<br />
* &nbsp;@return:<br />
*<br />
* &nbsp;0: fail<br />
* &nbsp;1: Success<br />
*/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> zipFiles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$count</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$zipname</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$filenames</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$zipfile</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$zipname</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.zip'</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/file_exists"><span style="color: #990000;">file_exists</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$zipfile</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$zipfile</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$zipname</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$count</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.zip'</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$count</span><span style="color: #339933;">++;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000088;">$zip</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ZipArchive<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$zip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">open</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$zipfile</span><span style="color: #339933;">,</span> ZIPARCHIVE<span style="color: #339933;">::</span><span style="color: #004000;">CREATE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!==</span><span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<a href="http://www.php.net/exit"><span style="color: #990000;">exit</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error opening , Make sure you have write permissionsn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$filenames</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$zip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addFile</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Adding &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$filename</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; to &lt;strong&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$zipfile</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/strong&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Files Packed = &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$zip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">numFiles</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$zip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">status</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Success&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Fail&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000088;">$zip</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009933; font-style: italic;">/**<br />
* parses the whole directory and archives it in small parts, each<br />
* containg $maxFiles files each.<br />
*<br />
* @param:<br />
*<br />
* $dir: Directory to archive recursively.<br />
*/</span><br />
<span style="color: #000000; font-weight: bold;">function</span> parse<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$filenames</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$fileNums</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$maxFiles</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/opendir"><span style="color: #990000;">opendir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span> <span style="color: #339933;">!==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/readdir"><span style="color: #990000;">readdir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;..&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/is_file"><span style="color: #990000;">is_file</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$filenames</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$fileNums</span><span style="color: #339933;">++;</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileNums</span> <span style="color: #339933;">&gt;=</span> <span style="color: #000088;">$maxFiles</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$fileNums</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>zipFiles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$filenames</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;.&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;..&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <a href="http://www.php.net/is_dir"><span style="color: #990000;">is_dir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
parse<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dir</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<a href="http://www.php.net/closedir"><span style="color: #990000;">closedir</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></td></tr></tbody></table></div>
<p>To get going, just upload the script file in your root directory and point the $directory variable to the folder you want to archive. Now run the script using your web browser(make sure you run it once) and you are done. You will see the backup zip files in the current directory.</p>
<p>Hope you find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/php-archive-files-backup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PHP: Relative URL to Absolute URL</title>
		<link>http://publicmind.in/blog/urltoabsolute/</link>
		<comments>http://publicmind.in/blog/urltoabsolute/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 10:45:31 +0000</pubDate>
		<dc:creator>Nitin</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://publicmind.phpzilla.net/?p=41</guid>
		<description><![CDATA[Recently, I was working on a project and I needed to convert the relative URLs to their absolute URLs. An absolute URL such as &#8220;http://www.example.com/image.jpg&#8221; but mostly written as only &#8220;image.jpg&#8221; (relative URL) on the web pages. Web browser creates a complete URL using this relative URL and base URL. The base URL, must be [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Digg Digg Disabled -->Recently, I was working on a project and I needed to convert the relative URLs to their absolute URLs. An absolute URL such as &#8220;http://www.example.com/image.jpg&#8221; but mostly written as only &#8220;image.jpg&#8221; (relative URL) on the web pages. Web browser creates a complete URL using this relative URL and base URL. The base URL, must be absolute and it is often the URL of the web page containing the relative URL.</p>
<p>Now, if you need to access a file whose relative URL and base URL are known, you must combine them to create an absolute URL.<br />
<span id="more-41"></span><br />
The RFC URL specification defines an &#8220;absolutize&#8221; algorithm for combining an absolute base URL with a relative URL to create a new absolute URL. This algorithm was already implemented and I found the PHP script for the algorithm at <a href="http://nadeausoftware.com/articles/2008/05/php_tip_how_convert_relative_url_absolute_url">nadeausoftware.com</a>. I have created a project <a href="http://sourceforge.net/projects/absoluteurl">UrlToAbsolute</a> at <a href="http://sourceforge.net" target="_blank">sourceforge</a>, as I needed to use it in my several open source projects including <a href="http://publicmind.in/blog/feedapi-imagegrabber">FeedAPI ImageGrabber</a>, <a href="http://drupal.org/project/facebook_link">Facebook-style Links</a> and <a href="http://drupal.org/project/facebook_link">Feeds Image Grabber</a>. As the original script was released under <a href="http://www.opensource.org/licenses/bsd-license.php" target="_blank">BSD License</a>, it was pretty easy to fork it. Here is the link to the project <a href="http://sourceforge.net/projects/absoluteurl" target="_blank">UrlToAbsolute</a>. You can also look at the step by step explanation of the script <a href="http://nadeausoftware.com/articles/2008/05/php_tip_how_convert_relative_url_absolute_url">here</a>.</p>
<p><strong> Usage Instructions</strong></p>
<p>
Extract the script (url_to_absolute.php) into your web directory, include it into your current php file using:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">require(path-to-file);</div></td></tr></tbody></table></div>
<p>then, you can convert the relative url to absolute url by calling:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">url_to_absolute( $baseUrl, $relativeUrl);</div></td></tr></tbody></table></div>
<p>It return false on failure, otherwise returns the absolute url. If the $relativeUrl is a valid absolute url, it  is returned without any modification.</p>
<p><strong>Related resources:</strong></p>
<ul>
<li>Project page: <a href="http://sourceforge.net/projects/absoluteurl">http://sourceforge.net/projects/absoluteurl</a></li>
<li>Original article: <a href="http://nadeausoftware.com/articles/2008/05/php_tip_how_convert_relative_url_absolute_url">http://nadeausoftware.com/articles/2008/05/php_tip_how_convert_relative_url_absolute_url</a></li>
</ul>
<div class="download"><strong>ChangeLog</strong></p>
<ul>
<li>v1.6, March 12, 2010<br />
- added <strong>encode_url</strong> function to convert an absolute url to its percentage<br />
  encoded equivalent, according to RFC 3986</li>
<li>v1.5, March 11, 2010<br />
- fixed to allow spaces in the path of url</li>
<li>v1.4, October 2, 2009<br />
- Percentage encoding of the absolute url disabled.</li>
<li>v1.0, February 27, 2009<br />
- Initial release of the script on <a href="http://nadeausoftware.com">nadeausoftware.com</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://publicmind.in/blog/urltoabsolute/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
