Sanjoy Roy

[MCM, MCP, SCJP] – Senior PHP Programmer

Category Archives: Uncategorized

Google Map – Add Markers using ExtJS API


Ext.onReady(function(){

    var mapwin;
    var button = Ext.get('show-btn');

    button.on('click', function(){
        // create the window on the first click and reuse on subsequent clicks
        if(!mapwin){

            mapwin = new Ext.Window({
                layout: 'fit',
                title: 'GMap Window',
                closeAction: 'hide',
				maximizable:true,
				minimizable:true,
                width:1024,
                height:786,
                x: 40,
                y: 60,
                items: {
                    xtype: 'gmappanel',
                    zoomLevel: 14,
                    gmapType: 'map',
                    mapConfOpts: ['enableScrollWheelZoom','enableDoubleClickZoom','enableDragging'],
                    mapControls: ['GSmallMapControl','GMapTypeControl','NonExistantControl'],
                    setCenter: {
                        geoCodeAddr: '1 Church St, Richmond, Victoria, 3121',
                        marker: {title: 'Branch Office'}
                    },
                    markers: [{
                        lat: -37.81748164010962,
                        lng: 144.99946296215057,
                        marker: {title: 'Richmond Police Station'},
                        listeners: {
                            click: function(e){
                                Ext.Msg.alert('Richmond', 'Richmond Police Station');
                            }
                        }
                    },{
                        lat: -37.82184477198719,
                        lng: 144.99804139137268,
                        marker: {title: 'Richmond Church'},
						 listeners: {
                            click: function(e){
                                Ext.Msg.alert('Richmond', 'Richmond Church');
                            }
                        }
                    }]
                }
            });
            
        }
        
        mapwin.show();
        
    });
    
 });

<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
<title>GMap Window Example</title>
<link rel=”stylesheet” type=”text/css” href=”../../resources/css/ext-all.css” />

<!– GC –>
<!– LIBS –>
<script type=”text/javascript” src=”../../adapter/ext/ext-base.js”></script>
<!– ENDLIBS –>

<script type=”text/javascript” src=”../../ext-all.js”></script>

<!– GMaps API Key that works for http://www.extjs.com –>
<script src=”http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA2CKu_qQN-JHtlfQ5L7BLlRRadLUjZPtnrRT4mXZqcP4UUH-2OxREmPm3GpN_NHsHuvuHd-QKI4YoRg&#8221; type=”text/javascript”></script>
<!– GMaps API Key that works for localhost –>
<!–<script src=”http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=ABQIAAAA2CKu_qQN-JHtlfQ5L7BLlRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQl3I3p2yrGARYK4f4bkjp9NHpm5w&#8221; type=”text/javascript”></script>–>

<script src=”../ux/GMapPanel.js”></script>
<script src=”gmap.js”></script>

<!– Common Styles for the examples –>
<link rel=”stylesheet” type=”text/css” href=”../shared/examples.css” />

<style type=”text/css”>
.x-panel-body p {
margin:10px;
font-size:12px;
}
</style>
</head>
<body>
<script type=”text/javascript” src=”../shared/examples.js”></script><!– EXAMPLES –>

<h1>GMap Window</h1>
<p>This example shows how to create an extension and utilize an external library.</p>
<input type=”button” id=”show-btn” value=”Gimme a Map” /><br /><br />
<p>Note that the js is not minified so it is readable. See <a href=”../ux/GMapPanel.js”>GMapPanel.js</a> and <a href=”gmap.js”>gmap.js</a> for the full source code.</p>

</body>
</html>

Magento – How to Change multiselect list box to select box?


In magento, by default if a select option has more than 2 values, it automatically make the select box to multiselect box.
if you need to change this to remain always select box, here is how to do:

Steps:
Edit the Form.php:
Location: /public_html/app/code/core/Mage/CatalogSearch/Block/Advanced/Form.php
Position: public function getAttributeSelectElement($attribute)
Line no.: 185
What to change: <pre>if (is_array($options) && count($options)>2)</pre>  to <pre>if (is_array($options) && count($options)>100)</pre>

Magento – How to display 3 select boxes in a single row in advance search page (li)?


Steps:
Modify the /public_html/skin/frontend/default/f001/css/custom.css file:
(f001 is your defind template)

At the end add the following: custom.css
————————————————————————–
#rim_diameter_inches_li .multiselect {width:70px;}

#tyre_width_li .multiselect {width:50px;}

#profile_li .input-box .multiselect {width:60px;}

#rim_diameter_inches_li {width: 60px; float: left; }
#tyre_width_li{float: left;background-image: url(../images/search-splitter.gif);
background-repeat: no-repeat;
background-position: right center;}
#tyre_width_li .input-box {width: 70px; }

