First code: Less code
Through regular expression to get the real address of Baidu Network disk, to achieve the effect of direct chain
Save the following code as downbd.php
Copy Code code as follows:
<?php
$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><a class= ' dbtn cancel Singledbtn ' href= (. *?) Id= "Downfilebuttom" >/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
Mainly the shareid=00000&uk=00000 format.
The second type:
Made a small feature, ready to share the pictures in the blog.
Look at the code! Code saved as bdp.php
Copy Code code as follows:
<?php
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 = $snoopy-> results;
$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 completes the task of getting web content and sending forms. This file can be Baidu. The above file requires a space to support PHP. Baidu Network disk upload pictures and share, get the 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 used in CKEditor image address. Other editors should also be available.
Web page directly Use