Bug 408019 GMF Notation git website migration
diff --git a/.project b/.project
old mode 100755
new mode 100644
diff --git a/_projectCommon.php b/_projectCommon.php
index a24e014..0a57c04 100644
--- a/_projectCommon.php
+++ b/_projectCommon.php
@@ -10,12 +10,43 @@
 *		Eclipse Foundation - Initial version
 *		Anthony Hunter - changes for GMF Notation
 ********************************************************************************/
+$Nav->setLinkList(null);
+
+$PR = "gmf-notation";
+$projectName = "GMF Notation";
+
+$debug = (isset ($_GET["debug"]) && preg_match("/^\d+$/", $_GET["debug"]) ? $_GET["debug"] : -1);
+
+$rooturl = "http://" . $_SERVER["HTTP_HOST"] . "/$PR";
+$downurl = "http://www.eclipse.org";
+$bugurl = "https://bugs.eclipse.org";
+
+$extraprojects = array(); //components with only downloads, no info yet, "prettyname" => "directory"
+$nodownloads = array(); //components with only information, no downloads, or no builds available yet, "projectkey"
+$nonewsgroup = array(); //components without newsgroup
+$nomailinglist = array(); //components without mailinglist
+$incubating = array(); // components which are incubating
+$nomenclature = "Project"; //are we dealing with "components" or "projects"?
+
+include_once($_SERVER["DOCUMENT_ROOT"] . "/gmf-notation/downloads/scripts.php");
+
+$regs = null;
+$projects = array("GMF Notation" => "gmf-notation");
+$proj = "/modeling"; // (isset($_GET["project"]) && preg_match("/^(" . join("|", $projects) . ")$/", $_GET["project"], $regs) ? $regs[1] : getProjectFromPath($PR));
+$projct= "gmf-notation";
+
+$buildtypes = array(
+		"R" => "Release",
+		"S" => "Stable",
+		"I" => "Integration",
+		"M" => "Maintenance",
+		"N" => "Nightly"
+);
 
 # Set the theme for your project's web pages.
 # See http://eclipse.org/phoenix/
 $theme = "Nova";
 
-
 # Define your project-wide Navigation here
 # This appears on the left of the page if you define a left nav
 # Format is Link text, link URL (can be http://www.someothersite.com/), target (_self, _blank), level (1, 2 or 3)
diff --git a/downloads.php b/downloads.php
old mode 100755
new mode 100644
diff --git a/downloads/downloads-common.php b/downloads/downloads-common.php
old mode 100755
new mode 100644
index 4bf7d5b..afa6067
--- a/downloads/downloads-common.php
+++ b/downloads/downloads-common.php
@@ -26,8 +26,8 @@
 	$proj = "";
 }
 
-if ((!$proj || $proj == "/") && isset($defaultProj)) { $proj = $defaultProj; }
-$projct = preg_replace("#^/#", "", $proj);
+$proj = $PR;
+$projct = $PR;
 if (strstr($PR, "/") !== false)
 {
 	list($topProj, $parentProj) = explode("/", $PR); # modeling, emf
@@ -71,27 +71,11 @@
 $showAll = (isset($_GET["showAll"]) && preg_match("/^(1)$/", $_GET["showAll"], $regs) ? $regs[1] : "0");
 $showMax = (isset($_GET["showMax"]) && preg_match("/^(\d+)$/", $_GET["showMax"], $regs) ? $regs[1] : ($sortBy == "date" ? "10" : "5"));
 $showBuildResults = !isset($_GET["light"]) && !isset($_GET["nostatus"]); // suppress display of status to render page faster
-$doRefreshPage = false;
 
-$PWD = getPWD("$projct/downloads/drops"); // see scripts.php
-$isTools = isset($_GET["tools"]);
-$isTech = isset($_GET["tech"]);
-if (preg_match("#/(tools|technology)/#", $PWD, $m))
-{
-	$isTools = $m[1] == "tools";
-	$isTech = $m[1] == "technology";
-}
+$PWD = "/home/data2/httpd/download.eclipse.org/modeling/gmp/$PR/downloads/drops";
 
-if ($isBuildServer || false != strpos($_SERVER["HTTP_HOST"], "fullmoon")) //internal
-{
-	$downloadScript = "../../../";
-	$downloadPre = "../../..";
-}
-else // all others
-{
-	$downloadScript = getdownloadScript();
-	$downloadPre = "";
-}
+$downloadScript = getdownloadScript();
+$downloadPre = "";
 
 print "<div id=\"midcolumn\">\n";
 print "<h2>GMF Notation P2 Repositories & SDK Dropins</h2>\n";
@@ -167,13 +151,6 @@
 	doLatest($builds, "Builds");
 }
 
-if ($doRefreshPage)
-{ ?>
-<script type="text/javascript">
-	setTimeout('document.location.reload()', 60*1000); // refresh every 60 seconds if there's a build in progress
-</script>
-<?php }
-
 if (isset($oldrels) && is_array($oldrels) && sizeof($oldrels) > 0)
 {
 	showArchived($oldrels);
diff --git a/downloads/downloads-scripts.php b/downloads/downloads-scripts.php
old mode 100755
new mode 100644
index cb00385..911024e
--- a/downloads/downloads-scripts.php
+++ b/downloads/downloads-scripts.php
@@ -164,11 +164,10 @@
 		// set default
 		$flip = array_flip($projects);
 		$dls[$proj] = array($flip[$projct] => array(
-				"<acronym title=\"Archived Update Site\"><img alt=\"Click to download archived All-In-One p2 Repo Update Site\" src=\"/modeling/images/dl-icon-update-zip.gif\"/> <b style=\"color:green\">All-In-One Update Site</b></acronym>" => "Update",
-				"SDK (Runtime, Source)" => "SDK",
-				"Runtime" => "runtime",
-				"Examples" => "examples",
-				"Automated Tests" => "automated-tests"
+				"<acronym title=\"Archived Update Site\"><img alt=\"Click to download archived All-In-One p2 Repo Update Site\" src=\"/modeling/images/dl-icon-update-zip.gif\"/> <b style=\"color:green\">All-In-One Update Site</b></acronym>" => "gmf-notation-Update",
+				"SDK (Runtime, Source)" => "gmf-sdk-notation",
+				"Runtime" => "gmf-notation",
+				"Automated Tests" => "gmf-tests-notation"
 		));
 	}
 
@@ -192,7 +191,7 @@
 				$cnt++;
 				if (!is_array($u)) // for compatibilty with uml2, where there's no "RT" value in $u
 				{
-					$u = $u ? array("-$u") : array("");
+					$u = $u ? array("$u") : array("");
 				}
 
 				// support EMF page with three different valid prefixes which can
