Index: www/www.reactos.org/getbuilds/ajax-getfiles-provider.php
--- www/www.reactos.org/getbuilds/ajax-getfiles-provider.php	(revision 898)
+++ www/www.reactos.org/getbuilds/ajax-getfiles-provider.php	(working copy)
@@ -5,7 +5,7 @@
   PURPOSE:    Easily download prebuilt ReactOS Revisions
   COPYRIGHT:  Copyright 2007-2008 Colin Finck <mail@colinfinck.de>
 */
-   
+
 	// This "ajax-getfiles.php" script has to be uploaded to the server, which contains the ISO files.
 	// Therefore it has an own configuration and doesn't use "config.inc.php".
 
@@ -17,121 +17,130 @@
 	// Functions
 	function fsize_str($size)
 	{
-		if($size > 1000000)
+		if($size > 1048576)
 		{
 			$size = $size / 1048576;
-			$unit = " MB";
+			$unit = " MiB";
 		}
-		else if($size > 1000)
+		else if($size > 1024)
 		{
 			$size = $size / 1024;
-			$unit = " KB";
+			$unit = " KiB";
 		}
 		else
 		{
 			$unit = " Bytes";
 		}
-		
+
 		return number_format($size, 2, ".", ",") . $unit;
 	}
-	
-	
+
+
 	// Entry point
 	header("Content-type: text/xml");
-	
+
 	if(!isset($_GET["startrev"]))
 		die("<error><message>Necessary information not specified!</message></error>");
-	
+
 	if($_GET["endrev"] - $_GET["startrev"] > $REV_RANGE_LIMIT)
 		die("<error><message>LIMIT</message><limit>$REV_RANGE_LIMIT</limit></error>");
-	
+
 	if($_GET["filelist"])
 		$get_filelist = true;
-	
-	$directories = array("bootcd", "livecd");
+
+	$directories = array('bootcd', 'bootcdregtest', 'livecd');
 	$file_patterns = array();
-	
+
 	if($_GET["bootcd-dbg"])
 		$file_patterns[] = "#bootcd-[0-9]+-dbg#";
+	if($_GET['bootcd-rel'])
+		$file_patterns[] = '#bootcd-[0-9]+-rel#';
+	// ToDo: if($_GET['bootcdregtest'])
+		$file_patterns[] = '#bootcdregtest-[0-9]+#';
 	if($_GET["livecd-dbg"])
 		$file_patterns[] = "#livecd-[0-9]+-dbg#";
-	if($_GET["bootcd-rel"])
-		$file_patterns[] = "#bootcd-[0-9]+-rel#";
 	if($_GET["livecd-rel"])
 		$file_patterns[] = "#livecd-[0-9]+-rel#";
-	
+
 	$exitloop = false;
 	$filecount = 0;
 	$firstrev = 0;
 	$lastrev = 0;
 	$morefiles = 0;
-	
+
+	// Build a '$fnames[] = {<rev> => <filenames>}' array, with all matching filenames.
 	foreach($directories as $d)
 	{
 		$dir = opendir($ROOT_DIR . $d) or die("<error><message>opendir failed!</message></error>");
-	
+
 		while($fname = readdir($dir))
-			if(preg_match("#-([0-9]+)-#", $fname, $matches))
-				$fnames[ $matches[1] ][] = $fname;
-		
+		{
+			// Match this filename if it contains a revision.
+			if(preg_match("#-([0-9]+)[-.]#", $fname, $matches))
+				$fnames[$matches[1]][] = $fname;
+		}
+
 		closedir($dir);
 	}
-	
+
 	echo "<fileinformation>";
-	
+
 	for($i = $_GET["startrev"]; $i <= $_GET["endrev"]; $i++)
 	{
-		if(isset($fnames[$i]))
+		// No filenames for this revision?
+		if(!isset($fnames[$i]))
+			continue;
+
+		// Sort by revision (n, n+1, n+2) [for() loop],
+		// then type (B, BRt, L) [here].
+		sort($fnames[$i]);
+
+		foreach($fnames[$i] as $fname)
 		{
-			sort($fnames[$i]);
-			
-			foreach($fnames[$i] as $fname)
+			// Is it an allowed CD Image type?
+			foreach($file_patterns as $p)
 			{
-				// Is it an allowed CD Image type?
-				foreach($file_patterns as $p)
+				// Filename not matching this type?
+				if(!preg_match($p, $fname))
+					continue;
+
+				// This is a file we are looking for
+				if($get_filelist)
 				{
-					if(preg_match($p, $fname))
-					{
-						// This is a file we are looking for
-						if($get_filelist)
-						{
-							$dir = substr($fname, 0, 6);
-							
-							echo "<file>";
-							printf("<name>%s</name>", $fname);
-							printf("<size>%s</size>", fsize_str(filesize("$ROOT_DIR/$dir/$fname")));
-							printf("<date>%s</date>", date("Y-m-d H:i", filemtime("$ROOT_DIR/$dir/$fname")));
-							echo "</file>";
-						}
-					
-						if($i < $firstrev || $firstrev == 0)
-							$firstrev = $i;
-				
-						if($i > $lastrev)
-							$lastrev = $i;
-						
-						$filecount++;
-						break;
-					}
+					$dir = substr($fname, 0, strpos($fname, '-'));
+
+					echo "<file>";
+					printf("<name>%s</name>", $fname);
+					printf("<size>%s</size>", fsize_str(filesize("$ROOT_DIR/$dir/$fname")));
+					printf("<date>%s</date>", date("Y-m-d H:i", filemtime("$ROOT_DIR/$dir/$fname")));
+					echo "</file>";
 				}
-				
-				if($filecount == $MAX_FILES_PER_PAGE)
-				{
-					$morefiles = 1;
-					$exitloop = true;
-					break;
-				}
+
+				if($firstrev === 0)
+					$firstrev = $i;
+
+				$lastrev = $i;
+
+				$filecount++;
+				break;
 			}
+
+			if($filecount === $MAX_FILES_PER_PAGE)
+			{
+				$morefiles = 1;
+				$exitloop = true;
+				break;
+			}
 		}
-		
+
 		if($exitloop)
 			break;
 	}
-	
+
 	printf("<filecount>%d</filecount>", $filecount);
 	printf("<firstrev>%d</firstrev>", $firstrev);
 	printf("<lastrev>%d</lastrev>", $lastrev);
 	printf("<morefiles>%d</morefiles>", $morefiles);
-	
+
 	echo "</fileinformation>";
 ?>
