Pages

Thứ Năm, 22 tháng 11, 2012

[Code] Auto tải ảnh từ LauXanh.us :))

Chức năng:
+ Tải ảnh từng topic
+ Tải ảnh từ box
+ Hỗ trợ tải nhiều link (box, topic) cùng lúc


<?php
if(!is_dir("lauxanh")){mkdir("lauxanh");}
function StartDownload($URL,$Prefix)
{
 $source=str_replace(array("\n","\r"),"",file_get_contents(trim($URL)));
 preg_match("#<title>(.*?)\-#i",$source,$Title);
 $Title=str_replace(array("\\","/","\"","*","?","|","<",">"),"",strtolower($Title[1]));
 preg_match("#<!-- message -->(.*?)<!-- / message -->#i",$source,$source);
 $source=$source[1];
 preg_match_all("#<img src=\"(.*?)\"#i",$source,$Links,PREG_SET_ORDER);
 $i=1;
 foreach($Links as $Link)
 {
  $Link=trim($Link[1]);
  if($Link=="" || !strpos(" ".$Link,"http://")){continue;}
  $Path="lauxanh/$Prefix-$Title-$i.jpg";
  if(!file_exists($Path))
  {
   if($Content=file_get_contents($Link))
   {
    file_put_contents($Path,$Content);
    echo "Downloaded: $Path<br/>";
   }
  }
  $i++;
 }
 echo "<br/><br/>";
}
?>
<form method="post" action="">
<textarea name="Link" style="width:100%;height:100px;display:block;"><?php if(isset($_POST["Link"])){echo $_POST["Link"];}else{
echo "http://lauxanh.us/diendan/forumdisplay.php?f=28
http://lauxanh.us/diendan/forumdisplay.php?f=98
http://lauxanh.us/diendan/forumdisplay.php?f=32
http://lauxanh.us/diendan/forumdisplay.php?f=157
http://lauxanh.us/diendan/forumdisplay.php?f=80
http://lauxanh.us/diendan/forumdisplay.php?f=182
http://lauxanh.us/diendan/forumdisplay.php?f=143";
}?></textarea>
<input type="submit" value="Download"/> <p style="font-size:10px; font-family:Arial; color:#666666">Coded by Leorius</p><br/>
<?php
 if(isset($_POST["Link"]))
 {
 $URLs=explode("\n",$_POST["Link"]);
 $Thread=array();
  foreach($URLs as $URL)
  {
   $URL=trim($URL);
   if($URL=="" || !strpos(" ".$URL,"http://")){continue;}
   if(strpos($URL,"showthread.php?t="))
   {
   StartDownload($URL,$Link[1]);
   }
   else if(strpos($URL,"forumdisplay.php?f="))
   {
    $source=file_get_contents($URL);
    $source=str_replace(array("\r","\n"),"",substr($source,strpos($source,'<td class="thead" colspan="7">')));
    preg_match_all("#\&amp\;t\=([0-9]+)#",$source,$Links,PREG_SET_ORDER);
    foreach($Links as $Link)
    {
     if(!in_array($Link,$Thread))
     {
     StartDownload("http://lauxanh.us/diendan/showthread.php?t=".$Link[1],$Link[1]);
     array_push($Thread,$Link);
     }
     else
     {
     continue;
     }
    }
   }
  }
 }
?>
</form>

Không có nhận xét nào:

Đăng nhận xét