Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[PHP/OOP] 4chan image downloader V2

duck you, I'm a dragon
Loyal Member
Joined
Apr 29, 2005
Messages
6,407
Reaction score
130
[PHP/OOP] 4chan image downloader V2 !UPDATED!

This is the next version of 4chan Image downloader I've added a gallery which let's you select which images you want to download. So you don't accidentally download 20 furry porn wallpapers to your server.

Requirements:

  • PHP 4.0 or higher (5.0 or higher recommended)
  • A web server which let's you edit ini settings.

Screenshots:

Pieman - [PHP/OOP] 4chan image downloader V2 - RaGEZONE Forums


How to use:

Put the script anywhere on your web server, call it "4chan_images.php" then create a directory called "images" (This can be changed). Then run the script and everything should be self-explanatory.

Script:

PHP:
<?php
error_reporting(0);

class image_downloader { 

    public $url;
    
    protected function get_source() {
    
        if(($source = @file_get_contents($this->url)) == false) {
        
            die("Could not open thread.");
        
        }
    
        return $source;
    }
    
    protected function get_file_link() {
    
        $source = $this->get_source();
		$i = 0;  
            
        preg_match_all("/\"\>File(.*?)\<blockquote\>/is", $source, $matches_image);
        
        while($i < count($matches_image[1])) {
        
            preg_match("/\<a href\=\\\"(.*?)\\\" target\=/is", $matches_image[0][$i], $images_array[$i]);
                    
            $i ++;
            
        }
                    
        return $images_array;
                
    }
    
    public function get_images() {
    
        $a_images = $_POST['amount'];
        $i = 0;
        
        while($i < $a_images) { 
        
            if(isset($_POST["image_$i"])) {
            
                $images_array[$i] .= $_POST["image_$i"];
            }
            
            $i ++;
            
        }
        
        return $images_array;
        
    }
    
    public function save_file() {
    
        $images_array = $this->get_images();
        $i = 0;
        $errors = 0;
		$file = "";
        
        while($i < count($images_array)) {
        
            $extension = preg_replace("/.*\./is", "", $images_array[$i]);
    
            if(($handle_external = @fopen($images_array[$i], "r"))) {
            
                while($line = fread($handle_external, 8192)) {
                
                    $file .= $line;
                    
                }
                //Change the directory between quotes to change the directory the images will be downloaded to.
                while(($handle_internal = fopen("images/".rand(0,9999999999999).".$extension", "x+"))== false)
                
                fclose($handle_external);
                fwrite($handle_internal, $file);
                fclose($handle_internal);
                unset($handle_external, $line, $file, $handle_internal);
                
            } else {
            
                $errors ++;
                
            }
            
            $i ++;
            
        }
            
        echo $errors . " image(s) not saved.<br/><br/><a href='".$_SERVER['PHP_SELF']."'><<back</a>";
        
    }                
}
class display_images extends image_downloader {

    public $url;

    private function get_thumbs() {
    
        $source = $this->get_source();
		$i = 0;  
            
        preg_match_all("/\"\>File(.*?)\<blockquote\>/is", $source, $matches_image);
        
        while($i < count($matches_image[1])) {
        
            preg_match("/img src=([a-z0-9:\/\.]*)/is", $matches_image[1][$i], $thumbs_array[$i]);
                    
            $i ++;
            
        }
        
        return $thumbs_array;
                
    }
    
