Esempio n. 1
0
function _xCronGrabThumbs()
{
    global $start;
    CronAppendLog(FILE_LOG_GRABBER, 'Grabber starting...', true);
    require_once 'dirdb.php';
    $db = new TradeDB();
    foreach ($db->RetrieveAll() as $trade) {
        if ($trade['flag_grabber']) {
            if (string_is_empty($trade['grabber_url'])) {
                $trade['grabber_url'] = $trade['return_url'];
            }
            $thumbnails = grab_thumbs($trade['domain'], $trade['grabber_url'], $trade['trigger_strings']);
            switch ($thumbnails) {
                case null:
                    CronAppendLog(FILE_LOG_GRABBER, 'Thumbnails could not be downloaded from ' . $trade['domain']);
                    break;
                case 0:
                    CronAppendLog(FILE_LOG_GRABBER, 'HTTP connection for ' . $trade['domain'] . ' has failed');
                    break;
                default:
                    $db->Update($trade['domain'], array('thumbnails' => $thumbnails));
                    break;
            }
        }
    }
    CronAppendLog(FILE_LOG_GRABBER, 'Grabber exiting...', true);
}
Esempio n. 2
0
function _xGrabThumbs()
{
    require_once 'dirdb.php';
    $db = new TradeDB();
    $trade = $db->Retrieve($_REQUEST['trade']);
    if ($trade['flag_grabber']) {
        if (string_is_empty($trade['grabber_url'])) {
            $trade['grabber_url'] = $trade['return_url'];
        }
        $thumbnails = grab_thumbs($trade['domain'], $trade['grabber_url'], $trade['trigger_strings']);
        switch ($thumbnails) {
            case null:
                JSON::Warning('Thumbnails could not be downloaded from ' . $trade['domain']);
                break;
            case 0:
                JSON::Warning('HTTP connection for ' . $trade['domain'] . ' has failed');
                break;
            default:
                $db->Update($_REQUEST['trade'], array('thumbnails' => $thumbnails));
                $html = '';
                for ($i = 1; $i <= $thumbnails; $i++) {
                    $html .= '<img src="../thumbs/' . $trade['domain'] . '-' . $i . '.jpg?' . mt_rand() . '" />';
                }
                JSON::Success(array(JSON_KEY_MESSAGE => 'Thumbnails have been successfully grabbed. Total: ' . $thumbnails, JSON_KEY_HTML => $html, JSON_KEY_ITEM_ID => $trade['domain']));
                break;
        }
    } else {
        JSON::Warning($trade['domain'] . ' does not have the "Grab thumbs" option enabled');
    }
}