#profile_li {
width: 70px;
float: left;
}
#profile_li .input-box {width: 50px;  float: left; }
#rim_diameter_inches_li .input-box {float: left; width: 50px;}
———————————————————————–

The form fields are:
Defind in /public_html/app/design/frontend/base/default/template/catalogsearch/advanced/form.phtml file:
<pre>

<ul id=”advanced-search-list”>
<li id=”tyre_width_li”>
<label for=”tyre_width”>Tyre Size</label>
<div>
<select name=”tyre_width” id=”tyre_width” title=”Width (mm)”><option value=”” selected=”selected”>All</option><option value=”54″>175</option><option value=”53″>185</option><option value=”67″>195</option><option value=”80″>205</option><option value=”79″>215</option><option value=”78″>225</option><option value=”77″>235</option><option value=”76″>245</option><option value=”75″>265</option><option value=”74″>275</option><option value=”73″>287</option><option value=”72″>295</option><option value=”71″>314</option><option value=”70″>315</option></select>                        </div>

</li>
<li id=”profile_li”>
<label for=”profile”></label>
<div>
<select name=”profile” id=”profile” title=”Profile”><option value=”” selected=”selected”>All</option><option value=”26″>35</option><option value=”25″>40</option><option value=”24″>45</option><option value=”23″>55</option><option value=”22″>60</option><option value=”21″>65</option><option value=”20″>70</option><option value=”19″>75</option><option value=”18″>80</option><option value=”17″>NA</option></select>                        </div>

</li>
<li id=”rim_diameter_inches_li”>
<label for=”rim_diameter_inches”></label>
<div>
<select name=”rim_diameter_inches” id=”rim_diameter_inches” title=”RIM diameter inches”><option value=”” selected=”selected”>All</option><option value=”36″>14</option><option value=”35″>14C</option><option value=”88″>15</option><option value=”87″>16</option><option value=”86″>16C</option><option value=”85″>17</option><option value=”84″>18</option><option value=”83″>19</option><option value=”82″>20</option><option value=”81″>22.5</option></select>                        </div>

</li>
<div style=”clear: both; padding-left: 170px;”><b>WIDTH</b>&nbsp;(mm)&nbsp;/&nbsp;<b>PROFILE</b>&nbsp;<b>RIM</b> (diameter inches)
</div>                                    <li id=”size_li”>
<label for=”size”>Size</label>
<div>

<input name=”size” id=”size” value=”” title=”Size” type=”text”>
</div>

</li>
<li id=”speed_li”>
<label for=”speed”>Speed</label>
<div>
<input name=”speed” id=”speed” value=”” title=”Speed” type=”text”>
</div>

</li>
<li id=”brand_li”>
<label for=”brand”>Brand</label>
<div>
<input name=”brand” id=”brand” value=”” title=”Brand” type=”text”>
</div>

</li>
<li id=”pattern_li”>

<label for=”pattern”>Pattern</label>
<div>
<input name=”pattern” id=”pattern” value=”” title=”Pattern” type=”text”>
</div>

</li>
<li id=”price_li”>
<label for=”price”>Price</label>
<div>

<input name=”price[from]” value=”” id=”price” title=”Price” type=”text”>
<span>-</span>
<input name=”price[to]” value=”” id=”price_to” title=”Price” type=”text”>
<small>(AUD)</small>
</div>
</li>
</ul>

</pre>

BrowserLab – Preview web pages across multiple browsers and operating systems


Accurately pinpoint compatibility issues and compare web pages at a glance to easily identify differences and potential problems. Preview full screenshots with multiple view options and customizable test settings.

With the integration of Dreamweaver CS5 or Firebug, you can also give BrowserLab permission to preview web pages that are behind a firewall.

Easy CMS/Block – Frontend Features


  • Extension key: magento-community/AsiaConnect_FreeCMS

    Label

    Easy CMS allow to put any HTML content to any position on Magento site. You can put text, banner, advertisement, images, flash, music, video, product… After a short time with more than 4000+ download, EasyCMS Frontend Features is available to install via Magento Connect now. Get the extension and have a happy time with your site now. Read more of this post

Magento is slow?


BACKEND SETTING:

1. Sign in to Backend (index.php/admin)
2. From the menu choose System->Cache Management
3. Click on Select All link
4. Choose Enable from Actions drop down list
5. Press Submit button.
6. To enable additional cache management press both the “Flush Catalog Images Cache” and “Flush JavaScript/CSS Cache” buttons.

APACHE SETTING:
(~public_html/.htaccess file changes)

<IfModule mod_deflate.c>
DeflateBufferSize 32768
DeflateCompressionLevel 5

<Location />
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|tiff)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
</Location>
</IfModule>

PHP SETTING:
(~public_html/php.ini)

zlib.output_compression = on