    public function d_img_form() {
    
        $thumbs_array = $this->get_thumbs();
        $images_array = $this->get_file_link();
        $i = 0;
        $thumbs = "";
		
        echo '<form name="image_form" method="post" action="4chan_images.php">';
        echo "\n";
        echo '<table cellspacing ="5" border ="0" align="center">';
        echo "\n";
        
        while($i < count($thumbs_array)) {
        
			if($i == 0) {
			
				$thumbs .= "<td><div style='width:130px; height:130px; background-color:#000000;' align='center'><input type='checkbox' checked='checked' name='image_$i' value='".$images_array[$i][1]."' style='float:right;'/><a href='".$images_array[$i][1]."' target='_blank'><img src='".$thumbs_array[$i][1]."' alt='Thumbnail $i' height='100px' width='126px' border='0'/></a></div></td>\n";
			} else {	
		
				$thumbs .= "<td><div style='width:130px; height:130px; background-color:#000000;' align='center'><input type='checkbox' checked='checked' name='image_$i' value='".$images_array[$i][1]."' style='float:right;'/><a href='".$images_array[$i][1]."' target='_blank'><img src='".$thumbs_array[$i][1]."' alt='Thumbnail $i' style='max-height:115px;' border='0'/></a></div></td>\n";
						
				if((($i+1) % $_POST['images_row'] == 0) || (count($thumbs_array) - $i == 1)) {
					
					echo "<tr>\n";
					echo $thumbs;
					echo "</tr>\n";
								
					$thumbs = "";
				}
			}
			$i ++;
		}
        
        echo "</table>";
        echo "<input type='hidden' name='amount' value='".count($thumbs_array)."'/>";
        echo "\n <br/> \n";
        echo '<div align="center"><input type="submit" name="download" value="download"/></div>';
        echo '</form>';
            
    }
}        
    
set_time_limit(0);
ini_set("max_execution_time", "0");

if(!isset($_POST['get_thread']) && !isset($_POST['download'])) {

    ?>
    <form method="post" action="">
    Link to thread:<br/>
    <input type="text" size="55" name="link" />
    <br/>
    Amount of images per row
    <select name="images_row">
    <option value="10">10</option>
    <option value="9">9</option>
    <option value="8">8</option>
    <option value="7">7</option>
    <option value="6">6</option>
    <option value="5">5</option>
    <option value="4">4</option>
    <option value="3">3</option>
    <option value="2">2</option>
    <option value="1">1</option>
    </select>
    <br/>
    <input type="submit" value="submit" name="get_thread" />
    </form>
    <?php
    
} else if(!isset($_POST['download'])) {

    $display = new display_images();
    $display -> url = $_POST['link'];
    $display -> d_img_form(); 
    
} else {

    $downloader = new image_downloader();
    $downloader -> save_file(); 

}
?>

If you encounter any bugs, please post them here and I'll try to fix them.

10-10-09: Updated the script, it now works again with all boards. It now also downloads the first image of every thread. Something the previous script didn't. Sorry it took so long.
 

Attachments

You must be registered for see attachments list
Last edited:
:)
Loyal Member
Joined
Jan 21, 2009
Messages
1,787
Reaction score
93
Yay. Now I can has my CP without going to 4chan!
 
