Exemple #1
0
 * License.
 *
 * Modified by Jeffrey S. Haemer <*****@*****.**>
 */
error_reporting(E_ALL);
require_once 'AWSSDKforPHP/sdk.class.php';
require_once 'include/book.inc.php';
// Make sure that at least one argument was given
if ($argc < 2) {
    exit('Usage: ' . $argv[0] . " URL...\n");
}
// Create the SQS access object
$sqs = new AmazonSQS();
$res = $sqs->create_queue(URL_QUEUE);
if ($res->isOK()) {
    $queueURL = urlFromQueueObject($res);
}
// Load each URL
for ($i = 1; $i < $argc; $i++) {
    // Create message
    $histItem = array('Posted by ' . $argv[0] . ' at ' . date('c'));
    $message = json_encode(array('Action' => 'FetchPage', 'Origin' => $argv[0], 'Data' => $argv[$i], 'History' => $histItem));
    // Post message
    $res = $sqs->send_message($queueURL, $message);
    if ($res->isOK()) {
        print "Posted '{$message}' to queue " . URL_QUEUE . "\n";
    } else {
        $error = $res->body->Error->Message;
        print "Could not post message to queue: {$error}\n";
    }
}
Exemple #2
0
$bucket = $argv[1] == '-' ? BOOK_BUCKET : $argv[1];
// Define image layout constants
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();
// 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;
Exemple #3
0
 * or in the "license.txt" file accompanying this file. This file is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
 * OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the
 * License.
 *
 * Modified by Jeffrey S. Haemer <*****@*****.**>
 */
error_reporting(E_ALL);
require_once 'AWSSDKforPHP/sdk.class.php';
require_once 'include/book.inc.php';
// Create the feed queue, if necessary, and grab its URL
$sqs = new AmazonSQS();
$res = $sqs->create_queue(FEED_QUEUE);
if ($res->isOK()) {
    $feedQueueUrl = urlFromQueueObject($res);
}
// Make sure that at least one argument was given
if ($argc < 2) {
    exit('Usage: ' . $argv[0] . " [URL] [-f FILE] ...\n");
}
// Create the SQS access object
$sqs = new AmazonSQS();
// Process each argument
for ($i = 1; $i < $argc; $i++) {
    if ($argv[$i] == '-f') {
        $urls = file($argv[++$i]);
        foreach ($urls as $url) {
            loadURL($sqs, $feedQueueUrl, trim($url));
        }
    } else {
Exemple #4
0
require_once 'include/book.inc.php';
if ($argc != 2) {
    exit("Usage: " . $argv[0] . " bucket name\n");
}
$bucket = $argv[1] == '-' ? BOOK_BUCKET : $argv[1];
// 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
Exemple #5
0
 */
error_reporting(E_ALL);
require_once 'AWSSDKforPHP/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();
// 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();