3 require_once(CONST_LibDir.'/init-website.php');
 
   4 require_once(CONST_LibDir.'/log.php');
 
   5 require_once(CONST_LibDir.'/output.php');
 
   6 ini_set('memory_limit', '200M');
 
   8 $oParams = new Nominatim\ParameterParser();
 
   9 $sOutputFormat = $oParams->getSet('format', array('json'), 'json');
 
  10 set_exception_handler_by_format($sOutputFormat);
 
  12 $iDays = $oParams->getInt('days', false);
 
  13 $bReduced = $oParams->getBool('reduced', false);
 
  14 $sClass = $oParams->getString('class', false);
 
  16 $oDB = new Nominatim\DB(CONST_Database_DSN);
 
  19 $iTotalBroken = (int) $oDB->getOne('SELECT count(*) FROM import_polygon_error');
 
  22 while ($iTotalBroken && empty($aPolygons)) {
 
  23     $sSQL = 'SELECT osm_type, osm_id, class, type, name->\'name\' as "name",';
 
  24     $sSQL .= 'country_code, errormessage, updated';
 
  25     $sSQL .= ' FROM import_polygon_error';
 
  29         $aWhere[] = "updated > 'now'::timestamp - '".$iDays." day'::interval";
 
  33     if ($bReduced) $aWhere[] = "errormessage like 'Area reduced%'";
 
  34     if ($sClass) $sWhere[] = "class = '".pg_escape_string($sClass)."'";
 
  36     if (!empty($aWhere)) {
 
  37         $sSQL .= ' WHERE '.join(' and ', $aWhere);
 
  40     $sSQL .= ' ORDER BY updated desc LIMIT 1000';
 
  41     $aPolygons = $oDB->getAll($sSQL);
 
  49 if ($sOutputFormat == 'json') {
 
  50     javascript_renderData($aPolygons);