<?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>Cohesive Web &#187; Php Talk</title>
	<atom:link href="http://blog.webconsultingengineering.com/category/phptalk/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.webconsultingengineering.com</link>
	<description>In search of reasons for web addiction</description>
	<lastBuildDate>Fri, 20 Aug 2010 14:17:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>SEO Correction in PEAR::Pager</title>
		<link>http://blog.webconsultingengineering.com/phptalk/seo-correction-pager.html</link>
		<comments>http://blog.webconsultingengineering.com/phptalk/seo-correction-pager.html#comments</comments>
		<pubDate>Fri, 20 Aug 2010 14:17:04 +0000</pubDate>
		<dc:creator>Susenjit</dc:creator>
				<category><![CDATA[Php Talk]]></category>
		<category><![CDATA[pager]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[url correction]]></category>
		<category><![CDATA[usefull tips]]></category>

		<guid isPermaLink="false">http://blog.webconsultingengineering.com/?p=100</guid>
		<description><![CDATA[jQuery(document).ready(function($) { window.setTimeout('loadDigg_100()',5000);window.setTimeout('loadTwitter_100()',5000); }); function loadDigg_100(){ jQuery(document).ready(function($) { $('.dd-digg-100').remove();$('.DD_DIGG_AJAX_100').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/seo-correction-pager.html&#38;title=SEO+Correction+in+PEAR%3A%3APager');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_100(){ jQuery(document).ready(function($) { $('.dd-twitter-100').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }Pagination is a common practice to show big volume of data. It is quite important if you are showing dynamically populated data. For myself I mostly use PEAR::Pager to display paginated data. If you are familiar with this [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"><a title="Post on Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count" data-url="http://blog.webconsultingengineering.com/phptalk/seo-correction-pager.html"></a><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script></div><script type="text/javascript">jQuery(document).ready(function($) { window.setTimeout('loadDigg_100()',5000);window.setTimeout('loadTwitter_100()',5000); });</script><script type="text/javascript"> function loadDigg_100(){ jQuery(document).ready(function($) { $('.dd-digg-100').remove();$('.DD_DIGG_AJAX_100').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/seo-correction-pager.html&amp;title=SEO+Correction+in+PEAR%3A%3APager');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_100(){ jQuery(document).ready(function($) { $('.dd-twitter-100').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }</script><div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-digg-ajax-load dd-digg-100'></div><a class='DiggThisButton DD_DIGG_AJAX_100 DiggMedium'></a></div><div class='dd_button'><div class='dd-twitter-ajax-load dd-twitter-100'></div><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.webconsultingengineering.com/phptalk/seo-correction-pager.html" data-count="vertical" data-text="SEO+Correction+in+PEAR%3A%3APager" data-via="susenjit" ></a></div></div></div><div style='clear:both'></div><p>Pagination is a common practice to show big volume of data. It is quite important if you are showing dynamically populated data.</p>
<p>For myself I mostly use <a href="http://pear.php.net/package/Pager" target="_blank">PEAR::Pager</a> to display paginated data. If you are familiar with this package then you know that you can use 2 types of pagination display, as &#8211; sliding and jumping. In case of sliding display with a common practice is to use it with constructor option append:true and urlVar:<em>&lt;variablename&gt;</em>.</p>
<p>Let me show an example of this kind of usage -</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$Params</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;itemData&#8217;</span> <span class="sy0">=&gt;</span> <span class="re0">$dataDetails</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;perPage&#8217;</span> <span class="sy0">=&gt;</span> <span class="re0">$ViewPerPage</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;append&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw4">true</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;separator&#8217;</span> <span class="sy0">=&gt;</span> <span class="st_h">&#8216;|&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;spacesBeforeSeparator&#8217;</span> <span class="sy0">=&gt;</span> <span class="nu0">1</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;spacesAfterSeparator&#8217;</span> <span class="sy0">=&gt;</span> <span class="nu0">1</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;clearIfVoid&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw4">false</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;urlVar&#8217;</span> <span class="sy0">=&gt;</span> <span class="st_h">&#8216;page&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;useSessions&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw4">true</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;closeSession&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw4">true</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;mode&#8217;</span> &nbsp;<span class="sy0">=&gt;</span> <span class="st_h">&#8216;Sliding&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;importQuery&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw4">true</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;linkClass&#8217;</span> <span class="sy0">=&gt;</span> <span class="st_h">&#8216;LinkStyle&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$Pager</span> <span class="sy0">=</span> Pager<span class="sy0">::</span><span class="me2">factory</span><span class="br0">&#40;</span><span class="re0">$Params</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$DataDetailsInArray</span> <span class="sy0">=</span> <span class="re0">$Pager</span><span class="sy0">-&gt;</span><span class="me1">getPageData</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$PaginationLinks</span> <span class="sy0">=</span> <span class="re0">$Pager</span><span class="sy0">-&gt;</span><span class="me1">getLinks</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
</div>
<p>Now if you print/echo the $PaginationLinks, then you will get pagination like 1 2 3 4 etc. </p>
<p>Now let me describe you the problem:<br />
Say your page url is mydata.php. So mydata.php page will show the first page of paginated data. while using the pagination links you will get a page with url mydata.php?page=1. This page shows the first page of paginated data. Now you are having a page with 2 different url like <em>mydata.php</em> and <em>mydata.php?page=1</em>. In SEO this is known as duplicate content. This is not good if you are seriously deal with SEO.</p>
<p>Here is the correction for this. This is simple but effective.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st_h">&#8216;page&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="sy0">&amp;&amp;</span> <span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st_h">&#8216;page&#8217;</span><span class="br0">&#93;</span> <span class="sy0">&gt;</span> 1<span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="re0">$PaginationLinks</span><span class="br0">&#91;</span><span class="st_h">&#8216;all&#8217;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <a href="http://www.php.net/str_replace"><span class="kw3">str_replace</span></a><span class="br0">&#40;</span><a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st_h">&#8216;?page=1&quot;&#8217;</span><span class="sy0">,</span> <span class="st_h">&#8216;&amp;amp;page=1&quot;&#8217;</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="st_h">&#8216;&quot;&#8217;</span><span class="sy0">,</span> <span class="re0">$PaginationLinks</span><span class="br0">&#91;</span><span class="st_h">&#8216;all&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
</div>
<p>Use this code section just after generating $PaginationLinks. Hope this will help you. As always comments/suggestions are welcome. But spammers please don&#8217;t waste your time. <img src='http://blog.webconsultingengineering.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<!-- Social Buttons Shared Counts Generated by Digg Digg plugin v4.2.2, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/ -->]]></content:encoded>
			<wfw:commentRss>http://blog.webconsultingengineering.com/phptalk/seo-correction-pager.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Freetag PEAR DB Version</title>
		<link>http://blog.webconsultingengineering.com/phptalk/freetag-peardb.html</link>
		<comments>http://blog.webconsultingengineering.com/phptalk/freetag-peardb.html#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:29:38 +0000</pubDate>
		<dc:creator>Susenjit</dc:creator>
				<category><![CDATA[Php Talk]]></category>
		<category><![CDATA[Folksonomy]]></category>
		<category><![CDATA[Freetag]]></category>
		<category><![CDATA[MySql]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php class]]></category>
		<category><![CDATA[Tagging]]></category>

		<guid isPermaLink="false">http://blog.webconsultingengineering.com/?p=84</guid>
		<description><![CDATA[jQuery(document).ready(function($) { window.setTimeout('loadDigg_84()',5000);window.setTimeout('loadTwitter_84()',5000); }); function loadDigg_84(){ jQuery(document).ready(function($) { $('.dd-digg-84').remove();$('.DD_DIGG_AJAX_84').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/freetag-peardb.html&#38;title=Freetag+PEAR+DB+Version');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_84(){ jQuery(document).ready(function($) { $('.dd-twitter-84').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }While working with tagging application my favourite is freetag by Gordon Luk. It is a comprehensive open source tagging and folksonomy code in php. The source code is also hosted in Google Code. The best feature of it [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"><a title="Post on Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count" data-url="http://blog.webconsultingengineering.com/phptalk/freetag-peardb.html"></a><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script></div><script type="text/javascript">jQuery(document).ready(function($) { window.setTimeout('loadDigg_84()',5000);window.setTimeout('loadTwitter_84()',5000); });</script><script type="text/javascript"> function loadDigg_84(){ jQuery(document).ready(function($) { $('.dd-digg-84').remove();$('.DD_DIGG_AJAX_84').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/freetag-peardb.html&amp;title=Freetag+PEAR+DB+Version');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_84(){ jQuery(document).ready(function($) { $('.dd-twitter-84').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }</script><div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-digg-ajax-load dd-digg-84'></div><a class='DiggThisButton DD_DIGG_AJAX_84 DiggMedium'></a></div><div class='dd_button'><div class='dd-twitter-ajax-load dd-twitter-84'></div><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.webconsultingengineering.com/phptalk/freetag-peardb.html" data-count="vertical" data-text="Freetag+PEAR+DB+Version" data-via="susenjit" ></a></div></div></div><div style='clear:both'></div><p>While working with tagging application my favourite is <a title="Freetag" href="http://getluky.net/freetag/" target="_blank">freetag</a> by Gordon Luk. It is a comprehensive open source tagging and folksonomy code in php. The <a href="http://code.google.com/p/freetag/" target="_blank">source code</a> is also hosted in Google Code. The best feature of it is you can use this code with little modification to fit your requirement. First time I used it in <a href="http://advaitaashrama.org/" target="_blank">advaitaashrama.org</a> for their book store application. Currently I am using it in another website which is under development.</p>
<p>I am having an issue of compatibility with this code and I am writting this post for it. If you look at the code you will find that it uses the <a href="http://phplens.com/adodb/" target="_blank">ADODB Library</a> for database operations. In my case I am happy with <a href="http://pear.php.net/package/DB/" target="_blank">PEAR::DB</a>. Now for me to use this code I need to use 2 different database component as PEAR::DB and ADODB Library. It seems useless to me. So I decided to make the code compatiable with PEAR::DB. While working upon the compatibility modification I also made 3 changes as</p>
<ol>
<li>I have written a function as  show_debug_text() which is a replacement of debug_text().</li>
<li>I have removed the silly_list() function from my code as it was declared as deprecated.</li>
<li>I have renamed the main class file from freetag.class.php to freetag.db.class.php</li>
</ol>
<p>Here is the sample code for use this</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="sy0">&lt;</span>php?</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">require_once</span><span class="br0">&#40;</span><span class="st0">&quot;/path-to/freetag.db.class.php&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$DbObj</span> <span class="sy0">=</span> DB<span class="sy0">::</span><span class="me2">connect</span><span class="br0">&#40;</span><span class="re0">$dsn</span><span class="sy0">,</span> <span class="re0">$options</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="co1">//this is the database connection object using PEAR::DB</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$OptionArray</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st_h">&#8216;table_prefix&#8217;</span> <span class="sy0">=&gt;</span> <span class="st_h">&#8216;mytags&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$TagObj</span> <span class="sy0">=</span> <span class="kw2">new</span> freetag<span class="br0">&#40;</span><span class="re0">$DbObj</span><span class="sy0">,</span> <span class="re0">$OptionArray</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// Use this object to call tag related functions .</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy1">?&gt;</span></div>
</li>
</ol>
</div>
</div>
<p>Here is the <a title="freetag.db.class.php" href="http://blog.webconsultingengineering.com/wp-content/uploads/freetag.db_.class.php_.txt" target="_blank"><strong>code</strong></a> modified by me.<br />
If you use this code please let me know if you have any problem.</p>
<!-- Social Buttons Shared Counts Generated by Digg Digg plugin v4.2.2, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/ -->]]></content:encoded>
			<wfw:commentRss>http://blog.webconsultingengineering.com/phptalk/freetag-peardb.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP serialization or Json</title>
		<link>http://blog.webconsultingengineering.com/phptalk/phpserialize-or-json.html</link>
		<comments>http://blog.webconsultingengineering.com/phptalk/phpserialize-or-json.html#comments</comments>
		<pubDate>Tue, 11 May 2010 11:19:50 +0000</pubDate>
		<dc:creator>Susenjit</dc:creator>
				<category><![CDATA[Php Talk]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[serialization]]></category>

		<guid isPermaLink="false">http://blog.webconsultingengineering.com/?p=80</guid>
		<description><![CDATA[jQuery(document).ready(function($) { window.setTimeout('loadDigg_80()',5000);window.setTimeout('loadTwitter_80()',5000); }); function loadDigg_80(){ jQuery(document).ready(function($) { $('.dd-digg-80').remove();$('.DD_DIGG_AJAX_80').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/phpserialize-or-json.html&#38;title=PHP+serialization+or+Json');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_80(){ jQuery(document).ready(function($) { $('.dd-twitter-80').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }Information storage and retrieval is an important job while designing or developing an application. We all know how to store data with normal data types in database or file systems. Here I am going to discuss about storage [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"><a title="Post on Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count" data-url="http://blog.webconsultingengineering.com/phptalk/phpserialize-or-json.html"></a><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script></div><script type="text/javascript">jQuery(document).ready(function($) { window.setTimeout('loadDigg_80()',5000);window.setTimeout('loadTwitter_80()',5000); });</script><script type="text/javascript"> function loadDigg_80(){ jQuery(document).ready(function($) { $('.dd-digg-80').remove();$('.DD_DIGG_AJAX_80').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/phpserialize-or-json.html&amp;title=PHP+serialization+or+Json');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_80(){ jQuery(document).ready(function($) { $('.dd-twitter-80').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }</script><div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-digg-ajax-load dd-digg-80'></div><a class='DiggThisButton DD_DIGG_AJAX_80 DiggMedium'></a></div><div class='dd_button'><div class='dd-twitter-ajax-load dd-twitter-80'></div><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.webconsultingengineering.com/phptalk/phpserialize-or-json.html" data-count="vertical" data-text="PHP+serialization+or+Json" data-via="susenjit" ></a></div></div></div><div style='clear:both'></div><p>Information storage and retrieval is an important job while designing or developing an application. We all know how to store data with normal data types in database or file systems. Here I am going to discuss about storage and retrieval of data having complex type. Complex type means they are not like normal string or number or boolean values. Complex type means data structure or objects.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-2303357471658970";
/* 468x60-cohesiveweb-textad-general */
google_ad_slot = "0998564731";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Think of a situation where you are working with some array. Now there may be some situations where you need to store the array and retrieve it back. If you are familiar with OOPS concept then objects are another type which you may need to store and retrieve.</p>
<p>Serialization is the process by which you can convert an object or data structure into a sequence of bits which can stored and retrieve back. Serialization is also known as deflating or marshalling. The opposite process (converting the serialized sequence of bits to object or data structure) is known as Deserialization or inflating or unmarshalling. Most of the important languages have their own implementation of these processes. In Java provides automatic serialization by implementing the <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/Serializable.html">java.io.Serializable</a> interface. In perl there are modules like <a href="http://perldoc.perl.org/Storable.html">Storable</a> or <a href="http://search.cpan.org/dist/FreezeThaw/">FreezeThaw</a>. Python implements serialization through the standard library module <a title="Python pickle" href="http://docs.python.org/library/pickle.html">pickle</a>. In PHP there are two built-in functions as <a title="php serialization function" href="http://php.net/manual/en/function.serialize.php">serialize()</a> and <a title="PHP unserailze function" href="http://www.php.net/manual/en/function.unserialize.php">unserialize()</a> for this purpose. However as I will continue the discussion with PHP then you should be aware of the fact that &#8211; there is a difference in the implementation of serialization in PHP 4.x and PHP 5.x.</p>
<p>In last couple of months I need to work with <a title="JSON" href="http://www.json.org/">JSON</a> (JavaScript Object Notation). JSON is an ideal data interchange format which is language independent. I had used the JSON to design some Ajax driven functionality in one of my projects. Over there I had encoded into JSON some normal and associative PHP array and passed them to access by JavaScript.</p>
<p>After successful completion of the project I started working upon the possibilities of storing data structure or object in PHP using JSON. IN case of PHP there are two function as json_encode() and json_decode(). Interesting thing with json_decode() is that it takes a boolean argument as second parameter[$assoc] which is by default false. But when TRUE json_decode() returns objects converted in associative array. After doing a lot R&amp;D I find out certain facts which favors JSON rather than using serialize() /unserialize(). In general if you consider the size of the stream produced by serialize() with json_encode(), later produces small sized stream. While working with data structure like arrays JSON produces the same structure after encode and decode. So in my opinion usage of JSON is better than PHP serialize()/unserialize().</p>
<p>Now while working with objects, JSON produces the same result as PHP serialization functions. However if the object is complex or if you like to take the benefit of <a href="http://www.php.net/manual/en/language.oop5.magic.php">magic methods</a> object oriented PHP5 then its better to use serialize()/unserialize(). As serialize() will attempt to call _sleep() [if exists] which can be used to do some last minute clean up of the object prior to serialization. Same way unserialize() will call _wakeup()[if exists] which can be used to do some reconstruction in the object just after unserialization. So if your objects are simple then use JSON otherwise go for serialize()/unserialize().</p>
<p>In the conclusion I will prefer to use JSON rather than PHP serialization methods. I won’t be surprised if I get good nos of comments for/against my preference.</p>
<!-- Social Buttons Shared Counts Generated by Digg Digg plugin v4.2.2, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/ -->]]></content:encoded>
			<wfw:commentRss>http://blog.webconsultingengineering.com/phptalk/phpserialize-or-json.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>QuickForm and AutoSuggest</title>
		<link>http://blog.webconsultingengineering.com/phptalk/quickform-autosuggest.html</link>
		<comments>http://blog.webconsultingengineering.com/phptalk/quickform-autosuggest.html#comments</comments>
		<pubDate>Tue, 12 Jan 2010 11:23:10 +0000</pubDate>
		<dc:creator>Susenjit</dc:creator>
				<category><![CDATA[Php Talk]]></category>
		<category><![CDATA[autosuggest]]></category>
		<category><![CDATA[dbtable]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[quickform]]></category>

		<guid isPermaLink="false">http://blog.webconsultingengineering.com/?p=70</guid>
		<description><![CDATA[jQuery(document).ready(function($) { window.setTimeout('loadDigg_70()',5000);window.setTimeout('loadTwitter_70()',5000); }); function loadDigg_70(){ jQuery(document).ready(function($) { $('.dd-digg-70').remove();$('.DD_DIGG_AJAX_70').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/quickform-autosuggest.html&#38;title=QuickForm+and+AutoSuggest');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_70(){ jQuery(document).ready(function($) { $('.dd-twitter-70').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }The best example of auttosuggest filed I can instantly think of is Google. While designing dynamic forms I felt the requirement of such field. As I mostly use PEAR class and HTML Quickform to design dynamic forms in [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"><a title="Post on Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count" data-url="http://blog.webconsultingengineering.com/phptalk/quickform-autosuggest.html"></a><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script></div><script type="text/javascript">jQuery(document).ready(function($) { window.setTimeout('loadDigg_70()',5000);window.setTimeout('loadTwitter_70()',5000); });</script><script type="text/javascript"> function loadDigg_70(){ jQuery(document).ready(function($) { $('.dd-digg-70').remove();$('.DD_DIGG_AJAX_70').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/quickform-autosuggest.html&amp;title=QuickForm+and+AutoSuggest');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_70(){ jQuery(document).ready(function($) { $('.dd-twitter-70').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }</script><div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-digg-ajax-load dd-digg-70'></div><a class='DiggThisButton DD_DIGG_AJAX_70 DiggMedium'></a></div><div class='dd_button'><div class='dd-twitter-ajax-load dd-twitter-70'></div><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.webconsultingengineering.com/phptalk/quickform-autosuggest.html" data-count="vertical" data-text="QuickForm+and+AutoSuggest" data-via="susenjit" ></a></div></div></div><div style='clear:both'></div><p>The best example of auttosuggest filed I can instantly think of is <a href="http://google.com" target="_blank">Google</a>. While designing dynamic forms I felt the requirement of such field. As I mostly use <a href="http://pear.php.net/" target="_blank">PEAR</a> class and <a href="http://pear.php.net/package/HTML_QuickForm" target="_blank">HTML Quickform</a> to design dynamic forms in php. However in HTML Quickform there is autocomplete type but still there is no support for autosuggest. I googled a lot to get such support, but found it out in RFC of HTML Quickform. So I started working upon it. My first job was to found out a autosuggest Javascript code suitable for integration. I searched out an autocomplete javascript code by <a href="http://www.beauscott.com" target="_blank">Beau D. Scott</a></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-2303357471658970";
/* 468x60-cohesiveweb-textad-general */
google_ad_slot = "0998564731";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>The reasons why I selected Beau’s code is :<br />
The code is simple to use but robust and has good documentation.<br />
It uses standard JS library like prototype and scriptaculous.</p>
<p>Now having previous knowledge of integration of <a title="QuickForm and Jscalender" href="http://blog.webconsultingengineering.com/phptalk/quickform-jscalendar.html">QuickForm and Jscalender</a> I created the code for autosuggest class. This autosuggest class file contains constructor function, toHtml function which generates the HTML code for the field, getFrozenHtml function to return the autosuggest content in HTML and finally the registering process of the autosuggest type with HTML QuickForm. I put this autosuggest class name as autosuggestwce. View this <a title="File - wceautosuggest.php" href="http://blog.webconsultingengineering.com/wp-content/uploads/wceautosuggest.php.txt">wceautosuggest.php</a> file.</p>
<p>To use this autosuggest field in HTML Quickform you need to have 3 javascript files as prototype.js, scriptaculous.js and autocomplete.js. Prototype Javascript is used for javascript framework, Scriptaculous for show and hide effect and AutoComplete is the main javascript functionality file. Among them scriptaculous.js can be removed if you don’t like to show effects, but you need to modify certain section in the wceautosuggest.php file. You also need to declare <strong>$GLOBALS['_HTML_QUICKFORM_AUTOSUGGEST_BASEPATH']</strong> the global path defining variable for the javascript files path in the page where you will generate the form.</p>
<p>This autosuggest uses php script to populate values. The name of the php script has to be mentioned in the $attribute array for the key ‘fileref’.</p>
<p>If you are using DB_Table here is snippet of code</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="st_h">&#8216;user_name&#8217;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st_h">&#8216;type&#8217;</span> <span class="sy0">=&gt;</span> <span class="st_h">&#8216;varchar&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st_h">&#8216;size&#8217;</span> <span class="sy0">=&gt;</span> <span class="nu0">255</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st_h">&#8216;qf_type&#8217;</span> <span class="sy0">=&gt;</span> <span class="st_h">&#8216;autosuggestwce&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st_h">&#8216;qf_label&#8217;</span><span class="sy0">=&gt;</span> <span class="st_h">&#8216;UserName:&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st_h">&#8216;require&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw4">false</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st_h">&#8216;qf_attrs&#8217;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st_h">&#8216;id&#8217;</span> <span class="sy0">=&gt;</span> <span class="st_h">&#8216;user_name_autosuggest&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st_h">&#8216;autocomplete&#8217;</span> <span class="sy0">=&gt;</span> <span class="st_h">&#8216;off&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st_h">&#8216;fileref&#8217;</span> <span class="sy0">=&gt;</span> <span class="st_h">&#8216;getusersname.php&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
</ol>
</div>
</div>
<p>If you are using QuickForm directly then here is the code snippet</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$form</span> <span class="sy0">=</span> <span class="kw2">new</span> HTML_QuickForm<span class="br0">&#40;</span><span class="st_h">&#8216;someTest&#8217;</span><span class="sy0">,</span> <span class="st_h">&#8216;get&#8217;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">addElement</span><span class="br0">&#40;</span><span class="st_h">&#8216;autosuggestwce&#8217;</span><span class="sy0">,</span> <span class="st_h">&#8216;username&#8217;</span><span class="sy0">,</span> <span class="st_h">&#8216;UserName:&#8217;</span><span class="sy0">,</span> <span class="st0">&quot;array(&#8216;id&#8217; =&gt; &#8216;user_name_autosuggest&#8217;, &#8216;autocomplete&#8217; =&gt; &#8216;off&#8217;, &#8216;fileref&#8217; =&gt; &#8216;getusersname.php&#8217;)&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">display</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
</div>
<p>Here is the code segment of php script</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$UsrObj</span> <span class="sy0">=</span> <span class="kw2">new</span> CLUsrChk<span class="br0">&#40;</span><span class="re0">$DBObj</span><span class="sy0">,</span> <span class="st_h">&#8216;hllqz_tblusers&#8217;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$SqlStatement</span> <span class="sy0">=</span> <span class="st0">&quot;SLECT user_name FROM &quot;</span><span class="sy0">.</span><span class="re0">$UsrObj</span><span class="sy0">-&gt;</span><span class="me1">table</span><span class="sy0">.</span><span class="st0">&quot; WHERE user_name LIKE (&#8216;&quot;</span><span class="sy0">.</span><span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st_h">&#8216;s&#8217;</span><span class="br0">&#93;</span><span class="sy0">.</span><span class="st0">&quot;%&#8217;)&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$UsrNameArray</span> <span class="sy0">=</span> <span class="re0">$UsrObj</span><span class="sy0">-&gt;</span><span class="me1">bd</span><span class="sy0">-&gt;</span><span class="me1">query</span><span class="br0">&#40;</span><span class="re0">$SqlStatement</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">echo</span> <a href="http://www.php.net/json_encode"><span class="kw3">json_encode</span></a><span class="br0">&#40;</span><span class="re0">$UsrNameArray</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy1">?&gt;</span></div>
</li>
</ol>
</div>
</div>
<p>Here is the screenshot</p>
<p style="text-align: center;"><img style="border: black 1px solid;" title="autosuggest_field" src="http://blog.webconsultingengineering.com/wp-content/uploads/autosuggest_field.gif" alt="autosuggest_field" width="307" height="104" /><br />
<img class="aligncenter size-full wp-image-73" style="border: black 1px solid;" title="autosuggest_filed_populated" src="http://blog.webconsultingengineering.com/wp-content/uploads/autosuggest_filed_populated.gif" alt="autosuggest_filed_populated" width="304" height="207" />
</p>
<p>However if you require the files for your reference please let me about that.</p>
<p>I was planning to do this post almost a month ago but I was busy with learning another Javascript framework <a title="jQuery" href="http://jquery.com" target="_blank">jQuery</a>. I am started loving it. Hope I will be able to post something about jQuery in near future.</p>
<!-- Social Buttons Shared Counts Generated by Digg Digg plugin v4.2.2, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/ -->]]></content:encoded>
			<wfw:commentRss>http://blog.webconsultingengineering.com/phptalk/quickform-autosuggest.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web site hacked via HTACCESS</title>
		<link>http://blog.webconsultingengineering.com/phptalk/website-hacked.html</link>
		<comments>http://blog.webconsultingengineering.com/phptalk/website-hacked.html#comments</comments>
		<pubDate>Mon, 09 Nov 2009 13:17:01 +0000</pubDate>
		<dc:creator>Susenjit</dc:creator>
				<category><![CDATA[Php Talk]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[site hacked]]></category>
		<category><![CDATA[URL rewriting]]></category>

		<guid isPermaLink="false">http://blog.webconsultingengineering.com/?p=62</guid>
		<description><![CDATA[jQuery(document).ready(function($) { window.setTimeout('loadDigg_62()',5000);window.setTimeout('loadTwitter_62()',5000); }); function loadDigg_62(){ jQuery(document).ready(function($) { $('.dd-digg-62').remove();$('.DD_DIGG_AJAX_62').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/website-hacked.html&#38;title=Web+site+hacked+via+HTACCESS');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_62(){ jQuery(document).ready(function($) { $('.dd-twitter-62').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }Here is another example how your site got hacked. I found this instance very recently in Godaddy server. This type of site hacking is not very common. You may not be able to detect any specific web page [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"><a title="Post on Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count" data-url="http://blog.webconsultingengineering.com/phptalk/website-hacked.html"></a><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script></div><script type="text/javascript">jQuery(document).ready(function($) { window.setTimeout('loadDigg_62()',5000);window.setTimeout('loadTwitter_62()',5000); });</script><script type="text/javascript"> function loadDigg_62(){ jQuery(document).ready(function($) { $('.dd-digg-62').remove();$('.DD_DIGG_AJAX_62').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/website-hacked.html&amp;title=Web+site+hacked+via+HTACCESS');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_62(){ jQuery(document).ready(function($) { $('.dd-twitter-62').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }</script><div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-digg-ajax-load dd-digg-62'></div><a class='DiggThisButton DD_DIGG_AJAX_62 DiggMedium'></a></div><div class='dd_button'><div class='dd-twitter-ajax-load dd-twitter-62'></div><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.webconsultingengineering.com/phptalk/website-hacked.html" data-count="vertical" data-text="Web+site+hacked+via+HTACCESS" data-via="susenjit" ></a></div></div></div><div style='clear:both'></div><p>Here is another example how your site got hacked. I found this instance very recently in Godaddy server. This type of site hacking is not very common. You may not be able to detect any specific web page infected if you search your site using Google Diagonestic tool for safe browsing mentioned in my earlier post &#8211; <a title="Iframe code injection" href="http://blog.webconsultingengineering.com/phptalk/iframe-code-injection.html">Iframe code injection</a>. In this kind of attack none of your web pages get infected but your .htaccess file gets modified and becomes the main source of redirection to malware containing site. Let me show you an infected .htaccess file for example. </p>
<div id="attachment_63" class="wp-caption aligncenter" style="width: 514px"><img class="size-full wp-image-63" title="hacked_htaccess" src="http://blog.webconsultingengineering.com/wp-content/uploads/hacked_htaccess.gif" alt="hacked_htaccess" width="504" height="178" /><p class="wp-caption-text">Modified HTACCESS file used for hacking</p></div>
<p>Experienced developer can understand why this is so dangerous. Let me explain a little for the newbies. In case of apache web server configuration directives are described in httpd.conf file. Many cases this file can&#8217;t be accessed or modified due to security reasons. So to change some configuration directives for a specific website or its sub directory best solution is to use .htaccess file. To know further about .htaccess file and its functionality you can read <a title=".HTACCESS file" href="http://httpd.apache.org/docs/1.3/howto/htaccess.html">.htaccess files</a>. However URL rewriting, URL redirection, authentication are the important functionality .htaccess file are used for.</p>
<p><!--adsense--></p>
<p>In the example htaccess file there are 3 sections. First line is for instructing the apache web server to put the rewrite engine on. This is first section. Second section goes from line no. 2 to line no. 8. This section is basically for condition checking on URL. Its checking if the visitors are coming from a website or page with URL containing the following words like google, aol, msn, yahoo, yandex, rambler or ya. <strong>NC</strong> means pattern checking will be case insensitive. <strong>OR</strong> means combines with other rule. Third section is in line no. 9. It says if any of the above pattern checking become true then it will redirect to the specified URL. Here <strong>R</strong> means redirection. Normally this generates HTTP response code 302 means moved temporarily. <strong>L</strong> means this is the last rule.</p>
<p>So the result is that if some visitor coming to the site from above specified search engine, they will be simply redirected to the malware site without understanding whats happening. So be careful if you come to know your site gotta hacked and youre unable to find out why then take a look at your .htaccess file.</p>
<!-- Social Buttons Shared Counts Generated by Digg Digg plugin v4.2.2, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/ -->]]></content:encoded>
			<wfw:commentRss>http://blog.webconsultingengineering.com/phptalk/website-hacked.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Iframe code injection</title>
		<link>http://blog.webconsultingengineering.com/phptalk/iframe-code-injection.html</link>
		<comments>http://blog.webconsultingengineering.com/phptalk/iframe-code-injection.html#comments</comments>
		<pubDate>Thu, 30 Jul 2009 11:33:53 +0000</pubDate>
		<dc:creator>Susenjit</dc:creator>
				<category><![CDATA[Php Talk]]></category>
		<category><![CDATA[antivirus]]></category>
		<category><![CDATA[badware]]></category>
		<category><![CDATA[code injection]]></category>
		<category><![CDATA[Google warning]]></category>
		<category><![CDATA[hidden iframe]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Iframe]]></category>

		<guid isPermaLink="false">http://blog.webconsultingengineering.com/?p=50</guid>
		<description><![CDATA[jQuery(document).ready(function($) { window.setTimeout('loadDigg_50()',5000);window.setTimeout('loadTwitter_50()',5000); }); function loadDigg_50(){ jQuery(document).ready(function($) { $('.dd-digg-50').remove();$('.DD_DIGG_AJAX_50').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/iframe-code-injection.html&#38;title=Iframe+code+injection');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_50(){ jQuery(document).ready(function($) { $('.dd-twitter-50').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }After a long days I am back for blog post. Last one month I was very much irritated with the problem occurred in some of my client website. In a Sunday morning while I was sleeping one of [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"><a title="Post on Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count" data-url="http://blog.webconsultingengineering.com/phptalk/iframe-code-injection.html"></a><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script></div><script type="text/javascript">jQuery(document).ready(function($) { window.setTimeout('loadDigg_50()',5000);window.setTimeout('loadTwitter_50()',5000); });</script><script type="text/javascript"> function loadDigg_50(){ jQuery(document).ready(function($) { $('.dd-digg-50').remove();$('.DD_DIGG_AJAX_50').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/iframe-code-injection.html&amp;title=Iframe+code+injection');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_50(){ jQuery(document).ready(function($) { $('.dd-twitter-50').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }</script><div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-digg-ajax-load dd-digg-50'></div><a class='DiggThisButton DD_DIGG_AJAX_50 DiggMedium'></a></div><div class='dd_button'><div class='dd-twitter-ajax-load dd-twitter-50'></div><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.webconsultingengineering.com/phptalk/iframe-code-injection.html" data-count="vertical" data-text="Iframe+code+injection" data-via="susenjit" ></a></div></div></div><div style='clear:both'></div><p>After a long days I am back for blog post. Last one month I was very much irritated with the problem occurred in some of my client website. In a Sunday morning while I was sleeping one of my client ranged me and asked me to check her website as she got a mail from google that her website is spreading malware. I got confused as I had never faced this kind of problem. I started checking the website. But the antivirus in my Laptop didn&#8217;t allowed me to open the site at all. Then I decided to go to my office to check the situation.<br />
<!--adsense--><br />
In my office I checked the site thoroughly(OMG, I was able to open the site in my office). I found iframe code with hidden visibility was inserted in some pages. To be more specific index pages. I checked all the index pages in office PC, deleted the infected pages in the server and uploaded the pages from PC. Checked, cleaned all the html, php, temporary files. Almost near about afternoon I was back to my home while thinking how this happened.<br />
<div id="attachment_53" class="wp-caption aligncenter" style="width: 360px"><a href="http://blog.webconsultingengineering.com/wp-content/uploads/iframe_injected.gif"><img src="http://blog.webconsultingengineering.com/wp-content/uploads/iframe_injected.gif" alt="Iframe Injected" title="iframe_injected" width="350" height="256" class="size-full wp-image-53" /></a><p class="wp-caption-text">Iframe Injected</p></div></p>
<p>Next Morning after arriving in the office I started checking the website and I found it was again infected by the hidden iframe. Site url was different as earler it was .cn and next day it was .ru I was upset about how to fix the things. Believe me or not in the last one month this site got infected 27 times. Our team had experienced the same attack for 5 more site. It was a horrible experience for us. </p>
<p>We had done lot of googleing to find out the preventive measurement. We found out lots of information regarding this. Some of them are good and some of them are misleading too. So here I like to point out some effective ones only.</p>
<ol>
<li>You should have good antivirus installed in your system from where you access web. I am using <a href="http://www.avast.com">avast</a> free edition and it works fine for me.</li>
<li>Please check your websites on a regular basis. If you see if any web page with a blank section in the top them be almost sure that it is infected. Your antivirus should give you warning.</li>
<li>If you find any of your website get infected then start following the next steps.</li>
<li>First of all scan your machine with the antivirus. A boot time scan is more preferable.</li>
<li>Replace all the pages in the website using a local copy from your system. If the web site is too big to repalce then try to repalce all the pages with name index. Then check the site again.</li>
<li>Once the site is cleaned change the ftp details for the site and if possible do the same for the other sites whose details are kept in your ftp application.</li>
<li>Keep checking the site in a short span of interval.</li>
</ol>
<p>You should also check your site in google too. If google find out some problem with your site they may have shown a warning message like &#8220;This site may harm your computer&#8221;. Another way to check your site is </p>
<p>http://www.google.com/safebrowsing/diagnostic?site=http://www.yourdomain.tld</p>
<p>If you find that google is showing the warning message for your site you can request Google for a recheck via <a href="https://www.google.com/webmasters/tools/">Google Webmaster Tool</a>. But you should check the site twice after cleaning and then request for review.</p>
<p>However I have designed a code in php for checking mainly the index pages in the website. Here is the code.</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// page-checker.php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$path</span> <span class="sy0">=</span> <span class="st0">&quot;.&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$baseDir</span> <span class="sy0">=</span> <a href="http://www.php.net/basename"><span class="kw3">basename</span></a><span class="br0">&#40;</span><a href="http://www.php.net/dirname"><span class="kw3">dirname</span></a><span class="br0">&#40;</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st_h">&#8216;PHP_SELF&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$WebPath</span> <span class="sy0">=</span> <span class="st_h">&#8216;http://&#8217;</span><span class="sy0">.</span><span class="re0">$_SERVER</span><span class="br0">&#91;</span><span class="st_h">&#8216;HTTP_HOST&#8217;</span><span class="br0">&#93;</span><span class="sy0">.</span><span class="st_h">&#8216;/&#8217;</span><span class="sy0">.</span><span class="re0">$baseDir</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$content_pattern</span> <span class="sy0">=</span> <span class="st0">&quot;iframe&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">echo</span> <span class="st0">&quot;Checking files for IFRAME Infection&lt;br/&gt;&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$dir_handle</span> <span class="sy0">=</span> <span class="sy0">@</span><a href="http://www.php.net/opendir"><span class="kw3">opendir</span></a><span class="br0">&#40;</span><span class="re0">$path</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;Unable to open <span class="es4">$path</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">echo</span> <span class="st0">&quot;Directory Structure of <span class="es4">$WebPath</span>&lt;br/&gt;&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">navigate<span class="br0">&#40;</span><span class="re0">$dir_handle</span><span class="sy0">,</span> <span class="re0">$path</span><span class="sy0">,</span> <span class="st_h">&#8221;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> navigate<span class="br0">&#40;</span><span class="re0">$dir_handle</span><span class="sy0">,</span><span class="re0">$path</span><span class="sy0">,</span> <span class="re0">$WebPth</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw2">global</span> <span class="re0">$WebPath</span><span class="sy0">,</span> <span class="re0">$content_pattern</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">echo</span> <span class="st0">&quot;&lt;ul&gt;&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">while</span> <span class="br0">&#40;</span><span class="kw4">false</span> <span class="sy0">!==</span> <span class="br0">&#40;</span><span class="re0">$file</span> <span class="sy0">=</span> <a href="http://www.php.net/readdir"><span class="kw3">readdir</span></a><span class="br0">&#40;</span><span class="re0">$dir_handle</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$dir</span> <span class="sy0">=</span> <span class="re0">$path</span><span class="sy0">.</span><span class="st_h">&#8216;/&#8217;</span><span class="sy0">.</span><span class="re0">$file</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/is_dir"><span class="kw3">is_dir</span></a><span class="br0">&#40;</span><span class="re0">$dir</span><span class="br0">&#41;</span> <span class="sy0">&amp;</span>amp<span class="sy0">;&amp;</span>amp<span class="sy0">;</span> <span class="re0">$file</span> <span class="sy0">!=</span> <span class="st_h">&#8216;.&#8217;</span> <span class="sy0">&amp;&amp;</span> <span class="re0">$file</span> <span class="sy0">!=</span><span class="st_h">&#8216;..&#8217;</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">$handle</span> <span class="sy0">=</span> <span class="sy0">@</span><a href="http://www.php.net/opendir"><span class="kw3">opendir</span></a><span class="br0">&#40;</span><span class="re0">$dir</span><span class="br0">&#41;</span> or <a href="http://www.php.net/die"><span class="kw3">die</span></a><span class="br0">&#40;</span><span class="st0">&quot;undable to open file <span class="es4">$file</span>&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">$WebRef</span> <span class="sy0">=</span> <span class="re0">$file</span><span class="sy0">.</span><span class="st_h">&#8216;/&#8217;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;navigate<span class="br0">&#40;</span><span class="re0">$handle</span><span class="sy0">,</span> <span class="re0">$dir</span><span class="sy0">,</span> <span class="re0">$WebRef</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw1">elseif</span><span class="br0">&#40;</span><span class="re0">$file</span> <span class="sy0">!=</span> <span class="st_h">&#8216;.&#8217;</span> <span class="sy0">&amp;</span>amp<span class="sy0">;&amp;</span>amp<span class="sy0">;</span> <span class="re0">$file</span> <span class="sy0">!=</span><span class="st_h">&#8216;..&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/preg_match"><span class="kw3">preg_match</span></a><span class="br0">&#40;</span><span class="st_h">&#8216;/^index+/&#8217;</span><span class="sy0">,</span><span class="re0">$file</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$ChcekFlag</span> <span class="sy0">=</span> <span class="kw4">FALSE</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">echo</span> <span class="st0">&quot;&lt;li&gt;&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">echo</span> <span class="st0">&quot;&lt;a href=&#8217;&quot;</span><span class="sy0">.</span><span class="re0">$WebPath</span><span class="sy0">.</span><span class="re0">$WebPth</span><span class="sy0">.</span><span class="re0">$file</span><span class="sy0">.</span><span class="st0">&quot;&#8217;&gt;&quot;</span><span class="sy0">.</span><span class="re0">$WebPth</span><span class="sy0">.</span><span class="re0">$file</span><span class="sy0">.</span><span class="st0">&quot;&lt;/a&gt;&lt;br /&gt;&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$handle</span> <span class="sy0">=</span> <span class="sy0">@</span><a href="http://www.php.net/fopen"><span class="kw3">fopen</span></a><span class="br0">&#40;</span><span class="re0">$dir</span><span class="sy0">,</span> <span class="st0">&quot;r&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$handle</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">while</span> <span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/feof"><span class="kw3">feof</span></a><span class="br0">&#40;</span><span class="re0">$handle</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$content</span> <span class="sy0">=</span> <a href="http://www.php.net/fgets"><span class="kw3">fgets</span></a><span class="br0">&#40;</span><span class="re0">$handle</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/stristr"><span class="kw3">stristr</span></a><span class="br0">&#40;</span><span class="re0">$content</span><span class="sy0">,</span> <span class="re0">$content_pattern</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">$test</span> <span class="sy0">=</span> <a href="http://www.php.net/stristr"><span class="kw3">stristr</span></a><span class="br0">&#40;</span><span class="re0">$content</span><span class="sy0">,</span> <span class="re0">$content_pattern</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">echo</span> <span class="re0">$test</span><span class="sy0">.</span><span class="st0">&quot;&lt;br /&gt;&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re0">$ChcekFlag</span> <span class="sy0">=</span> <span class="kw4">TRUE</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/fclose"><span class="kw3">fclose</span></a><span class="br0">&#40;</span><span class="re0">$handle</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$ChcekFlag</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">echo</span> <span class="st0">&quot;&lt;font color=&#8217;red&#8217;&gt;Infected&lt;/font&gt;&lt;br /&gt;&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="kw1">echo</span> <span class="st0">&quot;&lt;font color=&#8217;green&#8217;&gt;Clean&lt;/font&gt;&lt;br /&gt;&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">echo</span> <span class="st0">&quot;&lt;/li&gt;&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">echo</span> <span class="st0">&quot;&lt;/ul&gt;&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy1">?&gt;</span></div>
</li>
</ol>
</div>
</div>
<p>you can put this code in the root level of your website (in www or public_html or httpdocs). Browsing this page will show all the index pages with status of it. </p>
<p>Current I am working upon extending the code so that it can clean the infected pages automatically. Hopefully I will post it within few days.</p>
<!-- Social Buttons Shared Counts Generated by Digg Digg plugin v4.2.2, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/ -->]]></content:encoded>
			<wfw:commentRss>http://blog.webconsultingengineering.com/phptalk/iframe-code-injection.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Picasa web album slideshow &#8211; Development guide</title>
		<link>http://blog.webconsultingengineering.com/phptalk/picasa-web-album-slideshow.html</link>
		<comments>http://blog.webconsultingengineering.com/phptalk/picasa-web-album-slideshow.html#comments</comments>
		<pubDate>Tue, 31 Mar 2009 13:28:54 +0000</pubDate>
		<dc:creator>Susenjit</dc:creator>
				<category><![CDATA[Php Talk]]></category>
		<category><![CDATA[album slideshow]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[picasa]]></category>
		<category><![CDATA[picasa slideshow]]></category>
		<category><![CDATA[picasaweb]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[RSS Feed]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.webconsultingengineering.com/?p=44</guid>
		<description><![CDATA[jQuery(document).ready(function($) { window.setTimeout('loadDigg_44()',5000);window.setTimeout('loadTwitter_44()',5000); }); function loadDigg_44(){ jQuery(document).ready(function($) { $('.dd-digg-44').remove();$('.DD_DIGG_AJAX_44').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/picasa-web-album-slideshow.html&#38;title=Picasa+web+album+slideshow+-+Development+guide');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_44(){ jQuery(document).ready(function($) { $('.dd-twitter-44').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }I was looking for a application to embed slideshow using pictures from picase web album. I found some plugins which can be used in blog or myspace. Some of them uses the picasa slide show url opened in [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"><a title="Post on Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count" data-url="http://blog.webconsultingengineering.com/phptalk/picasa-web-album-slideshow.html"></a><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script></div><script type="text/javascript">jQuery(document).ready(function($) { window.setTimeout('loadDigg_44()',5000);window.setTimeout('loadTwitter_44()',5000); });</script><script type="text/javascript"> function loadDigg_44(){ jQuery(document).ready(function($) { $('.dd-digg-44').remove();$('.DD_DIGG_AJAX_44').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/picasa-web-album-slideshow.html&amp;title=Picasa+web+album+slideshow+-+Development+guide');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_44(){ jQuery(document).ready(function($) { $('.dd-twitter-44').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }</script><div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-digg-ajax-load dd-digg-44'></div><a class='DiggThisButton DD_DIGG_AJAX_44 DiggMedium'></a></div><div class='dd_button'><div class='dd-twitter-ajax-load dd-twitter-44'></div><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.webconsultingengineering.com/phptalk/picasa-web-album-slideshow.html" data-count="vertical" data-text="Picasa+web+album+slideshow+-+Development+guide" data-via="susenjit" ></a></div></div></div><div style='clear:both'></div><p>I was looking for a application to embed slideshow using pictures from <a title="picasa web" href="http://picasa.google.com/">picase web album</a>. I found some plugins which can be used in blog or myspace. Some of them uses the picasa slide show url opened in a iframe or div. Then you will have less control on the slideshow as it is controlled by the slideshow application of picasa. But I required more control on the images from picasa.</p>
<p>I was looking for some application which will fetch/store all the images for an album in picasa and create a slideshow with more control on the images. I found nothing thats suites my requirement. So I started to design an application of such kind. On the basis of functionality I sub devided it into two major part. First is fetch the image related information for an album and store it if required. Second is display the slideshow using those image information.</p>
<p>In picasa you can view the pictures as set or individual but you won&#8217;t get actual picture name or its location. So I found now simple way to get the pictures name and their location. While searching more for such option I found there is a RSS feed for each album. The RSS feed provides image names and its location details. It makes my job easier. Now objective became to process the RSS feed to get the image related information. For this purpose I used XML-RSS package from <a href="http://pear.php.net">PEAR</a>. Here is snapshot of the code I wrote to process the feed:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">require_once</span> <span class="st0">&quot;XML/RSS.php&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//$FeedURL is the URL of the rss feed of an album in picasa</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$FeedURL</span> <span class="sy0">=</span> <span class="st0">&quot;http://picasaweb.google.com/data/feed/base/user/wce/albumid/5331321673727336541?alt=rss&amp;kind=photo&amp;hl=en_GB&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$rss</span> <span class="sy0">=&amp;</span> <span class="kw2">new</span> XML_RSS<span class="br0">&#40;</span><span class="re0">$FeedURL</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$rss</span><span class="sy0">-&gt;</span><span class="me1">parse</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$rssArray</span> <span class="sy0">=</span> <span class="re0">$rss</span><span class="sy0">-&gt;</span><span class="me1">getStructure</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$PicasaDataArray</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$InfoArray</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$C</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$C</span><span class="sy0">&lt;</span>count<span class="br0">&#40;</span><span class="re0">$rssArray</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$C</span><span class="sy0">++</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;type&#8217;</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="st_h">&#8216;item&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$PicasaDataArray</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;title&#8217;</span> <span class="sy0">=&gt;</span> <span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;title&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;image&#8217;</span> <span class="sy0">=&gt;</span> <span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;enclosures&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;url&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;link&#8217;</span> <span class="sy0">=&gt;</span> <span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;link&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;description&#8217;</span> <span class="sy0">=&gt;</span> <span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;description&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">elseif</span><span class="br0">&#40;</span><span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;type&#8217;</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="st_h">&#8216;image&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$AlbumTitle</span> <span class="sy0">=</span> &nbsp;<span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;title&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$AlbumPicture</span> <span class="sy0">=</span> &nbsp;<span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;url&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$CreateDate</span> <span class="sy0">=</span> &nbsp;<span class="re0">$MetaInfo</span><span class="br0">&#91;</span><span class="st_h">&#8216;lastbuilddate&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">// this $PicasaDataArray contains all the picture related information of an album from picasa web.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy1">?&gt;</span></div>
</li>
</ol>
</div>
</div>
<p>Now this $PicasaDataArray can be stored in files/database or can be directly used for the slideshow. While processing the feed by this I found the feed contain other information like title, description, link of the album, its last build date etc. So I modified the code a little more to store these information too. So the first part of my application is complete.</p>
<p>Now the second part &#8211; slideshow using $PicasaDataArray. For this section I didn&#8217;t tried to put my head to develop slide show application as I had already seen some very nice attractive slideshow application. They are also easy to use and configure. One of my favourite is <a href="http://www.lokeshdhakar.com/projects/lightbox2/">Lightbox JS</a>. Another good slideshow script is <a href="http://highslide.com/">Highslide</a>. Both of them are very nice and easy to configure. So I used one of them for my purpose. Here is another snapshot of code</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">require_once</span> <span class="st0">&quot;XML/RSS.php&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//$FeedURL is the URL of the rss feed of an album in picasa</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$FeedURL</span> <span class="sy0">=</span> <span class="st0">&quot;http://picasaweb.google.com/data/feed/base/user/wce/albumid/5331321673727336541?alt=rss&amp;kind=photo&amp;hl=en_GB&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$rss</span> <span class="sy0">=&amp;</span> <span class="kw2">new</span> XML_RSS<span class="br0">&#40;</span><span class="re0">$FeedURL</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$rss</span><span class="sy0">-&gt;</span><span class="me1">parse</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$rssArray</span> <span class="sy0">=</span> <span class="re0">$rss</span><span class="sy0">-&gt;</span><span class="me1">getStructure</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$PicasaDataArray</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$InfoArray</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$C</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$C</span><span class="sy0">&lt;</span>count<span class="br0">&#40;</span><span class="re0">$rssArray</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$C</span><span class="sy0">++</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;type&#8217;</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="st_h">&#8216;item&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$PicasaDataArray</span><span class="br0">&#91;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;title&#8217;</span> <span class="sy0">=&gt;</span> <span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;title&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;image&#8217;</span> <span class="sy0">=&gt;</span> <span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;enclosures&#8217;</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;url&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;link&#8217;</span> <span class="sy0">=&gt;</span> <span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;link&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st_h">&#8216;description&#8217;</span> <span class="sy0">=&gt;</span> <span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;description&#8217;</span><span class="br0">&#93;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">elseif</span><span class="br0">&#40;</span><span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;type&#8217;</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="st_h">&#8216;image&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$AlbumTitle</span> <span class="sy0">=</span> &nbsp;<span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;title&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$AlbumPicture</span> <span class="sy0">=</span> &nbsp;<span class="re0">$rssArray</span><span class="br0">&#91;</span><span class="re0">$C</span><span class="br0">&#93;</span><span class="br0">&#91;</span><span class="st_h">&#8216;url&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="re0">$CreateDate</span> <span class="sy0">=</span> &nbsp;<span class="re0">$MetaInfo</span><span class="br0">&#91;</span><span class="st_h">&#8216;lastbuilddate&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="sy1">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&lt;html&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;head&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;title&gt;Slide Show :: <span class="kw2">&lt;?php</span> <span class="kw1">echo</span> &nbsp;<span class="re0">$AlbumTitle</span><span class="sy0">;</span><span class="sy1">?&gt;</span>&lt;/title&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;script type=&quot;text/javascript&quot; src=&quot;js/prototype.js&quot;&gt;&lt;/script&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;script type=&quot;text/javascript&quot; src=&quot;js/scriptaculous.js?load=effects,builder&quot;&gt;&lt;/script&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;script type=&quot;text/javascript&quot; src=&quot;js/lightbox.js&quot;&gt;&lt;/script&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;link rel=&quot;stylesheet&quot; href=&quot;css/lightbox.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;/head&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;body&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;a href=&quot;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> &nbsp;<span class="re0">$AlbumPicture</span><span class="sy0">;</span><span class="sy1">?&gt;</span>&quot; rel=&quot;lightbox[picasa]&quot;&gt;&lt;img src=&quot;<span class="kw2">&lt;?php</span> <span class="kw1">echo</span> &nbsp;<span class="re0">$AlbumPicture</span><span class="sy0">;</span><span class="sy1">?&gt;</span>&quot; /&gt;&lt;/a&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;div style=&quot;display:box;&quot;&gt;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$PicasaDataArray</span> <span class="kw1">as</span> <span class="re0">$ImageInfo</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="kw1">echo</span> <span class="st_h">&#8216;&lt;a href=&quot;&#8217;</span><span class="sy0">.</span><span class="re0">$ImageInfo</span><span class="br0">&#91;</span><span class="st_h">&#8216;image&#8217;</span><span class="br0">&#93;</span><span class="sy0">.</span><span class="st_h">&#8216;&quot;&#8217;</span> rel<span class="sy0">=</span><span class="st0">&quot;lightbox[picasa]&quot;</span><span class="sy0">&gt;</span><span class="st_h">&#8216;.$ImageInfo['</span>title<span class="st_h">'].&#8217;</span><span class="sy0">&lt;/</span>a<span class="sy0">&gt;&lt;</span>br<span class="sy0">&gt;</span> <span class="st_h">&#8216;;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st_h">}</span></div>
</li>
<li class="li1">
<div class="de1"><span class="st_h">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&lt;/div&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;/body&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;/html&gt;</div>
</li>
</ol>
</div>
</div>
<p>I made this  code simple and easy to use. Though I have used xml-rss class from pear but it can be repalced by and standard xml-rss parser class. Experienced developer can modify this code or enhance its feature much more as per their requirement. If like to use this code or if you have any suggestion let me know about it via your comment. </p>
<!-- Social Buttons Shared Counts Generated by Digg Digg plugin v4.2.2, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/ -->]]></content:encoded>
			<wfw:commentRss>http://blog.webconsultingengineering.com/phptalk/picasa-web-album-slideshow.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Converting Excel date/time to Unix timestamp</title>
		<link>http://blog.webconsultingengineering.com/phptalk/timestamp-excel2unix.html</link>
		<comments>http://blog.webconsultingengineering.com/phptalk/timestamp-excel2unix.html#comments</comments>
		<pubDate>Fri, 29 Aug 2008 13:04:40 +0000</pubDate>
		<dc:creator>Susenjit</dc:creator>
				<category><![CDATA[Php Talk]]></category>

		<guid isPermaLink="false">http://blog.webconsultingengineering.com/?p=12</guid>
		<description><![CDATA[jQuery(document).ready(function($) { window.setTimeout('loadDigg_12()',5000);window.setTimeout('loadTwitter_12()',5000); }); function loadDigg_12(){ jQuery(document).ready(function($) { $('.dd-digg-12').remove();$('.DD_DIGG_AJAX_12').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/timestamp-excel2unix.html&#38;title=Converting+Excel+date%2Ftime+to+Unix+timestamp');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_12(){ jQuery(document).ready(function($) { $('.dd-twitter-12').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }Timestamp conversion are required when you import information generated by Windows based application to UNIX system. I faced a similar type of problem when I was trying to read data from a MS Excel file and storing it [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"><a title="Post on Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count" data-url="http://blog.webconsultingengineering.com/phptalk/timestamp-excel2unix.html"></a><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script></div><script type="text/javascript">jQuery(document).ready(function($) { window.setTimeout('loadDigg_12()',5000);window.setTimeout('loadTwitter_12()',5000); });</script><script type="text/javascript"> function loadDigg_12(){ jQuery(document).ready(function($) { $('.dd-digg-12').remove();$('.DD_DIGG_AJAX_12').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/timestamp-excel2unix.html&amp;title=Converting+Excel+date%2Ftime+to+Unix+timestamp');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_12(){ jQuery(document).ready(function($) { $('.dd-twitter-12').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }</script><div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-digg-ajax-load dd-digg-12'></div><a class='DiggThisButton DD_DIGG_AJAX_12 DiggMedium'></a></div><div class='dd_button'><div class='dd-twitter-ajax-load dd-twitter-12'></div><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.webconsultingengineering.com/phptalk/timestamp-excel2unix.html" data-count="vertical" data-text="Converting+Excel+date%2Ftime+to+Unix+timestamp" data-via="susenjit" ></a></div></div></div><div style='clear:both'></div><p>Timestamp conversion are required when you import information generated by Windows based application to UNIX system. I faced a similar type of problem when I was trying to read data from a MS Excel file and storing it in MySQL database using a php code.</p>
<p>I was using Excel_reader class to read the Excel file. In that file there were two columns for 2 dates. While reading those column value I found they contain some numeric value. Those values are not same as unix timestamp value. As I was trying to store those values as timestamp I need to convert them into the timestamp.</p>
<p>After some searching and reading from internet I found that Windows and Unix system stores timestamp in different manner. Once this is clear to me I have converted them easily. So let us understand how these two system stores timestamp .</p>
<p>In Unix system timestamp is stored as integer in terms of seconds. If we consider the current timestamp value in Unix then it is basically the no. of seconds passed from 1 January 1970 00.00Hrs to till now. One important thing for Unix timestamp is that it is measured with reference to GMT time. That means there is no time-zone adjustment considered in case of Unix timestamp.</p>
<p>In case of Windows time it is stored as floating point/real number but in terms of days. For current timestamp, the no. days spent from 1 January 1900 stored in integer part and fraction of the day stored in the fractional part of the timestamp.</p>
<p>Now comes the conversion process. I made a simple conversion calculation as follows:</p>
<div class="codesnip-container" >
<div class="php-brief codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$DayDifference</span> <span class="sy0">=</span> <span class="nu0">25569</span><span class="sy0">;</span> <span class="co1">//Day difference between 1 January 1900 to 1 January 1970</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$Day2Seconds</span> <span class="sy0">=</span> <span class="nu0">86400</span><span class="sy0">;</span> <span class="co1">// no. of seconds in a day</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$ExcelTime</span> <span class="co1">//integer value stored in the Excel column</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$UnixTime</span> <span class="sy0">=</span> <span class="br0">&#40;</span><span class="re0">$ExcelTime</span> <span class="sy0">-</span> <span class="re0">$DayDifference</span><span class="br0">&#41;</span><span class="sy0">*</span><span class="re0">$Day2Seconds</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
</div>
<p>Now if you look at the calculation, you may find that the conversion is not absolutely accurate. This is because I haven&#8217;t consider the fractional part of the Excel time. The reason behind doing so is that all I need to do is to convert a date from Windows format to Unix format. So fraction part of windows time won&#8217;t affect a lot for my requirement. But if you use this calculation for converting a date-time from Windows format to Unix format then conversion of the fractional part should done.<br />
If you like this small tips please let me know about it.</p>
<!-- Social Buttons Shared Counts Generated by Digg Digg plugin v4.2.2, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/ -->]]></content:encoded>
			<wfw:commentRss>http://blog.webconsultingengineering.com/phptalk/timestamp-excel2unix.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>QuickForm and Jscalendar</title>
		<link>http://blog.webconsultingengineering.com/phptalk/quickform-jscalendar.html</link>
		<comments>http://blog.webconsultingengineering.com/phptalk/quickform-jscalendar.html#comments</comments>
		<pubDate>Tue, 08 Jul 2008 08:19:23 +0000</pubDate>
		<dc:creator>Susenjit</dc:creator>
				<category><![CDATA[Php Talk]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[dbtable]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[jscalendar]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[quickform]]></category>

		<guid isPermaLink="false">http://blog.webconsultingengineering.com/?p=5</guid>
		<description><![CDATA[jQuery(document).ready(function($) { window.setTimeout('loadDigg_5()',5000);window.setTimeout('loadTwitter_5()',5000); }); function loadDigg_5(){ jQuery(document).ready(function($) { $('.dd-digg-5').remove();$('.DD_DIGG_AJAX_5').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/quickform-jscalendar.html&#38;title=QuickForm+and+Jscalendar');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_5(){ jQuery(document).ready(function($) { $('.dd-twitter-5').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }Most of us are familiar with calendars in web pages. Small calendar showing date and year are really good to see and useful too. While in case of forms we have seen calendars attached with date fields. In [...]]]></description>
			<content:encoded><![CDATA[<div style="float:left;margin:0px 0px 0px 0px;"><a title="Post on Google Buzz" class="google-buzz-button" href="http://www.google.com/buzz/post" data-button-style="normal-count" data-url="http://blog.webconsultingengineering.com/phptalk/quickform-jscalendar.html"></a><script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script></div><script type="text/javascript">jQuery(document).ready(function($) { window.setTimeout('loadDigg_5()',5000);window.setTimeout('loadTwitter_5()',5000); });</script><script type="text/javascript"> function loadDigg_5(){ jQuery(document).ready(function($) { $('.dd-digg-5').remove();$('.DD_DIGG_AJAX_5').attr('href','http://digg.com/submit?url=http://blog.webconsultingengineering.com/phptalk/quickform-jscalendar.html&amp;title=QuickForm+and+Jscalendar');$.getScript('http://widgets.digg.com/buttons.js'); }); } function loadTwitter_5(){ jQuery(document).ready(function($) { $('.dd-twitter-5').remove();$.getScript('http://platform.twitter.com/widgets.js'); }); }</script><div class='dd_post_share'><div class='dd_buttons'><div class='dd_button'><div class='dd-digg-ajax-load dd-digg-5'></div><a class='DiggThisButton DD_DIGG_AJAX_5 DiggMedium'></a></div><div class='dd_button'><div class='dd-twitter-ajax-load dd-twitter-5'></div><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.webconsultingengineering.com/phptalk/quickform-jscalendar.html" data-count="vertical" data-text="QuickForm+and+Jscalendar" data-via="susenjit" ></a></div></div></div><div style='clear:both'></div><p>Most of us are familiar with calendars in web pages. Small calendar showing date and year are really good to see and useful too. While in case of forms we have seen calendars attached with date fields. In some of my earlier projects I have designed date fields using simple drop down menu containing the data, month and year menu. It’s good but not very user friendly as user need to select 3 menus to choose a certain date. I had to stick with that format as I mostly use PEAR <a title="HTML_QuickForm" href="http://pear.php.net/package/HTML_QuickForm">HTML_QuickForm</a> to design forms in the web pages. Among many reasons the most unavoidable one is that it automatically generates client side validation JavaScript code. With time I realized that I should find some options to integrate calendar object with the QuickForm.</p>
<p>After giving a thorough search I selected <a title="Jscalendar" href="http://www.dynarch.com/projects/calendar/">jscalendar</a> to incorporate with my form elements. The reasons behind selecting jscalendar are:</p>
<ul>
<li>It has a nice interface and wide variety of themes.</li>
<li>Multiple integration options along with selectable date format to put the date in the text field.</li>
<li>Support for integrating the calendar object with HTML_QuickForm.</li>
</ul>
<p>Prior to integrate the jscalendar I need to upgrade HTML_QuickFom version to 3.2.10 as I found some code added in this version to support jscalendar. I also need to upgrade my <a href="http://pear.php.net/package/DB">PEAR DB</a> package to version 1.7.13 and <a href="http://pear.php.net/package/DB_Table">DB_Table</a> to version 1.5.5. In my projects most of the cases I generate forms using DB_Table instead of using QuickForm directly. This gives an extra benefit for data validation and storing them in database.</p>
<p>After the up-gradating the required pear packages I worked upon integrating the jscalendar code. After a spending a moderate amount of time I was able to work jscalender with the QuickForm. But unfortunately when I was trying generate forms using DB_Table jscalendar component was not working. I was getting javascript errors.<br />
I was following the method described by Philippe Jausions of <a href="http://www.11abacus.com/">11abacus</a> in jscalendar.php file. It was working fine with the QuickForm. In that case I was using addElements function to add jscalendar with proper options using the $option array like this –</p>
<div class="codesnip-container" >
<div class="php-brief codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$options</span> <span class="sy0">=</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;baseURL&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;../js/jscalendar/&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;styleCss&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;calendar-win2k-1.css&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;language&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;en&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;button&#8217;</span> &nbsp; <span class="sy0">=&gt;</span> <span class="st0">&#8221;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;setup&#8217;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;inputField&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;datefield1&#8242;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;ifFormat&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;%d.%m.%Y %H:%M&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;showsTime&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw2">true</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;time24&#8242;</span> <span class="sy0">=&gt;</span> <span class="kw2">true</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;weekNumbers&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw2">false</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;showOthers&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw2">true</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$form</span><span class="sy0">-&gt;</span><span class="me1">addElement</span><span class="br0">&#40;</span><span class="st0">&#8216;jscalendar&#8217;</span><span class="sy0">,</span> <span class="st0">&#8216; datefield1&#8242;</span><span class="sy0">,</span> <span class="st0">&#8216;My Date&#8217;</span><span class="sy0">,</span> <span class="re0">$options</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
</div>
<p>I used this same option array in the column definition for the same field, as DB_Table uses the column definition for the attributes of the form elements of the form. I written like</p>
<div class="codesnip-container" >
<div class="php-brief codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="st0">&#8216;datefield1&#8242;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;type&#8217;</span> &nbsp; &nbsp;<span class="sy0">=&gt;</span> <span class="st0">&#8216;varchar&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;size&#8217;</span> &nbsp; &nbsp;<span class="sy0">=&gt;</span> <span class="nu0">20</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_type&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;jscalendar&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_label&#8217;</span><span class="sy0">=&gt;</span> <span class="st0">&#8216;&lt;span class=&quot;caption&quot;&gt;Date:&lt;/span&gt;&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;require&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw2">false</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_attrs&#8217;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;class&#8217;</span><span class="sy0">=&gt;</span> <span class="st0">&#8216;formfield&#8217;</span><span class="sy0">,</span><span class="st0">&#8216;id&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;datefield1&#8242;</span><span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_opts&#8217;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;baseURL&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;../js/jscalendar/&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;styleCss&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;calendar-win2k-1.css&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;language&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;en&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;button&#8217;</span> &nbsp; <span class="sy0">=&gt;</span> <span class="st0">&#8221;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;setup&#8217;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;inputField&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;listadata&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;ifFormat&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;%d.%m.%Y %H:%M&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;showsTime&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw2">true</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;time24&#8242;</span> <span class="sy0">=&gt;</span> <span class="kw2">true</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;weekNumbers&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw2">false</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;showOthers&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw2">true</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_client&#8217;</span><span class="sy0">=&gt;</span> <span class="kw2">true</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;qf_rules&#8217;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;required&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;Date is required.&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
</ol>
</div>
</div>
<p>It didn’t worked and also gave the javascript error as calendar.Setup &#8211; no such method found….<br />
Now I started working on how to fix this problem. I started checking the all the codes thoroughly and found that using QuickForm from DB_Table setting all these options can’t be done. After spending some upon those codes I rewrite the column definition like this</p>
<div class="codesnip-container" >
<div class="php-brief codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="st0">&#8216;datefield1&#8242;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;type&#8217;</span> &nbsp; &nbsp;<span class="sy0">=&gt;</span> <span class="st0">&#8216;varchar&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;size&#8217;</span> &nbsp; &nbsp;<span class="sy0">=&gt;</span> <span class="nu0">20</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_type&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;jscalendar&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_label&#8217;</span><span class="sy0">=&gt;</span> <span class="st0">&#8216;&lt;span class=&quot;caption&quot;&gt;Date:&lt;/span&gt;&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;require&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw2">false</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_attrs&#8217;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;class&#8217;</span><span class="sy0">=&gt;</span> <span class="st0">&#8216;formfield&#8217;</span><span class="sy0">,</span><span class="st0">&#8216;id&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;datefield1&#8242;</span><span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_opts&#8217;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;ifFormat&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;%d.%m.%Y&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;showsTime&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw2">false</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;time24&#8242;</span> <span class="sy0">=&gt;</span> <span class="kw2">false</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;weekNumbers&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw2">false</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;showOthers&#8217;</span> <span class="sy0">=&gt;</span> <span class="kw2">false</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="st0">&#8216;button&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8221;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_client&#8217;</span><span class="sy0">=&gt;</span> <span class="kw2">true</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_rules&#8217;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;required&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;Date is required.&#8217;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
</ol>
</div>
</div>
<p>Also I declared the global path defining variable in the page where I was generating the form. I defined</p>
<div class="codesnip-container" >
<div class="php-brief codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$GLOBALS</span><span class="br0">&#91;</span><span class="st0">&#8216;_HTML_QUICKFORM_JSCALENDAR_BASEPATH&#8217;</span><span class="br0">&#93;</span> <span class="sy0">=</span> <span class="st0">&quot;/js/jscalendar/&quot;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
</div>
<p>Oh that time it worked. It showed the small calendar while the clicking the small button beside the text field for data. But I wasn’t still happy with it. What I found that the calendar was coming but it wasn’t using any style and dates are raveling upon a transparent layer, making it too ugly. I tried to define the style using style class/ stylesheet file name in different places as different parameter. But nothing worked. Now I had two options then</p>
<p>Define the stylesheet for the calendar within the head tags of the page containing the form, means hardcode the name of the stylesheet.<br />
Change the coding to accommodate to options for setting the style class for the calendar.</p>
<p>Selecting the 1st option means loosing some dynamicity and selecting the 2nd option means I need to change or modify certain code in pear class package files. So it was difficult to select any option. I was investigating the benefits and the hitches which can come out as a result of using any one of those options. Also side by side I was looking for third other option which can be better then these two. I spent almost two days and came up with a decision of selecting the second option. I decided to add two lines of code in the QuicfForm.php file in the DB package as</p>
<div class="codesnip-container" >
<div class="php-brief codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$col</span><span class="br0">&#91;</span><span class="st0">&#8216;qf_theme&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$element</span><span class="sy0">-&gt;</span><span class="me1">theme</span> <span class="sy0">=</span> <span class="re0">$col</span><span class="br0">&#91;</span><span class="st0">&#8216;qf_theme&#8217;</span><span class="br0">&#93;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
</div>
<p>Also I have added one more element in column definitions for the date field as</p>
<div class="codesnip-container" >
<div class="php-brief codesnip" style="font-family:monospace;">
<ol>
<li class="li1">
<div class="de1"><span class="st0">&#8216;datefield1&#8242;</span> <span class="sy0">=&gt;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; …… &nbsp; &nbsp;……<span class="sy0">.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; …… &nbsp; &nbsp;……<span class="sy0">.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&#8216;qf_theme&#8217;</span> <span class="sy0">=&gt;</span> <span class="st0">&#8216;calendar-win2k-2&#8242;</span><span class="sy0">,</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span><span class="sy0">,</span></div>
</li>
</ol>
</div>
</div>
<p>Now my problem is solved and the jscalendar is working seamlessly with the QuickForm from the DB_Table package too.</p>
<p>My opinion is if you like to add the two lines of code in QuickForm.php file you can add it but you need to remember it at the time when you upgrade the pear package. Also you need to check if it works properly or not. The other way is to hardcode the stylesheet file within the head tag part of the page where you will go to generate the form. In this case you will surely loose some dynamicity but this is easier to work with. Choice is yours.</p>
<p>Currently I am working upon another important issue in php. I need some time to accomplish this job. I will discuss this issue too cause I find it very interesting. However if you find this above discussion useful then I might expect your comment here. Suggestion and queries are also welcome.</p>
<!-- Social Buttons Shared Counts Generated by Digg Digg plugin v4.2.2, 
    Author : Yong Mook Kim
    Website : http://www.mkyong.com/blog/digg-digg-wordpress-plugin/ -->]]></content:encoded>
			<wfw:commentRss>http://blog.webconsultingengineering.com/phptalk/quickform-jscalendar.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
