Yii framework case insensitive URLs

This is really a quick tip, So sometimes we may want to treat our urls in case sensitive way, this applies to when you are hosting on Linux, and sometimes you want them to be treated the same regardless of the case   So what you need to do is to open your main.config file and look for urlManager component. by default this component is commented as shown below   Now just after urlFormat item add another array item as shown below Important bit above is introduction to caseSensitive setting above and setting its value to false. By default its true   I hope this helps Cheers … [Read more...]

Yii framework hide index.php

Hi Guys, So after a long time I had to setup another Yii based site. Yes and I found myself in same old unfamiliar Yii setup territory :) Even though it all good when you end up setting it up but there are few things that I need to remember and hiding index.php is something that was on top of the agenda. So set this up create a .htaccess file in directory where your index.php file is and enter the following Above means that if file or directory do not exists then redirect all requests to index.php As you notice that we are using RewriteEngine directive thus it becomes important that you have this line uncommented #LoadModule rewrite_module modules/mod_rewrite.so in you httpd.conf file. Before you restart your apache server make sure that your project directory settings has AllowOveride All directive set as shown below   Restart your apache server. Well if you still don't see anything happening then goto your config file under webroot/protectect/config/main.config and uncomment urlManager component it should look like this   I hope this helps. I am pretty sure that I will come back to my post again in few weeks time :) Cheers. … [Read more...]

Linux Writing multiple lines to a file from command line

Hi Guys, We learn something new everyday. I did too. I know I am a late learner but its better late than never.   I asked myself a question about how to write multiple lines using say echo to a file. I generally will open my vi editor and and write something there and then save my file. and when I am using echo I never really had that situation where I need to write multiple lines to a file. But things changed :) Normally I will do something like this   Above will write word hello to file named test.txt in your current directory     Let me show you how to write multiple lines Trick is when you start you echo command follow it with " (double quotes) and don't close them until you are finished with your sentense as shown below Above will write "Sit lectus dis placerat non aenean ultrices. Tempor, amet nisi in arcu, amet turpis, cras mattis ultrices, enim, penatibus. "  to your test.txt file. I hope this helps Cheers     … [Read more...]

.htaccess redirect all traffic to maintenance page except my IP address

Hi Guys,   This is a follow up to my previous post. I had to switch one of my website off for general public viewing while I was doing some maintenance work. There are many reasons why you would like to do redirect all website visitors to your maintenance page. Few question that you may ask yourself are Do I want my site visitors to see 404, 403 (depending what you do), while I do my maintenance work Do I wish to update my users about how long still they will need to wait before they can order or get help from my website. Do I want them to feed them useful links from maintenance so that they can view your mirrored website etc etc For any of the above questions if you answered Yes to one of them read below else you can play another game of iBasket on your iPhone :)   Ok So here is the deal Lets first redirect all traffic to your maintenance page Open your .htaccess file and paste the following   In the above snippet just chage YOUR_MAINTENANCE_PAGE to a fitting name e.g. index_down.html or index_maintenance.html etc Let me try to explain above rule. Above rule says redirect all URLs that does not end with /YOUR_MAINTENANCE_PAGE.html to YOUR_MAINTENANCE_PAGE.html That's Ok if you are just uploading a couple of updates and but what if you are going to change your cart and you need some testing of you new stuff. You guessed it right, we will allow your IP normal access to the website. So change the above rule to this Make required changes IP address Maintenance file name to above Upload or save your .htaccess file and try to access you website from your home and office. Depending on which IP is allowed will see your website as per normal and other will be redirected to your maintenance page Pre-requites: You will need mod_rewrite module enabled in your apache web server for the above to work. So uncomment mod_rewrite line in your apache config, restart the … [Read more...]

.htaccess Block all IP but mine to access my website

Hi Guys, Well I am writing this one because I thought I did this stuff today so why not share :) Well sometimes when you are testing your application online, I mean your website you really don't want general public to get access to your website which is still under construction. Your use case scenario may differ but here is something that you can do really quick and easy using .htaccess file that is really a handy file and generally exists in your website root directory. You can do the same stuff that I am going to show you in actually httpd.conf or apache.conf files too. But lets see what needs to be done in case to achieve the above   Simple enough, so we have set a rule for the current website that anyone other than YOUR _IP_ADDRESS should be denied access to your website. Remember to change YOUR_IP_ADDRESS to your own IP address such as 123.234.345.456 In other scenarios if you work from home and office then you will want to add more IP address to be able to access you website. Here is what you can do Simple so yeah you add more "allow from" lines to your .htaccess file. If you don't already have .htaccess file you will have to create one something like this   assuming that your website root is /var/www/html In windows you can use your text editor to create one and then upload it to your website root directory. I hope this helps you Cheers … [Read more...]

ExtJS 4 php get request payload

Hi Guys, I am pretty sure that you will know this one but in case you don't then this post might help you. This post is not about how to create a ExtJS grid. Please follow Extjs 4's documentation for that. This post is about data handling at server side. While using data writers such as JSON common when you use Ext JS Grid, when you try to update, create a row or cell the data is posted to your PHP script as RAW POST. Ok may be I am not making any sense at this stage so consider a Grid such as  shown below     And when I try to change Unit price above as shown below It will create a request such as shown below   Now the Request payload data is not directly available to you as such in $_POST. Instead its a raw post which you can read at server side as shown below If I use print_r() on my $rawpostdata I get this In the above code this is main part $rawpostdata = file_get_contents("php://input");   You can also set always_populate_raw_post_data =truein your php.ini file so that the raw post is available to you in global var $HTTP_RAW_POST_DATA. When using file_get_contents("php://input"); you will need to take care because it does not support enctype="multipart/form-data" I hope this helps Cheers … [Read more...]

