1 <? require_once("inc/header.php"); ?>
5 $version = $_GET["version"];
8 "bacula" => "Source Code",
9 "Win32_64" => "Windows",
10 "rpms" => "Linux RPMs (official)",
11 "rpms-contrib-psheaffer" => "Linux RPMs (psheaffer)",
12 "rpms-contrib-fschwarz" => "Linux RPMs (fschwarz)",
13 "depkgs" => "Dependency package (mtx, SQLite3)",
14 "depkgs-qt" => "Dependency package (qt4 to build bat)"
28 curl_setopt($ch, CURLOPT_URL, "http://sourceforge.net/projects/bacula/files/");
29 curl_setopt($ch, CURLOPT_HEADER, false);
30 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
31 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
32 $res = curl_exec($ch);
35 $res = strstr($res, "All Files");
37 $res = str_replace("\n", "", $res);
38 $res = str_replace("\r", "", $res);
40 // get list of all available files and their attributes
41 $count = preg_match_all(
43 "!href=\"(/projects/bacula/files/([^/]+)/([^/]+)/([^/]+)/download)\"" .
44 // size date downloads
45 ".*?<td>([\d\.]+ [a-zA-Z]+)</td>.*?<td>(.*?)</td>.*?<td>(.*?)</td>!",
46 $res, $files, PREG_SET_ORDER);
48 // remove duplicates (due to "latest files" list)
49 $out = array_filter_unique(
50 $files, create_function('$a,$b', 'return strcmp($a[1], $b[1]);'));
54 function array_filter_unique($array, $compare)
56 usort($array, $compare);
57 for ($x = 0; $x < count($array) - 1; $x++)
58 if (call_user_func($compare, $array[$x], $array[$x+1]) != 0)
61 $out[] = $array[count($array) - 1]; // last one is never a dupe
65 function versioncmp($a, $b)
67 // [0] = entire string, [1] = major, [2] = minor, [3] = rev
68 for ($x = 1; $x < count($a); $x++)
79 function getversions(&$files)
83 // assemble version strings into their own array
84 foreach ($files as $file)
85 $versions[] = $file[$VER];
87 // filter out versions not matching A.B.Cd format
88 $versions = preg_grep("/^[0-9]+\.[0-9]+\.[0-9]+[a-z]?$/", $versions);
90 // split string into array at '.' and prepend original string
91 foreach ($versions as $version)
93 $tmp = explode(".", $version);
94 $out[] = array_merge((array)$version, $tmp);
97 // remove identical versions
98 $out = array_filter_unique($out, "versioncmp");
100 // create result array containing original strings
101 for ($x = 0; $x < count($out); $x++)
102 $out2[] = $out[$x][0];
104 // finally, return array in reverse order (most recent version first)
105 return array_reverse($out2);
109 $avail_versions = getversions($files);
112 $version = $avail_versions[0];
114 $version_ = strtr($version, ".", "_");
116 $notes = "https://bacula.git.sourceforge.net/git/gitweb-index.cgi";
117 $chglog = "http://apcupsd.cvs.sourceforge.net/viewvc/*checkout*/apcupsd/apcupsd/ChangeLog?pathrev=Release-$version_";
118 $pubkey = "https://sourceforge.net/projects/apcupsd/files/apcupsd%20Public%20Key/Current%20Public%20Key/apcupsd.pub/download";
119 $rpmkey = "https://sourceforge.net/projects/apcupsd/files/apcupsd%20Public%20Key/Current%20Public%20Key/rpmkey-apcupsd-0.1-3.noarch.rpm/download";
122 echo "<title>Bacula $version Downloads</title>\n";
124 echo "<h1>Bacula $version Downloads</h1>\n";
125 echo "<form method=\"get\" action=\"/en/?page=dl&\">\n";
126 echo "Other Versions:\n";
127 echo "<select name=\"version\">\n";
128 foreach ($avail_versions as $ver)
130 echo " <option value=\"$ver\"";
131 if ($ver == $version)
132 echo " selected=\"selected\"";
133 echo ">$ver</option>\n";
136 echo "<input type=\"submit\" value=\"Go\"></input>\n";
139 echo "<a href=\"$notes\">Release Notes</a> | \n";
140 echo "<a href=\"$chglog\">ChangeLog</a> | \n";
141 echo "<a href=\"$pubkey\">Public Key</a> | \n";
142 echo "<a href=\"$rpmkey\">RPM Public Key</a>\n";
145 $colors = array("#E8E8FF", "#B9B9FF");
147 foreach ($category_map as $category => $catname)
152 foreach ($files as $file)
154 $isrpm = preg_match("/\.rpm$/", $file[$NAM]);
155 $issig = preg_match("/\.sig$/", $file[$NAM]);
156 $isrel = $file[$NAM] == "ReleaseNotes";
158 if (!$issig && !$isrel &&
159 $file[$VER] == $version && $file[$CAT] == $category)
161 // only output the table header if table won't be empty
165 echo "<table title=\"$catname\">\n";
166 echo "<tr bgcolor=\"#2E2EFF\">\n";
167 echo " <th><font size=\"+1\" color=\"FFFFFF\">$catname</font></th>\n";
168 echo " <th><font color=\"FFFFFF\"> Signature </font></th>\n";
169 echo " <th><font color=\"FFFFFF\">Size</font></th>\n";
170 echo " <th><font color=\"FFFFFF\"> Release Date </font></th>\n";
171 echo " <th><font color=\"FFFFFF\"> Downloads </font></th>\n";
175 echo "<tr bgcolor=\"$colors[$color]\">\n";
176 echo " <td><a href=\"https://sourceforge.net$file[$URL]\">$file[$NAM]</a></td></td>\n";
178 echo " <td align=\"center\">N/A</td>\n";
180 echo " <td align=\"center\"><a href=\"https://sourceforge.net/projects/bacula/files/$category/$file[$VER]/$file[$NAM].sig/download\">sig</td>\n";
181 echo " <td align=\"right\">$file[$SIZ]</td>\n";
182 echo " <td align=\"center\">$file[$DAT]</td>\n";
183 echo " <td align=\"center\">$file[$DLS]</td>\n";
186 $color = ($color + 1) & 1;
191 echo "</table><br>\n";
198 <? require_once("inc/footer.php"); ?>