00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: index.php 5429 2006-02-17 22:59:20Z toddy $
00006 #
00007 # Copyright 2002-2004 (c) Mathieu Roy <yeupou--at--gnu.org>
00008 # Derek Feichtinger <derek.feichtinger--at--cern.ch>
00009 # Yves Perrin <yves.perrin--at--cern.ch>
00010 #
00011 # The Savane project is free software; you can redistribute it and/or
00012 # modify it under the terms of the GNU General Public License
00013 # as published by the Free Software Foundation; either version 2
00014 # of the License, or (at your option) any later version.
00015 #
00016 # The Savane project is distributed in the hope that it will be useful,
00017 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 # GNU General Public License for more details.
00020 #
00021 # You should have received a copy of the GNU General Public License
00022 # along with the Savane project; if not, write to the Free Software
00023 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024
00025 require "../include/pre.php";
00026
00027 if ($group_id) {
00028
00029 $files_dir = $project->getDir("download");
00030 $files_path = $project->getUrl("download");
00031
00032 dbg("dir:$files_dir path:$files_path");
00033
00034 # If nothing is found, redirect on the configured area
00035
00036 if (!$project->CanUse("download") || $files_dir == '/' || $files_dir == '')
00037 { Header("Location: $files_path"); }
00038 else
00039 {
00040
00041 # ################################### BUILD CONTENT
00042
00043 $content .= '<p>'._("Below is a list of files of the project. You can access the project download area directly at").' <a href="'.$files_path.'">'.$files_path.'</a>';
00044
00045
00046
00047 if (!isset($thread_max)) {
00048 $thread_max = "4";
00049 } else {
00050 $thread_max = $thread_max - 1;
00051 }
00052 if (!isset($thread_show)) {
00053 $thread_show = "0";
00054 }
00055
00056 if (!isset($highlight)) {
00057 $highlight = "?.?.?";
00058 }
00059
00060
00061 $content .= '<form action="'. $PHP_SELF .'" method="get">';
00062 $content .= '<input type="hidden" NAME="group_id" value="'.$group_id.'" />';
00063 $content .= '<h3>'.sprintf(_("Show %s and highlight version %s."),'<select name="thread_max"><option value="1"> 1</option><option value="3"> 3</option><option value="5" selected> 5</option><option value="10">10</option><option value="20">20</option><option value="50">50</option></select>', '<input type="text" size="6" name="highlight" value="'.$highlight.'" />');
00064
00065 $content .= ' <input type="submit" value="'._("Apply").'" /></form>';
00066 $content .= '</h3>';
00067
00068 $content .= '<p>';
00069 $i=0;
00070 if (is_dir($files_dir))
00071 {
00072 $package_dir = opendir($files_dir);
00073 $ext = ".pkg";
00074 $lext = strlen($ext);
00075 while ($package_name = readdir($package_dir))
00076 {
00077 $lfile=strlen($package_name)-$lext;
00078 if(@is_dir($files_dir."/".$package_name) && substr($package_name,$lfile,$lext)==$ext)
00079 {
00080
00081 $content .= $HTML->box1_top(ereg_replace(".pkg","",$package_name), 0);
00082 $version_array = "";
00083 $content .= '<tr><td><table width="100%">'."\n";
00084
00085 $i=0;
00086 $content .= '<tr class="'. utils_get_alt_row_color($i) .'"><td> </td><td width="55%" class="bold"> </td><td width="15%" class="center"><em class="smaller">Filesize</em></td><td width="15%" class="center"><em class="smaller">File Type</em></td><td width="15%" class="center"><em class="smaller">Date</em></td></tr>'."\n";
00087
00088
00089 $version_dir = opendir($files_dir."/".$package_name);
00090 while ($version_name = readdir($version_dir))
00091 {
00092 if(is_dir($files_dir."/".$package_name."/".$version_name) && $version_name != ".." && $version_name != ".")
00093 {
00094 $version_array[] = "$version_name";
00095 }
00096 }
00097
00098
00099 $version_max = count($version_array);
00100 if (is_array($version_array))
00101 { rsort($version_array); }
00102 for ($x = 0; $x <$version_max; $x++)
00103 {
00104
00105
00106 $content .= '<tr class="';
00107 if ($highlight==$version_array[$x]) {
00108
00109 $this_row_color = 'boxhighlight';
00110 }
00111 else
00112 {
00113 $this_row_color = utils_get_alt_row_color($i);
00114 }
00115 /* if > $thread_max, we dont show any package details */
00116 /* if = $thead_show, we show package details */
00117 if ($thread_max < $x && $thread_show != $package_name.$x)
00118 {
00119 $content .= $this_row_color.'"><td> </td><td width="55%" class="bold"><a href="'.$PHP_SELF.'?group_id='.$group_id.'&thread_show='.$package_name.$x.'#'.ereg_replace(".pkg","",$package_name).$version_array[$x].'" name="'.ereg_replace(".pkg","",$package_name).$version_array[$x].'">';
00120 $content .= $version_array[$x];
00121 $content .= '</a></td><td width="15%" class="center"> </td><td width="15%" class="center"> </td><td width="15%" class="center"> </td></tr>'."\n";
00122 }
00123 else
00124 {
00125 $content .= $this_row_color.'"><td> </td><td width="55%" class="bold"><a name="'.ereg_replace(".pkg","",$package_name).$version_array[$x].'"></a>';
00126 $content .= $version_array[$x];
00127 $file_array = ""; /* initialise array for files */
00128 $content .= '</td><td width="15%" class="center"> </td><td width="15%" class="center"> </td><td width="15%" class="center"> </td></tr>'."\n";
00129
00130 /* create an array of files */
00131 $final_dir = opendir($files_dir."/".$package_name."/".$version_array[$x]);
00132 while ($file_name = readdir($final_dir))
00133 {
00134 if($file_name != ".." && $file_name != ".")
00135 {
00136 $file_array[] = "$file_name";
00137 }
00138 }
00139 closedir($final_dir);
00140
00141 /* an entry for each file in the array */
00142 $file_max = count($file_array);
00143 if(is_array($file_array))
00144 { sort($file_array); }
00145 for ($z = 0; $z <$file_max; $z++)
00146 {
00147 # Allow directories as items
00148 # if (is_file($files_dir."/".$package_name."/".$version_array[$x]."/".$file_array[$z]))
00149 #{
00150 $content .= '<tr class="'. $this_row_color .'"><td> </td><td>';
00151 $content .= ' <a href="'.$files_path.'/'.$package_name.'/'.$version_array[$x].'/'.$file_array[$z].'">'.$file_array[$z].'</a>';
00152 $content .= '</td><td class="center">';
00153 $content .= utils_filesize($files_dir."/".$package_name."/".$version_array[$x]."/".$file_array[$z]).'</td>';
00154 $content .= '<td class="center">'.utils_fileextension($files_dir."/".$package_name."/".$version_array[$x]."/"
00155 .$file_array[$z]).'</td>';
00156 $content .= '<td class="center">'.format_date('',@filemtime($files_dir."/".$package_name."/".$version_array[$x]."/".$file_array[$z])).'</td>';
00157 $content .= '</tr>'."\n";
00158 #}
00159 }
00160
00161 }
00162 $i++;
00163 }
00164 closedir($version_dir);
00165
00166 $content .= '</table>'."\n";
00167 $content .= $HTML->box1_bottom(0);
00168 $content .= '<br /><br /><br />'."\n";
00169 }
00170 }
00171 closedir($package_dir);
00172 }
00173
00174
00175 }
00176
00177
00178 # ################################### REDIRECT IF NO RESULTS
00179
00180 if (!$i)
00181 {
00182 Header("Location: $files_path");
00183 }
00184
00185
00186 # ################################### PRINT
00187
00188 site_project_header(array('group'=>$group_id,'context'=>'download'));
00189
00190
00191 print $content;
00192
00193 site_project_footer(array());
00194 }
00195 else
00196 {
00197
00198 exit_no_group();
00199
00200 }
00201
00202 ?>