@@ -206,16 +205,12 @@
 				foreach ($u as $ux)
 				{
 					foreach ($filePreProj as $filePre)
-					{
+					{ 
 						$tries[] = "$branch/$ID/$pre2$filePre$ux-$ziplabel.zip"; // for compatibilty with uml2, where there's no "runtime" value in $ux
 						$tries[] = "$branch/$ID/$filePre$ux-$ziplabel.zip"; // for compatibilty with uml2, where there's no "runtime" value in $ux
 						$tries[] = "$branch/$ID/$pre2$filePre$ux-incubation-$ziplabel.zip"; // for compatibilty with uml2, where there's no "runtime" value in $ux
 						$tries[] = "$branch/$ID/$filePre$ux-incubation-$ziplabel.zip"; // for compatibilty with uml2, where there's no "runtime" value in $ux
-						// -------------------
-						$tries[] = "$branch/$ID/$pre2$filePre$ux-$ziplabel.tar.gz"; // for compatibilty with uml2, where there's no "runtime" value in $ux
-						$tries[] = "$branch/$ID/$filePre$ux-$ziplabel.tar.gz"; // for compatibilty with uml2, where there's no "runtime" value in $ux
-						$tries[] = "$branch/$ID/$pre2$filePre$ux-incubation-$ziplabel.tar.gz"; // for compatibilty with uml2, where there's no "runtime" value in $ux
-						$tries[] = "$branch/$ID/$filePre$ux-incubation-$ziplabel.tar.gz"; // for compatibilty with uml2, where there's no "runtime" value in $ux
+						$tries[] = "$branch/$ID/$ux-$ziplabel.zip"; // for compatibilty with uml2, where there's no "runtime" value in $ux
 					}
 				}
 				$outNotFound = "<i><b>$pre2</b>$filePre";
@@ -264,9 +259,8 @@
 /* if $styled = 0 or false, return text only */
 function showBuildResults($PWD, $path, $styled=1) // given path to /../downloads/drops/M200402021234/
 {
-	global $downloadPre, $pre, $isBuildServer, $doRefreshPage, $numzips, $PR, $projct, $isBuildDotEclipseServer, $isTech, $isTools;
-	$PR2 = ($isTools ? "tools/$PR" : ($isTech ? "technology/$PR" : "$PR")); # to allow for www.eclipse.org/gef/ and download.eclipse.org/tools/gef
-	$mid = "$downloadPre/$PR2" . ($projct == "" ? $projct : "/$projct") . "/downloads/drops/";
+	global $downloadPre, $pre, $numzips, $PR, $projct;
+	$mid = "$downloadPre/$PR" . ($projct == "" ? $projct : "/$projct") . "/downloads/drops/";
 	$out = "";
 	$buildlog = "$PWD${path}buildlog.txt";
 	$buildlog_cache = null;
@@ -287,265 +281,200 @@
 	$link2 = "";
 
 	$ID = substr($path, -14);
-	if (is_file("${path}testing/${ID}testing/linux.gtk_consolelog.txt")) // testing or perhaps failed and didn't clean up
+
+	if (!$icon && (is_file("$PWD${path}index.html") || is_file("$PWD${path}index.php")))
 	{
+		$indexHTML = is_file("$PWD${path}index.html") ? file_get_contents("$PWD${path}index.html") : "";
+		$zips = loadDirSimple($PWD . $path, "(\.zip|\.tar\.gz)", "f"); // get files count
+		$md5s = is_dir($PWD . $path . "/checksum") ? loadDirSimple($PWD . $path . "/checksum", "(\.zip\.md5|\.tar\.gz\.md5)", "f") :
+		loadDirSimple($PWD . $path, "(\.zip\.md5|\.tar\.gz\.md5)", "f"); // get files count
+
+		if ((sizeof($zips) >= $numzips && sizeof($md5s) >= $numzips))
+		{
+			//check testresults/chkpii/ for results
+			if (is_file("$PWD${path}testresults/chkpii/org.eclipse.nls.summary.txt"))
+			{
+				$chkpiiResults = file_get_contents("$PWD${path}testresults/chkpii/org.eclipse.nls.summary.txt");
+				// eg, file contains:
+				//htm: 6 E, 0 W
+				//xml: 1 E, 1 W
+				//properties: 0 E, 2 W
+				$regs = null;
+				preg_match_all("/^\S+: (\d+) E, (\d+) W$/m", $chkpiiResults, $regs);
+				for ($i = 0; $i < sizeof($regs[0]); $i++)
+				{
+					$errors += $regs[1][$i];
+					$warnings += $regs[2][$i];
+					$icon = "not";
+					$link = "$pre$mid${path}testresults/chkpii/";
+					$link2 = "$pre$mid${path}testresults/chkpii/";
+				}
+			}
+
+			// check JUnit results
+			$files = loadDirSimple("$PWD${path}testresults/xml/", ".xml", "f");
+			$out = "";
+			$noProblems = true;
+			foreach ($files as $file)
+			{
+				$results = getTestResultsJUnitXML("$PWD${path}testresults/xml/" . $file);
+				if ($results && is_array($results))
+				{
+					$errors += $results[0];
+					$failures += $results[1];
+					$didnotruns += $results[2];
+					$icon = "not";
+					$results = null;
+				}
+			}
+
+			//check compilelogs/summary.txt for results
+			if (is_file("$PWD${path}compilelogs/summary.txt"))
+			{
+				$compilelogSummary = file_get_contents("$PWD${path}compilelogs/summary.txt");
+				$link2 = "http://www.eclipse.org/$PR/downloads/testResults.php?hl=1&amp;project=$projct&amp;ID=" . substr($path, 0, strlen($path) - 1);
+				if ($compilelogSummary)
+				{
+					$m = null;
+					if (preg_match("/(\d+)P, (\d+)W, (\d+)E, (\d+)F/", $compilelogSummary, $m))
+					{
+						$warnings += $m[2];
+						$errors += $m[3];
+						$failures += $m[4];
+					}
+				}
+			}
+
+			if ($errors)
+			{
+				$icon = "not";
+				$result = "ERROR";
+			}
+			else if ($didnotruns)
+			{
+				$icon = "not";
+				$result = "CAUTION";
+			}
+			else
+			{
+				$icon = ($warnings ? "check-maybe" : "check");
+				$result = "";
+			}
+
+			//parse out the check/fail icons in index.html, if we haven't failed already
+			if ($icon != "not" && $indexHTML)
+			{
+				if (preg_match("/<font size=\"-1\" color=\"#FF0000\">skipped<\/font>/", $indexHTML))
+				{
+					$icon = "check-maybe";
+					$result = "Skipped ";
+				}
+				else if (preg_match("/(?:<!-- Examples -->.*FAIL\.gif|FAIL\.gif.*<!-- Automated Tests -->)/s", $indexHTML))
+				{
+					$icon = "not";
+					$result = "FAILED ";
+				}
+				else if (preg_match("/<!-- Automated Tests -->.*FAIL\.gif.*<!-- Examples -->/s", $indexHTML))
+				{
+					$icon = "check-tests-failed";
+					$result = "TESTS FAILED ";
+				}
+			}
+		}
+	}
+
+	if (!$icon)
+	{
+		// display in progress icon & link to log
+		$result = "...";
+		$icon = "question";
+	}
+
+	clearstatcache();
+
+	if (!$result && !is_dir("$PWD${path}testresults/xml/"))
+	{
+		$result = "Skipped ";
 		$icon = "check-maybe";
+	}
+
+	if (!$link) // return a string with icon, result, and counts (if applic)
+	{
+		$link = "http://download.eclipse.org/" . $mid . $path . "buildlog.txt";
+	}
+
+	if (!$link2) // link to console log in progress if it exists
+	{
+		$ID = substr($path, -14);
 		$conlog = "${path}testing/${ID}testing/linux.gtk_consolelog.txt";
-		$testlog = ($isBuildServer ? "" : "http://www.eclipse.org") . "/$PR2/downloads/testResults.php?hl=1&amp;project=$projct&amp;ID=" . substr($path, 0, strlen($path) - 1);
-		$link = ($isBuildServer && !$isBuildDotEclipseServer ? "/$PR/build/log-viewer.php?" . ($isTools ? "tools&" : ($isTech ? "technology&" : "")) . "project=$projct&amp;build=$path" :
-				($isBuildServer ? "" : "http://download.eclipse.org/") . $mid.$path."buildlog.txt");
+		$testlog = "http://www.eclipse.org/$PR/downloads/testResults.php?hl=1&amp;project=$projct&amp;ID=" . substr($path, 0, strlen($path) - 1);
 		$link2 = (is_file("$PWD$conlog") ? "$mid$conlog" : (is_file("$PWD$testlog") ? "$testlog" : $link));
 		$result = (is_file("$PWD$conlog") ? "Testing..." : $result);
-}
-
-if (!$icon && $isBuildServer && is_file($buildlog)) // if the log's too big, don't open it!
-{
-	$buildlog_cache = (isset($buildlog_cache) && $buildlog_cache) ? $buildlog_cache : loadFile($buildlog);
-	if (grep("/BUILD FAILED/", $buildlog, $buildlog_cache))
-	{
-		$icon = "not";
-		$result = "FAILED"; // BUILD
-	}
-}
-
-if (!$icon && (is_file("$PWD${path}index.html") || is_file("$PWD${path}index.php")))
-{
-	$indexHTML = is_file("$PWD${path}index.html") ? file_get_contents("$PWD${path}index.html") : "";
-	$zips = loadDirSimple($PWD . $path, "(\.zip|\.tar\.gz)", "f"); // get files count
-	$md5s = is_dir($PWD . $path . "/checksum") ? loadDirSimple($PWD . $path . "/checksum", "(\.zip\.md5|\.tar\.gz\.md5)", "f") :
-	loadDirSimple($PWD . $path, "(\.zip\.md5|\.tar\.gz\.md5)", "f"); // get files count
-
-	if ((sizeof($zips) >= $numzips && sizeof($md5s) >= $numzips))
-	{
-		//check testresults/chkpii/ for results
-		if (is_file("$PWD${path}testresults/chkpii/org.eclipse.nls.summary.txt"))
-		{
-			$chkpiiResults = file_get_contents("$PWD${path}testresults/chkpii/org.eclipse.nls.summary.txt");
-			// eg, file contains:
-			//htm: 6 E, 0 W
-			//xml: 1 E, 1 W
-			//properties: 0 E, 2 W
-			$regs = null;
-			preg_match_all("/^\S+: (\d+) E, (\d+) W$/m", $chkpiiResults, $regs);
-			for ($i = 0; $i < sizeof($regs[0]); $i++)
-			{
-				$errors += $regs[1][$i];
-				$warnings += $regs[2][$i];
-				$icon = "not";
-				$link = "$pre$mid${path}testresults/chkpii/";
-				$link2 = "$pre$mid${path}testresults/chkpii/";
-}
-}
-
-// check JUnit results
-$files = loadDirSimple("$PWD${path}testresults/xml/", ".xml", "f");
-$out = "";
-$noProblems = true;
-foreach ($files as $file)
-{
-	$results = getTestResultsJUnitXML("$PWD${path}testresults/xml/" . $file);
-	if ($results && is_array($results))
-	{
-		$errors += $results[0];
-		$failures += $results[1];
-		$didnotruns += $results[2];
-		$icon = "not";
-		$results = null;
-	}
-}
-
-//check compilelogs/summary.txt for results
-if (is_file("$PWD${path}compilelogs/summary.txt"))
-{
-	$compilelogSummary = file_get_contents("$PWD${path}compilelogs/summary.txt");
-	$link2 = ($isBuildServer ? "" : "http://www.eclipse.org") . "/$PR/downloads/testResults.php?hl=1&amp;project=$projct&amp;ID=" . substr($path, 0, strlen($path) - 1);
-	if ($compilelogSummary)
-	{
-		$m = null;
-		if (preg_match("/(\d+)P, (\d+)W, (\d+)E, (\d+)F/", $compilelogSummary, $m))
-		{
-			$warnings += $m[2];
-			$errors += $m[3];
-			$failures += $m[4];
-		}
-	}
-}
-
-if ($errors)
-{
-	$icon = "not";
-	$result = "ERROR";
-}
-else if ($didnotruns)
-{
-	$icon = "not";
-	$result = "CAUTION";
-}
-else
-{
-	$icon = ($warnings ? "check-maybe" : "check");
-	$result = "";
-}
-
-//parse out the check/fail icons in index.html, if we haven't failed already
-if ($icon != "not" && $indexHTML)
-{
-	if (preg_match("/<font size=\"-1\" color=\"#FF0000\">skipped<\/font>/", $indexHTML))
-	{
-		$icon = "check-maybe";
-		$result = "Skipped ";
-	}
-	else if (preg_match("/(?:<!-- Examples -->.*FAIL\.gif|FAIL\.gif.*<!-- Automated Tests -->)/s", $indexHTML))
-	{
-		$icon = "not";
-		$result = "FAILED ";
-	}
-	else if (preg_match("/<!-- Automated Tests -->.*FAIL\.gif.*<!-- Examples -->/s", $indexHTML))
-	{
-		$icon = "check-tests-failed";
-		$result = "TESTS FAILED ";
-	}
-}
-}
-}
-
-if (!$icon)
-{
-	// display in progress icon & link to log
-	$result = "...";
-	$icon = "question";
-}
-
-clearstatcache();
-if ($isBuildServer && $icon == "question" && is_file($buildlog))
-{
-	$buildlog_cache = (isset($buildlog_cache) && $buildlog_cache) ? $buildlog_cache : loadFile($buildlog);
-	if ($isBuildServer && grep("/\[start\] start\.sh finished on: /", $buildlog, $buildlog_cache))
-	{
-		$icon = "not"; //display failed icon - not in progress anymore!
-		$result = "FAILED"; // BUILD
 	}
 
-	if ($result != "FAILED" && strtotime("now") - filemtime($buildlog) < 7200)
+	if ($styled)
 	{
-		$doRefreshPage = true;
-	}
-	else
-	{
-		$mightHavePassed = false;
-		if (grep("/BUILD SUCCESSFUL/", $buildlog, $buildlog_cache))
-		{
-			$mightHavePassed = true;
-		}
-		else if (grep("/BUILD FAILED/", $buildlog, $buildlog_cache))
-		{
-			$icon = "not"; //display failed icon
-			$result = "FAILED"; // BUILD
-		}
-
-		if ($result != "FAILED" && $mightHavePassed)
-		{
-			$icon = "check-maybe";
-			$result = "Stalled!";
-		}
-		else if ($result != "FAILED" && !$mightHavePassed)
-		{
-			$icon = "not";
-			$result = "FAILED";
-		}
-	}
-}
-
-if (!$result && !is_dir("$PWD${path}testresults/xml/"))
-{
-	$result = "Skipped ";
-	$icon = "check-maybe";
-}
-
-if (!$link) // return a string with icon, result, and counts (if applic)
-{
-	$link = ($isBuildServer && !$isBuildDotEclipseServer ? "/$PR/build/log-viewer.php?" . ($isTools ? "tools&" : ($isTech ? "technology&" : "")) . "project=$projct&amp;build=$path" :
-			($isBuildServer ? "" : "http://download.eclipse.org/") . $mid.$path."buildlog.txt");
-}
-
-if (!$link2) // link to console log in progress if it exists
-{
-	$ID = substr($path, -14);
-	$conlog = "${path}testing/${ID}testing/linux.gtk_consolelog.txt";
-	$testlog = ($isBuildServer ? "" : "http://www.eclipse.org") . "/$PR2/downloads/testResults.php?hl=1&amp;project=$projct&amp;ID=" . substr($path, 0, strlen($path) - 1);
-	$link2 = (is_file("$PWD$conlog") ? "$mid$conlog" : (is_file("$PWD$testlog") ? "$testlog" : $link));
-	$result = (is_file("$PWD$conlog") ? "Testing..." : $result);
-}
-
-if ($styled)
-{
-	$out .= "<a " .
+		$out .= "<a " .
 			(preg_match("/FAIL|CAUTION|ERROR/", $result) || $didnotruns > 0 || $errors > 0 || $failures > 0 ? "class=\"fail\" " :
 					(preg_match("/Testing|Stalled|Skipped/",$result) || $warnings > 0 ? "class=\"warning\" " :
 							"class=\"success\" ") ) .
 							"href=\"$link2\">$result";
-}
-else
-{
-	$out .= (preg_match("/FAIL|CAUTION|ERROR/", $result) || $didnotruns > 0 || $errors > 0 || $failures > 0 ? "FAILURE / " :
+	}
+	else
+	{
+		$out .= (preg_match("/FAIL|CAUTION|ERROR/", $result) || $didnotruns > 0 || $errors > 0 || $failures > 0 ? "FAILURE / " :
 			(preg_match("/Testing|Stalled|Skipped/",$result) || $warnings > 0 ? "WARNING / " :
 					"SUCCESS / ") ) .
 					"$result";
-}
-if ($errors == 0 && $failures == 0 && $warnings == 0 && !$result)
-{
-	$out .= "OK";
-}
-else
-{
-	$out  .= ($result && $result != "..."  && $result != "Skipped" ? ": " : "");
-	$out2  = "";
-	$out2 .= ($didnotruns > 0 ? "$didnotruns D N R, " : "");
-	$out2 .= ($errors > 0 ? "$errors E, " : "");
-	$out2 .= ($failures > 0 ? "$failures F, " : "");
-	$out2 .= ($warnings > 0 ? "$warnings W" : "");
-	$out  .= preg_replace("/^(.+), $/","$1",$out2);
-}
-if ($styled)
-{
-	$out .= "</a> <a href=\"$link\"><img src=\"/modeling/images/$icon.gif\" alt=\"$icon\"/></a>";
-}
+	}
+	if ($errors == 0 && $failures == 0 && $warnings == 0 && !$result)
+	{
+		$out .= "OK";
+	}
+	else
+	{
+		$out  .= ($result && $result != "..."  && $result != "Skipped" ? ": " : "");
+		$out2  = "";
+		$out2 .= ($didnotruns > 0 ? "$didnotruns D N R, " : "");
+		$out2 .= ($errors > 0 ? "$errors E, " : "");
+		$out2 .= ($failures > 0 ? "$failures F, " : "");
+		$out2 .= ($warnings > 0 ? "$warnings W" : "");
+		$out  .= preg_replace("/^(.+), $/","$1",$out2);
+	}
+	if ($styled)
+	{
+		$out .= "</a> <a href=\"$link\"><img src=\"/modeling/images/$icon.gif\" alt=\"$icon\"/></a>";
+	}
 
-$replacements = array(
+	$replacements = array(
 		"SUCCESS / Success" => "SUCCESS",
 		"SUCCESS / ..." => "UNKNOWN",
 		"FAILURE / FAILED: " => "FAILED"
-);
-foreach ($replacements as $match => $replace)
-{
-	if ($out == $match) $out = $replace;
-}
+	);
+	foreach ($replacements as $match => $replace)
+	{
+		if ($out == $match) $out = $replace;
+	}
 
-return $isBuildServer ?
-array(
-		preg_replace("#^/modeling/#", "http://" . $_SERVER["SERVER_NAME"] . "/modeling/", $out),
-		"http://" . $_SERVER["SERVER_NAME"] . $link2,
-		"http://" . $_SERVER["SERVER_NAME"] . $link
-) :
-array(
+	return array(
 		$out,
 		$link2,
 		$link
-);
+	);
 }
 
 function fileFound($PWD, $url, $label, $md5AlignRight = true, $icon = null)
 {
-	global $isBuildServer, $downloadScript, $downloadPre, $PR, $proj, $isTools, $isTech;
+	global $downloadScript, $downloadPre, $PR, $proj;
 
 	$out = "";
-	$mid = "$downloadPre/" . ($isTools ? "tools/$PR" : ($isTech ? "technology/$PR" : "$PR$proj")) . "/downloads/drops/"; // new for www.eclipse.org centralized download.php script
+	$mid = "$downloadPre/modeling/gmp/$proj/downloads/drops/"; // new for www.eclipse.org centralized download.php script
 	$md5files = array("$url.md5", preg_replace("#/([^/]+$)#", "/checksum/$1", $url) . ".md5");
 	foreach ($md5files as $md5file)
 	{
 		if (is_file($PWD.$md5file))
 		{
-			$out .= "<span style=\"float:right;\">&nbsp;&nbsp;" . pretty_size(filesize("$PWD$url")) . " (<a href=\"" . ($isBuildServer ? "" : "http://download.eclipse.org") .
+			$out .= "<span style=\"float:right;\">&nbsp;&nbsp;" . pretty_size(filesize("$PWD$url")) . " (<a href=\"" . "http://download.eclipse.org" .
 			"$mid$md5file\">md5</a>)</span>"; break;
 		}
 	}
@@ -638,73 +567,10 @@
 /* if $styled = 0 or false, return text only */
 function getExtraTestsResults($branch, $ID, $styled=1)
 {
-	global $isBuildServer, $jdk14testsPWD, $jdk50testsPWD, $jdk60testsPWD, $testsPWD;
+	global $jdk14testsPWD, $jdk50testsPWD, $jdk60testsPWD, $testsPWD;
 	$tests = "";
 	$s = array(0 => "");
 	$t = array(0 => "");
-	if ($isBuildServer && function_exists("getJDKTestResults") && function_exists("getOldTestResults"))
-	{
-		if (isset($jdk14testsPWD) && $jdk14testsPWD && is_dir($jdk14testsPWD))
-		{
-			$summary = "";
-			$tests = getJDKTestResults("$jdk14testsPWD/", "$branch/$ID/", "jdk14", $summary) . "\n";
-			if (!$styled)
-			{
-				$summary = toPlainTextSummaries($summary);
-				$s[0] .= $summary[0];
-				$t[0] .= $summary[1];
-			}
-			else
-			{
-				$s[] = $summary;
-			}
-		}
-		if (isset($jdk50testsPWD) && $jdk50testsPWD && is_dir($jdk50testsPWD))
-		{
-			$summary = "";
-			$tests .= getJDKTestResults("$jdk50testsPWD/", "$branch/$ID/", "jdk50", $summary) . "\n";
-			if (!$styled)
-			{
-				$summary = toPlainTextSummaries($summary);
-				$s[0] .= $summary[0];
-				$t[0] .= $summary[1];
-			}
-			else
-			{
-				$s[] = $summary;
-			}
-		}
-		if (isset($jdk60testsPWD) && $jdk60testsPWD && is_dir($jdk60testsPWD))
-		{
-			$summary = "";
-			$tests .= getJDKTestResults("$jdk60testsPWD/", "$branch/$ID/", "jdk60", $summary) . "\n";
-			if (!$styled)
-			{
-				$summary = toPlainTextSummaries($summary);
-				$s[0] .= $summary[0];
-				$t[0] .= $summary[1];
-			}
-			else
-			{
-				$s[] = $summary;
-			}
-		}
-		if (isset($testsPWD) && $testsPWD && is_dir($testsPWD))
-		{
-			$summary = "";
-			$tests .= getOldTestResults("$testsPWD/", "$branch/$ID/", $summary) . "\n";
-			if (!$styled)
-			{
-				$summary = toPlainTextSummaries($summary);
-				$s[0] .= $summary[0];
-				$t[0] .= $summary[1];
-			}
-			else
-			{
-				$s[] = $summary;
-			}
-		}
-	}
 	return array($s, $t, $tests);
 }
 
@@ -782,17 +648,14 @@
 
 function outputBuild($branch, $ID, $c)
 {
-	global $PWD, $isBuildServer, $dls, $filePre, $proj, $showBuildResults, $sortBy, $projct, $jdk14testsPWD, $jdk50testsPWD, $jdk60testsPWD, $testsPWD, $deps, $PR, $hiddenBuilds;
+	global $PWD, $dls, $filePre, $proj, $showBuildResults, $sortBy, $projct, $jdk14testsPWD, $jdk50testsPWD, $jdk60testsPWD, $testsPWD, $deps, $PR, $hiddenBuilds;
 
 	# suppress hidden builds for public server
-	if (!$isBuildServer)
-	{
-		foreach ($hiddenBuilds as $hb) {
-			if (trim($hb) == "$PR/$branch/$ID")
-			{
-				debug("Build $PR/$branch/$ID is hidden, pending mirror replication.", 1);
-				return "";
-			}
+	foreach ($hiddenBuilds as $hb) {
+		if (trim($hb) == "$PR/$branch/$ID")
+		{
+			debug("Build $PR/$branch/$ID is hidden, pending mirror replication.", 1);
+			return "";
 		}
 	}
 	$pre2 = (is_dir("$PWD/$branch/$ID/eclipse/$ID/") ? "eclipse/$branch/$ID/" : "");
@@ -831,10 +694,9 @@
 	if (!isset($filePre[$proj]))
 	{
 		$topProj = preg_replace("#.+/(.+)#","$1", $PR);
-		$filePre[$proj] = $topProj == "emft" ?
-		array("emft-" . $projct, "emf-" . $projct) :
-		array($topProj . "-" . $projct);
+		$filePre[$proj] = array($projct);
 	}
+	
 	$ret .= createFileLinks($dls, $PWD, $branch, $ID, $pre2, $filePre[$proj], $ziplabel);
 
 	$ret .= $extraTestsResults[2];
@@ -890,186 +752,26 @@
 
 function getBuildArtifacts($dir, $branchID)
 {
-	global $isBuildServer, $downloadPre, $PR, $deps, $proj, $projct, $isTools, $isTech, $debug;
+	global $downloadPre, $PR, $deps, $proj, $projct, $debug;
 
-	$PR2 = ($isTools ? "tools/$proj" : ($isTech ? "technology/$proj" : "$PR" . ($proj != "/" ? $proj : ""))); # to allow for www.eclipse.org/gef/ and download.eclipse.org/tools/gef, but also modeling/emf
-	$mid = "$downloadPre/$PR2" . "/downloads/drops/";
+	$PR = "$PR" . ($proj != "/" ? $proj : ""); # to allow for modeling/emf
+	$mid = "$downloadPre/$PR" . "/downloads/drops/";
 	$file = "$dir/$branchID/build.cfg";
 	$havedeps = array();
 	$opts = loadBuildConfig($file, $deps);
 
-	// Modeling build style
-	foreach (array_keys($deps) as $z)
-	{
-		$builddir[$z] = (isset($opts["${z}DownloadURL"]) ? $opts["${z}DownloadURL"] : ""). (isset($opts["${z}BuildURL"]) ? $opts["${z}BuildURL"] : ""); if ($builddir[$z] == "/downloads") {
-			$builddir[$z] = null;
-		}
-		# Eclipse: R-3.2.1-200609210945 or S-3.3M2-200609220010 or I20060926-0935 or M20060919-1045
-		# Other: 2.2.1/R200609210005 or 2.2.1/S200609210005
-		$buildID[$z] = isset($opts["${z}BuildURL"]) ? str_replace("/", " ", preg_replace("/.+\/drops\/(.+)/", "$1", $opts["${z}BuildURL"])) : "";
-		$buildfile[$z] = $builddir[$z] . "/" . (isset($opts["${z}File"]) ? $opts["${z}File"] : "");
-		$builddir[$z] = $builddir[$z] ? (!preg_match("/^http/", $builddir[$z]) ? getDownloadScript() . "$builddir[$z]" : $builddir[$z]) : "";
-		$buildfile[$z] = (!preg_match("/^http/", $buildfile[$z]) ? getDownloadScript() . "$buildfile[$z]" : $buildfile[$z]);
-		if ($builddir[$z]) {
-			$havedeps[$z] = $z;
-		}
-}
+	$ret = "";
 
-// Athena build style
-$eclipseDownloadURL=$opts["eclipse.download.url"];
-foreach (array_keys($opts) as $y)
-{
-	preg_match("/^(.+)\.buildurl$/", $y, $regs); $z = $regs[1];
-	if ($z)
-	{
-		# hudson.job.cbi.emft.mwe.0.7.integration.lastSuccessfulBuild.artifact.snapshot.base.url=https://build.eclipse.org/hudson/job/cbi-emft-mwe-0.7-integration/lastSuccessfulBuild/artifact/snapshot/emft-mwe-SDK-incubation-S-Snapshot.zip
-		$builddir[$z] =
-		(isset($opts["${z}.url"]) && preg_match("#.+(build.eclipse.org/hudson/job).+#",$opts["${z}.url"]) ? "https://build.eclipse.org" : $eclipseDownloadURL) .
-		(isset($opts["${z}.buildurl"]) ? $opts["${z}.buildurl"] : ""); if ($builddir[$z] == "/downloads") {
-			$builddir[$z] = null;
-		}
-		/*if ($debug>10) {
-		 echo "<br/>---{{ download-scripts.php :: $Revision: 1.4 $ }}---<br/>";
-		echo "[??][".$opts["${z}.url"]."]<br/>";
-		echo "[??][".$builddir[$z]."]<br/>";
-		}*/
-
-		# Eclipse: R-3.2.1-200609210945 or S-3.3M2-200609220010 or I20060926-0935 or M20060919-1045
-		# Other: 2.2.1/R200609210005 or 2.2.1/S200609210005
-		$buildID[$z] = isset($opts["${z}.buildurl"]) ? str_replace("/", " ", preg_replace("/.+\/drops\/(.+)/", "$1", $opts["${z}.buildurl"])) : "";
-		$buildfile[$z] = $builddir[$z] . "/" . (isset($opts["${z}.file"]) ? $opts["${z}.file"] : "");
-		$builddir[$z] = $builddir[$z] ? (!preg_match("/^http/", $builddir[$z]) ? getDownloadScript()  . "$builddir[$z]" : $builddir[$z]) : "";
-		$buildfile[$z] = (!preg_match("/^http/", $buildfile[$z]) ? getDownloadScript() . "$buildfile[$z]" : $buildfile[$z]);
-		/*if ($debug>10) {
-		 echo "[!!][".$builddir[$z]."]<br/>";
-		echo "[!!][".$buildfile[$z]."]<br/>";
-		}*/
-		if ($builddir[$z]) {
-			$havedeps[$z] = $z;
-		}
-}
-}
-
-$ret = "";
-
-# ANy: Added to depict details via Hudson build job
-if (isset($opts["hudson.job.url"])){
-	$ret .= "<li>\n";
-	$ret .= "<img src=\"/modeling/images/dl-more.gif\" alt=\"More info about this build\"/> Build Details\n";
-	$ret .= "<ul>\n";
-	$ret .= "<li>Hudson job <a href=\"" . $opts["hudson.job.url"] . "\">" . $opts["hudson.job.name"] . " #" . $opts["hudson.job.id"] . "</a></li>\n";
-	$ret .= "</ul>\n";
-	$ret .= "</li>\n";
-}
-# This is for old style builds
-else if (is_array($havedeps))
-{
-	$details = array(
-			"Config File" => "build.cfg",
-			"Map File" => "directory.txt",
-			"Build Log" => "buildlog.txt"
-	);
-
-	$link = ($isBuildServer ? "" : "http://download.eclipse.org");
-
-	$ret .= "<li>\n";
-	$ret .= "<img src=\"/modeling/images/dl-deps.gif\" alt=\"Upstream dependencies used to build this driver\"/> Build Dependencies\n";
-	$ret .= "<ul>\n";
-	if (sizeof($opts) > 0)
-	{
-		$ret .= (isset($opts["javaHome"]) && $opts["javaHome"] ? "<li>" . ucwords(str_replace("-", " ", $opts["javaHome"])) . "</li>" :
-				(isset($opts["JAVA_HOME"]) && $opts["JAVA_HOME"] ? "<li>" . ucwords(str_replace("-", " ", $opts["JAVA_HOME"])) . "</li>" :
-						(isset($opts["java.home"]) && $opts["java.home"] ? "<li>" . ucwords(str_replace("-", " ", $opts["java.home"])) . "</li>" : "")
-				)
-		);
-		foreach (array_keys($havedeps) as $z)
-		{
-			$vanity = $buildID[$z];
-			preg_match("/.+-(incubation-|sdk_|)([^-]+)(\.zip|\.tar\.gz)/", $buildfile[$z], $reg);
-			if ($reg && is_array($reg) && sizeof($reg) > 0)
-			{
-				$vanity = $buildID[$z];
-				$vanity = preg_replace("#(-|_|sdk_)+#"," ",$vanity);
-				$vanity = preg_replace("#(.+ downloads|downloads)+#"," ",$vanity);
-				$vanity = trim(preg_replace("/(\d+\.\d+|\d+\.\d+\.\d+) ([NIMRS]\d+)/","$2",$vanity));
-				if ($vanity != $reg[2])
-				{
-					$vanity = str_replace("_"," ",$reg[2]) . " " . $vanity;
-				}
-			}
-			if ($vanity == " downloads") {
-				$vanity="";
-			}
-
-			# trim duplicate information
-			$vanity = preg_replace("#incubation#","",$vanity);
-			$vanity = preg_replace("#( \d+\.\d+ )#"," ",$vanity);
-			$vanity = preg_replace("#( [IMNRS] )#"," ",$vanity);
-
-			/*if ($debug>10) {
-			 echo "{{ download-scripts.php :: $Revision: 1.4 $ }}<br/>";
-			echo "[A][$vanity]<br/>";
-			echo "[B][".hudsonURLcleanup($vanity)."]<br/>";
-			echo "[#][".$builddir[$z]."]<br/>";
-			echo "[#][".$buildfile[$z]."]<br/>";
-			echo "[?] deps[z] = $deps[$z], z = $z<br/>";
-			echo "[!] deps[z] = $deps[$z], z = ".hudsonURLcleanup(str_replace("."," ",$z))."<br/>";
-			}*/
-
-			$vanity = preg_match("#snapshot|Snapshot#",$vanity) ? "Snapshot" : hudsonURLcleanup($vanity);
-
-			# tokenize and reassemble, avoiding dupes
-			$vanityBits = explode(" ",trim($vanity));
-			$vanity=""; foreach ($vanityBits as $vb){
-				if ($vb && false===strstr($vanity,$vb)){
-					$vanity.=" $vb";
-				}
-			}
-
-			$bf = array();
-			if (preg_match("#(.+)/orbitBundles-(.+).map$#", $buildfile[$z], $bfbits))
-			{
-				$bf[] = $bfbits[1] . "/orbit-" . $bfbits[2] . ".zip";
-				$bf[] = $buildfile[$z]; // map
-			}
-			else if (preg_match("#(.+)/orbit-(.+).zip$#", $buildfile[$z], $bfbits))
-			{
-				$bf[] = $buildfile[$z]; // zip
-				$bf[] = $bfbits[1] . "/orbitBundles-" . $bfbits[2] . ".map";
-			}
-			$ret .= "<li>".($builddir[$z]?"<div><a href=\"$builddir[$z]\">Build Page</a></div>":""). ($deps[$z]?$deps[$z]:ucwords(hudsonURLcleanup(str_replace("."," ",$z)))) . " " .
-					($z == "orbit" ? "<a href=\"{$bf[0]}\">$vanity</a> (<a href=\"{$bf[1]}\">map</a>)" : "<a href=\"{$buildfile[$z]}\">$vanity</a>") .
-					"</li>\n";
-		}
+	# ANy: Added to depict details via Hudson build job
+	if (isset($opts["hudson.job.url"])){
+		$ret .= "<li>\n";
+		$ret .= "<img src=\"/modeling/images/dl-more.gif\" alt=\"More info about this build\"/> Build Details\n";
+		$ret .= "<ul>\n";
+		$ret .= "<li>Hudson job <a href=\"" . $opts["hudson.job.url"] . "\">" . $opts["hudson.job.name"] . " #" . $opts["hudson.job.id"] . "</a></li>\n";
+		$ret .= "</ul>\n";
+		$ret .= "</li>\n";
 	}
-	else
-	{
-		$ret .= "<li><i>Missing or empty build.cfg!</i></li>\n";
-	}
-	$ret .= "</ul>\n";
-	$ret .= "</li>\n";
-
-	$ret .= "<li>\n";
-	$ret .= "<img src=\"/modeling/images/dl-more.gif\" alt=\"More info about this build\"/> Build Details\n";
-	$ret .= "<ul>\n";
-
-	$version = (isset($opts["buildAlias"]) ? $opts["buildAlias"] : (preg_match("#(.+)/([IM]\d+)#", $branchID, $matches) ? $matches[2]: "HEAD"));
-	#$ret .= "<li><a href=\"http://www.eclipse.org/$PR/news/relnotes.php?project=$projct&amp;version=$version\">Changes In This Build</a></li>\n";
-	$ret .= "<li><a href=\"" . ($isBuildServer ? "" : "http://www.eclipse.org") . "/$PR/downloads/testResults.php?hl=1&amp;project=$projct&amp;ID=$branchID\">Test Results &amp; Compile Logs</a></li>\n";
-	$details2 = array();
-	foreach (array_keys($details) as $label)
-	{
-		if (is_file("$dir/$branchID/" . $details[$label]))
-		{
-			$details2[$label] = preg_replace("/^(.+)$/", "<a href=\"$link$mid$branchID/$1\">$label</a>", $details[$label]);
-		}
-	}
-	$details = $details2; unset($details2);
-	$ret .= "<li>" . join(", ", $details) . "</li>\n";
-	$ret .= "</ul>\n";
-	$ret .= "</li>\n";
-}
-return $ret;
+	return $ret;
 }
 
 function hudsonURLcleanup($vanity)
diff --git a/downloads/downloads.js b/downloads/downloads.js
old mode 100755
new mode 100644
diff --git a/downloads/scripts.php b/downloads/scripts.php
new file mode 100644
index 0000000..877178c
--- /dev/null
+++ b/downloads/scripts.php
@@ -0,0 +1,600 @@
+<?php
+
+// $Id: scripts.php,v 1.89 2011/01/26 20:19:18 ahunter Exp $
+
+function PWD_check($PWD, $suf)
+{
+	debug ("&#160; &#160; <b>PWD = </b>$PWD; <b>suf = </b>$suf;<br/>&#160; &#160; &#160; is_dir? <b style='color:green'>" . is_dir($PWD) . "</b>; is_readable? <b style='color:green'>" . is_readable($PWD) . "</b>; is_writable? <b style='color:green'>" . is_writable($PWD) . "</b><br/>", 2);
+	return(!is_dir($PWD) || !is_readable($PWD) ||($suf == "logs" && !is_writable($PWD)));
+}
+
+function getPWD($suf = "", $doDynCheck = true, $debug_echoPWD = 1) // set 0 to hide (for security purposes!)
+{
+	global $PR, $App;
+	debug ("<br/>getPWD <b>PR = </b>$PR, <b>suf = </b>$suf</br>", 2);
+	$PWDs = array();
+
+	if($doDynCheck)
+	{
+		//dynamic assignments
+		$PWD = $App->getDownloadBasePath() . "/$PR/" . $suf;
+		$PWDs[] = $PWD;
+
+		//second dynamic assignment
+		if(PWD_check($PWD, $suf))
+		{
+			$PWD = $_SERVER["DOCUMENT_ROOT"] . "/$PR/" . $suf;
+			$PWDs[] = $PWD;
+		}
+
+		if(!PWD_check($PWD, $suf))
+		{
+			debug("'$suf' ended up with first '$PWD' (is_readable: <b style='color:green'>" . is_readable($PWD) . "</b>, is_dir: <b style='color:green'>" . is_dir($PWD) . "</b>)");
+			return $PWD;
+		}
+	}
+	$PWD = "";
+
+	//static assignments
+	if(PWD_check($PWD, $suf))
+	{
+		$servers = array(
+				"/buildbox(?:\.torolab\.ibm\.com)?/" => "/home/www-data/build",
+				"/build\.eclipse\.org/" => "/opt/public/modeling/build",
+				"/emf(?:\.torolab\.ibm\.com)?/" => "/home/www-data/build",
+				"/(emft|modeling)(?:\.eclipse\.org)?/" => "/home/www-data/build",
+				"/localhost/" => "/home/www-data/build",
+				"/download1\.eclipse\.org/" => "/home/local/data/httpd/download.eclipse.org",
+				"/fullmoon\.torolab\.ibm\.com/" => "/home/www");
+
+		foreach(array_keys($servers) as $z)
+		{
+			$PWD = $servers[$z] . "/$PR/$suf";
+			if(preg_match($z, $_SERVER["HTTP_HOST"]) && !PWD_check($PWD, $suf))
+			{
+				$PWDs[] = $PWD;
+			}
+		}
+		foreach(array_keys($servers) as $z)
+		{
+			$PWD = $servers[$z] . "/$suf";
+			if(preg_match($z, $_SERVER["HTTP_HOST"]) && !PWD_check($PWD, $suf))
+			{
+				$PWDs[] = $PWD;
+			}
+		}
+	}
+	$PWD = "";
+
+	//try a default guess: /home/www, two options
+	if(PWD_check($PWD, $suf))
+	{
+		$data = array(
+				4 => array(
+						"checkdir" => "/home/data/httpd/download.eclipse.org/",
+						"tries" => array("/home/data/httpd/download.eclipse.org/$suf",
+								"/home/data/httpd/download.eclipse.org/$PR/$suf",)
+				),
+				5 => array("checkdir" => "/home/data2/httpd/download.eclipse.org/",
+						"tries" => array("/home/data2/httpd/download.eclipse.org/$suf",
+								"/home/data2/httpd/download.eclipse.org/$PR/$suf",)
+				),
+				6 => array("checkdir" => "/home/local/data/httpd/download.eclipse.org/",
+						"tries" => array($doDynCheck ? $App->getDownloadBasePath() . "/$PR/" . $suf : null,
+								"/home/local/data/httpd/download.eclipse.org/$suf",
+								"/home/local/data/httpd/download.eclipse.org/$PR/$suf",)
+				),
+				7 => array("checkdir" => "/var/www/",
+						"tries" => array("/var/www/$PR/$suf",
+								"/var/www/html/$PR/$suf",)
+				)
+		);
+
+		foreach(array_keys($data) as $y)
+		{
+			$PWD = $data[$y]["checkdir"];
+			if(is_dir($PWD) && is_readable($PWD))
+			{
+				foreach(array_keys($data[$y]["tries"]) as $z)
+				{
+					#debug("&#160; &#160; &#160; &#160; &#160; \$data[$y][\"tries\"][$z] = " . $data[$y]["tries"][$z],3);
+					$PWD = $data[$y]["tries"][$z];
+					if($PWD && !PWD_check($PWD, $suf))
+					{
+						$PWDs[] = $PWD;
+						break 2;
+				}
+			}
+		}
+	}
+}
+$PWD = "/home/data2/httpd/download.eclipse.org/gmf-notation/gmf-notation/downloads/drops";
+
+krsort($PWDs);
+reset($PWDs);
+	debug_r($PWDs, "<hr>PWDs: ", "<hr>", 2);
+foreach($PWDs as $i => $PWD)
+{
+	debug(" &#160; &#160; $i : $PWD", 9);
+	if(!PWD_check($PWD, $suf))
+	{
+		debug("'$suf' ended up with second '$PWD' (is_readable: <b style='color:green'>" . is_readable($PWD) . "</b>, is_dir: <b style='color:green'>" . is_dir($PWD) . "</b>)");
+		return $PWD;
+	}
+}
+
+debug("<!-- PWD not found! -->");
+debug("'$suf' ended up with third '$PWD' (is_readable: <b style='color:green'>" . is_readable($PWD) . "</b>, is_dir: <b style='color:green'>" . is_dir($PWD) . "</b>)");
+return $PWD;
+}
+
+function loadDirSimple($dir, $ext, $type) // 1D array, not 2D
+{
+	$stuff = array();
+
+	if(is_dir($dir) && is_readable($dir))
+	{
+		$handle = opendir($dir);
+		while(($file = readdir($handle)) !== false)
+		{
+			if(preg_match("/$ext$/", $file) && !preg_match("/^\.{1,2}$/", $file))
+			{
+				if(($type == "d" && is_dir("$dir/$file")) ||($type == "f" && is_file("$dir/$file")))
+				{
+					$stuff[] = $file;
+				}
+			}
+		}
+		closedir($handle);
+	}
+	else
+	{
+		global $hadLoadDirSimpleError;
+		if(!$hadLoadDirSimpleError)
+		{
+			$issue =(!is_dir($dir) ? "NOT FOUND" :(!is_readable($dir) ? "NOT READABLE" : "PROBLEM"));
+			print "<p>Directory ($dir) <b>$issue</b> on mirror: <b>" . $_SERVER["HTTP_HOST"] . "</b>!</p>";
+			print "<p>Please report this error to <a href=\"mailto:webmaster@eclipse.org?Subject=Directory ($dir) $issue in scripts.php::loadDirSimple() on mirror " . $_SERVER["HTTP_HOST"] . "\">webmaster@eclipse.org</a>, or make directory readable.</p>";
+			$hadLoadDirSimpleError = 1;
+		}
+	}
+
+	return $stuff;
+}
+
+function wArr($arr)
+{
+	print "<pre>\n";
+	print_r($arr);
+	print "</pre>\n";
+}
+
+function w($s, $br = "") // shortcut for echo() with second parameter: "add break+newline"
+{
+	if(stristr($br, "n"))
+	{
+		$br = "\n";
+	}
+	else
+	if($br)
+	{
+		$br = "<br/>\n";
+	}
+
+	print $s . $br;
+}
+
+function getNews($lim, $key, $xml = "", $linkOnly = false, $dateFmtPre = "", $dateFmtSuf = "") // allow overriding in case the file's not in /$PR/
+{
+	global $PR;
+
+	$xml =($xml ? $xml : file_get_contents($_SERVER["DOCUMENT_ROOT"] . "/$PR/" . "news/news.xml"));
+	$news_regex = "%
+			<news\ date=\"([^\"]+)\"\ showOn=\"([^\"]+)\">.*\\n
+			(.+)\\n
+			</news>.*\\n
+			%mx";
+
+	if(!$xml)
+	{
+		print "<p><b><i>Error</i></b> Couldn't find any news!</p>\n";
+	}
+
+	$regs = null;
+	preg_match_all($news_regex, $xml, $regs);
+	$i_real = 0;
+	foreach(array_keys($regs[0]) as $i)
+	{
+		if($i_real >= $lim && $lim > 0)
+		{
+			return;
+		}
+
+		$showOn = explode(",", $regs[2][$i]);
+		if($key == "all" || in_array($key, $showOn))
+		{
+			$i_real++;
+			print "<p>\n";
+			if(strtotime($regs[1][$i]) > strtotime("-3 weeks"))
+			{
+				if(preg_match("/update/i", $regs[3][$i]))
+				{
+					print '<img src="/modeling/images/updated.gif" alt="Updated!"/> ';
+				}
+				else
+				{
+					print '<img src="/modeling/images/new.gif" alt="New!"/> ';
+				}
+
+			}
+			if(!$dateFmtPre && !$dateFmtSuf)
+			{
+				$app =(date("Y", strtotime($regs[1][$i])) < date("Y") ? ", Y" : "");
+				print date("M" . '\&\n\b\s\p\;jS' . $app, strtotime($regs[1][$i])) . ' - ' . "\n";
+			}
+			else
+			if($dateFmtPre)
+			{
+				print date($dateFmtPre, strtotime($regs[1][$i]));
+			}
+			if($linkOnly)
+			{
+				$link = preg_replace("#.+(<a .+</a>).+#", "$1", $regs[3][$i]);
+			}
+			else
+			{
+				$link = $regs[3][$i];
+			}
+			print $link;
+			if($dateFmtSuf)
+			{
+				print date($dateFmtSuf, strtotime($regs[1][$i]));
+			}
+			print "</p>\n";
+		}
+	}
+}
+
+/* TODO: remove this when we upgrade php to >= 4.3.0 everywhere */
+if(!function_exists("file_get_contents"))
+{
+	function file_get_contents($file)
+	{
+		return(is_file($file) ? join("", file($file)) : "");
+	}
+}
+
+function getProjectArray($projects, $extraprojects, $nodownloads, $PR) //only the projects we have the files for
+{
+	$pwd = getPWD();
+
+	$projs = loadDirSimple($pwd, ".*", "d"); // locally available
+	foreach($nodownloads as $z)
+	{
+		/* php <4.2.0 returns NULL on array_search() failure, but php >=4.2.0 returns FALSE on array_search() failure, so don't check that */
+		if(is_numeric($s = array_search($z, $projs)))
+		{
+			unset($projs[$s]);
+		}
+	}
+
+	return array_intersect(array_merge($projects, $extraprojects), $projs);
+}
+
+function doSelectProject($projectArray, $proj, $nomenclature, $style = "homeitem3col", $showAll = "", $showMax = "", $sortBy = "")
+{
+	global $incubating;
+	$vars = array("showAll", "showMax", "sortBy", "hlbuild");
+	$tmp = preg_replace("#^/#", "", $proj);
+
+	$hlbuild =(isset($_GET["hlbuild"]) && preg_match("/^[IMNRS]\d{12}$/", $_GET["hlbuild"]) ? $_GET["hlbuild"] : "");
+
+	$out = "<div class=\"" .($style == "sideitem" ? "sideitem" : "homeitem3col") . "\">\n";
+	$tag =($style == "sideitem" ? "h6" : "h3");
+	$out .= "<$tag>";
+	if($style != "sideitem" && isset($incubating) && in_array($tmp, $incubating))
+	{
+		$out .= '<a href="http://www.eclipse.org/projects/what-is-incubation.php"><img style="float:right"
+				src="http://www.eclipse.org/modeling/images/egg-icon.png" alt="Validation (Incubation) Phase"
+				border="0" /></a>';
+	}
+	$out .= "$nomenclature selection</$tag>\n";
+	$out .= "<form action=\"" . $_SERVER["SCRIPT_NAME"] . "\" method=\"get\" id=\"subproject_form\">\n";
+	$out .= "<p>\n";
+	$out .= "<label for=\"project\">$nomenclature: </label>\n";
+
+	$out .= "<select id=\"project\" name=\"project\" onchange=\"javascript:document.getElementById('subproject_form').submit()\">\n";
+	foreach($projectArray as $k => $v)
+	{
+		$out .= "<option value=\"$v\">$k</option>\n";
+	}
+	$out .= "</select>\n";
+	foreach($vars as $z)
+	{
+		if($$z !== "")
+		{
+			$out .= "<input type=\"hidden\" name=\"$z\" value=\"" . $$z . "\"/>\n";
+		}
+	}
+	$out = preg_replace("#<option (value=\"$tmp\")>#", "<option selected=\"selected\" $1>", $out);
+	$out .= "<input type=\"submit\" value=\"Go!\"/>\n";
+	$out .= "</p>\n";
+	$out .= "</form>\n";
+	$out .= "</div>\n";
+
+	return $out;
+}
+
+function project_name($proj)
+{
+	global $projects, $PR;
+
+	if (isset($projects))
+	{
+		$tmp = array_flip($projects);
+		$proj = preg_replace("#^/#", "", $proj);
+		return isset($tmp[$proj]) ? $tmp[$proj] :(isset($tmp[$PR]) ? $tmp[$PR] : "");
+	}
+	else
+	{
+		return strtoupper($proj);
+	}
+
+}
+
+function debug($str, $level = 0)
+{
+	global $debug;
+
+	if($debug > $level)
+	{
+		print "<div class=\"debug\">$str</div>\n";
+	}
+}
+
+function debug_r($str, $header = "", $footer = "", $level = 0, $isPreformatted = false)
+{
+	global $debug;
+
+	if($debug > $level)
+	{
+		if($header)
+		{
+			print "<div class=\"debug\">";
+			print $header;
+			print "</div>\n";
+		}
+		print "<div class=\"debug\">";
+		print $isPreformatted ? "<pre><small>" : "";
+		print_r($str);
+		print $isPreformatted ? "</small></pre>" : "";
+		print "</div>\n";
+		if($footer)
+		{
+			print "<div class=\"debug\">";
+			print $footer;
+			print "</div>\n";
+		}
+	}
+}
+
+function domainSuffix($domain)
+{
+	return preg_replace("/.*([^\.]+\.[^\.]+)$/", "$1", $domain);
+}
+
+/* convert a wiki category page into a series of <li> items */
+function wikiCategoryToListItems($category)
+{
+	$wiki_contents = "";
+
+	// insert wiki content
+	$host = "wiki.eclipse.org";
+	$url = "/Category:" . $category;
+
+	$header = "Host: $host\r\n";
+	$header .= "User-Agent: PHP Script\r\n";
+	$header .= "Connection: close\r\n\r\n";
+
+	$fp = fsockopen($host, 80, $errno, $errstr, 30);
+	if(!$fp)
+	{
+		$out .= "<li><i>$errstr ($errno)</i></li>\n";
+	}
+	else
+	{
+		fputs($fp, "GET $url HTTP/1.1\r\n");
+		fputs($fp, $header);
+		while(!feof($fp))
+		{
+			$wiki_contents .= fgets($fp, 128);
+		}
+		fclose($fp);
+	}
+
+	$out = "";
+	if($wiki_contents)
+	{
+		$m = null;
+		if(preg_match("#<div id=\"mw-pages\">(.+)</div>[ \t\n]*<div class=\"printfooter\">#s", $wiki_contents, $m))
+		{
+			$links = null;
+			if(preg_match_all("#<a href=\"([^\"]+)\" title=\"([^\"]+)\">([^<]+)</a>#", $m[1], $links, PREG_SET_ORDER))
+			{
+				foreach($links as $z)
+				{
+					$out .= "<li><a href=\"http://wiki.eclipse.org/$z[1]\" title=\"$z[2]\">$z[3]</a></li>\n";
+				}
+			}
+		}
+	}
+	return $out;
+}
+
+function getProjectFromPath($PR)
+{
+	$m = null;
+	return preg_match("#/" . $PR . "/([^/]+)/build/.+#", $_SERVER["PHP_SELF"], $m) ? $m[1] :(preg_match("#/(" .
+			$PR . ")/build/.+#", $_SERVER["PHP_SELF"], $m) ? $m[1] : "");
+}
+
+function cvsminus($rev)
+{
+	if(preg_match("/^1\.1$/", $rev)) // "1.10" == "1.1" returns true, curiously enough
+	{
+		return $rev;
+	}
+	else
+	{
+		if(preg_match("/\.1$/", $rev))
+		{
+			return preg_replace("/^(\d+\.\d+)\..+$/", "$1", $rev);
+		}
+		else
+		{
+			return preg_replace("/^(.+\.)(\d+)$/e", "\"$1\" . ($2 - 1);", $rev);
+		}
+	}
+}
+
+function changesetForm($bugid = "")
+{
+	?>
+<form action="http://www.eclipse.org/modeling/emf/news/changeset.php"
+	method="get" target="_blank">
+	<p>
+		<label for="bugid">Bug ID: </label><input size="7" type="text"
+			name="bugid" id="bugid" value="<?php print $bugid; ?>" /> <input
+			type="submit" value="Go!" />
+	</p>
+	<p>
+		<a href="javascript:void(0)"
+			onclick="javascript:this.style.display = 'none'; document.getElementById('changesetinfo').style.display = 'block';">How
+			does this work?</a>
+	</p>
+	<div id="changesetinfo" style="display: none">
+		<p>Use this form to generate a bash shell script which can be run
+			against the projects and plugins in your workspace to produce a patch
+			file showing all changes for a given bug.</p>
+		<p>
+			The requested bug must be indexed in the <a
+				href="http://www.eclipse.org/modeling/searchcvs.php?q=190525">Search
+				CVS</a> database. Download the generated script for more
+			information. If the script is empty, then the bug was not found.
+		</p>
+	</div>
+</form>
+<?php
+
+}
+
+function tokenize($in) # split a shell command into flag/value pairs
+{
+	/* 17722 ? Ss 0:00 /bin/bash /home/www-data/build/modeling/scripts/start.sh -proj gmf
+	 * -sub gmf -version 2.1.0 -branch HEAD
+	* -URL http://download.eclipse.org/eclipse/downloads/drops/S-3.4M7-200805020100/eclipse-SDK-3.4M7-linux-gtk.tar.gz
+	* -URL http://download.eclipse.org/modeling/emf/emf/downloads/drops/2.4.0/S200805052017/emf-sdo-xsd-SDK-2.4.0M7.zip
+	* -URL http://download.eclipse.org/modeling/mdt/uml2/downloads/drops/2.2.0/S200805052208/mdt-uml2-SDK-2.2.0M7.zip
+	* -URL http://download.eclipse.org/tools/orbit/downloads/drops/S20080427194908/orbitBundles-S20080427194908.map
+	* -URL http://emft.eclipse.org/modeling/mdt/ocl/downloads/drops/1.2.0/S200805061053/mdt-ocl-SDK-1.2.0M7.zip
+	* -URL http://emft.eclipse.org/modeling/emf/query/downloads/drops/1.2.0/S200805061125/emf-query-SDK-1.2.0M7.zip
+	* -URL http://download.eclipse.org/modeling/emf/transaction/downloads/drops/1.2.0/S200805061205/emf-transaction-SDK-1.2.0M7.zip
+	* -URL http://emft.eclipse.org/modeling/emf/validation/downloads/drops/1.2.0/S200805061125/emf-validation-SDK-1.2.0M7.zip
+	* -URL http://download.eclipse.org/tools/gef/downloads/drops/3.4.0/S200804291800/GEF-ALL-3.4.0M7.zip -antTarget run
+	* -mapfileRule use-false -buildType I -javaHome /opt/sun-java2-5.0 -downloadsDir /home/www-data/build/downloads
+	* -buildDir /home/www-data/build/modeling/gmf/gmf/downloads/drops/2.1.0/I200805072353
+	* -email gmf-releng@eclipse.org,nickboldt@gmail.com,max.feldman@borland.com,anthonyh@ca.ibm.com
+	* -basebuilderBranch RC1_34
+	*/
+	$bits = explode(" -", $in);
+	$pairs["cmd"] = $bits[0];
+	for($i = 1; $i < sizeof($bits); $i++)
+	{
+		$pair = explode(" ", $bits[$i]);
+		if(isset($pair[0]) && isset($pair[1]))
+		{
+			$pairs[$pair[0]] = $pair[1];
+		}
+		else
+		if(isset($pair[0]))
+		{
+			$pairs[$pair[0]] = "";
+		}
+	}
+	return $pairs;
+}
+
+function addGoogleAnalyticsTrackingCodeToHeader($UA = "UA-2566337-8")
+{
+	# http://wiki.eclipse.org/Using_Phoenix#Google_Analytics
+	global $App;
+	$App->SetGoogleAnalyticsTrackingCode("$UA");
+}
+
+function getDownloadScript()
+{
+	global $PR;
+	if(strstr($PR, "/") !== false)
+	{
+		list($topProj, $parentProj) = explode("/", $PR); # modeling, emf
+	}
+	else
+	{
+		list($topProj, $parentProj) = array("NONE", $PR); # NONE, gef
+	}
+
+	# if this is a Modeling page, use /modeling/download.php;
+	# if this is a GEF page, use /gef/download.php
+	# if /foo/download.php doesn't exist, revert to /downloads/download.php
+	$dlScriptFile = $_SERVER["DOCUMENT_ROOT"] . "/" .($topProj == "NONE" ? $parentProj : $topProj) . "/download.php";
+	#print "[$dlScriptFile =? " . is_file($dlScriptFile) . "]<br>";
+	if(is_file($dlScriptFile))
+	{
+		$downloadScript = "http://www.eclipse.org/" .($topProj == "NONE" ? $parentProj : $topProj) . "/download.php?file=";
+	}
+	else
+	{
+		$downloadScript = "http://www.eclipse.org/downloads/download.php?file=";
+	}
+	return $downloadScript;
+}
+
+/* thanks to http://www.php.net/manual/en/function.filesize.php#80995 */
+function dirsize($path)
+{
+	$dirsize = exec("du -s $path");
+	if($dirsize)
+	{
+		$dirsize = explode(" ", $dirsize);
+		return($dirsize[0] - 0) * 1024;
+	}
+	if(!is_dir($path))
+	{
+		return filesize($path);
+	}
+	$size = 0;
+	foreach(scandir($path) as $file)
+	{
+		if($file != '.' && $file != '..')
+		{
+			$size += dirsize($path . '/' . $file);
+		}
+	}
+	return $size;
+}
+
+function pretty_size($bytes)
+{
+	$sufs = array("B", "K", "M", "G", "T", "P"); //we shouldn't be larger than 999.9 petabytes any time soon, hopefully
+	$suf = 0;
+
+	while($bytes >= 1000)
+	{
+		$bytes /= 1024;
+		$suf++;
+	}
+
+	return sprintf("%3.1f%s", $bytes, $sufs[$suf]);
+}
+
+?>