How To Stop Spammers Using Your Feedback Form


Not securing your feedback form can leave it open to spammers possibly allowing them to send junk mail to anyone with it appearing to have originated from you. This could in the worst case scenario see your domain blacklisted by many mail servers.

The Solution

Luckily there are a few things you can do to make your feedback form a lot harder to exploit. The main technique spammers use is to try and insert bcc: headers into the feedback form. Say for example you have a feedback form with a message and an email field, this is passed to a PHP script without any validation which does something similar to the following:

   mail('you@yourdomain.com', 'Feedback', $_POST['message'], 'From: '.$_POST['email']);

If the spammer can send “fake@address.com%0ABcc:recipient1@domain.com,recipient2@domain.com” in the email address field on your form then whatever they type in the message box will not only be sent to you but to all those listed recipients aswell. What if 100’s or 1000’s of bcc: recipients are listed?

A few extra lines of code and this problem can be solved eliminating the majority of attacks on your forms. The following simply removes all occurances of bcc:, cc:, to: or content-type: headers so that the content of the form can only be submitted to you and not to anyone else.

 $find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i");
   $message = preg_replace($find, '', $_POST['message']);
   $email = preg_replace($find, '', $_POST['email']);
   mail('you@yourdomain.com', 'Feedback', $message, 'From: '.$email);

IP Addresses

You may also wish to capture the ip address of the person sending the form.

$ip = $_SERVER['X_FORWARDED_FOR'] ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
   mail('you@yourdomain.com', 'Feedback', $message, 'From: '.$email."\nX-From-IP:".$ip);

