1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

支持老鬼.我也来个小偷源码,自己去研究吧!

本帖由 阿祖2005-09-06 发布。版面名称:源码讨论

  1. 阿祖

    阿祖 New Member

    注册:
    2005-09-06
    帖子:
    63
    赞:
    0
    <?php
    // ---------------设置部分--------------
    set_time_limit(60);
    $time_start = getmicrotime();

    if($i == "" and $end == ""){
    echo "i 太强了,什么都不提价就来搞..用URL提交一下.<br><br>";
    }else{
    if ($i > $end){
    echo "结束于 ID: $i";
    exit();
    }else{
    echo $i.".";
    read($i);
    echo "浏览器马上将自动跳转到处理下一条数据页面.<br>";
    $i = $i + 1;
    echo "<meta http-equiv=refresh content=2;URL=./caiji.php?i=".$i."&end=".$end.">";
    }
    }

    // ---------------函数部分--------------
    // 整个读取封包函数
    function read($id) {
    // 采集的页面,影片详细资料动态 $id.
    // $url = 'http://www.xxxxx.net/list.asp?id=$id';
    $url = "http://www.xxxxx.net/list.asp?id=$id";

    // 读取全部页面
    $str = file("$url");
    $count = count($str);
    for ($i=0;$i<$count;$i++){
    $file .= $str[$i];
    }
    // 分割标记 - <小块>
    $flage_pic_star = "<IMG height=334
    src=\"";
    $flage_pic_end = "\"
    width=277></TD>
    <TD width=1 background=images/31.gif>";
    $flage_name_star = "<FONT
    style=\"FONT-SIZE: 12pt\"
    color=red>";
    $flage_name_end = "</FONT></TD></TR>
    <TR>
    <TD align=middle width=\"10%\" height=24>";
    $flage_zhuyan_star = "主要演员:</FONT></TD>
    <TD width=\"44%\" height=24><FONT style=\"FONT-SIZE: 9pt\"
    color=#000000>";
    $flage_zhuyan_end = "</FONT></TD></TR>
    <TR>
    <TD align=middle width=\"10%\" height=23>
    <FONT
    style=\"FONT-SIZE: 9pt\" color=#000000>屏幕尺寸:";
    $flage_class_star = "影片类型:</TD>
    <TD width=\"44%\" height=20><FONT style=\"FONT-SIZE: 9pt\"
    color=#000000>";
    $flage_class_end = "</FONT></TD></TR>
    <TR>
    <TD align=middle width=\"10%\" height=23>文件大小:";
    $flage_js_star = "影片集数:</TD>
    <TD width=\"44%\" height=25><FONT style=\"FONT-SIZE: 9pt\"
    color=#000000>";
    $flage_js_end = "</FONT></TD></TR>
    <TR>
    <TD align=middle width=\"10%\" height=12>观看次数:";
    $flage_intro_star = "<SPAN style=\"FONT-SIZE: 9pt\">";
    $flage_intro_end = "</SPAN>
    </TD></TR></TBODY></TABLE></TD></TR>
    <TR>
    <TD>";
    // 分割代码 - 截取图片地址
    $string = explode($flage_pic_star, $file);
    $pic_all = explode($flage_pic_end, $string[1]);
    $pic = $pic_all[0];
    // 分割代码 - 截取电影名称
    $string = explode($flage_name_star, $file);
    $name_all = explode($flage_name_end, $string[1]);
    $name = $name_all[0];
    // 分割代码 - 截取主演
    $string = explode($flage_zhuyan_star, $file);
    $zhuyan_all = explode($flage_zhuyan_end, $string[1]);
    $zhuyan = $zhuyan_all[0];
    $zhuyan = str_replace("'","\'",$zhuyan);
    // 分割代码 - 截取类别
    $string = explode($flage_class_star, $file);
    $class_all = explode($flage_class_end, $string[1]);
    $class = $class_all[0];
    // 分割代码 - 截取集数
    $string = explode($flage_js_star, $file);
    $js_all = explode($flage_js_end, $string[1]);
    $js = $js_all[0];
    // 分割代码 - 截取电影介绍
    $string = explode($flage_intro_star, $file);
    $intro_all = explode($flage_intro_end, $string[1]);
    $intro = $intro_all[0];
    $intro = str_replace("\\"," ",$intro);
    $intro = trim(str_replace("'","\'",$intro));
    // 调用写函数
    if ($name <> "" and $class <> ""){
    echo "$id 抓文件成功 <br>";
    write_mysql($id, $name, $zhuyan, $class, $js, $pic, $intro);
    copypic($id);
    }else{
    echo "$id 空ID没有数据. <br>";
    }

    }

    // 数据加入数据库函数
    function write_mysql($id, $name, $zhuyan, $class, $js, $pic, $intro){
    // MYSL连接参数
    $servername = 'localhost';
    $dbusername = 'root';
    $dbpassword = 'root';
    $dbname = 'movie';
    // MYSQL连接池
    mysql_connect($servername, $dbusername, $dbpassword);
    mysql_select_db($dbname) or die(mysql_error());
    $sql = "INSERT INTO `movie` ( `xxxxxid` , `name` , `zhuyan` , `class` , `js` , `pic`, `intro` )
    VALUES ( '$id', '$name', '$zhuyan', '$class', '$js', '$pic', '$intro' );";
    if(mysql_query($sql)){
    echo "ID: $id NAME: $name CLASS: $class 填加成功<br>";
    }else{
    echo "ID: $id NAME: $name CLASS: $class 填加失败<br>";
    // exit();
    }
    }


    // 图象COPY函数 $id - xxxxxxid
    function copypic($id){
    // 读数据库把现有的有效数据的ID读出来然后按照这些ID取图片。
    $sql = "SELECT pic FROM movie WHERE xxxxxxid='$id'";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    $file = "http://www.xxxxx.net/".$row[0];
    $dir = 'pic'; // 保持图片的地址
    if(!is_dir($dir)) mkdir($dir,0777);
    $data = @file_get_contents($file);
    $filename = $dir."/".$id.strrchr( $file, "." );
    @fwrite(fopen($filename,"wb+"),$data);
    echo "抓取图片成功 ";
    $sample = $filename;
    $target = 'pic2/'.$id.'.jpg';
    makethumb($sample,$target);

    }

    // 缩略图函数
    function makethumb($srcFile,$dstFile){
    $data = GetImageSize($srcFile);

    // $dstW: 目标图片宽度
    // $dstH: 目标文件高度
    if($data[0]<100 and $data[1]<150){
    $dstW = $data[0];
    $dstH = $data[1];
    }else{
    $dstW = 100;
    $dstH = 150;
    }
    switch($data[2]){
    case 1:
    $im = @ImageCreateFromGIF($srcFile);
    break;
    case 2:
    $im = @ImageCreateFromJPEG($srcFile);
    break;
    case 3:
    $im = @ImageCreateFromPNG($srcFile);
    break;
    }
    $srcW = ImageSX($im);
    $srcH = ImageSY($im);
    $ni = ImageCreate($dstW,$dstH);
    ImageCopyResized($ni,$im,0,0,0,0,$dstW,$dstH,$srcW,$srcH);
    ImageJpeg($ni,$dstFile);
    echo "缩略图成功 <br>";
    // 如果需要输出到浏览器,那么将上一句改为ImageJpeg($ni);
    //ImageJpeg($ni);
    // 如果需要其它格式的asp>图片,改动最后一句就可以了
    }



    // 页面时间函数
    function getmicrotime(){
    list($usec, $sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
    }

    // 页面时间输出
    $time_end = getmicrotime();
    $time = $time_end - $time_start;
    echo "<br> $time seconds";

    ?>
     
  2. xxx

    xxx New Member

    注册:
    2005-09-05
    帖子:
    3
    赞:
    0
    :cool: 研究一下