PURGE other hostnames

This commit is contained in:
Savetheinternet 2011-05-22 01:19:06 +10:00
parent 41c2b29a55
commit d4aff84741
2 changed files with 4 additions and 1 deletions

View File

@ -665,6 +665,7 @@
// you can configure Tinyboard to PURGE files when they're written to // you can configure Tinyboard to PURGE files when they're written to
//$config['purge'] = Array( //$config['purge'] = Array(
// Array('127.0.0.1', 80) // Array('127.0.0.1', 80)
// Array('127.0.0.1', 80, 'example.org')
//); //);
// Connection timeout, in seconds // Connection timeout, in seconds
$config['purge_timeout'] = 3; $config['purge_timeout'] = 3;

View File

@ -221,11 +221,13 @@
function purge($uri) { function purge($uri) {
global $config; global $config;
$uri = (str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) == '/' ? '/' : str_replace('\\', '/', dirname($_SERVER['REQUEST_URI'])) . '/') . $uri; $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) { foreach($config['purge'] as &$purge) {
$host = $purge[0]; $host = $purge[0];
$port = $purge[1]; $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'])) { if($fp = fsockopen($host, $port, $errno, $errstr, $config['purge_timeout'])) {
fwrite($fp, $request); fwrite($fp, $request);
fclose($fp); fclose($fp);