Browse Source

PURGE other hostnames

pull/40/head
Savetheinternet 12 years ago
parent
commit
d4aff84741
  1. 1
      inc/config.php
  2. 4
      inc/functions.php

1
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;

4
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);

Loading…
Cancel
Save