The first type of code: less Code
Through regular expression to obtain the real address of the Baidu network disk file, to achieve the effect of straight chain
Save the following code as downbd.php
Copy CodeThe code is as follows:
$canshu =$_server["Query_string"];
if ($canshu = = "")
{
Die ("file does not exist");
}
Else
{
$wangzhi = "Http://pan.baidu.com/share/link?". $canshu;
$file =file_get_contents ($wangzhi);
$pattern = '/a>/i ';
Preg_match_all ($pattern, $file, $result);
$tempurl =implode ("", $result [1]);
$FILEURLT =str_replace ("\" "," ", $tempurl);
$fileurl =str_replace ("&", "&", $FILEURLT);
Header ("Location: $fileurl");
}
?>
Call Method:
http://***/downbd.php?shareid=00000&uk=00000
Basically, the format of shareid=00000&uk=00000.
The second type:
Do a little function and prepare to share the pictures in your blog.
Look at the code! Code Save As Bdp.php
Copy CodeThe code is as follows:
Require_once (' snoopy.class.php ');
http://www.abc.com/bdp.php?shareid=29160&uk=2855065916
$url = ' http://pan.baidu.com/share/link?shareid= '. $_get[' Shareid '. ' &uk= '. $_get[' UK '];
$snoopy = new Snoopy ();
$snoopy-read_timeout = 0;
$snoopy, Fetch ($URL);
$n = results, $snoopy;
$regex = '/(_.src= ") (. +) (";)/";
$match = ";
Preg_match ($regex, $n, $match);
if (Preg_match ('/.gif/', $match [2])) {
Header ("Content-type:image/gif");
Imagegif (Imagecreatefromgif ($match [2]);
}elseif (Preg_match ('/.jpg/', $match [2])) {
Header ("Content-type:image/jpeg");
Imagejpeg (Imagecreatefromjpeg ($match [2]);
}elseif (Preg_match ('/.png/', $match [2])) {
Header ("Content-type:image/png");
Imagepng (Imagecreatefrompng ($match [2]);
}elseif (Preg_match ('/.wbmp/', $match [2])) {
Header ("Content-type:image/vnd.wap.wbmp");
Imagewbmp (Imagecreatefromwbmp ($match [2]);
}else{}
?>
Snoopy.class.php is a PHP class that mimics the functionality of a Web browser, which accomplishes the task of getting web content and sending forms. This file can be Baidu a bit. The above file requires a space that supports PHP. Baidu Web disk upload pictures and share, get share address after the shareid=29160&uk=2855065916 parameters.
Use http://Your domain name/bdp.php?shareid=29160&uk=2855065916 to get pictures, this address can be placed in the CKEditor image address to use. Other editors should also be able.
Direct use in Web pages
http://www.bkjia.com/PHPjc/326163.html www.bkjia.com true http://www.bkjia.com/PHPjc/326163.html techarticle The first kind of code: less code through regular expression to obtain the real address of the Baidu network disk file, to achieve the effect of the straight chain to save the following code as downbd.php copy code code such as ...