File: /srv/admin/htdocs/purge.php
<?php
$debug = false;
$cmd = isset($_GET["all"]) ? 'PURGEALL' : 'PURGE';
$hostname = isset($_GET["host"]) ? $_GET["host"] : $_SERVER["HTTP_HOST"];
$path = isset($_GET["path"]) ? $_GET["path"] : '';
$purge_url = "http://" . $hostname . "/$path";
purgeURL( $cmd, $purge_url, $debug );
function purgeURL( $cmd, $purge_url, $debug )
{
$curlOptionList = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => $cmd,
CURLOPT_URL => $purge_url,
CURLOPT_CONNECTTIMEOUT_MS => 2000
);
$fd = false;
if( $debug == true )
{
print "\n---- Curl debug -----\n";
$fd = fopen("php://output", 'w+');
$curlOptionList[CURLOPT_VERBOSE] = true;
$curlOptionList[CURLOPT_STDERR] = $fd;
}
$curlHandler = curl_init();
curl_setopt_array( $curlHandler, $curlOptionList );
$data = curl_exec( $curlHandler );
curl_close( $curlHandler );
if( $fd !== false )
{
fclose( $fd );
}
print($data);
}
?>