Tuesday, April 29, 2014

Using password_hash function to generate hash

PHP 5.5 and greater versions supports an inbuilt function called password_hash to generate stronger password hashes. It's uses the PHP's password hashing API.

Monday, April 28, 2014

Grabbing image or file from different server to your server

In this post we'll be using cURL php extension to fetch the image directly on our server.

Forcing web browser to download the file using Headers

Sometime it requires you to force the browser to download the file instead of opening it in the brower. For example to force the browser to download the PDF or image file instead of opening it. To achieve that we'll be using header function.

Sunday, April 27, 2014

Measuring your website loading time using PHP

To make a speed efficient application it's important to know how much time it takes to load, if you know that then you can try some other tricks to reduce the time. Measuring the page loading time helps a lot.
In this post we'll see how to use microtime function to get the website loading time.

Hiding .PHP extension with .htaccess

Yes! it's possible to hide the .php extension from your URLs using .htaccess file. You can do many more things with .htaccess file!

Saturday, April 26, 2014

A simple feed reading class in PHP

By using this class you can read RSS feed. It supports both RSS version 1.0 and also supports RSS version 2.0

Friday, April 25, 2014

How to detect Ajax requests in PHP

This is what we mostly don't do, many times when we built an Ajax application we won't validate whether the request which the PHP file is receiving is an Ajax request. Because of this many times attackers can easily attack. That's why it's very important to detect whether the request is an Ajax request or not.

Wednesday, April 23, 2014

A simple file wrapper class in PHP

This is a simple file wrapper class which helps to write, read, delete files.

Exploring PREG functions in PHP

Regular expression or Regex which is a must thing in a perfect validation system. Regex not only help us to validate but it also help us to match and replace or split or filter the content. In this post we'll be exploring PHP inbuilt PREG function.

Tuesday, April 22, 2014

Creating a file validating function in PHP

Before allowing a user to upload a file on your server it's very important to first validate it and check whether the file which the user trying to upload is not a harmful file. In this post we'll be creating two functions, one which will get the file extension and second one to validate it.

Getting user informations using IP Address

Getting user informations like Geo location, city, region, country etc are very easy. In this post we'll be utilizing ipinfo.io web API to get the user information from the IP Address.

Building a simple content fetching function

The function which we will build will help us to fetch content from URL using cURL or using file_get_contents. The function just require two parameters in which the second one is optional. The first parameter should be the URL of which we want to fetch content.

Monday, April 21, 2014

Exiting out of a iframe using Javascript

In this i'll be sharing a simple trick which is used to check whether your website is loaded inside an iframe. If it's loaded inside an iframe then it will redirect the user to the original link.

The best way to validate email address

Email validation is very important to protect your website from fake registered email addresses. In this post i'm sharing a function which i always use to validate email address.