Hi guys!
With this script you can make a permanent 302 redirection with php headers. This is very usefull when you want to make that google think that your domain.com is the same that www.domain.com.
Here the script:
if ($_SERVER[”HTTP_HOST”] == “www.domain.com”)
-
{
-
Header( "HTTP/1.1 301 Moved Permanently" );
-
Header( "Location: http://domain.com".$_SERVER["REQUEST_URI"]);
-
}
It’s very simple, but very usefull.
|
November 10th, 2007
7287pwkr
Hi guys,
With this script you can control the access to your files with a ACL from secures referrers.
Here the code:
//Array with valid referers.
-
$validos = Array
-
(
-
"http://www.domain.com/files.php",
-
"http://www.domain.com/forum.php",
-
"http://www.domain.com/download/file.php"
-
};
-
-
//If is the referer in the array, we open the file
-
if (in_array($_SERVER["HTTP_REFERER"],$validos))
-
{
-
//Open the file
-
$file = $_SERVER["DOCUMENT_ROOT"]."/somefile.rar";
-
//Send the header with the content type of the file
-
header("Content-type: application/x-rar-compressed;");
-
//Send the header with the length of the file
-
header('Content-Length: ' . filesize($file));
-
//Send the header with the name of the file
-
header('Content-Disposition: attachment; filename= somefile.rar');
-
//Put the content in the var
-
readfile($file);
-
}
-
else
-
//we redirect the user to another page.
-
header("Location:http://www.domain.com/notpermision.php");
|
June 16th, 2007
7287pwkr
Hi Guys,
If we need make a backup of a directory, the best options is use tar.
For example, you have a directory called /home/emanuelq/files and you would like to compress this directory,you can type tar command as follows:
-
tar -zcvf backup.tar.gz /home/emanuelq/files
The above command will create an archive called backup.tar.gz in the current directory.
If you want to extract the content of the file you need to run this command.
The above command will be extract the files in the current directory.
|
February 21st, 2007
7287pwkr
Params:$hex: Hexadecimal value
Return:Array with the decimal value for red, gren and blue.
function hexToRgb($hex)
-
{
-
//Delete the # char (if exist)
-
if (0 === strpos($hex, '#')) {
-
$hex = substr($hex, 1);
-
} else if (0 === strpos($hex, '&H')) {
-
$hex = substr($hex, 2);
-
}
-
//get the 3 hex values
-
$cutpoint = ceil(strlen($hex) / 2)-1;
-
$rgb = explode(':', wordwrap($hex, $cutpoint, ':', $cutpoint), 3);
-
-
//Convert to decimal
-
$rgb[0] = (isset($rgb[0]) ? hexdec($rgb[0]) : 0);
-
$rgb[1] = (isset($rgb[1]) ? hexdec($rgb[1]) : 0);
-
$rgb[2] = (isset($rgb[2]) ? hexdec($rgb[2]) : 0);
-
-
return $rgb;
-
}
|
February 16th, 2007
7287pwkr
Params:$s: Original text.
Return:The text without the specials chars
-
function clearChars($s)
-
{
-
//Array with the chars to remplace
-
$remplazos = Array
-
(
-
"[áàâãª]" => "a",
-
"[ÁÀÂÃ]" => "A",
-
"[ÍÌÎ]" => "I",
-
"[íìî]" => "i",
-
"[éèê]" => "e",
-
"[ÉÈÊ]" => "E",
-
"[óòôõº]" => "o",
-
"[ÓÒÔÕ]" => "O",
-
"[úùû]" => "u",
-
"[ÚÙÛ]" => "U",
-
"ç" => "c",
-
"Ç" => "C",
-
"[ñ]" => "n",
-
"[Ñ]" => "N"
-
);
-
foreach($remplazos AS $original => $remplazo)
-
$s = ereg_replace($original,$remplazo,$s);
-
return $s;
-
}
|
October 5th, 2006
7287pwkr