• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[PHP] Getting 4Chan /b/ Images.

EvulMastah

๏̯͡๏﴿
Premium User
Joined
Aug 19, 2007
Messages
4,941
Solutions
11
Reaction score
352
So, basically I am releasing my old script that will get images from 4Chan for you, because it is slower than my current one written with cURL extension.
PHP:
<?php
	set_time_limit(0);
	$keys = array();
	$values = array();

	$do = strtolower($_GET['do']); //Action type.
	$threadid = $_GET['thread']; //Simple thread id.
	$threadsFrom = $_GET['from']; //Page number to start from.
	$threadsTo = $_GET['to']; //Page number to end at.

	$chan = "";
	$trds = "";

	if(in_array($do, array("page", "pages", "only", 1)))
		for($p = 1; $p < 16; $p++)
			$chan .= @file_get_contents("http://boards.4chan.org/b/{$p}");
	elseif(in_array($do, array("thread", "threadid", 2)))
		$chan .= @file_get_contents("http://boards.4chan.org/b/res/{$threadid}");
	elseif(in_array($do, array("threads", "all", 3)))
	{
		$threadsFrom = ($threadsFrom < 1 || $threadsFrom > 15) ? 1 : $threadsFrom;
		$threadsTo = $threadsTo > 15 ? 15 : $threadsTo;
		$threadsTo = $threadsTo >= $threadsFrom ? $threadsTo : $threadsFrom;

		for($p = $threadsFrom; $p <= $threadsTo; $p++)
			$trds .= @file_get_contents("http://boards.4chan.org/b/{$p}");

		preg_match_all('/\<input type\=checkbox name\="(.*?)" value\=(.*?)>/is', $trds, $tMatches);

		foreach($tMatches[1] as $t)
			$chan .= @file_get_contents("http://boards.4chan.org/b/res/{$t}");
	}
	else
	{
		echo "I don't know wtf are you doin', but you're doin' it wrong.";
		exit;
	}

	preg_match_all('/\<a href\="http:\/\/images\.4chan\.org\/b\/src\/(.*?)" target\=(.*?)\>\<img src\=(.*?)\>\<\/a\>/is', $chan, $matches);
	str_replace("align=left", "", $matches[0]);

	foreach($matches[1] as $val)
		$values[] = $val;

	foreach($matches[3] as $th)
	{
		$th = explode(" ", $th);
		$keys[] = $th[0];
	}

	$content = "";
	if(count($keys))
		$content .= "<div align=\"center\">Output: ".count($keys)." images.</div><br />";

	for($i = 0; $i <= count($values); $i++)
		if(!empty($keys[$i]))
		{
			if($i % 5 == 0)
				$content .= "<br /><br />";

			$content .= "<a href=\"http://images.4chan.org/b/src/{$values[$i]}\"><img src=\"{$keys[$i]}\" /></a>&nbsp;&nbsp;";
		}

	echo $content;
?>

Way to use it:
1. ?do=1/pages/page/only -> Will get you images from 15 main /b/ pages.
2. ?do=2/thread/threadid&thread=id_here -> Will get you images from specified thread.
3. ?do=3/all/threads&from=page&to=page -> Will get you images from threads that are on specified pages (from -> to).

Have fun, bye.
 
Last edited:
lol, 4chan is teh pwner of all internetz. everyone knows that. /b/ forever
 
If tibia is so gay, why do you have 3,3k posts on a fucking tibia forum then?

Me being a part of OpenTibia (hence, it is not tibia forum, tard) forum makes me tibia player? Since when? Sure, I used to play, like 2 or even 3 years ago.

Im actually mostly just reading polish comunity board and sometimes posting there, if you are so curious.

Neverthless, youre still a dumbfuck posting nonsense on threads you actually know nothing about. I'd like to see you actually do something for the community, instead of just asking for help.

Have fun and please, stay away from here.
 
Nemaneth Ftw ^^

<offtopic>
@All trolls flaming because they sucks so hard and have nothing else to do because they got 0 knowledge on everything:
FFFFFFUUUUUUUUUUU and GTFO!!!!!111


Wow i'm a flamer now :D:D:D:D</offtopic>
 
Last edited:
Me being a part of OpenTibia (hence, it is not tibia forum, tard) forum makes me tibia player? Since when? Sure, I used to play, like 2 or even 3 years ago.

Im actually mostly just reading polish comunity board and sometimes posting there, if you are so curious.

Neverthless, youre still a dumbfuck posting nonsense on threads you actually know nothing about. I'd like to see you actually do something for the community, instead of just asking for help.

Have fun and please, stay away from here.

OpenTIBIA, it's directly related to Tibia.
 
4chan is stupid...but I guess you can say that about anything. I went there once to check it out and was full of horny pre-mature outcasts
 
4chan is stupid...but I guess you can say that about anything. I went there once to check it out and was full of horny pre-mature outcasts
/b/ is full of underage B& nowdays

fuk, rules 1 & 2 :mad:@
 
Back
Top