]> git.openstreetmap.org Git - nominatim.git/blob - utils/blocks.php
remove state and county data for US and make postcode import optional
[nominatim.git] / utils / blocks.php
1 #!/usr/bin/php -Cq
2 <?php
3
4         require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
5         require_once(CONST_BasePath.'/lib/init-cmd.php');
6         ini_set('memory_limit', '800M');
7
8         $aCMDOptions = array(
9                 "Manage service blocks / restrictions",
10                 array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
11                 array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
12                 array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
13                 array('list', 'l', 0, 1, 0, 0, 'bool', 'List recent blocks'),
14                 array('delete', 'd', 0, 1, 0, 0, 'bool', 'Clear recent blocks list'),
15                 array('flush', '', 0, 1, 0, 0, 'bool', 'Flush all blocks / stats'),
16         );
17         getCmdOpt($_SERVER['argv'], $aCMDOptions, $aResult, true, true);
18
19         $m = getBucketMemcache();
20         if (!$m)
21         {
22                 echo "ERROR: Bucket memcache is not configured\n";
23                 exit;
24         }
25
26         if ($aResult['list'])
27         {
28                 $iCurrentSleeping = $m->get('sleepCounter');
29                 echo "\n Sleeping blocks count: $iCurrentSleeping\n";
30
31                 $aBlocks = getBucketBlocks();
32                 echo "\n";
33                 printf(" %-40s | %12s | %7s | %13s | %31s | %8s\n", "Key", "Total Blocks", "Current", "Still Blocked", "Last Block Time", "Sleeping");
34                 printf(" %'--40s-|-%'-12s-|-%'-7s-|-%'-13s-|-%'-31s-|-%'-8s\n", "", "", "", "", "", "");
35                 foreach($aBlocks as $sKey => $aDetails)
36                 {
37                         printf(" %-40s | %12s | %7s | %13s | %31s | %8s\n", $sKey, $aDetails['totalBlocks'], 
38                                 (int)$aDetails['currentBucketSize'], $aDetails['currentlyBlocked']?'Y':'N', 
39                                 date("r", $aDetails['lastBlockTimestamp']), $aDetails['isSleeping']?'Y':'N');
40                 }
41                 echo "\n";
42         }
43
44         if ($aResult['delete'])
45         {
46                 $m->set('sleepCounter', 0);
47                 clearBucketBlocks();
48         }
49
50         if ($aResult['flush'])
51         {
52                 $m->flush();
53         }