This could be used in creating your own ‘blacklist’ once you know the ip address of any offenders. The message can then only be sent if its not in your banned ip list:

 $ip = $_SERVER['X_FORWARDED_FOR'] ? $_SERVER['X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
   $banned_ip = array('195.99.99.99','137.11.11.11');
   if(!in_array($ip,$banned_ip)) {
      mail('you@yourdomain.com', 'Feedback', $message, 'From: '.$email."\nX-From-IP:".$ip);
   }

Grameenphone P5/P6 internet package, use efficiently


Grameenphone P5/P6 packages are data limited packages, taking the most out of them should be a priority.

To efficiently use your data quota, you should follow few things:

1. Use firefox browser with adblocker plus extension.Ads use lots of bandwidth, so using adblocker saves your bandwidth.
2. Don’t use torrent clients.Torrents uses both uploading and downloading, so while downloading a 20MB file with torrent, you may end up using 30MB or more of your data quota.
3. Use pidgin messenger instead of official yahoo/msn messenger.Official yahoo/msn messengers shows lots of ads which eats up your data quota, so using pidgin for chat will save your pocket.
4.Update softwares using update packs.Many softwares provide a smaller upgrader package when new versions are available. Download and use it instead of full package.
5. Turn off showing images on web pages when you only need text information. This will save you most bandwidth in the long run.

ICCR & My Scholarship


https://i0.wp.com/www.iccrindia.org/images/topbar4_1.gif

The Indian Council for Cultural Relations (ICCR) was founded on 9th April 1950 by Maulana Abul Kalam Azad, the first Education Minister of independent India. Since then we have seen in India the consolidation of Indian democracy, the establishment of an equitable social order, the rapid development of the Indian economy, the empowerment of Indian women, the creation of a vibrant infrastructure of world-class educational institutions, and the powerful revitalization of scientific traditions.
There has also been a revival, reiteration and renewal of the five-millennia old Indian culture, exemplified by the energetic projection, development and experimentation in Indian arts, the confident and creative expansion of Indian languages, and the great energy in Indian cinema. ICCR, in harmony with these developments, is in unison with contemporary India.The last five decades have been one of the most exciting periods in the arts in India’s long history. Indian literature, music and dance,
Indian paintings, sculpture and crafts, as well as Indian theatre and films, has each witnessed great outbursts of creativity. ICCR continues to encourage improvisation and experimentation with the new, while it pays homage to the classical as well as the folk forms of India’s cultural expression. Read more of this post

How to use a portion of an image from a group?


HTML Block:

    	Actual Image:

        Result:
    	

CSS Block:

.logo{
	background:transparent url(../images/buttons.png) no-repeat 0 0;
	display:block;
	margin:0 0 5px;
	padding:10px 0 2px 213px;
	height:21px;
	overflow:hidden;
	clear:none;
	background-position:-307px -152px;
	/*Starting of x position, ending of y position - measure it in photoshop info viewer tool*/
	color:#7f7f7f;
	text-transform:uppercase;
	font-size:77%;
	position:relative;
}

Live Demo

Daylight Saving in Victoria


https://i0.wp.com/www.vic.gov.au/kernel/user_files/Images/OnSite/DaylightSaving1forward.gif
At start of daylight saving period, move clock forward one hour at 2 am.

https://i0.wp.com/www.vic.gov.au/kernel/user_files/Images/OnSite/DaylightSaving2back.gif
At end of daylight saving period, move clock back one hour at 3 am.
2009/2010
Victoria’s period of daylight saving will start at 2:00am on Sunday 4 October 2009. At 2:00am move clocks forward one hour to 3:00am.
Victoria’s period of daylight saving will end on Sunday 4 April 2010. At 3:00am move clocks backward one hour to 2:00am.
2010/2011
Victoria’s period of daylight saving will start at 2:00am on Sunday 3 October 2010. At 2:00am move clocks forward one hour to 3:00am.
Victoria’s period of daylight saving will end on Sunday 3 April 2011. At 3:00am move clocks backward one hour to 2:00am.
Source

Ten Rules for a Good Day!


  • TODAY I WILL NOT STRIKE BACK – If someone is rude, if someone is impatient, if someone is unkindI will not respond in a like manner.
  • TODAY I WILL ASK GOD TO BLESS MY ENEMY – If I come across someone who treats me harshly or unfairly, I will quietly ask God to bless that individual. I understand the enemy could be a family member, neighbor, co-worker, or a stranger.
  • TODAY I WILL BE CAREFUL ABOUT WHAT I SAY – I will carefully choose and guard my words being certain that I do not spread gossip.
  • TODAY I WILL GO THE EXTRA MILE – I will find ways to help share the burden of another person.
  • TODAY I WILL FORGIVE – I will forgive any hurts or injuries that come my way.
  • TODAY I WILL DO SOMETHING NICE FOR SOMEONE, BUT I WILL NOT DO IT SECRETLY – I will reach out anonymously and bless the life of another.
  • TODAY I WILL TREAT OTHERS THE WAY I WISH TO BE TREATED – I will practice the golden rule Do unto others as I would have them do unto me with everyone I encounter.
  • TODAY I WILL RAISE THE SPIRITS OF SOMEONE I DISCOURAGED – My smile, my words, my expression of support, can make the difference to someone who is wrestling life.
  • TODAY I WILL NUTURE MY BODY – I will eat less; I will eat only healthy foods. I will thank God for my body.
  • TODAY I WILL GROW SPIRITUALLUY – I will spend a little more time in prayer today: I will begin reading something spiritual or inspirational today; I will find a quiet place (at some point during the day)!

Can u take 10 seconds away from ur busy schedule?


Here is a chance to make a difference, by devoting JUST 10 seconds a day.
You don’t need to go anywhere, donate money, stage protests or shout slogans.
How? If you use computer to work, just remember to switch off your monitor every time you leave your desk. Very simple, isn’t it?
What difference does it make? Roughly, normal monitors consume around 150 W.
Even if your screen remains ON for 1 hour per day without any use, energy wasted per day is 150 W-h (or 0.15 ‘units’).
This is enough to light a small lamp for 10 hours! If you care to switch off your monitor each time you leave your place, you save electricity enough for basic household needs of a small family in a village!
If your monitor remains ON overnight, this figure becomes 10-fold ,so you can probably save electricity for 10 families.
And supposing that you leave your seat 5 times a day and it takes 1 second to switch the monitor ON/OFF,
you spend only 10 seconds a day for this deed which saves LOTS of energy on a long run!
I hope you will follow this practice…
Energy saved is energy produced !!

Welcome to My Blog


Hello, and welcome to my blog! I’m not sure exactly what I’ll be writing about, but with the project I’ve been working on for the past 7 months recently announced, I felt compelled to finally start one. Of course, it has taken me almost a week to get my blog up and running – more on that in future blog entries…

I joined Macromedia around 9 months ago, and run the recently announced project code-named “Zorn” with Sho Kuwamoto. My prime motivation for joining Macromedia was that I saw incredible things being done in Flash that just blew me away, but every time I picked it up, my eyes would glaze over. Within this dichotomy I saw a tremendous opportunity to help make building these rich internet apps easier for people like me.

So Zorn is the new development tool that we’re building to make it easier to build apps that run on the Flash Platform. Zorn is built on Eclipse and I think will help make Flash more approachable for developers. I’ve got to say that as I typed that last sentence, I almost had to laugh. Developers, especially really good ones, are usually the type of people who don’t need things to be made more approachable – their whole reason for being is to figure out the hard stuff! Yet it’s amazing how many great developers I’ve met who can’t figure out how to do anything in Flash and just give up. The problem is that the Flash model, while very intuitive for animators and designers, is just completely foreign to experienced developers. Timelines? Movieclips? Layers with code? Huh? I’ll be talking more about how we will address these issues in the months ahead. Read more of this post