function __perform_refresh_thumbnails_batch()
 {
     if ($this->_batchlimit > 0) {
         $results = fetch_file_cache_rs('ITEM');
         if ($results) {
             while ($file_cache_r = db_fetch_assoc($results)) {
                 // its not a case of only a thumbnail, if not even the source exists
                 if (file_cache_get_cache_file($file_cache_r) !== FALSE && file_cache_get_cache_file_thumbnail($file_cache_r) === FALSE) {
                     // in this case we want to refresh the URL, so TRUE as last parameter idicates overwrite
                     if (file_cache_save_thumbnail_file($file_cache_r, $errors)) {
                         $this->_processed++;
                     } else {
                         $this->_failures++;
                     }
                     // don't process anymore this time around.
                     if ($this->_processed >= $this->_batchlimit) {
                         break;
                     }
                 }
             }
             db_free_result($results);
         }
     }
     $this->_remaining = fetch_file_cache_missing_thumbs_cnt('ITEM');
 }
Beispiel #2
0
     $HTTP_VARS['order_by'] = 'cache_date';
 }
 $listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS);
 $listingObject->setNoRowsMessage(get_opendb_lang_var('no_items_found'));
 $listingObject->startListing();
 $listingObject->addHeaderColumn('URL', 'url');
 $listingObject->addHeaderColumn('Cached', 'cache_date');
 $listingObject->addHeaderColumn('Expires', 'expire_date');
 if (is_numeric($listingObject->getItemsPerPage())) {
     $listingObject->setTotalItems(fetch_file_cache_cnt($HTTP_VARS['cache_type']));
 }
 $results = fetch_file_cache_rs($HTTP_VARS['cache_type'], $listingObject->getCurrentOrderBy(), $listingObject->getCurrentSortOrder(), $listingObject->getStartIndex(), $listingObject->getItemsPerPage());
 if ($results) {
     while ($file_cache_r = db_fetch_assoc($results)) {
         $listingObject->startRow();
         if (file_cache_get_cache_file($file_cache_r)) {
             $popupUrl = "url.php?id=" . $file_cache_r['sequence_number'];
             $listingObject->addColumn("<a href=\"" . $file_cache_r['url'] . "\" onclick=\"popup('{$popupUrl}'); return false;\" target=\"_new\">" . get_overflow_tooltip_column($file_cache_r['url'], 100) . "</a>");
         } else {
             $listingObject->addColumn(get_overflow_tooltip_column($file_cache_r['url'], 100));
         }
         $listingObject->addColumn(get_localised_timestamp(get_opendb_config_var('http', 'datetime_mask'), $file_cache_r['cache_date']));
         $column = '';
         if ($file_cache_r['expired_ind'] == 'Y') {
             $column .= "<span class=\"error\">";
         }
         if ($file_cache_r['expire_date'] != NULL) {
             $column .= get_localised_timestamp(get_opendb_config_var('http', 'datetime_mask'), $file_cache_r['expire_date']);
         } else {
             $column .= "NA";
         }
 function get_cached_image($url)
 {
     $file_cache_r = fetch_url_file_cache_r($url, 'ITEM', INCLUDE_EXPIRED);
     if ($file_cache_r != FALSE) {
         //$imagefile = file_cache_get_cache_file_thumbnail($file_cache_r);
         $imagefile = file_cache_get_cache_file($file_cache_r);
         if ($imagefile != FALSE) {
             return $imagefile;
         }
     }
     //else
     return NULL;
 }
Beispiel #4
0
 function &fetchURI($URI, $http_cache = TRUE)
 {
     @set_time_limit(600);
     $URI = trim($URI);
     $this->__debug('fetchURI', "URI: {$URI}");
     $this->_file_cache_r = NULL;
     $overwrite_cache_entry = FALSE;
     if ($http_cache !== FALSE && $this->_file_cache_enabled) {
         // see if we can find the cache file.
         $this->_file_cache_r = fetch_url_file_cache_r($URI, 'HTTP');
         if ($this->_file_cache_r !== FALSE) {
             $file_location = file_cache_get_cache_file($this->_file_cache_r);
             if ($file_location !== FALSE) {
                 $this->_file_cache_r['content'] = file_get_contents($file_location);
                 if (strlen($this->_file_cache_r['content']) == 0) {
                     $this->__debug('fetchURI', 'URL cache invalid');
                     $overwrite_cache_entry = TRUE;
                     unset($this->_file_cache_r);
                 }
             } else {
                 unset($this->_file_cache_r);
             }
         }
     }
     if (is_not_empty_array($this->_file_cache_r)) {
         $this->__debug('fetchURI', 'URL cached');
         return $this->_file_cache_r['content'];
     } else {
         $this->__debug('fetchURI', 'URL NOT cached');
         if ($this->fetch($URI) && $this->status >= 200 && $this->status < 300) {
             opendb_logger(OPENDB_LOG_INFO, __FILE__, __FUNCTION__, NULL, array($URI));
             $this->_file_cache_r['url'] = $URI;
             $this->_file_cache_r['content'] = $this->results;
             $this->results = NULL;
             if (strlen($this->_file_cache_r['content']) > 0) {
                 $this->__debug('fetchURI', 'URL fetched (Size=' . strlen($this->_file_cache_r['content']) . ')');
                 // assume a default.
                 $this->_file_cache_r['content_type'] = 'text/html';
                 if (is_array($this->headers) && count($this->headers) > 0) {
                     for ($i = 0; $i < count($this->headers); $i++) {
                         if (preg_match("/^([^:]*):([^\$]*)\$/i", $this->headers[$i], $matches)) {
                             if (strcasecmp(trim($matches[1]), 'content-type') === 0) {
                                 $this->_file_cache_r['content_type'] = trim($matches[2]);
                                 break;
                             }
                         }
                     }
                 }
                 $this->_file_cache_r['location'] = $this->lastredirectaddr;
                 if ($http_cache !== FALSE && $this->_file_cache_enabled) {
                     if (file_cache_insert_file($this->_file_cache_r['url'], $this->_file_cache_r['location'], $this->_file_cache_r['content_type'], $this->_file_cache_r['content'], 'HTTP', $overwrite_cache_entry) !== FALSE) {
                         $this->__debug('fetchURI', "Added {$URI} to file cache");
                     } else {
                         $this->__debug('fetchURI', "Failed to add {$URI} to file cache");
                     }
                 }
                 //if($http_cache!==FALSE && $this->_file_cache_enabled)
             }
             //if(strlen($_file_cache_r['content'])>0)
             return $this->_file_cache_r['content'];
         } else {
             $this->__debug('fetchURI', "Failed to fetch {$URI}", ifempty($this->error, 'Status ' . $this->status));
             opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, ifempty($this->error, 'Status ' . $this->status), array($URI));
             return FALSE;
         }
     }
 }
Beispiel #5
0
function file_cache_delete_orphans($cache_type = 'HTTP')
{
    $results = fetch_file_cache_rs($cache_type);
    if ($results) {
        while ($file_cache_r = db_fetch_assoc($results)) {
            // where file does not exist, delete it.
            if (!file_cache_get_cache_file($file_cache_r)) {
                delete_file_cache($file_cache_r);
            }
        }
    }
    return TRUE;
}