From d4aff8474120cacab05f92800b8e6a6273cde385 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sun, 22 May 2011 01:19:06 +1000 Subject: [PATCH] PURGE other hostnames --- inc/config.php | 1 + inc/functions.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/config.php b/inc/config.php index b519fe1e..aca2c85c 100644 --- a/inc/config.php +++ b/inc/config.php @@ -665,6 +665,7 @@ // you can configure Tinyboard to PURGE files when they're written to //$config['purge'] = Array( // Array('127.0.0.1', 80) + // Array('127.0.0.1', 80, 'example.org') //); // Connection timeout, in seconds $config['purge_timeout'] = 3; diff --git a/inc/functions.php b/inc/functions.php index a55a9727..de483340 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -221,11 +221,13 @@ function purge($uri) { global $config; $uri = (str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) == '/' ? '/' : str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) . '/') . $uri; - $request = "PURGE {$uri} HTTP/1.0\r\nHost: {$_SERVER['HTTP_HOST']}\r\nUser-Agent: Tinyboard\r\nConnection: Close\r\n\r\n"; + foreach($config['purge'] as &$purge) { $host = $purge[0]; $port = $purge[1]; + $http_host = isset($purge[2]) ? $purge[2] : $_SERVER['HTTP_HOST']; + $request = "PURGE {$uri} HTTP/1.0\r\nHost: {$http_host}\r\nUser-Agent: Tinyboard\r\nConnection: Close\r\n\r\n"; if($fp = fsockopen($host, $port, $errno, $errstr, $config['purge_timeout'])) { fwrite($fp, $request); fclose($fp);