-if (is_dir($_PLANET_FOLDER)) {
- $htaccess_contents = file_get_contents($_PLANET_HTACCESS);
- $htaccess_handle = fopen($_PLANET_HTACCESS, 'a');
- if ($dh = opendir($_PLANET_FOLDER)) {
- while (($file = readdir($dh)) !== false ) {
- if (preg_match($_PLANET_REGEX,$file)) {
- $file_slashed = 'planet/'.$_YEAR.'/'.str_replace(array('.','-'), array('\.','\-'), $file);
- if (strpos($htaccess_contents,$file_slashed) === false) {
- $file_size = filesize($_PLANET_FOLDER.$file);
- sleep(rand(2,5));
- $file_mirror_size = _MIRROR_FILE_SIZE($_MIRROR.$file);
- if ($file_size==$file_mirror_size) {
- echo 'Adding: '.$file."\n";
- fwrite($htaccess_handle, 'RewriteRule'."\t".
- '^('.$file_slashed.')$'."\t".
- 'https://ftp5.gwdg.de/pub/misc/openstreetmap/planet.openstreetmap.org/$1'."\t".
- '[R,L]'."\n");
- }
- }
- }
- }
- closedir($dh);
- fclose($htaccess_handle);
- }
+$htaccess_contents = file_get_contents($_PLANET_HTACCESS);
+$htaccess_handle = fopen($_PLANET_HTACCESS, 'a');
+
+foreach ($_FOLDERS as $FOLDER) {
+
+ $_PLANET_FOLDER = $FOLDER["FOLDER"];
+ $_PLANET_REGEX = $FOLDER["REGEX"];
+
+ if (!(is_dir($_PLANET_FOLDER))) {
+ continue;
+ }
+
+ if ($dh = opendir($_PLANET_FOLDER)) {
+ while (($file = readdir($dh)) !== false ) {
+ if (preg_match($_PLANET_REGEX, $file)) {
+ $file_slashed = $FOLDER['DIR_PREFIX'].str_replace(array('.','-'), array('\.','\-'), $file);
+ if (strpos($htaccess_contents, $file_slashed) === false) {
+ $file_size = filesize($_PLANET_FOLDER.$file);
+ sleep(rand(2,5));
+ $file_mirror_size = _MIRROR_FILE_SIZE($_MIRROR.$FOLDER['DIR_PREFIX'].$file);
+ if ($file_size==$file_mirror_size) {
+ echo 'Adding: '.$file."\n";
+ fwrite($htaccess_handle, 'RewriteRule'."\t". '^('.$file_slashed.')$'."\t".$_MIRROR.'$1'."\t".'[R,L]'."\n");
+ }
+ }
+ }
+ }
+ closedir($dh);
+ }