Custom Title Activated
Loyal Member
Joined
Dec 10, 2007
Messages
2,194
Reaction score
263
EDIT:
I get this error (cut most of it out, as it just keeps going):
Warning: fopen(http://forum.ragezone.com/images/1231557360.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fopen(http://forum.ragezone.com/images/1057467094.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/155272629.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1302480645.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/313769124.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1284281773.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1224554075.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/803840865.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/183298859.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/620502664.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/827122343.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1144948452.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/447014245.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/228927755.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/957838674.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1240111155.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/373707797.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/458845759.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1027499656.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/771991171.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/525457841.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/545948870.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/952255751.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/946560081.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/885259376.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1241851128.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1075727281.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/597348005.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/100885000.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/485501204.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/894793242.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/149357804.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/441168312.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1210086757.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1201313926.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/930353098.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/705887364.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/353684963.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1080417580.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/494662297.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/114535030.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/533831215.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/960195144.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/411181887.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/673270827.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/289079470.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/514106299.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/845810821.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/781306574.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/408946110.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1295449843.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1029980198.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/481323632.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/675401954.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/285130141.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/993384451.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/570665700.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/838556004.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/9635530.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1298209213.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/204853762.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1232885278.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/360016702.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/84661853.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/207734052.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1036704544.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/404250197.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1269059853.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/914622255.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/119300948.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/323280556.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/328548306.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/469745044.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/1166790340.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/177173665.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/970125418.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/810317116.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/918153208.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/116220436.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/170772757.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/946784065.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/109741947.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/52495455.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

Warning: fopen(http://forum.ragezone.com/images/160563504.jpg) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 74

Warning: fclose(): 2 is not a valid stream resource in /home/rasta21/public_html/foskett.ws/4chan/4chan_images.php on line 76

I've tried it on localhost, and my webhost, neither work.
 
Mythic Archon
Joined
Apr 8, 2007
Messages
759
Reaction score
21
It's very nice.

I got the same error as you, Rasta. I can't remember exactly how I fixed it but it had something to do with PHP permissions... Either that or I installed another webserver software, WAMP that is.
 
duck you, I'm a dragon
Loyal Member
Joined
Apr 29, 2005
Messages
6,407
Reaction score
130
EDIT:
I get this error (cut most of it out, as it just keeps going):

I've tried it on localhost, and my webhost, neither work.

It seems php can't open the folder where the images are saved in. Try to chmod the folder to 777. If that doesn't work change
PHP:
while(($handle_internal = fopen("http://forum.ragezone.com/images/".rand(0000000000001,9999999999999).".$extension", "x+"))== false)
on line 74 to
PHP:
while(($handle_internal = fopen("".rand(0000000000001,9999999999999).".$extension", "x+"))== false)

This will save all the images in the same folder as the script is located.

As Mr. Lucifer said, it has to do something with permissions. I'm unsure how to fix it though, other than the methods I named above.
 
Custom Title Activated
Loyal Member
Joined
Dec 10, 2007
Messages
2,194
Reaction score
263
It seems php can't open the folder where the images are saved in. Try to chmod the folder to 777. If that doesn't work change
PHP:
while(($handle_internal = fopen("http://forum.ragezone.com/images/".rand(0000000000001,9999999999999).".$extension", "x+"))== false)
on line 74 to
PHP:
while(($handle_internal = fopen("".rand(0000000000001,9999999999999).".$extension", "x+"))== false)
This will save all the images in the same folder as the script is located.

As Mr. Lucifer said, it has to do something with permissions. I'm unsure how to fix it though, other than the methods I named above.
Thanks, it now works perfectly.

Also, when I tried to chmod it to 777 yesterday, it gave me the 500 error.

But anyways, that fix worked. :thumbup1:
 
duck you, I'm a dragon
Loyal Member
Joined
Apr 29, 2005
Messages
6,407
Reaction score
130
Thanks, it now works perfectly.

Also, when I tried to chmod it to 777 yesterday, it gave me the 500 error.

But anyways, that fix worked. :thumbup1:

Glad to help :):
 
Don't you mean Bizzarro!
Loyal Member
Joined
Apr 4, 2008
Messages
1,126
Reaction score
0
This is probably a small problem I keep getting.

Code:
Notice: Undefined variable: i in C:\wamp\www\IMAGES\4chan_images.php on line 23

Notice: Undefined variable: images_array in C:\wamp\www\IMAGES\4chan_images.php on line 31
0 image(s) not saved.

Whats that mean?
Theres no images? o_O
 
duck you, I'm a dragon
Loyal Member
Joined
Apr 29, 2005
Messages
6,407
Reaction score
130
This is probably a small problem I keep getting.

Code:
Notice: Undefined variable: i in C:\wamp\www\IMAGES\4chan_images.php on line 23

Notice: Undefined variable: images_array in C:\wamp\www\IMAGES\4chan_images.php on line 31
0 image(s) not saved.

Whats that mean?
Theres no images? o_O

It's just an empty variable. Just add error_reporting(1); add the top of the file and it should be fixed.

Or better yet, add
PHP:
 $i = 0;
under
PHP:
$source = $this->get_source();

On line 19.
 
duck you, I'm a dragon
Loyal Member
Joined
Apr 29, 2005
Messages
6,407
Reaction score
130
im more interested in a CSS image downloader

Like a script that downloads all images from a CSS file? That does sound useful indeed... Maybe an idea for my next project.
 
Joined
Jun 8, 2007
Messages
1,985
Reaction score
490
It seems php can't open the folder where the images are saved in. Try to chmod the folder to 777. If that doesn't work change
PHP:
while(($handle_internal = fopen("http://forum.ragezone.com/images/".rand(0000000000001,9999999999999).".$extension", "x+"))== false)
on line 74 to
PHP:
while(($handle_internal = fopen("".rand(0000000000001,9999999999999).".$extension", "x+"))== false)
This will save all the images in the same folder as the script is located.

As Mr. Lucifer said, it has to do something with permissions. I'm unsure how to fix it though, other than the methods I named above.

Actually it's because it says http://forum.ragezone.com/images/ instead of ./images.

If you just replaced the http://forum.ragezone.com part with a [.] it should be fine.

Ragezone glitch hurts sometimes :8:
 
Custom Title Activated
Loyal Member
Joined
Dec 10, 2007
Messages
2,194
Reaction score
263
The script no longer works for me..
 
Junior Spellweaver
Joined
Jul 12, 2008
Messages
130
Reaction score
6
Rasta your script works fine :)

