enable_cache(false); $feed->enable_order_by_date(); $feed->set_feed_url($urls); $feed->init(); $feed->handle_content_type(); foreach($feed->get_items() as $i) { $html = $i->get_description(); if (strlen($html) == 0) { $html = $i->get_content(); } preg_match('/src="(.*)"(.*)>/', $html, $matches); $parts = preg_split('/\"/', $matches[1]); $list[] = $parts[0]; } if (count($list) == 0) { return false; } return $list; } function initializeArray(&$area) { for($y = 0; $y < MAX_H; $y++) { for($x = 0; $x < MAX_W; $x++) { $area[$y][$x] = "0"; } } } function fillinArray(&$area, $img=null) { $yend = 0; $xend = 0; $lasty = $img['y'] + $img['h']; if ($lasty >= MAX_H) { $yend = MAX_H; } else { $yend = $lasty; } $lastx = $img['x'] + $img['w']; if ($lastx >= MAX_W) { $xend = MAX_W; } else { $xend = $lastx; } for($y = $img['y']; $y < $yend; $y++) { for($x = $img['x']; $x < $xend; $x++) { $area[$y][$x] = "1"; } } } function totalArray(&$area) { $total = 0; for($y = 0; $y < MAX_H; $y++) { for($x = 0; $x < MAX_W; $x++) { $total += $area[$y][$x]; } } return $total; } function findFirstBlank(&$area) { $coords = array('x' => 0, 'y' => 0); for($y = 0; $y < MAX_H; $y++) { for($x = 0; $x < MAX_W; $x++) { if ($area[$y][$x] == "0") { $coords['y'] = $y; $coords['x'] = $x; return $coords; } } } } function noDuplicateUrl(&$pics, &$used) { $count_check = 0; $url = $pics[rand(0, count($pics)-1)]; while (in_array($url, $used)) { $url = $pics[rand(0, count($pics)-1)]; $count_check++; if ($count_check > 100) { break; } } $used[] = $url; return $url; } function main($urls=null) { if ($urls == null || count($urls) == 0) { PikachoorError("No urls given."); } $pics = fetchImageList($urls); if ($pics == false) { PikachoorError("No urls."); } $total = 0; $used = array(); $area = array(); initializeArray($area); $baseimg = imagecreatetruecolor(MAX_W, MAX_H); $bg = imagecolorallocate($baseimg, 0xFF, 0xFF, 0xFF); imagefill($baseimg, 0, 0, $bg); while ($total < AREA) { $img = getImage($baseimg, $area, noDuplicateUrl($pics, $used)); fillinArray($area, $img); $total = totalArray($area); } imagedestroy($baseimg); printf("Your collage is: %s\n", THE_FILE); } // Starts the program main(array("http://backend.deviantart.com/rss.xml?q=boost%3Apopular+pinkie%20pie&type=deviation", "http://feed.photobucket.com/images/pinkie+pie/feed.rss")); ?>