Posts

Installing mod_geoip2 Apache module

Image
Actually this is not a post on PHP but yeah Many times you happen to come across a situation where you need to compile and install Apache modules while writing PHP applications. This is one of my condition I came along. Here I am working for a multinational company which sells it products all over the world and they've this pretty nice thing to set-up in their website . They redirect their users to their countries own domain. For example google.com will be redirected to google.com.au if the visitors geographical location is australia. So, for such a case, we are going to use MaxMind's API. So before we could do that we need to install an Apache module. This post is basically on the installation of this modules. Well I am on fedora 18 for now while I am writing this post and doing the installation. First thing I believe is you definitely have been to this page http://dev.maxmind.com/geoip/mod_geoip2 . Here's all the stuffs described. Okey so lets download the files: First fi...

Export to csv : CI Helper File

Image
This is another helper file by Jérôme Jaglale. I used this helper file to export my data into csv files in a codeigniter project: Registraion System . Its preety good and easy than to export to .xls file. CSV files are good if you are more flexible to use. You might like to use it. To know more about csv file please visit the click here . The helper file is embeded as follows:

Random String Generator : CI Helper File

Image
Now, I have this small helper file that I used in a project I was working on using codeigniter where I generated random strings which were used as activation code of users. The helper file is embeded as follows: Using this is very easy just copy the code in a file rand_helper.php and put it in helpers directory and load the helper file using $this->load->helper('rand_helper') and call the function generateRandomString()or with length of string to be generated generateRandomString(15). THe default length of string is 10. Its documented in the helper file too. If you need to modify it, please go ahead. :)

Numbers to Words conversion library for codeigniter

Image
If you are writing an application that deals with financial stuffs, then most probably you will come to a situation where you would have to convert numerical values to words e.g. to write the amounts in words. And if the situation has come then you are at the right place, here is a CodeIgniter library that will help you with what you are really in need of. This library can be used in your CodeIgniter project. And the usage is very simple. Just import the library and call the function as follows: <?php $a=$this->load->library('numbertowords'); $number=1234567890; echo $this->numbertowords->convert_number($number); ?>  Not only this, you can also use the following javascript library: To use this javascript library, all you need to do is select all the code and save it in a file numbertoword.js and use it as follows: //Import the javascript file: <script src="numbertoword.js"></script> //Call the function toWords(number) passing a number ...

Finding page id of Facebook fan-page

Image
Sometimes you come to a situation when you need the page id of the Facebook fan page. This happens usually when you are writing Facebook application that needs to use the Facebook fan-pages. If you have been to the situation then here's you solution. It just a few lines of code which is as follows: This simple program echoes your Facebook fan-page when "http://www.facebook.com/nosklub" is replaced with the url of your Facebook Fan-page. No rocket science right?  :) And yeah one more thing to add, this not only just gives you the id of your fanpage, it also returns the facebook id of the user, supplied the persons facebook url e.g. http://www.facebook.com/opnchaudhary

How to update facebook status using php?

Image
In this post, I'll be showing you how, you can write a php application to update your  Facebook  status. Before we start writing the application. Lets get prepared for it. Download the php sdk of  Facebook  from the link: https://github.com/facebook/facebook-php-sdk . Download the zip file and extract it. We need the src folder content in it, place it in the root directory of the application. i.e.  we have a directory fbapp created in which the src directory will be placed. Now we have the sdk, lets create a facebook application. To create a  Facebook app, you need to be logged into https://developers.facebook.com/apps . If not login now. And create an app. For this example, I am creating an app called Test . And our fbapp directory is in test.com domain. So our application is accessible from http://test.com/fbapp . So lets add test.com to our website with  Facebook  application from the applications settings that you will have after cr...

Multiple File upload library for codeigniter

Image
Actually this is not my code, but I find this so useful that I couldn't just stop myself to share this. This is a library for codeigniter framework. It is a very good library for multiple file uploads. The code can be accessed from:  https://gist.github.com/4594439  . It has a pretty nice documentation. So, I think it won't be needed to write more about it here in this post.  Here's the gist of the library: