Q. How do I redirect my domain name using a php server side scripting under Apache web server?

A. Under PHP you need to use header() to send a raw HTTP header.

If you want to redirect a domain to some other URL, you can use the PHP script as below

<?php
header("Location: http://example.com/");
exit();
?>

See PHP Redirect To Another URL / Page Script FAQ for further information.

source here

HTML:Iframe-inf removal Instruction   February 8th, 2010

If your blog has been infected by the HTML:Iframe-inf  infection according to avast here are two scripts that can help you.

First What is the HTML:Iframe infection? – Its just a line of text that is inserted at the end of every index.php and/or index.htm in your website. Nothing to freak out about but you want to fix it. And Its probably due to wordpress not being secure.

Anyways, here is what you do : This is something you run on the commmand line – See the video below for an idea.

You will need to find infected files first.

find / -type f | xargs grep -l '<iframe'  2>/dev/null

or you could print out a list of files possibly comprimised. 

by typing 

find / -type f | xargs grep -l '<iframe'  2>/dev/null >infectedFileslist.txt

The first step is figuring out what is going on with your virus infection.

If you know the time frame of when the virus ran then you could narrow the list of infected files even more by tweaking the find command.

Lets say you know it infected your website about 5 days ago.

Then you would modify the find command to search all files modified less than 10 days ago.

find / -type f -mtime -10 | xargs grep -l '<iframe'  2>/dev/null >infectedFileslist.txt

More info on the find command here

http://content.hccfl.edu/pollock/Unix/FindCmd.htm 
my short version
find . -mtime +5 -mtime -10 # find files modifed between 5 and 10 days ago

Ok so now you have a list of infected files ...
This is VERY HELPFUL as you are halfway there to cleaning up your server.

Remove infected text till here source

to find all infected files use this php script, upload it to your root domain and name it clean.

http://www.yourname.com/clean.php?c=iframe

This script will show you all files containing the iframe tag, but to remember it is an html tag and is used mostly in webpages.

My site has been injected with these tags.

The above first one was injected into PHP while the second to htm and html.

I also used this script to remove it from each and every webpages extensions.

I used these commands

  1. find . -name ‘*.php’ | xargs perl -pi -e ‘s/echo “<iframe.*<\/iframe>”;//g’
  2. find . -name ‘*.htm’ | xargs perl -pi -e ‘s/<iframe.*<\/iframe>//g’
  3. find . -name ‘*.html’ | xargs perl -pi -e ‘s/<iframe.*<\/iframe>//g’
  4. find . -name ‘*.css’ | xargs perl -pi -e ‘s/<iframe.*<\/iframe>//g’
  5. find . -name ‘*.js’ | xargs perl -pi -e ‘s/<iframe.*<\/iframe>//g’

After running it check ur webpages one by one and teh virus tags would be removed.

Thanks to SWK and AUK.

PHP: Upload Files to the Server   June 20th, 2009

With PHP, it is simple to upload any file to your server.

uploader.php

$target_path = “uploads/”;

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo “The file “. basename( $_FILES['uploadedfile']['name']). ” has been uploaded”;
} else{
echo “There was an error uploading the file, please try again!”;
}?>

The form used to apply this uploading:

Upload File:

I suggest implementing a password (php) protection on this page to ensure noone other than the administrator can upload files. Missuse of uploading can surpass a server’s space and cause fines or bans of site owners. So be careful.

courtesy http://www.tech-recipes.com/rx/3112/php-upload-files-to-the-server-2/

Hardcoding the year in a copyright notice is an easy way to get a blog or other website started, just placing the starting and ending years next to the copyright symbol. We have the very best of intentions to change this number right after the big ball drops in Times Square each year. We’re also human and, all too often, I see websites with copyright notices that are years behind. If your website is PHP-powered, this quick bit of code will put the current year in your copyright notice and off of your mind.

To change your copyright notice, or anything else you’d like that should display the current year, you must first find the script in which the copyright display is generated. If you are using a WordPress blog, for example, this is likely in your footer.php file in the directory of the theme you are using. If you aren’t sure which file holds this, you could try searching for the text © in all of the scripts that make up your website. This is the code that generates the copyright logo and should lead you directly to the file(s) involved.

Once you’ve found this, there are two possibilities for including the year information depending on how the script is setup. It is possible that the script is sending the line including the copyright information from an ‘echo’ command in PHP, something like:

echo ‘© 1812–2006 Olde Time Blogs’;

In this case you need to modify this PHP echo command so that it calls the PHP date command. Note that the command could also work with double quotes instead of single quotes, just be sure to keep using the same kind.

echo ‘© 1812–’.echo date(‘Y’).’ Olde Time Blogs’;

In PHP, the period symbol is used to stitch together strings, so the command above makes one string out of three.

The other possibility is that the PHP script is formatted as HTML content with separate PHP instructions enclosed by opening/closing PHP tags. This is more proper and common in applications like WordPress. In this case, inserting a dynamic, ever-correct year is a matter of changing:

© 1812–2006 Olde Time Blogs

to

© 1812– Olde Time Blogs

courtesy http://www.tech-recipes.com/rx/2815/php_print_the_current_year_for_copyright_notices/

Cookies may be created with an expiration time. It may become necessary to expire a cookie before the expiration time such as when a user logs out of a cookie-based authentication web application. This recipe describes expiring a cookie.

Expiring a cookie uses the same command as creating a cookie. The cookie value is left blank and the expiration time needs to be in the past. To expire the cookie ‘user’ use:

setcookie(‘user’,”,1);

The second parameter is the cookie value and is set to blank with the double quotes. The third parameter is the expiration time. A value of zero here indicates that the cookie is to remain valid until the browser is closed. A positive value indicates the time at which the cookie is to expire. Many sources indicate using something like

setcookie(‘user’,”,time()-3600)

which sets the expiration time 3600 seconds (1 hour) in the past. The trick is that this references the time on the server while the cookie expiration is dependent on the time of the host running the browser. If there is a mismatch of time between the two hosts, it is possible that it a cookie may not expire. However, using a time of ‘1′ indicates an expiration time of 1 second after midnight, January 1st, 1970 which is the earliest possible expiration time.

courtesy http://www.tech-recipes.com/rx/1501/php_delete_or_expire_a_browser_cookie/