一只牛の窝

生命只是在演绎着自己的精彩,分享才是最大的快乐……

« ASP代码实现图片防盗链及附件防盗链ASP时间函数获取服务器时间和相关例子 »

php小偷程序原理与电影小偷如何编写(第一课)

一、php小偷程序原理:
可以通过这种小偷程序,完成过去一些似乎完全不可能实现的任务,比如说把某个站的页面偷梁换柱后变成自己的页面,或者把某个站的一些数据(文章,图片)保存到本地数据库中加以利用。
二、下在给大家介绍一下PHP电影小偷基本编写配置文件:
1、首先我们先定义好2个重要的基本配置文件(global.php,commom.php);
(1)、其中global.php是定义所有函数的配置文件,直接把下面代码另存为global.php即可不必修改,相关函数的使用方法将在一下课给大家讲解。

<?php
$timestamp = time();
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('<script language=javascript>document.write("<a href="+window.location+">超时,请点击这里...</a>");</script>');
                                }
        return $theget;

}

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

(2)、而commom.php则为网站的基本配置文件,使用时需修改相关参数:

<?php
$fromurl = "http://www.cccyy.com"; //小偷程序目标网站,后面不要带 “/”
$flush="30";//update函数中自动同步更新时间分钟
$cachefile="cache";//生成缓存目录,不要带 “/”
include './global.php';
?>

缓存目录,文件夹需要提前建好,如果是linux服务器的话要求把目录权限设为777,如果需要在缓存目录生成二级目录的,也同样要把目录权限改为777,否则无法写入,所以建议大家做小偷站使用Windows服务器比较方便。


原创文章如转载,请注明:转载自 阳春一月 [ http://blog.ycjan.com/ ]

本文链接地址:http://blog.ycjan.com/php/20090530881.html

  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

Search

最近发表

Powered By Z-Blog 1.8 Arwen Build 81206

Copyright ycjan.com 粤ICP备08002314号