function shrinktheweb_checkWebsiteThumbnailCaptured in ShrinkTheWeb 7
Same name and namespace in other branches
- 8 shrinktheweb.api.inc \shrinktheweb_checkWebsiteThumbnailCaptured()
- 6 shrinktheweb.api.inc \shrinktheweb_checkWebsiteThumbnailCaptured()
Method that checks if the thumbnail for the specified website exists
1 call to shrinktheweb_checkWebsiteThumbnailCaptured()
- shrinktheweb_getCachedThumbnail in ./
shrinktheweb.api.inc - Get a thumbnail, caching it first if possible
File
- ./
shrinktheweb.api.inc, line 306
Code
function shrinktheweb_checkWebsiteThumbnailCaptured($aArgs) {
$sRequestUrl = PROTOCOL . 'images.shrinktheweb.com/xino.php';
$sRemoteData = shrinktheweb_fileGetContent($sRequestUrl, $aArgs);
// check if we get no response or the maintenance string
if ($sRemoteData == '' || $sRemoteData == 'offline') {
$aImage = array(
'status' => 'no_response',
);
if ($sRemoteData != '') {
$aImage['message'] = MAINTENANCE;
}
}
else {
$aResponse = shrinktheweb_getXMLResponse($sRemoteData);
// thumbnail is existing, download it
if ($aResponse['exists'] && $aResponse['thumbnail'] != '') {
$aImage = array(
'status' => 'save',
'url' => $aResponse['thumbnail'],
);
// bandwidth limit has reached, grab embedded image and store it as BANDWIDTH_IMAGE
}
else {
if ($aResponse['stw_bandwidth_remaining'] == 0 && !$aResponse['locked'] && !$aResponse['invalid'] && !$aResponse['exists'] && !$aResponse['problem']) {
$aImage = array(
'status' => 'bandwidth_exceed',
'url' => $aResponse['thumbnail'],
);
// quota limit has reached, grab embedded image and store it as QUOTA_IMAGE
}
else {
if ($aResponse['stw_quota_remaining'] == 0 && !$aResponse['locked'] && !$aResponse['invalid'] && !$aResponse['exists'] && !$aResponse['problem']) {
$aImage = array(
'status' => 'quota_exceed',
'url' => $aResponse['thumbnail'],
);
// an error has occured, return the url but dont save the image
}
else {
if (!$aResponse['exists'] && $aResponse['thumbnail'] != '') {
$aImage = array(
'status' => 'nosave',
'url' => $aResponse['thumbnail'],
);
// otherwise return error because we dont know the situation
}
else {
$aImage = array(
'status' => 'error',
);
}
}
}
}
// add the request to the database if debug is enabled
if (DEBUG) {
$aArgs['stwq'] = isset($aArgs['stwq']) ? $aArgs['stwq'] : 95;
$aArgs['stwfull'] = isset($aArgs['stwfull']) ? $aArgs['stwfull'] : 0;
$aArgs['stwxmax'] = isset($aArgs['stwxmax']) ? $aArgs['stwxmax'] : (isset($stwxmax) ? $stwxmax : 0);
$aArgs['stwymax'] = isset($aArgs['stwymax']) ? $aArgs['stwymax'] : (isset($stwymax) ? $stwymax : 0);
$aArgs['stwnrx'] = isset($aArgs['stwnrx']) ? $aArgs['stwnrx'] : 1024;
$aArgs['stwnry'] = isset($aArgs['stwnry']) ? $aArgs['stwnry'] : 768;
$sHash = shrinktheweb_generateHash($aArgs);
$aFields = array(
'stw_domain' => $aArgs['stwurl'],
'stw_timestamp' => time(),
'stw_capturedon' => $aResponse['stw_last_captured'],
'stw_quality' => $aArgs['stwq'],
'stw_full' => $aArgs['stwfull'],
'stw_xmax' => $aArgs['stwxmax'],
'stw_ymax' => $aArgs['stwymax'],
'stw_nrx' => $aArgs['stwnrx'],
'stw_nry' => $aArgs['stwnry'],
'stw_invalid' => $aResponse['invalid'] != '' ? $aResponse['invalid'] : 0,
'stw_stwerrcode' => $aResponse['stw_response_code'],
'stw_error' => $aResponse['error'] != '' ? $aResponse['error'] : 0,
'stw_errcode' => $aResponse['stw_response_status'],
'stw_hash' => $sHash,
);
db_merge('shrinktheweb_log')
->key(array(
'stw_hash' => $sHash,
))
->fields($aFields)
->updateFields($aFields)
->execute();
}
}
return $aImage;
}