Setting up your own OpenStreetMap Server

Hi Guys, I will try to keep it simple and straight forward. Most of the content has been taken from openstreetmap.org's wiki. I end up configuring it last night so it is still fresh in my brain. Alright first things first If you are thinking for running a OSM server on a machine that has 4GB RAM and Intel Core Dual Core Processor then forget about it. You will need really good hardware to run your OSM server. I recommend at least 24 GB RAM and a Xeon quad core processor (Dual) with probably super fast iSCSI drives or good SSD. To import full planet OSM data you will need more than 600GB of free Hard disk space. It can take up to 10+ days depending on your Hardware to import and Index everything planel.osm has to offer. I will be using Ubuntu Desktop version 11.10 64 bit. for this example. So prepare your new machine with basic Ubuntu Desktop version 11.10 64 bit. install. No need to install anything else. You can choose to download updates for the OS. After you can login to your newly laid Ubuntu Desktop. Do the Following Download latest planet.osm data or you can try to search for extracts for your Country if you don't want to import full size planet data. I will be using Australia.osm. Thanks to Matt who is running this really helpful website http://www.osmaustralia.org (optional) Extract the bz2 file to an accessible location on your Hard drive. So now we have good Hardware and we've got the required OSM data files its time to get our hands dirty. Open your Ubuntu Terminal * TIP nearly all command will require to be run as Super User i.e. administrator. I will be working in this directory /home/osm. You can will need to choose your own whenever possible. Lets set up the environment first. As a prerequisites we need to install following packages GCC compiler PostgreSQL Proj4 GEOS PostGIS PHP PHP-pgsql PEAR::DB Lets install DB package  Now that we've got postgreSQL installed we will tune … [Read more...]

NuSphere phpEd code completion can’t find my classes

Hi Guys, I had this problem with phpEd when I upgraded from version 6 to version 7. After I reloaded my projects Some of the classes went missing from the code completion As a first step in troubleshooting this I thought maybe this has something to do with restarting the machine after my upgrade. I did that but the problem was still there. So I thought what could be wrong. I had similar situation before too and I fixed it before and couldn't remember how I did it then. Scratched my head and yes I remembered and was able to solve this problem Here are the steps you will need to follow.   Right Click on Code Explorer window and Click Refresh from the Context Menu. Step 1 should initiate a re-scan of you project files and the code completion cache will be re-built. If that doesn't work then start afresh. See Step 4. Check where your project's .PPX file is. e.g. If your project name is fooproj.ppj then your .PPX file name should be fooproj.ppx. Close your IDE. Delete .ppx file Re-open the project.   Also you can try this Goto Project > Project settings, You will see a window with following tabs Click on the includes tab At the bottom right corner, Click refresh. Wait for few seconds to minutes, depending on your project size. Once it finishes try to use auto complete feature now. With me this works 95/100 times because it rebuild include file cache. Make sure that you have "Limit scope to Includes" unchecked if you want scope to be project specific. Now because the IDE will re-scan your project files again thus your completion cache will be rebuilt. I hope this helps Cheers!         … [Read more...]

play .flv file

Hi Guys, So I did some research on this. Research means Googling :) and I thought why my Media Player wont play FLV files. Obvious answer is that FLV format is not support by media player. Where to next. I was glad to find out that a Free player called VLC player can play that for me Here is the features page for VLC player. http://www.videolan.org/vlc/features.html You can download it here http://www.videolan.org/vlc/ Now the reason. FLV is a proprietary media format for video content delivery over the internet. Video stream included in the FLV file can be a variant of H.263 standard or the other advanced VP6 codec. As an example youtube uses H.263 which is referred to as FLV1 and FLV4. Thus you can upload and view both types of formats to/from YouTube. Now because FLV needs a codec to run thus it by default wont play on any player which does not support FLV file format. Thus VLC becomes a really good choice because of all the file format support it have out of the box. So download it.   However you can also fix your windows media player too by installing codec files. You can look up for FFDShow Video decoder which can be found here http://www.free-codecs.com/download/ffdshow.htm If you want to go directly to the download page then this is the link http://www.free-codecs.com/ffdshow_download.htm At the end I was able to play my FLV file :) I hope this helps Cheers.     … [Read more...]

iStockPhoto promo code

Hi Guys, Read further if you want to save on iStockPhoto credits. There are a few iStockPhoto.com promo code that you can use to save. 10% discount 15% discount   10 FREE credits Expired Get upto 20% Off with purchases over $25 New Members Expired Use the code below to get 15% off after joining for your purchase of 50 credits or more Expired Please let me know if any of the above does not work for you so that I can get rid of them. iStock history In year 2000, Bruce Livingstone was on the edge of going into traditional stock click photography business, but he had big problems marketing against established competitors. Well at the start he had many Compact disks full of heaps of Photos that were ready to be sold. But a thought came up in his mind that the old method of distributing images may not work now in the age of internet. So he decided to put all his click online for FREE to see how prospective customers react to that. The name he came up with was called iStock . So the interest was shown by heaps of webdesigners and they just loved the concept and they downloaded as many pics as they could. Now with this came the twist. These designer who has cameras with them also started to upload images that they clicked. Now the monthly bandwidth Bill went out of the roof and then bruce polled the growing stock community if people would support paying for images. Then in year 2002 they started selling credits from their website. A royalty free license for an image was under dollar 1 and the contributor got a share from it. Big names in the business became interested in this and the contributors start sending illustration, videos, sound effects and many more digital media. They never saw back and are one of the big name in stock photography. iStockphoto do their business based on what they call Credits when you use any of the codes above your final savings will be in dollars but put it in this way … [Read more...]