idk whats up with mine though.

I've edited everything i need to but check it out:



When you enter the URL of the thread it doesn't show any pictures it only shows the download button.

here is what I have in the script:

(File permissions are at 755)

PHP:
<?php 
class image_downloader {  

    public $url; 
     
    protected function get_source() { 
     
        if(($source = @file_get_contents($this->url)) == false) { 
         
            die("Could not open thread."); 
         
        } 
     
        return $source; 
    } 
     
    protected function get_file_link() { 
     
        $source = $this->get_source(); 
             
        preg_match_all("/File :(.*?)\<blockquote\>/is", $source, $matches_image); 
         
        while($i < count($matches_image[1])) { 
         
            preg_match("/\<a href\=\\\"(.*?)\\\" target\=/is", $matches_image[0][$i], $images_array[$i]); 
                     
            $i ++; 
             
        } 
                     
        return $images_array; 
                 
    } 
     
    public function get_images() { 
     
        $a_images = $_POST['amount']; 
        $i = 1; 
         
        while($i < $a_images) {  
         
            if(isset($_POST["image_$i"])) { 
             
                $images_array[$i] .= $_POST["image_$i"]; 
                 
            } 
             
            $i ++; 
             
        } 
         
        return $images_array; 
         
    } 
     
    public function save_file() { 
     
        $images_array = $this->get_images(); 
        $i = 1; 
        $errors = 0; 
         
        while($i < count($images_array)) { 
         
            $extension = preg_replace("/.*\./is", "", $images_array[$i]); 
     
            if(($handle_external = @fopen($images_array[$i], "r"))) { 
             
                while($line = fread($handle_external, 8192)) { 
                 
                    $file .= $line; 
                     
                } 
                //Change the directory between quotes to change the directory the image will be downloaded to. 
                while(($handle_internal = fopen("./images".rand(0000000000001,9999999999999).".$extension", "x+"))== false) 
                 
                fclose($handle_external); 
                fwrite($handle_internal, $file); 
                fclose($handle_internal); 
                unset($handle_external, $line, $file, $handle_internal); 
                 
            } else { 
             
                $errors ++; 
                 
            } 
             
            $i ++; 
             
        } 
             
        echo $errors . " image(s) not saved.<br/><br/><a href='".$_SERVER['PHP_SELF']."'><<back</a>"; 
         
    }                 
} 
class display_images extends image_downloader { 

    public $url; 

    private function get_thumbs() { 
     
        $source = $this->get_source(); 
             
        preg_match_all("/File :(.*?)\<blockquote\>/is", $source, $matches_image); 
         
        while($i < count($matches_image[1])) { 
         
            preg_match("/img src=([a-z0-9:\/\.]*)/is", $matches_image[0][$i], $thumbs_array[$i]); 
                     
            $i ++; 
             
        } 
                     
        return $thumbs_array; 
                 
    } 
     
