]> git.sur5r.net Git - bacula/docs/blob - docs/home-page/en/pages/dl.php
Merge branch 'master' of ssh://bacula.git.sourceforge.net/gitroot/bacula/docs
[bacula/docs] / docs / home-page / en / pages / dl.php
1 <? require_once("inc/header.php"); ?>
2
3 <?php
4
5 $version = $_GET["version"];
6
7 $category_map = array(
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)"
15 );
16
17 $URL  = 1;
18 $CAT  = 2;
19 $VER  = 3;
20 $NAM  = 4;
21 $SIZ  = 5;
22 $DAT  = 6;
23 $DLS  = 7;
24
25 function getfiles()
26 {
27    $ch = curl_init();
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);
33    curl_close($ch);
34
35    $res = strstr($res, "All Files");
36 //   echo "res=$res";
37    $res = str_replace("\n", "", $res);
38    $res = str_replace("\r", "", $res);
39
40    // get list of all available files and their attributes
41    $count = preg_match_all(
42       //                                  cat    vers    name
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);
47
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]);'));
51    return $out;
52 }
53
54 function array_filter_unique($array, $compare)
55 {
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)
59          $out[] = $array[$x];
60    if (count($array))
61       $out[] = $array[count($array) - 1]; // last one is never a dupe
62    return $out;
63 }
64
65 function versioncmp($a, $b)
66 {
67    // [0] = entire string, [1] = major, [2] = minor, [3] = rev
68    for ($x = 1; $x < count($a); $x++)
69    {
70       if ($a[$x] < $b[$x])
71          return -1;
72       if ($a[$x] > $b[$x])
73          return 1;
74    }
75
76    return 0;
77 }
78
79 function getversions(&$files)
80 {
81    global $VER;
82
83    // assemble version strings into their own array
84    foreach ($files as $file)
85       $versions[] = $file[$VER];
86
87    // filter out versions not matching A.B.Cd format
88    $versions = preg_grep("/^[0-9]+\.[0-9]+\.[0-9]+[a-z]?$/", $versions);
89
90    // split string into array at '.' and prepend original string
91    foreach ($versions as $version)
92    {
93       $tmp = explode(".", $version);
94       $out[] = array_merge((array)$version, $tmp);
95    }
96
97    // remove identical versions
98    $out = array_filter_unique($out, "versioncmp");
99
100    // create result array containing original strings
101    for ($x = 0; $x < count($out); $x++)
102       $out2[] = $out[$x][0];
103
104    // finally, return array in reverse order (most recent version first)
105    return array_reverse($out2);
106 }
107
108 $files = getfiles();
109 $avail_versions = getversions($files);
110
111 if ($version == "")
112    $version = $avail_versions[0];
113
114 $version_ = strtr($version, ".", "_");
115
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";
120
121 echo "<html>\n";
122 echo "<title>Bacula $version Downloads</title>\n";
123 echo "<body>\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)
129 {
130    echo "  <option value=\"$ver\"";
131    if ($ver == $version)
132       echo " selected=\"selected\"";
133    echo ">$ver</option>\n";
134 }
135 echo "</select>\n";
136 echo "<input type=\"submit\" value=\"Go\"></input>\n";
137 echo "</form>\n";
138 echo "<p>\n";
139 echo "<a href=\"$notes\">Release Notes</a>&nbsp;|&nbsp;\n";
140 echo "<a href=\"$chglog\">ChangeLog</a>&nbsp;|&nbsp;\n";
141 echo "<a href=\"$pubkey\">Public Key</a>&nbsp;|&nbsp;\n";
142 echo "<a href=\"$rpmkey\">RPM Public Key</a>\n";
143 echo "<p>\n";
144
145 $colors = array("#E8E8FF", "#B9B9FF");
146
147 foreach ($category_map as $category => $catname)
148 {
149    $color = 0;
150    $header = false;
151
152    foreach ($files as $file)
153    {
154       $isrpm = preg_match("/\.rpm$/", $file[$NAM]);
155       $issig = preg_match("/\.sig$/", $file[$NAM]);
156       $isrel = $file[$NAM] == "ReleaseNotes";
157
158       if (!$issig && !$isrel &&
159           $file[$VER] == $version && $file[$CAT] == $category)
160       {
161          // only output the table header if table won't be empty
162          if (!$header)
163          {
164             $header = true;
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\">&nbsp;Signature&nbsp;</font></th>\n";
169             echo "  <th><font color=\"FFFFFF\">Size</font></th>\n";
170             echo "  <th><font color=\"FFFFFF\">&nbsp;Release Date&nbsp;</font></th>\n";
171             echo "  <th><font color=\"FFFFFF\">&nbsp;Downloads&nbsp;</font></th>\n";
172             echo "</tr>\n";
173          }
174
175          echo "<tr bgcolor=\"$colors[$color]\">\n";
176          echo "  <td><a href=\"https://sourceforge.net$file[$URL]\">$file[$NAM]</a></td></td>\n";
177          if ($isrpm)
178             echo "  <td align=\"center\">N/A</td>\n";
179          else
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";
184          echo "</tr>\n";
185
186          $color = ($color + 1) & 1;
187       }
188    }
189
190    if ($header)
191       echo "</table><br>\n";
192 }
193
194 echo "</body>\n";
195 echo "</html>\n";
196 ?>
197
198 <? require_once("inc/footer.php"); ?>