}
// output feed
debug('Done!');
/*
if ($debug_mode) {
	$_apc_data = apc_cache_info('user');
	var_dump($_apc_data); exit;
}
*/
if (!$debug_mode) {
    if ($callback) {
        echo "{$callback}(";
    }
    // if $callback is set, $format also == 'json'
    if ($format == 'json') {
        $output->setFormat($callback === null ? JSON : JSONP);
    }
    $add_to_cache = $options->caching === true;
    // is smart cache mode enabled?
    if ($add_to_cache && $options->apc === true && $options->smart_cache === true) {
        // yes, so only cache if this is the second request for this URL
        $add_to_cache = $apc_cache_hits >= 2;
        // purge cache
        if ($options->cache_cleanup > 0) {
            if (rand(1, $options->cache_cleanup) == 1) {
                // apc purge code adapted from from http://www.thimbleopensource.com/tutorials-snippets/php-apc-expunge-script
                $_apc_data = apc_cache_info('user');
                foreach ($_apc_data['cache_list'] as $_apc_item) {
                    if ($_apc_item['ttl'] > 0 && $_apc_item['ttl'] + $_apc_item['creation_time'] < time()) {
                        apc_delete($_apc_item['info']);
                    }
예제 #2
0
                }
                if ($enclosure->get_language()) {
                    $enc['lang'] = $enclosure->get_language();
                }
                $newitem->addElement('media:content', '', $enc);
            }
        }
    }
    /* } */
    $output->addItem($newitem);
    unset($html);
    $item_count++;
}
// output feed
if ($format == 'json') {
    $output->setFormat(JSON);
}
if ($options->caching) {
    ob_start();
    $output->genarateFeed();
    $output = ob_get_contents();
    ob_end_clean();
    if ($html_only && $item_count == 0) {
        // do not cache - in case of temporary server glitch at source URL
    } else {
        $cache->save($output, $cache_id);
    }
    echo $output;
} else {
    $output->genarateFeed();
}