SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | /* | |
| 3 | || // || Script By: Seff Preston | |
| 4 | || // || // || Script Premise: If U Seek Amy | |
| 5 | || // || // || ~some informational assistance from Nymph | |
| 6 | - | || // || // || |
| 6 | + | || // || // || ~Updated for 2016 by Erin |
| 7 | || // ||))))) // || Special Thank you to the circlejerks | |
| 8 | || // || )) // || ~You make my kokoro go doki doki | |
| 9 | || // || )) // || | |
| 10 | || // || )) // || P.S. | |
| 11 | || // || )) // || I love you for making the API Mootykins | |
| 12 | || // |||||)) // || Now, just give peace a chance? | |
| 13 | |*/ | |
| 14 | //set available boards | |
| 15 | - | $bArray = array("a","b","c","d","e","g","gif","h","hr","k","m","o","p","r","s","t","u","v","vg","w","wg","i","ic","r9k","cm","hm","y","3","adv","an","cgl","ck","co","diy","fa","fit","hc","int","jp","lit","mlp","mu","n","po","pol","sci","soc","sp","tg","toy","trv","tv","vp","wsg","x");
|
| 15 | + | $bArray = array("3","a","aco","adv","an","asp","b","biz","c","cgl","ck","cm","co","d","diy","e","f","fa","fit","g","gd","gif","h","hc","his","hm","hr","i","ic","int","jp","k","lgbt","lit","m","mlp","mu","n","news","o","out","p","po","pol","qa","r","r9k","s","s4s","sci","soc","sp","t","tg","toy","trash","trv","tv","u","v","vg","vp","vr","w","wg","wsg","wsr","x","y");
|
| 16 | ||
| 17 | if(!isset($_POST['id'])) | |
| 18 | {
| |
| 19 | //Thread Insert Form | |
| 20 | ?> | |
| 21 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
| 22 | <html xmlns="http://www.w3.org/1999/xhtml"> | |
| 23 | <head> | |
| 24 | <title>Seff's Image Catcher</title> | |
| 25 | <meta http-equiv="content-type" content="text/html;charset=utf-8" /> | |
| 26 | </head> | |
| 27 | <body> | |
| 28 | - | <form name="imageCatcher" action="SID.php" method="POST"> |
| 28 | + | <form name="imageCatcher" method="POST"> |
| 29 | Select a Board:<br/> | |
| 30 | <select name="board"> | |
| 31 | <?php | |
| 32 | foreach($bArray as $b) | |
| 33 | {
| |
| 34 | echo("<option value=\"$b\">$b</option>");
| |
| 35 | } | |
| 36 | ?> | |
| 37 | </select><br/><br/> | |
| 38 | Image ID with extension (ex: 1363032507873.png):<br/> | |
| 39 | <input type="text" name="id" /><br/><br/> | |
| 40 | Number of copies (default 1):<br/> | |
| 41 | <input type="text" name="copies" /><br/><br/> | |
| 42 | <input type="submit" value="Submit"> | |
| 43 | </form> | |
| 44 | </body> | |
| 45 | </html> | |
| 46 | <?php | |
| 47 | } else {
| |
| 48 | ||
| 49 | //clean input data with regular expressions | |
| 50 | $board = preg_replace("/[^a-z]/", "", strtolower($_POST['board']));
| |
| 51 | $id = preg_replace("/[^0-9a-z\.]/","", $_POST['id']);
| |
| 52 | $copies = preg_replace("/[^0-9]/","", $_POST['copies']);
| |
| 53 | if($copies > 100){ $copies = 100; }
| |
| 54 | if($copies < 1){ $copies = 1; }
| |
| 55 | if(!is_numeric($copies)){ $copies = 1; }
| |
| 56 | ||
| 57 | //set the thread url to load | |
| 58 | - | $url = "http://images.4chan.org/$board/src/$id"; |
| 58 | + | $url = "http://i.4cdn.org/$board/$id"; |
| 59 | ||
| 60 | //load the thread from the 4chan api, @ supresses any errors | |
| 61 | $image = @file_get_contents($url); | |
| 62 | if($image === false){ echo("Unable to load the image"); } else {
| |
| 63 | ||
| 64 | //create an image resource | |
| 65 | $original = imagecreatefromstring($image); | |
| 66 | ||
| 67 | //repeat the following actions for each image | |
| 68 | for($i=0; $i<$copies; $i++) | |
| 69 | {
| |
| 70 | ||
| 71 | //generate a copy of the same image resource | |
| 72 | $copy = imagecreatetruecolor(imagesx($original), imagesy($original)); | |
| 73 | imagesavealpha($copy, true); | |
| 74 | ||
| 75 | //make the background transparent | |
| 76 | $trans_color = imagecolorallocatealpha($copy, 0, 0, 0, 127); | |
| 77 | imagefill($copy, 0, 0, $trans_color); | |
| 78 | ||
| 79 | //give the image a random height/width | |
| 80 | $height1 = imagesy($original); | |
| 81 | $height2 = imagesy($original)+rand(1,5); | |
| 82 | $width1 = imagesx($original); | |
| 83 | $width2 = imagesx($original)+rand(1,5); | |
| 84 | //copy the original image into the copy resource with the new proportions | |
| 85 | imagecopyresized($copy,$original,0,0,0,0,$width2,$height2,$width1,$height1); | |
| 86 | ||
| 87 | //repeat the following actions for each modification of the image | |
| 88 | for($j=0; $j<=250; $j++) | |
| 89 | {
| |
| 90 | //generate random coordinates for pixel replacement | |
| 91 | $pixelx = rand(0, imagesx($copy)); | |
| 92 | $pixely = rand(0, imagesy($copy)); | |
| 93 | ||
| 94 | //retrieve the current rgb values of that coordinate and modify them | |
| 95 | $rgb = imagecolorat($copy, $pixelx, $pixely); | |
| 96 | $r = ($rgb >> 16) & 0xFF; $r += rand(-5, 5); | |
| 97 | $g = ($rgb >> 8) & 0xFF; $g += rand(-5, 5); | |
| 98 | $b = $rgb & 0xFF; $b += rand(-5, 5); | |
| 99 | ||
| 100 | //clean the rgb values | |
| 101 | if($r > 255) { $r=255; } if($g > 255) { $g=255; } if($b > 255) { $b=255; }
| |
| 102 | if($r < 0) { $r = 0; } if($g < 0) { $g = 0; } if($b < 0) { $b = 0; }
| |
| 103 | ||
| 104 | //insert modified pixel color | |
| 105 | $color = imagecolorallocate($copy, $r, $g, $b); | |
| 106 | ||
| 107 | //modify a random pixel of the image copy | |
| 108 | imagesetpixel($copy, $pixelx, $pixely, $color); | |
| 109 | ||
| 110 | } | |
| 111 | ||
| 112 | //start buffering to cature image data | |
| 113 | ob_start(); | |
| 114 | //generate the image as a png | |
| 115 | imagepng($copy); | |
| 116 | //capture the image | |
| 117 | $contents = ob_get_contents(); | |
| 118 | //end buffering | |
| 119 | ob_end_clean(); | |
| 120 | //output the image | |
| 121 | echo "<img src='data:image/png;base64,".base64_encode($contents)."' />"; | |
| 122 | //clean the image | |
| 123 | imagedestroy($copy); | |
| 124 | ||
| 125 | } | |
| 126 | } | |
| 127 | } | |
| 128 | ?> |