今天所学到的PHP网页小偷(偷华军哦)

做PHP也一些时间了,以前都是基本上写企业程序.今天张哥给我出一韪目,就是偷取小日本网页上的内容...
今天看了大半天,现在终于写好了全站代码:废话少说..大家看吧.不是吹的哦..

commom.php 文件:

<?php
include './config.php';
include './global.php';
?>

config.php 文件:

<?php
$fromurl = "http://www.newhua.com/";
$flush="120";//update函数中自动同步更新时间
?>

global.php 文件(主要函数)

<?php
function open($file,$type=''){
         global $fromurl,$referer;
         $cachename=$file;
                 if($type){
                         $file=$fromurl.'/'.$type.'/'.$file;
                 }else{
                         $file=$fromurl.$file;
                 }

               
               
               
                         if($open=file($file)){
                                         $count=count($open);
                                         for($i=0;$i<$count;$i++){
                                                 $theget.=$open[$i];

                                         }
                                       
                                 }else{
                                         die('请求过多,超时,请刷新');
                                 }
               
               
         return $theget;

}

function update($file,$type=''){
//更新cache中的文件
         global $timestamp,$flush;
         if(!file_exists("cache/$file")){
                 if($type){
                         $data=open($file,$type);
                 }else{
                         $data=open($file);
                 }
               
                 writetofile("cache/$file",$data);
         }else{
                 $lastflesh=@filemtime("cache/$file");
               
       
       
                 if($lastflesh + ($flush * 60) < $timestamp ){
                         if($type){
                                 $data=open($file,$type);
                         }else{
                                 $data=open($file);
                         }
                         writetofile("cache/$file",$data);
                 }
         }

}
function readfromfile($file_name) {
         if($filenum=fopen($file_name,"r")){
                 flock($filenum,LOCK_SH);
                 $file_data=fread($filenum,filesize($file_name));
                 fclose($filenum);
                 return $file_data;
         }else{
                 return false;
         }
       
}


function writetofile($file_name,$data,$method="w") {
         if($filenum=fopen($file_name,$method)){
                 flock($filenum,LOCK_EX);
                 $file_data=fwrite($filenum,$data);
                 fclose($filenum);
                 return $file_data;
         }else{
                 return false;
         }
}
function cut($file,$from,$end){

         $message=explode($from,$file);
         $message=explode($end,$message[1]);
return         $message[0];
}
function updatecache($file,$cache=''){
         global $timestamp,$flush;
         if(!file_exists($file)){
                 writetofile($file,$cache);
                 $return=$cache;
         }elseif(@filemtime($file) < $timestamp - ($flush * 60)){
                 writetofile($file,$cache);
                 $return=$cache;
         }else{
                 $return=readfromfile($file);       
         }
         return $return;
}
?>

index.php 文件用于...不用说了吧?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?
require './commom.php';
update("index.htm");
$file=readfromfile("cache/index.htm");
$gnrj = cut($file,"<td valign=top bgcolor=#ffffff class=fontline10 colspan=2>","<td valign=top align=center width=290>");
///gnrj 定义下面的调用内容.
///<td valign=top bgcolor=#ffffff class=fontline10 colspan=2>取目标页面中的后面部分.
///<td valign=top align=center width=290>取目标页面中的前面部分.
$gnrj = str_replace("soft/","soft.php?id=",$gnrj);
$gnrj = str_replace(".htm","",$gnrj);
//就是把偷过来的国外软件中的代码更换.
//原来的
//<a target=_blank href="soft/18204.htm">
//变为了现在的
//<a target=_blank href="soft.php?id=18204">
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>华军PHP小偷</title>
</head>

<body>
<table width="416" height="187" border="1" align="center">
<tr>
    <td>华军国内软件</td>
</tr>
<tr>
    <td><? echo $gnrj; ///调用数据?></td>
</tr>
</table>
</body>
</html>

转载于:https://www.cnblogs.com/vicenteforever/articles/1614501.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值