*/
$dir = '/www.111cn.net ';
if (Strstr ($src, "http://") &&!strstr ($src, $_server[' Http_host ')) {
$SRC = getimg ($SRC);
}
function getimg ($l 1) {
$l 2 = $dir. substr (MD5 ($l 1), 10,10). STRRCHR ($l 1, ".");
File exists, return address directly
if (File_exists ($l 2)) {
echo "Exits ...";
return $l 2;
}
Start getting the file and return to the new path
$img = file_get_contents ($l 1);
if ($img) {
if (!is_dir ($dir)) {
@mkdir ($dir);
}
SaveFile ($l 2, $img);
echo "File_get";
return $l 2;
}
}
Save file (file, [content])
function SaveFile ($l 1, $l 2 = ') {
if (function_exists (file_put_contents)) {
File_put_contents ($l 1, $l 2);
} else{
$fp = @fopen ($l 1, ' WB ');
@fwrite ($FP, $l 2);
Fclose ($FP);
}
}
/*
The STRRCHR () function finds the last occurrence of a string in another string and returns all characters from that position to the end of the string
The Strstr () function searches for a string that appears for the first time in another string. The function returns the remainder of the string (from a match point). returns false if the searched string is not found.
File_exists determines whether the file exists, is returned ture or 1 does not return FALSE or 0
The file_get_contents () function reads the entire file into a string.
mkdir Create directory, success Ture no false
The file_put_contents () function writes a string to the file and calls fopen (), fwrite (), and fclose () in turn.
This procedure is the home page to determine whether we read the address is the network or local, if the picture address of the server is not processed otherwise the remote server pictures or files downloaded to the local server.
*/
This article original in www.111cn.net reprint to indicate the origin