'/home/geograph', //base installation dir 'config'=>'www.geograph.org.uk', //effective config 'timeout'=>14, //timeout in minutes 'sleep'=>10, //sleep time in seconds 'load'=>100, //maximum load average 'load'=>100, //maximum load average 'base'=>1, //maximum load average 'dryrun'=>0, //maximum load average 'help'=>0, //show script help? ); //very simple argument parser for($i=1; $i : base directory (/home/geograph) --config= : effective domain config (www.geograph.org.uk) --timeout= : maximum runtime of script (14) --sleep= : seconds to sleep if load average exceeded (10) --load= : maximum load average (100) --base=1/0 : delete the basemap (1) --dryrun=1/0 : dont actully delete (0) --help : show this message --------------------------------------------------------------------- ENDHELP; exit; } //set up suitable environment ini_set('include_path', $param['dir'].'/libs/'); $_SERVER['DOCUMENT_ROOT'] = $param['dir'].'/public_html/'; $_SERVER['HTTP_HOST'] = $param['config']; //-------------------------------------------- // nothing below here should need changing require_once('geograph/global.inc.php'); require_once('geograph/gridimage.class.php'); require_once('geograph/gridsquare.class.php'); require_once('geograph/map.class.php'); require_once('geograph/image.inc.php'); require_once('geograph/mapmosaic.class.php'); $db = NewADOConnection($GLOBALS['DSN']); $start_time = time(); $end_time = $start_time + (60*$param['timeout']); $prefixes = $db->GetAll("select * from gridprefix order by rand();"); foreach($prefixes as $idx=>$prefix) { //sleep until calm if we've specified a load average if ($param['load']<100) { while (get_loadavg() > $param['load']) { sleep($param['sleep']); if (time()>$end_time) exit; } } //mysql might of closed the connection in the meantime if we reuse the same object $mosaic = new GeographMapMosaic; print "Starting {$prefix['prefix']}...\n";flush(); $minx=$prefix['origin_x']; $maxx=$prefix['origin_x']+$prefix['width']-1; $miny=$prefix['origin_y']; $maxy=$prefix['origin_y']+$prefix['height']-1; $crit = "map_x between $minx and $maxx and ". "map_y between $miny and $maxy and ". "pixels_per_km >= 40 and ". "((map_x-{$prefix['origin_x']}) mod 5) != 0 and ". "((map_y-{$prefix['origin_y']}) mod 5) != 0"; $count = $mosaic->deleteBySql($crit,$param['dryrun'],$param['base']); print "Deleted $count\n"; $total += $count; if (time()>$end_time) { //well come to the end of the scripts useful life exit; } } print "Total: $total\n"; exit; ?>