define('BORDER_BOTTOM', 12); define('IMAGES_ACROSS', 4); define('IMAGES_DOWN', 4); define('GAP_SIZE', 6); // Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Convert the queuenames to URLs $res = $sqs->create_queue(RENDER_QUEUE); if ($res->isOK()) { $renderQueueURL = urlFromQueueObject($res); } // Pull, process while (true) { // Pull the message from the queue $message = pullMessage($sqs, $renderQueueURL); if ($message != null) { // Extract message detail $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $imageKeys = $messageDetail['Data']; $pageTitle = $messageDetail['PageTitle']; print "Processing message with " . count($imageKeys) . " images:\n"; // Create destination image $outX = BORDER_LEFT + BORDER_RIGHT + IMAGES_ACROSS * THUMB_SIZE + (IMAGES_ACROSS - 1) * GAP_SIZE; $outY = BORDER_TOP + BORDER_BOTTOM + IMAGES_DOWN * THUMB_SIZE + (IMAGES_DOWN - 1) * GAP_SIZE; $imageOut = ImageCreateTrueColor($outX, $outY); // Paint the image white ImageFill($imageOut, 0, 0, ImageColorAllocate($imageOut, 255, 255, 255)); // Draw a border in destination image ImageRectangle($imageOut, 0, 0, $outX - 1, $outY - 1, ImageColorAllocate($imageOut, 0, 0, 0));
define('BORDER_LEFT', 12); define('BORDER_RIGHT', 12); define('BORDER_TOP', 12); define('BORDER_BOTTOM', 12); define('IMAGES_ACROSS', 4); define('IMAGES_DOWN', 4); define('GAP_SIZE', 6); // Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Get the queue URL $queueURL_Render = $sqs->create_queue(RENDER_QUEUE)->body->CreateQueueResult->QueueUrl; // Pull, process while (true) { // Pull the message from the queue $message = pullMessage($sqs, $queueURL_Render); if ($message != null) { // Extract message detail $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $imageKeys = $messageDetail['Data']; $pageTitle = $messageDetail['PageTitle']; print "Processing message with " . count($imageKeys) . " images:\n"; // Create destination image $outX = BORDER_LEFT + BORDER_RIGHT + IMAGES_ACROSS * THUMB_SIZE + (IMAGES_ACROSS - 1) * GAP_SIZE; $outY = BORDER_TOP + BORDER_BOTTOM + IMAGES_DOWN * THUMB_SIZE + (IMAGES_DOWN - 1) * GAP_SIZE; $imageOut = ImageCreateTrueColor($outX, $outY); // Paint the image white ImageFill($imageOut, 0, 0, ImageColorAllocate($imageOut, 255, 255, 255)); // Draw a border in destination image ImageRectangle($imageOut, 0, 0, $outX - 1, $outY - 1, ImageColorAllocate($imageOut, 0, 0, 0));
* License. */ error_reporting(E_ALL); require_once 'sdk.class.php'; require_once 'include/simple_html_dom.php'; require_once 'include/book.inc.php'; // Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Get the Queue URLs $queueURL_Parse = $sqs->create_queue(PARSE_QUEUE)->body->CreateQueueResult->QueueUrl; $queueURL_Image = $sqs->create_queue(IMAGE_QUEUE)->body->CreateQueueResult->QueueUrl; // Pull, process, post while (true) { // Pull the message from the queue $message = pullMessage($sqs, $queueURL_Parse); if ($message != null) { // Extract message detail $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $pageURL = $messageDetail['Data']; // Fetch and parse the page print "Processing URL '{$pageURL}':\n"; $dom = new simple_html_dom(); $dom->load_file($pageURL); // Get the page title $pageTitle = $dom->find('title', 0)->innertext(); print " Retrieved page '{$pageTitle}'\n"; // Capture up to 16 image URLs $imageURLs = array(); foreach ($dom->find('img') as $image) {
* specific language governing permissions and limitations under the * License. */ error_reporting(E_ALL); require_once 'sdk.class.php'; require_once 'include/book.inc.php'; // Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Get the Queue URLs $queueURL_URL = $sqs->create_queue(URL_QUEUE)->body->CreateQueueResult->QueueUrl; $queueURL_Parse = $sqs->create_queue(PARSE_QUEUE)->body->CreateQueueResult->QueueUrl; // Pull, process, post while (true) { // Pull the message from the queue $message = pullMessage($sqs, $queueURL_URL); if ($message != null) { // Extract message detail $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $pageURL = $messageDetail['Data']; // Fetch the page print "Processing URL '{$pageURL}':\n"; $html = file_get_contents($pageURL); print " Retrieved " . strlen($html) . " bytes of HTML\n"; // Store the page in S3 $key = 'page_' . md5($pageURL) . '.html'; if (uploadObject($s3, BOOK_BUCKET, $key, $html, AmazonS3::ACL_PUBLIC)) { // Get URL in S3 $s3URL = $s3->get_object_url(BOOK_BUCKET, $key); print " Uploaded page to S3 as '{$key}'\n";
// Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Convert the queuenames to URLs $res = $sqs->create_queue(IMAGE_QUEUE); if ($res->isOK()) { $imageQueueURL = urlFromQueueObject($res); } $res = $sqs->create_queue(RENDER_QUEUE); if ($res->isOK()) { $renderQueueURL = urlFromQueueObject($res); } // Pull, process, post while (true) { // Pull the message from the queue $message = pullMessage($sqs, $imageQueueURL); if ($message != null) { // Extract message detail $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $imageURLs = $messageDetail['Data']; print "Processing message with " . count($imageURLs) . " images:\n"; // Do the work $s3ImageKeys = array(); foreach ($imageURLs as $imageURL) { // Fetch the image print " Fetch image '{$imageURL}'\n"; $image = file_get_contents($imageURL); print " Retrieved " . strlen($image) . " byte image\n"; // Create a thumbnail $imageThumb = thumbnailImage($image, 'image/png');
// Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Convert the queuenames to URLs $res = $sqs->create_queue(URL_QUEUE); if ($res->isOK()) { $urlQueueURL = urlFromQueueObject($res); } $res = $sqs->create_queue(PARSE_QUEUE); if ($res->isOK()) { $parseQueueURL = urlFromQueueObject($res); } // Pull, process, post while (true) { // Pull the message from the queue $message = pullMessage($sqs, $urlQueueURL); if ($message != null) { // Extract message detail $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $pageURL = $messageDetail['Data']; // Fetch the page print "Processing URL '{$pageURL}':\n"; $html = file_get_contents($pageURL); print " Retrieved " . strlen($html) . " bytes of HTML\n"; // Store the page in S3 $key = 'page_' . md5($pageURL) . '.html'; if (uploadObject($s3, $bucket, $key, $html, AmazonS3::ACL_PUBLIC)) { // Get URL in S3 $s3URL = $s3->get_object_url($bucket, $key, "60 seconds"); print " Uploaded page to S3 as '{$key}'\n";
// Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Convert the queuenames to URLs $res = $sqs->create_queue(PARSE_QUEUE); if ($res->isOK()) { $parseQueueURL = urlFromQueueObject($res); } $res = $sqs->create_queue(IMAGE_QUEUE); if ($res->isOK()) { $imageQueueURL = urlFromQueueObject($res); } // Pull, process, post while (true) { // Pull the message from the queue $message = pullMessage($sqs, $parseQueueURL); if ($message != null) { // Extract message detail $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $pageURL = $messageDetail['Data']; $pageURL = preg_replace('/\\?.*$/', '', $pageURL); // jsh: very questionable hack // Fetch and parse the page print "Processing URL '{$pageURL}':\n"; $dom = new simple_html_dom(); $dom->load_file($pageURL); // Get the page title $pageTitle = $dom->find('title', 0)->innertext(); print " Retrieved page '{$pageTitle}'\n"; // Capture up to 16 image URLs
* specific language governing permissions and limitations under the * License. */ error_reporting(E_ALL); require_once 'sdk.class.php'; require_once 'include/book.inc.php'; // Create the SQS and S3 access objects $sqs = new AmazonSQS(); $s3 = new AmazonS3(); // Get the Queue URLs $queueURL_Image = $sqs->create_queue(IMAGE_QUEUE)->body->CreateQueueResult->QueueUrl; $queueURL_Render = $sqs->create_queue(RENDER_QUEUE)->body->CreateQueueResult->QueueUrl; // Pull, process, post while (true) { // Pull the message from the queue $message = pullMessage($sqs, $queueURL_Image); if ($message != null) { // Extract message detail $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $imageURLs = $messageDetail['Data']; print "Processing message with " . count($imageURLs) . " images:\n"; // Do the work $s3ImageKeys = array(); foreach ($imageURLs as $imageURL) { // Fetch the image print " Fetch image '{$imageURL}'\n"; $image = file_get_contents($imageURL); print " Retrieved " . strlen($image) . " byte image\n"; // Create a thumbnail $imageThumb = thumbnailImage($image, 'image/png');
// Get list of feeds to process $urls = file(FEEDS); print "Begin processing " . count($urls) . " feeds\n"; foreach ($urls as $url) { $url = trim($url); if (updateFeed($sdb, $url)) { print $url . " - updated.\n"; } else { print $url . " - not updated.\n"; } } } // Process queue argument if ($doQueue) { while (true) { $message = pullMessage($sqs, $feedQueueUrl); if ($message != null) { $messageDetail = $message['MessageDetail']; $receiptHandle = (string) $message['ReceiptHandle']; $url = $messageDetail['FeedURL']; if (updateFeed($sdb, $url)) { print $url . " - updated.\n"; } else { print $url . " - not updated.\n"; } // Delete the message $sqs->delete_message($feedQueueUrl, $receiptHandle); } } } /*