Example #1
0
/**
 * Call the cache server to purge the cache with Varnish HTTP Purge.
 *
 * @since 2.5.5
 *
 * @return void
 */
function rocket_clean_varnish_http_purge()
{
    if (class_exists('VarnishPurger')) {
        $purger = new VarnishPurger();
        $purger->executePurge();
    }
}
Example #2
0
if (isset($_REQUEST['urllist'])) {
    $lines = explode("\n", $_REQUEST['urllist']);
    if (!empty($lines)) {
        foreach ($lines as $line) {
            if (trim($line)) {
                $purge_urls[] = '/' . preg_replace('/^https?:\\/\\/.*\\//U', '', trim($line));
            }
        }
    }
}
if (isset($_REQUEST['regex'])) {
    $regex = trim($_REQUEST['regex']);
    if ($regex) {
        $purge_reg = $regex;
    }
}
$vp = VarnishPurger::Instance();
if (!empty($purge_urls)) {
    foreach ($purge_urls as $url) {
        $vp->purge($url);
    }
}
if ($purge_reg) {
    $vp->purge($purge_reg, true);
}
$tpl->setVariable('purged_urls', $purge_urls);
$tpl->setVariable('purged_reg', $purge_reg);
$Result = array();
$Result['content'] = $tpl->fetch("design:modules/varnish/main.tpl");
$Result['left_menu'] = false;
$Result['path'] = array(array('url' => false, 'text' => 'Varnish'), array('url' => false, 'text' => 'Main'));
 /**
  *
  */
 static function purgeList()
 {
     $ini_varnish = eZINI::instance('mugo_varnish.ini');
     $maxBanRequests = $ini_varnish->variable('VarnishSettings', 'MaxBanRequests');
     // Calculate max limit
     $limit = count(self::$urlsToPurge);
     if ($maxBanRequests) {
         if (count(self::$urlsToPurge) > $maxBanRequests) {
             $limit = $maxBanRequests;
             eZDebug::writeWarning('Maximal ban requests limit exceeded.', 'mugovarnish-general');
         } else {
             $limit = count(self::$urlsToPurge);
         }
     }
     $urlsToPurgeLimited = array_slice(self::$urlsToPurge, 0, $limit);
     // Call purger to do the job
     $purger = VarnishPurger::Instance();
     if ($ini_varnish->variable('VarnishSettings', 'UseCurlMultiHandler') == 'enabled') {
         $purger->purgeList($urlsToPurgeLimited);
     } else {
         foreach ($urlsToPurgeLimited as $url) {
             $purger->purge($url);
         }
     }
 }