套套进来,吼吼
套套牌电影台:www.156.net.ru
在套套的基础上增加:
支持登录论坛采集,绝大部分ubb代码转换,修正相对目录图片显示,增加访客访问过的内容保存为html(这算不算是一种缓存呢?)
[ 本帖最后由 _liege 于 2007-4-1 03:46 编辑 ] 套套牌不错,安全可靠 更新以下代码:
主要改进:网页分类依然存在,具体子栏目的帖子列表改为动态,只有具体帖子为静态
<?php
error_reporting(E_ALL);
/**************
* 网站地址
**************/
$site = 'localhost';
// 目标地址
$target = 'bbs.cnxp.com';
// 目标端口
$port = 80;
//* 目标目录
$dir = '/archiver/';
/**********************
* 是否装换ubb代码,非0既真
************************/
$ubbb=1;
/***
COOKIE验证
****/
$loginurl='';//登录URL,含登录各种信息,如帐号密码,不要带主域名,格式为 xxx.php?.......
$cookie='';//保存login()的cookie信息
$logonoff=0;//标识,非0即登录
$query_str = '';
foreach ($_GET as $key => $val) {
$query_str .= $key . $val;
}
/**
* 读取远程文件
*/
if (empty($query_str)) {
$fp = fsockopen($target, $port, $errno, $error, 30);
if (!$fp) {
echo "[$errno]$error<br />\n";
} else {
fwrite($fp, "GET $dir HTTP/1.1\r\n");
fwrite($fp, "Host: $target\r\n");
if($logonoff)
fwrite($fp,"Cookie:$cookie\r\n");
fwrite($fp, "Connection: Close\r\n\r\n");
$content = '';
while (!feof($fp)) {
$content .= fgets($fp, 128);
}
fclose($fp);
}
} else {
if(file_exists("$query_str.htm")){
header("Location: $query_str.htm");
}else{
$fp = fsockopen($target, $port, $errno, $error, 30);
if (!$fp) {
echo "[$errno]$error<br />\n";
} else {
fwrite($fp, "GET $dir?$query_str HTTP/1.1\r\n");
fwrite($fp, "Host: $target\r\n");
if($logonoff)
fwrite($fp,"Cookie:$cookie\r\n");
fwrite($fp, "Connection: Close\r\n\r\n");
$content = '';
while (!feof($fp)) {
$content .= fgets($fp, 128);
}
fclose($fp);
}
}
}
/**
* 相关替换
*/
$content = preg_replace("~.+(<html>.+<\/html>).+~is", "\\1", $content);
$content = str_replace($target, $site, $content);
$content = str_replace("archiver/", "", $content);
$content = preg_replace("~<font.+?查看完整版本.+?<\/a>~", "", $content);
$content = str_replace('影视帝国', '套套牌电影', $content);
/**
* CSS 文件下载
*/
preg_match_all("~href=\"(.+?)\"~is", "<link rel=\"stylesheet\" type=\"text/css\" href=\"forumdata/cache/style_7.css\">",
$match);
$css_file = 'http://' . $target . '/' . $match;
$local_css = explode('/', $match);
$local_css = $local_css;
if (!file_exists($local_css)) {
$css = file_get_contents($css_file);
$fp = fopen($local_css, 'w');
fwrite($fp, $css);
fclose($fp);
chmod($local_css, 0777);
}
$content = preg_replace("~forumdata\/cache\/(.+?).css~", " \\1.css", $content);
/**
* 统计
*/
$content .= "<script src='http://s67.cnzz.com/stat.php?id=445168&web_id=445168&online=1&show=line ' language='JavaScript'
charset='gb2312'></script>";
if($ubbb)
$content=ubb($content);
if(empty($query_str)){
echo $content;
}else{
if(!strstr($query_str,'tid')){
echo $content;
}else{
$s=$query_str.'.htm';
$fp=fopen("$s","w");
if(!$fp){
echo $query_str;
echo "无法创建并打开文件";
}else{
fwrite($fp, $content)?header("Location: $s"): print("无法缓存文件,请检查目录写入权限是否为777");
fclose($fp);
}
}
}
/*************************************************
UBB代码
*************************************************/
functionubb($Text)
{
global $site,$target;
$Text=stripslashes($Text);
$Text=ereg_replace("\r\n","<br/>",$Text);
$Text=ereg_replace("\r","<br/>",$Text);
$Text=nl2br($Text);
$Text=preg_replace("/\\t/is"," ",$Text);
$Text=ereg_replace(""," ; ; ; ;",$Text);
$Text=preg_replace("/\(.+?)\[\/h1\]/is","<h1>\\1</h1>",$Text);
$Text=preg_replace("/\(.+?)\[\/h2\]/is","<h2>\\1</h2>",$Text);
$Text=preg_replace("/\(.+?)\[\/h3\]/is","<h3>\\1</h3>",$Text);
$Text=preg_replace("/\(.+?)\[\/h4\]/is","<h4>\\1</h4>",$Text);
$Text=preg_replace("/\(.+?)\[\/h5\]/is","<h5>\\1</h5>",$Text);
$Text=preg_replace("/\(.+?)\[\/h6\]/is","<h6>\\1</h6>",$Text);
$Text=preg_replace("/\(.+?)\[\/center\]/is","<center>\\1</center>",$Text);
$Text=preg_replace("/\(.+?)\[\/big\]/is","<big>\\1</big>",$Text);
$Text=preg_replace("/\(.+?)\[\/small\]/is","<small>\\1</small>",$Text);
$Text=preg_replace("/\(http:\/\/.+?)\[\/url\]/is","<ahref=\\1>\\1</a>",$Text);
$Text=preg_replace("/\(.+?)\[\/url\]/is","<ahref=\'http://\\1\'>http://\\1</a>",$Text);
$Text=preg_replace("/\(.*)\[\/url\]/is","<ahref=\\1>\\2</a>",$Text);
$Text=preg_replace("/\(.*)\[\/url\]/is","<ahref=http://\\1>\\2</a>",$Text);
$Text=preg_replace("/\(http:\/\/.+?)\[\/img\]/is","<imgsrc=\\1border=0>",$Text);
//替换相对目录的图片地址为绝对地址。受目标网站是否防盗链影响
$Text=str_replace("http://image.$site","http://image.$target",$Text);
$Text=preg_replace("/\(.+?)\[\/color\]/is","<fontcolor=\\1>\\2</font>",$Text);
$Text=preg_replace("/\(.+?)\[\/size\]/is","<fontsize=\\1>\\2</font>",$Text);
$Text=preg_replace("/\(.+?)\[\/sup\]/is","<sup>\\1</sup>",$Text);
$Text=preg_replace("/\(.+?)\[\/sub\]/is","<sub>\\1</sub>",$Text);
$Text=preg_replace("/\(.+?)\[\/pre\]/is","<pre>\\1</pre>",$Text);
$Text=preg_replace("/\(.+?)\[\/email\]/is","<ahref=mailto:\\1>\\1</a>",$Text);
$Text=preg_replace("/\(.+?)\[\/i\]/is","<i>\\1</i>",$Text);
$Text=preg_replace("/\(.+?)\[\/b\]/is","<b>\\1</b>",$Text);
$Text=preg_replace("/\(.+?)\[\/quote\]/is","<blockquote><fontsize='1'face='Courier
New'>quote:</font><hr>\\1<hr></blockquote>",$Text);
return $Text;
}
function login(){
global $cookie,$logurl;
$fp=fsockopen("$host",80);
$c="GET $logurl HTTP/1.1";
fputs($fp,$c);
$result = '';
while($line = fgets($fp))
{
$result .= $line;
$tmp = explode(":",$line);
if($tmp=="Set-Cookie")
$cookie .= $tmp;
}
fclose($fp);
}
?>
[ 本帖最后由 _liege 于 2007-4-1 05:20 编辑 ] 郁闷
居然死掉了
这论坛
HTTP/1.1 200 OK
Server: Zeus/4.2
Date: Sat, 31 Mar 2007 21:08:37 GMT
Connection: close
Content-Type: text/html
X-Powered-By: PHP/4.3.11
Discuz! info: Can not connect to MySQL server
Time: 2007-3-31 9:08pm
Script:
Error:; ;Can't connect to MySQL server on '192.168.1.84' (111)
Errno.:; ;2003
Similar error report has beed dispatched to administrator before.
页:
[1]