    public function d_img_form() { 
     
        $thumbs_array = $this->get_thumbs(); 
        $images_array = $this->get_file_link(); 
        $i = 1; 
         
        echo '<form name="image_form" method="post" action="4chan.php">'; 
        echo "\n"; 
        echo '<table cellspacing ="5" border ="0" align="center">'; 
        echo "\n"; 
         
        while($i < count($thumbs_array)) { 
         
            $thumbs .= "<td><div style='width:130px; height:130px; background-color:#000000;' align='center'><input type='checkbox' checked='checked' name='image_$i' value='".$images_array[$i][1]."' style='float:right;'/><a href='".$images_array[$i][1]."' target='_blank'><img src='".$thumbs_array[$i][1]."' alt='Thumbnail $i' style='max-height:115px;' border='0'/></a></div></td>\n"; 
                     
            if(($i % $_POST['images_row'] == 0) || (count($thumbs_array) - $i == 1)) { 
                 
                echo "<tr>\n"; 
                echo $thumbs; 
                echo "</tr>\n"; 
                             
                unset($thumbs); 
            } 
             
            $i ++; 
             
        } 
         
        echo "</table>"; 
        echo "<input type='hidden' name='amount' value='".count($thumbs_array)."'/>"; 
        echo "\n <br/> \n"; 
        echo '<div align="center"><input type="submit" name="download" value="download"/></div>'; 
        echo '</form>'; 
             
    } 
}         
     
set_time_limit(0); 
ini_set("max_execution_time", "0"); 

if(!isset($_POST['get_thread']) && !isset($_POST['download'])) { 

    ?> 
    <form method="post" action="<?=$_SERVER['PHP_SELF'];?>"> 
    Link to thread:<br/> 
    <input type="text" size="55" name="link" /> 
    <br/> 
    Amount of images per row 
    <select name="images_row"> 
    <option value="10">10</option> 
    <option value="9">9</option> 
    <option value="8">8</option> 
    <option value="7">7</option> 
    <option value="6">6</option> 
    <option value="5">5</option> 
    <option value="4">4</option> 
    <option value="3">3</option> 
    <option value="2">2</option> 
    <option value="1">1</option> 
    </select> 
    <br/> 
    <input type="submit" value="submit" name="get_thread" /> 
    </form> 
    <?php 
     
} else if(!isset($_POST['download'])) { 

    $display = new display_images(); 
    $display -> url = $_POST['link']; 
    $display -> d_img_form();  
     
} else { 

    $downloader = new image_downloader(); 
    $downloader -> save_file();  

} 
?>
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Dec 10, 2007
Messages
2,194
Reaction score
263
Rasta your script works fine :)

idk whats up with mine though.

I've edited everything i need to but check it out:



When you enter the URL of the thread it doesn't show any pictures it only shows the download button.

here is what I have in the script:

(File permissions are at 755)

PHP:
<?php 
class image_downloader {  

    public $url; 
     
    protected function get_source() { 
     
        if(($source = @file_get_contents($this->url)) == false) { 
         
            die("Could not open thread."); 
         
        } 
     
        return $source; 
    } 
     
    protected function get_file_link() { 
     
        $source = $this->get_source(); 
             
        preg_match_all("/File :(.*?)\<blockquote\>/is", $source, $matches_image); 
         
        while($i < count($matches_image[1])) { 
         
            preg_match("/\<a href\=\\\"(.*?)\\\" target\=/is", $matches_image[0][$i], $images_array[$i]); 
                     
            $i ++; 
             
        } 
                     
        return $images_array; 
                 
    } 
     
    public function get_images() { 
     
        $a_images = $_POST['amount']; 
        $i = 1; 
         
        while($i < $a_images) {  
         
            if(isset($_POST["image_$i"])) { 
             
                $images_array[$i] .= $_POST["image_$i"]; 
                 
            } 
             
            $i ++; 
             
        } 
         
        return $images_array; 
         
    } 
     
