All pastes #371403 Raw Edit

Anonymous

public php v1 · immutable
#371403 ·published 2007-02-25 08:46 UTC
rendered paste body
<?php/*	Title: 4chan Ripper	Description: Searches the first webpage of an image board on 4chan for				 A list of pages, searches those pages for threads, searches				 those threads for images, downloads the images to a folder				 based on date and image board.		*/set_time_limit(300000000000); //Depending on the internet connection used, this can take quite							  //A while...//getSourceList looks at the bottom of the main page of an image board. It looks for links, and//if it finds a link, it'll add it to an array of "Source Pages". These are checked for//"Sub-source Pages."function getSourceList($origUrl) {	$justBeforePos = "";	$justAfterPos = "";	$sourceList = array();	$url = file($origUrl);		array_push($sourceList, $origUrl);		for($i=0;$i<count($url);$i++)	{		if(strpos($url[$i], 'document.delform.pwd.value=get_pass("4chan_pass");'))		{			for($j=10;$j>=0;$j--)			{				if(strpos($url[$i], '[<a href="' . $j . '.html">' . $j . '</a>]'))				{						array_push($sourceList, $origUrl . $j . '.html');				}			}		}	}	return($sourceList);}//getSubSourceList searches every page in the source list for threads. Threads are marked with//the string "[Reply]". These threads are added to a list, and passed to the getPictureList//function.function getSubSourceList($sourceList, $origUrl){	$justBeforePos = "";	$justAfterPos = "";	$subSourceList = array();		for($j=0;$j<count($sourceList);$j++)	{		$url = file($sourceList[$j]);				for($i=0;$i<count($url);$i++)		{			if(strpos($url[$i], 'Reply</a>]</span>'))			{				$justAfterPos = strpos($url[$i], 'Reply</a>]</span>') - 2;				$justBeforePos = strrpos($url[$i], '[<a href="') + strlen('[<a href="');				array_push($subSourceList, ($origUrl . substr($url[$i], $justBeforePos, ($justAfterPos - $justBeforePos))));			}		}	}	return($subSourceList);}//This searches the threads for posts with pictures in them. When it finds them, it extracts the//link to the file, and adds it to a list of pictures.function getPictureList($subSourceList, $origUrl){	$justBeforePos = "";	$justAfterPos = "";	$pictureList = array();		for($i=0;$i<count($subSourceList);$i++)	{		$url = file($subSourceList[$i]);		for($j=0;$j<count($url);$j++)		{			if(strpos($url[$j], '<span class="filesize">'))			{				$justAfterPos = strpos($url[$j], '" target="_blank">');				$justBeforePos = strpos($url[$j], 'File :<a href="') + strlen('File :<a href="');				array_push($pictureList, substr($url[$j], $justBeforePos, ($justAfterPos - $justBeforePos)));			}		}	}	return($pictureList);}function($pictureList, $url){	//Make the folder	$folder = 'pictures\\' . substr($url, (strlen($url) - 2), 1) . '_' . date(d-m-y_H:i:s);	if(!is_dir($folder))	{		mkdir($folder);	}		//Copy the pictures	for($i=0;$i<count($pictureList);$i++)	{		if(!is_file($folder.'\\'.basename($pictureList[$i])))		{			copy($pictureList[$i],$folder.'\\'.basename($pictureList[$i]));		}	}}$url = 'http://cgi.4chan.org/s/'; //This is the address of the image board./*$SL = getSourceList($url);$SSL = getSubSourceList($SL, $url);$PL = getPictureList($SSL,$url);copyPictures($PL);*///Test Area$SSL = array("http://cgi.4chan.org/s/res/926833.html");$PL = getPictureList($SSL, $url);copyPictures($PL);?>