仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1510|回复: 20
打印 上一主题 下一主题

[学习教程] PHP编程:百度空间图片防盗链破解法式 - PHP版

[复制链接]
爱飞 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-4 00:10:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
只要实现最基本的功能就可以了 就是可以添加留言 然后可以显示留言,然后加入管理功能百度|法式|防盗链|破解   上传百度的图片没法从内部援用,让很多伴侣伤透了头脑,Verdana同窗开辟出了一个破解法式,可以用一段PHP代码来处理这个成绩.当地清空IE 缓存后测试胜利,因为没有主机,所以没有在 Internet 下面测试,有前提的伴侣可以协助测试一下,感谢!如有乐趣也在此法式基本上持续优化完美

                               
登录/注册后可看大图


以下是PHP源码.

/**
* 百度空间相册图片防盗链破解法式 - PHP版
*
* 利用办法:
*
*


                               
登录/注册后可看大图

*
* @author verdana
* @version 1.0
* @since July 16, 2006
*/
Class Frivoller
{
/**
* The HTTP Version (1.0, 1.1) , Baidu use version 1.1
*
* @var string
*/
protected $version;
/**
* The HTTP response body
*
* @var string
*/
protected $body;

/**
* The HTTP URL
*
* @var string
*/
protected $link;
/**
* An array that containing any of the various components of the URL.
*
* @var array
*/
protected $components;
/**
* The HTTP host
*
* @var string
*/
protected $host;
/**
* The path of required file.
* (e.g. '/verdana/abpic/item/mygirl.png')
*
* @var string
*/
protected $path;
/**
* The HTTP referer, extra it from original URL
*
* @var string
*/
protected $referer;
/**
* The HTTP method, 'GET' for default
*
* @var string
*/
protected $method = 'GET';
/**
* The HTTP port, 80 for default
*
* @var int
*/
protected $port = 80;
/**
* Timeout period on a stream
*
* @var int
*/
protected $timeout = 100;
/**
* The filename of image
*
* @var string
*/
protected $filename;
/**
* The ContentType of image file.
* image/jpeg, image/gif, image/png, image
*
* @var string
*/
protected $contentType;
/**
* Frivoller constructor
*
* @param string $link
*/
public function __construct($link)
{
// parse the http link
$this->parseLink($link);
// begin to fetch the image
$stream = fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout);
if (!$stream) die ("ERROR: $errno - $errstrn");
fputs($stream, $this->buildHeaders());
$this->body = "";
while (!feof($stream)) {
$this->body .= fgets($stream, 4096);
}
// extract picture data
$this->extractBody($this->body);
// send 'ContentType' header for saving this file correctly
// 假如不发送CT,则在试图保留图片时,IE7 会产生毛病 (800700de)
// Flock, Firefox 则没有这个成绩,Opera 没有测试
header("Content-Type: $this->contentType");
print $this->body;
// save this picture
// file_put_contents('hello.jpg', $this->body);
fclose($stream);
}
/**
* Compose HTTP request header
*
* @return string
*/
private function buildHeaders()
{
$request = "$this->method $this->path HTTP/1.1rn";
$request .= "Host: $this->hostrn";
$request .= "Content-Type: image/jpegrn";
$request .= "Accept: */*rn";
$request .= "Keep-Alive: 300rn";
$request .= "Connection: closern";
$request .= "Referer: $this->refererrn";
$request .= "Cache-Control: max-age=315360000rnrn";
return $request;
}
/**
* Strip initial header and filesize info
*/
private function extractBody(&$body)
{
// The status of link
if(strpos($body, '200 OK') > 0) {
// strip header
$endpos = strpos($body, "rnrn");
$body = substr($body, $endpos + 4);
// strip filesize at nextline
$body = substr($body, strpos($body, "rn") + 2);
}
}
/**
* Extra the http url
*
* @param $link
*/
private function parseLink($link)
{
$this->link = $link;
$this->components = parse_url($this->link);
$this->host = $this->components['host'];
$this->path = $this->components['path'];
$this->referer = $this->components['scheme'] . '://' . $this->components['host'];
$this->filename = basename($this->path);

// extract the content type
$ext = substr(strrchr($this->path, '.'), 1);
if ($ext == 'jpg' or $ext == 'jpeg') {
$this->contentType = 'image/pjpeg';
}
elseif ($ext == 'gif') {
$this->contentType = 'image/gif';
}
elseif ($ext == 'png') {
$this->contentType = 'image/x-png';
}
elseif ($ext == 'bmp') {
$this->contentType = 'image/bmp';
}
else {
$this->contentType = 'application/octet-stream';
}
}
}
// Get the url, maybe you should check the given url
if (isset($_GET['url']) and $_GET['url'] != '') {
new Frivoller($_GET['url']);
}
?>培训的第四阶段,就是应用PHP语言开发实际的程序。以结合实际的项目开发来进行学习,效果真的很好,在学习完之后就开始练习,能比较容易掌握所学的知识,这是学校的学习所没法比的。
admin 该用户已被删除
沙发
发表于 2015-2-4 09:49:12 | 只看该作者
没接触过框架的人,也不用害怕,其实框架就是一种命名规范及插件,学会一个框架其余的框架都很好上手的。
第二个灵魂 该用户已被删除
板凳
发表于 2015-2-9 21:38:10 | 只看该作者
爱上php,他也会爱上你。
海妖 该用户已被删除
地板
发表于 2015-2-27 22:22:52 | 只看该作者
最后祝愿,php会给你带来快乐的同时 你也会给他带来快乐。
愤怒的大鸟 该用户已被删除
5#
发表于 2015-3-3 02:31:49 | 只看该作者
使用zendstdio 写代码的的时候,把tab 的缩进设置成4个空格是很有必要的
兰色精灵 该用户已被删除
6#
发表于 2015-3-7 06:06:55 | 只看该作者
最后介绍一个代码出错,但是老找不到错误方法,就是 go to wc (囧),出去换换气没准回来就找到错误啦。
小魔女 该用户已被删除
7#
发表于 2015-3-11 01:40:41 | 只看该作者
遇到出错的时候,我经常把错误信息直接复制到 google的搜索栏,一般情况都是能搜到结果的,不过有时候会搜出来一大片英文的出来,这时候就得过滤一下,吧中文的弄出来,挨着式方法。
谁可相欹 该用户已被删除
8#
发表于 2015-3-17 12:10:31 | 只看该作者
这些都是最基本最常用功能,我们这些菜鸟在系统学习后,可以先对这些功能深入研究。
金色的骷髅 该用户已被删除
9#
发表于 2015-3-21 20:10:34 | 只看该作者
环境搭建好,当你看见你的浏览器输出“it works\\\\\\\"时你一定是喜悦的。在你解决问题的时候,我强烈建议多读php手册。
精灵巫婆 该用户已被删除
10#
发表于 2015-3-23 22:27:10 | 只看该作者
至于模板嘛,各位高人一直以来就是争论不休,我一只小菜鸟就不加入战团啦,咱们新手还是多学点东西的好。
蒙在股里 该用户已被删除
11#
发表于 2015-3-24 02:54:13 | 只看该作者
装在C盘下面可以利用windows的ghost功能可以还原回来(顺便当做是重转啦),当然啦我的编译目录要放在别的盘下,不然自己的劳动成果就悲剧啦。
飘灵儿 该用户已被删除
12#
发表于 2015-4-1 13:20:40 | 只看该作者
本文当是我的笔记啦,遇到的问题随时填充
透明 该用户已被删除
13#
发表于 2015-4-5 13:14:36 | 只看该作者
php里的数组为空的时候是不能拿来遍历的;(这个有点低级啊,不过我刚被这个边界问题墨迹了好长一会)
分手快乐 该用户已被删除
14#
发表于 2015-4-6 18:09:16 | 只看该作者
首先声明:我是一个菜鸟,是一个初学者。学习了一段php后总是感觉自己没有提高,无奈。经过反思我认为我学习过程中存在很多问题,我改变了学习方法后自我感觉有了明显的进步。
变相怪杰 该用户已被删除
15#
发表于 2015-4-28 09:32:27 | 只看该作者
首先我是坚决反对新手上来就用框架的,因为对底层的东西一点都不了解,造成知识上的真空,会对以后的发展不利。我的观点上手了解下框架就好,代码还是手写。当然啦如果是位别的编程语言的高手的话,这个就另当别论啦。
16#
发表于 2015-4-29 00:38:20 | 只看该作者
环境搭建好,当你看见你的浏览器输出“it works\\\\\\\"时你一定是喜悦的。在你解决问题的时候,我强烈建议多读php手册。
小妖女 该用户已被删除
17#
发表于 2015-5-3 11:39:27 | 只看该作者
环境搭建好,当你看见你的浏览器输出“it works\\\\\\\"时你一定是喜悦的。在你解决问题的时候,我强烈建议多读php手册。
山那边是海 该用户已被删除
18#
发表于 2015-5-9 02:52:42 | 只看该作者
最后介绍一个代码出错,但是老找不到错误方法,就是 go to wc (囧),出去换换气没准回来就找到错误啦。
灵魂腐蚀 该用户已被删除
19#
发表于 2015-6-6 02:39:18 | 只看该作者
php里的数组为空的时候是不能拿来遍历的;(这个有点低级啊,不过我刚被这个边界问题墨迹了好长一会)
简单生活 该用户已被删除
20#
发表于 2015-6-14 21:25:48 | 只看该作者
基础有没有对学习php没有太大区别,关键是兴趣。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-14 13:52

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表