    public function save_file() { 
     
        $images_array = $this->get_images(); 
        $i = 1; 
        $errors = 0; 
         
        while($i < count($images_array)) { 
         
            $extension = preg_replace("/.*\./is", "", $images_array[$i]); 
     
            if(($handle_external = @fopen($images_array[$i], "r"))) { 
             
                while($line = fread($handle_external, 8192)) { 
                 
                    $file .= $line; 
                     
                } 
                //Change the directory between quotes to change the directory the image will be downloaded to. 
                while(($handle_internal = fopen("./images".rand(0000000000001,9999999999999).".$extension", "x+"))== false) 
                 
                fclose($handle_external); 
                fwrite($handle_internal, $file); 
                fclose($handle_internal); 
                unset($handle_external, $line, $file, $handle_internal); 
                 
            } else { 
             
                $errors ++; 
                 
            } 
             
            $i ++; 
             
        } 
             
        echo $errors . " image(s) not saved.<br/><br/><a href='".$_SERVER['PHP_SELF']."'><<back</a>"; 
         
    }                 
} 
class display_images extends image_downloader { 

    public $url; 

    private function get_thumbs() { 
     
        $source = $this->get_source(); 
             
        preg_match_all("/File :(.*?)\<blockquote\>/is", $source, $matches_image); 
         
        while($i < count($matches_image[1])) { 
         
            preg_match("/img src=([a-z0-9:\/\.]*)/is", $matches_image[0][$i], $thumbs_array[$i]); 
                     
            $i ++; 
             
        } 
                     
        return $thumbs_array; 
                 
    } 
     
    public function d_img_form() { 
     
        $thumbs_array = $this->get_thumbs(); 
        $images_array = $this->get_file_link(); 
        $i = 1; 
         
        echo '<form name="image_form" method="post" action="4chan.php">'; 
        echo "\n"; 
        echo '<table cellspacing ="5" border ="0" align="center">'; 
        echo "\n"; 
         
        while($i < count($thumbs_array)) { 
         
            $thumbs .= "<td><div style='width:130px; height:130px; background-color:#000000;' align='center'><input type='checkbox' checked='checked' name='image_$i' value='".$images_array[$i][1]."' style='float:right;'/><a href='".$images_array[$i][1]."' target='_blank'><img src='".$thumbs_array[$i][1]."' alt='Thumbnail $i' style='max-height:115px;' border='0'/></a></div></td>\n"; 
                     
            if(($i % $_POST['images_row'] == 0) || (count($thumbs_array) - $i == 1)) { 
                 
                echo "<tr>\n"; 
                echo $thumbs; 
                echo "</tr>\n"; 
                             
                unset($thumbs); 
            } 
             
            $i ++; 
             
        } 
         
        echo "</table>"; 
        echo "<input type='hidden' name='amount' value='".count($thumbs_array)."'/>"; 
        echo "\n <br/> \n"; 
        echo '<div align="center"><input type="submit" name="download" value="download"/></div>'; 
        echo '</form>'; 
             
    } 
}         
     
set_time_limit(0); 
ini_set("max_execution_time", "0"); 

if(!isset($_POST['get_thread']) && !isset($_POST['download'])) { 

    ?> 
    <form method="post" action="<?=$_SERVER['PHP_SELF'];?>"> 
    Link to thread:<br/> 
    <input type="text" size="55" name="link" /> 
    <br/> 
    Amount of images per row 
    <select name="images_row"> 
    <option value="10">10</option> 
    <option value="9">9</option> 
    <option value="8">8</option> 
    <option value="7">7</option> 
    <option value="6">6</option> 
    <option value="5">5</option> 
    <option value="4">4</option> 
    <option value="3">3</option> 
    <option value="2">2</option> 
    <option value="1">1</option> 
    </select> 
    <br/> 
    <input type="submit" value="submit" name="get_thread" /> 
    </form> 
    <?php 
     
} else if(!isset($_POST['download'])) { 

    $display = new display_images(); 
    $display -> url = $_POST['link']; 
    $display -> d_img_form();  
     
} else { 

    $downloader = new image_downloader(); 
    $downloader -> save_file();  

} 
?>
Yes, mine has the same error.
 
duck you, I'm a dragon
Loyal Member
Joined
Apr 29, 2005
Messages
6,407
Reaction score
130
I think 4chan changed it's source code around a bit because the script doesn't seem to work anymore. I'll try to fix it as soon as possible.
 
Back
Top