Know Whether the url was Rewrittern or Not

A simple function to detect if the current page address was rewritten by mod_rewrite:

<?php
function urlWasRewritten() {
$realScriptName=$_SERVER['SCRIPT_NAME'];
$virtualScriptName=reset(explode("?", $_SERVER['REQUEST_URI']));
return !($realScriptName==$virtualScriptName);
}
?>

Now, How to use this function?
Here is the code for that

<?php
if(urlWasRewritten())
echo 'Url Rewritten !';
else
echo 'Url Not Rewritten !';
?>

Get old gmail from new gmail

A few days ago Gmail changed its theme and provided its user’s the new look.
But a lot of people complaining me about this. So i found out the way to get the old gmail back.
Well, I founded the way the same day I moved to new gmail from old one (as i disliked it) but doesn’t thought that many peoples will dislike it.
So this are steps to get back to your lovely old gmail.

1. Go to mail home page
2. Click on the setting button (located near to paging above all displayed mails)

Revert to old google

Setting button

3. A drop-down will open
4. select Revert to old look temporarily, click on it.
5. You will be asked for confirmation using an dialog box

Confirmation

Revert to old gmail confirmation

6. select Revert to old gmail temporarily
The page will be refreshed and you will be with your old gmail.

Send Files via FTP using php

Sending files to a server via FTP is an essential ability of any web developer or designer. Of course, we all use glossy FTP clients like WS_FTP and FireFTP, but what about FTP automation? You can use PHP to FTP files from one server to another. Let me show you how

<?php
$server = "server name";
$ftp_user_name = "username";
$ftp_user_pass = "password";
$connection = ftp_connect($server);
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
if (!$connection || !$login) { die('Connection attempt failed!'); }
$upload = ftp_put($connection, $dest, $source, $mode);
if (!$upload) { echo 'FTP upload failed!'; }
ftp_close($connection);
?>

Obviously, the first task is to connect to the other server. Once the connection is created, you pass the login credentials. Once you’re logged in, you can use the ftp_put() function to send the file. That’s it!
What would you use this for? Well, you could set up a cron to create a database backup and send it to an offsite server.

Sending mail from myhost/gmail

When I was new to php I was sending mail using php’s basic mail() function, but later I came across phpMailer class, which can be used to send mail using any host of your choice (Gmail, for example).
This is an simple code script needed to send an mail using your host and login details.

<?php
//including phpMailer class
require_once("phpmailer/phpmailer.php");
//creating object for phpMailer class
$mail = new PHPMailer();
IsSMTP();
$mail->SMTPAuth = true;
$mail->From = "Your Email";// example stufflies@domain.com
$mail->FromName = "Your Name";// example Stuff Lies
$mail->Username = "Your Username"; //example stufflies, for gmail username@gmail.com
$mail->Password = "Your Password";//example *******
$mail->Host = "Your Host name"; //example for gmail smtp.gmail.com
$mail->SMTPSecure = "ssl";//ssl/tls
$mail->Port = "Your Host port number";//example for gmail 465
$mail->AddReplyTo("Your Email","Your name");
$mail->AddAddress("Recepient email address","Recepient name");
$mail->IsHTML(true);
$mail->Subject = "Your subject"; //example Stufflies phpMailer
//$mail->AddAttachment("temp file", "filename");//remove comments if attachment required
$mail->Body = "Your message"; //example Testing message from stufflies.wordpress.com
if($mail->send())
{ echo "Mail sent"; }
else { echo "Sending failed"; }
?>

The code uses phpMailer class which can be downloaded from phpMailer Download.

Although every effort is made to make this code simple , yet if any issue arise feel free to comment or contact me.