Skip to content

Instantly share code, notes, and snippets.

@mudkipme
Created July 10, 2013 17:47
Show Gist options
  • Save mudkipme/5968486 to your computer and use it in GitHub Desktop.
Save mudkipme/5968486 to your computer and use it in GitHub Desktop.
<?php
header('Content-Length: 0');
$key = array();
$base = urldecode($_SERVER['REQUEST_URI']);
$base_ori = $_SERVER['REQUEST_URI'];
$key[] = $base;
$key[] = $base.'zh';
$key[] = $base.'zh-hans';
$key[] = $base.'zh-hant';
if (strpos($base, '/wiki/') !== FALSE) {
$key[] = str_replace('/wiki/', '/zh/', $base);
$key[] = str_replace('/wiki/', '/zh-hans/', $base);
$key[] = str_replace('/wiki/', '/zh-hant/', $base);
}
$key[] = $base_ori;
$key[] = $base_ori.'zh';
$key[] = $base_ori.'zh-hans';
$key[] = $base_ori.'zh-hant';
foreach ($key as $u) {
$k = md5($u);
$filename = '/var/cache/nginx/wiki/'.substr($k, -2).'/'.substr($k, -4, 2).'/'.$k;
if (file_exists($filename)) {
if (unlink($filename)) {
file_put_contents('/home/52poke/logs/wiki-purge.log', 'Purge '.$k.' '.$u.' '.date(DATE_ATOM)."\n", FILE_APPEND);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment