MAY 2ND, 2013
By MOHAMMAD SAJJAD HOSSAIN
My WordPress plugin WP Reroute Email has been approved and I have released the first version of it.
This plugin intercepts all outgoing emails from a WordPress site, sent using the wp_mail() function, and reroutes them to a predefined configurable email address. This is useful in case where you do not want email sent from a WordPress site to reach the users. For an example, to resolve an issue you downloaded production database to your development site and you want no email is sent to production users when testing. You may enable this plugin in development server and reroute emails to your given email address.
AUGUST 18TH, 2010
By MOHAMMAD SAJJAD HOSSAIN

In one of my previous
post I have shown how we can use both secure and non-secure URLs. Now I am going to show how we can do this, extending native libraries.
What we are going to do…
We will create secure version of some functions. For this we will create a helper file ‘my_url_helper.php’ and save it in ‘system/application/helpers’. We will be creating secure version of following functions:
- site_url()
- base_url()
- anchor()
- redirect()
Lets’ start…
First we will add the following config element in the config file:
$config['secure_base_url'] = 'https://example.com'; |
Then, open the my_url_helper.php file (system/application/helpers/my_url_helper.php) and add the following codes.
if( ! function_exists('secure_site_url') )
{
function secure_site_url($uri = '')
{
$CI =& get_instance();
return $CI->config->secure_site_url($uri);
}
}
if( ! function_exists('secure_base_url') )
{
function secure_base_url()
{
$CI =& get_instance();
return $CI->config->slash_item('secure_base_url');
}
}
if ( ! function_exists('secure_anchor'))
{
function secure_anchor($uri = '', $title = '', $attributes = '')
{
$title = (string) $title;
if ( ! is_array($uri))
{
$secure_site_url = ( ! preg_match('!^\w+://! i', $uri)) ? secure_site_url($uri) : $uri;
}
else
{
$secure_site_url = secure_site_url($uri);
}
if ($title == '')
{
$title = $secure_site_url;
}
if ($attributes != '')
{
$attributes = _parse_attributes($attributes);
}
return '<a href="'.$secure_site_url.'" ' . $attributes . '>'.$title.'</a>';
}
}
if ( ! function_exists('secure_redirect'))
{
function secure_redirect($uri = '', $method = 'location', $http_response_code = 302)
{
switch($method)
{
case 'refresh' : header("Refresh:0;url=".secure_site_url($uri));
break;
default : header("Location: ".secure_site_url($uri), TRUE, $http_response_code);
break;
}
exit;
}
} |
Now, I will extend the Config library (system/libraries/Config.php). I assume that the sub class prefix is set as ‘MY_’ in config file (system/application/config/config.php). Create a file ‘MY_Config.php’ in ‘system/application/libraries’ folder and save the file with following code.
class MY_Config extends CI_Config
{
function MY_Config()
{
parent::CI_Config();
}
function secure_site_url($uri = '')
{
if (is_array($uri))
{
$uri = implode('/', $uri);
}
if ($uri == '')
{
return $this->slash_item('secure_base_url').$this->item('index_page');
}
else
{
$suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix');
return $this->slash_item('secure_base_url').$this->slash_item('index_page').preg_replace("|^/*(.+?)/*$|", "\\1", $uri).$suffix;
}
}
} |
Now what we have…
Now we have secured versions of those function. You may now use them as their insecured version. Enjoy coding

.
MARCH 10TH, 2010
By MOHAMMAD SAJJAD HOSSAIN
A few days back one of my project’s domain changed. The nature of this project was such that it provides URLs to it’s subscribers to use in their site for different purposes. As it has a huge user base, it was quite impossible to change the URLs already provided to the subscribers. That’s why I searched for a solution which will redirect the subscribers to new domain. I knew HTACCESS files can provide this type of service. So, I searched web for a solution to this problem – 301 redirection with HTACCESS file. Then I found the following solution. Before I provide the solution, I just want to say I am not an expert of HTACCESS
.
I have created .htaccess file with the following line to redirect any request to http://www.oldurl.com/ to https://www.newurl.com/.
redirect 301 / https://www.newurl.com/ |
The line stated above tells Apache server to redirect all request to http://www.oldurl.com/ will be redirected to https://www.newurl.com/using 301 permanent redirection. It worked fine.
After implementing the solution I faced another problem. The line of code was redirecting to only HTTPS irrespective of the request made to HTTP or HTTPS. This caused a problem for the pages which were non-secured, I mean shown via HTTP. These pages contain elements like CSS, JavaScript files, images etc. which are linked as HTTP. So, browsers started generating security warnings. Again I took help of Google and searched for a solution. After studying different problems I wrote the following lines of code in the .htaccess file and it worked.
RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ https://www.newurl.com/$1 [L,R=301]
RewriteCond %{HTTPS} !^443
RewriteRule ^(.*)$ http://www.newurl.com/$1 [L,R=301] |
The above code does a conditional redirection. If the request is made to HTTP then it redirects to HTTP and the same is for HTTPS.
FYI, my project is built with CodeIgniter and the redirection worked fine with it.
JANUARY 18TH, 2010
By MOHAMMAD SAJJAD HOSSAIN
JULY 5TH, 2009
By MOHAMMAD SAJJAD HOSSAIN
Yesterday was my holiday. I thought that I will go for a movie. I heard Pink Panther 2 has been released in Dhaka. I went to Star Cineplex at Bashundhara City mall to get the timing. I haven’t gone there (Cineplex) before. I reached at 4:30pm and saw that a show was going to start at 5:15pm. Without thinking much I bought a ticket and went in to the hall. I found Star Cineplex is a very nice place to watch movie.
I enjoyed this movie very much. It was full of comedy. And the actors done a great job. From first to last I laughed. Though I found thrill not that much and the ending could be better, but I enjoyed comedy. I have seen many people went to see this movie may be for Aishwarya Rai as she was more focus on the posters at Cineplex. She looked aged, but acted as usual. Steve Martin’s acting is remarkable.
I think you should go and watch this movie. Laughter is the best medicine, and this type of films supplies this medicine
.
JUNE 22ND, 2009
By MOHAMMAD SAJJAD HOSSAIN
Yesterday, June 21 2009, I had to give a presentation on payment gateway integration at our office. That’s why I prepared a slide show. I mainly tried to show how PayPal’s Direct Payment API calls are made. I have choosen this because this technique is also used by other payment gateways. As I have shown the example based on PayPal, I called this session – “Integration of Payment Gateways, The PayPal Way“. It gives a basic idea how we can make API calls for payment processing. I have quoted some texts and images from PayPal’s integration documents.

You can download the presentation from here. For PDF version, click here.