Php Excel reader

PHP, PHP Library No Comments »

The PHP library expands on the great work done in the PHP Excel Reader project on SourceForge. It reads the binary format of XLS files directly and can return values and formats from any cell. I have only played around with it for an hour , but for anyone who is working with php and excel you will find it very useful. Well what are you waiting for Get started now.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon] none

PHPIDS (PHP-Intrusion Detection System)

PHP No Comments »

I came across this about a month ago, It’s a php library that helps you do sanity checks on user input variables

e.g $_POST , $_GET and $_REQUEST .

The library works on defined intrusion patterns which detect a malicious users’ attempts to break your php code and it also allows you to add define your own patterns. This helps to prevent a lot of issues like sql injections, url tempering and others. I have been playing around with it for weeks now and I am impressed with it’s functionality, it’s deninately going to be added into my code base. I would advice that you check it out and see what it can do for you.

Details:
Site     – PHPIDS
Demo     – PHPIDS DEMO
Download – Here

Please remember to read the license before you start using it.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon] none

Php DNS Daemon

PHP No Comments »

I know what you thinking, I had the same thing happen to when I read the title on the original blog. Apparently the concept does work and It seems to get the job done. you can read more on this subject at PhP DNS Daemon . This makes you wonder how far you can push php, I guess sometimes all you need is imagination and the will to see it through.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon] none

Detecting mobile devices on your website

PHP 3 Comments »

The purpose of this post is to introduce the concept of detecting mobile devices on your website using an open source library called wurfl, The library can be deployed using the following programming languages:

  1. 1C++
  2. Dot Net
  3. Java
  4. Perl
  5. Python
  6. PHP
  7. Ruby

I will be using PHP for all the examples on this post, So I hope you have a little understanding of PHP to go through some of the example code.

Requirements for this Exercise:

  • At least 50 mega bytes of storage(for the wurfl files to be generated).

Step 1:This step can be set up in different ways, It all depends on how you want to use wurfl on your project, I personally use it on more than one project. To avoid creating a wurfl installation for all my projects I have had to set up a global wurfl installation on my web server which allows all my projects to use one wurfl instance.

create wurfl global

go to /www and create a folder called /www/global and inside global create another directory called /www/global/wurfl. We need to create one last directory inside our /www/global/wurfl/ directory which we are going to call /www/global/wurfl/data, Before we close this step please make sure that your directory /www/global/wurfl/data is writeable

chmod 0777 /www/global/wurfl/data

NB chmod 0777 is not recommended on a production server and one must be careful when granting write permission to files. For the sake of the demonstration we will ignore this rule though.

Your directory structure should look like this: /www/global/wurfl/data

Step 2:
Go to wurfl download page and get the PHP files and store them inside /www/global/wurfl directory http://wurfl.sourceforge.net/php/index.php
you need to also download the http://wurfl.sourceforge.net/wurfl.xml(7mb) which contains all the information about the different types of phones in the market. This file is updated constantly and you need to update it on your side regularly. This file must be copied to /www/global/wurfl/data/wurfl.xml

Step 3:
After you uncompress the downloaded PHP files you should have these following files available:1.

  1. check_wurfl.php
  2. update_cache.php
  3. wurfl_class.php
  4. wurfl_config.php
  5. wurfl_parser.php
  6. readme.txt

Step 4:

Now lets configure our library by opening /www/global/wurfl/wurfl_config.php
lets change the config file as shown below.

Line 90:
NB: Make path absolute

// Where all data is stored (wurfl.xml, cache file, logs, etc) define(”DATADIR”, ‘/www/global/wurfl/data/’);

Line 93:
// Path and filename of wurfl_parser.php define(”WURFL_PARSER_FILE”, ‘/www/global/wurfl/wurfl_parser.php’);

Line 96:
// Path and filename of wurfl_class.php define(”WURFL_CLASS_FILE”, ‘/www/global/wurfl/wurfl_class.php’);

That will do for now. If you are interested in some of the configuration settings on this file you can consult the documentation for the library.

Step 5:
We now need to run /www/global/wurfl/update_cache.php on the console which will create a folder called /global/wurfl/data/multicache that has a lot of files inside of it.

/usr/bin/php -f /www/global/wurfl/update_cache.php

After you run the command it will create the folder mentioned above and a file called /www/global/wurfl/data/cache.php. This command will take a while to execute depending on your machine but will take between 30 to 60 seconds to execute. My /www/global/wurfl/data directory’s size is now 37 mega bytes.

Step 6:
Lets write a little test code which determines if the device on our site is a mobile device and if so we can then redirect the device to the mobile version of our site.


Just like that we now have a script that can tell us whether the user is using a computer web browser or phone browser. If the phone is picked up by our script $myDevice->brand = nokia will carry the phone brand while $myDevice->model = N70. But Please remember that this method is not 100% accurate and also keeping an updated version of /www/global/wurfl/data/wurfl.xml will increase the accuracy rate.

$wurfl_class->capabilities holds an array of the device’s capabilities e.g.
can the device support gif images?

Please try and explore the documentation for the library and you will find all sorts of features. For the sake of keeping this post small I will not show any more examples but rather encourage you to read up a bit on this beautiful library. I hope you find this post useful and you get to do magical stuff with this library , Feel free to leave a comment.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
Tags: , , ,
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in