-
- }
-
- if ($aResult['import-npi-all'])
- {
- $iNPIID = $oDB->getOne('select max(npiid) from import_npi_log');
- if (PEAR::isError($iNPIID))
- {
- var_dump($iNPIID);
- exit(1);
- }
- $sConfigDirectory = CONST_InstallPath.'/settings';
- $sCMDImportTemplate = $sBasePath.'/nominatim/nominatim -d gazetteer -P 5433 -I -T '.CONST_BasePath.'/nominatim/partitionedtags.def -F ';
- while(true)
- {
- $fStartTime = time();
-
- $iNPIID++;
-
- $sImportFile = CONST_BasePath.'/export/diff/';
- $sImportFile .= str_pad(floor($iNPIID/1000000), 3, '0', STR_PAD_LEFT);
- $sImportFile .= '/'.str_pad(floor($iNPIID/1000) % 1000, 3, '0', STR_PAD_LEFT);
- $sImportFile .= '/'.str_pad($iNPIID % 1000, 3, '0', STR_PAD_LEFT);
- $sImportFile .= ".npi";
- while(!file_exists($sImportFile) && !file_exists($sImportFile.'.bz2'))
- {
- echo "sleep (waiting for $sImportFile)\n";
- sleep(10);
- }
- if (file_exists($sImportFile.'.bz2')) $sImportFile .= '.bz2';
-
- $iFileSize = filesize($sImportFile);
-
- // Import the file
- $fCMDStartTime = time();
- $sCMDImport = $sCMDImportTemplate . $sImportFile;
- echo $sCMDImport."\n";
- exec($sCMDImport, $sJunk, $iErrorLevel);
- if ($iErrorLevel)
- {
- fail("Error: $iErrorLevel\n");
- }
- $sBatchEnd = $iNPIID;
- echo "Completed for $sBatchEnd in ".round((time()-$fCMDStartTime)/60,2)." minutes\n";
- $sSQL = "INSERT INTO import_npi_log values ($iNPIID, null, $iFileSize,'".date('Y-m-d H:i:s',$fCMDStartTime)."','".date('Y-m-d H:i:s')."','import')";
- var_Dump($sSQL);
- $oDB->query($sSQL);
- }
-