Main Page | Directories | File List | File Members

files/add.php

Go to the documentation of this file.
00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: add.php 5429 2006-02-17 22:59:20Z toddy $
00006 #
00007 #  Copyright 2002-2003 (c) Mathieu Roy <yeupou--at--gnu.org>
00008 #
00009 # The Savane project is free software; you can redistribute it and/or
00010 # modify it under the terms of the GNU General Public License
00011 # as published by the Free Software Foundation; either version 2
00012 # of the License, or (at your option) any later version.
00013 #
00014 # The Savane project is distributed in the hope that it will be useful,
00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 # GNU General Public License for more details.
00018 #
00019 # You should have received a copy of the GNU General Public License
00020 # along with the Savane project; if not, write to the Free Software
00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 
00023 
00024 # FIXME: this page wont show up if there is nothing for the filelist
00025 # in the download area. It is problematic for people that want to use
00026 # it without having already files in their download area
00027 
00028 require '../include/pre.php';
00029 
00030 $project=project_get_object($group_id);
00031 
00032 if ($group_id) {
00033 
00034   if (member_check(0,$group_id)) {
00035 
00036     site_project_header(array('title'=>_("Add"),
00037                               'group'=>$group_id,
00038                               'context'=>'download'));
00039 
00040 
00041     # NOTE: because it was not really needed for the backend and frontend,
00042     # the download host configuration  per group type has been removed.
00043     # However, if you really need Download type host that would be group
00044     # specific and not equal to the TypeHost, write to savannah-dev@gnu.org
00045     # Will find a way to configure that.
00046 
00047     $files_dir = $project->getTypeDir("download").$project->getUnixName();
00048     $files_path = $project->getTypeUrl("download").$project->getUnixName();
00049     $scp_dir = $project->getTypeBaseHost().":".$files_dir;
00050 
00051     if ( $project->getTypeName() == 'GNU' ){
00052         $scp_dir = "*not available*".$files_dir;
00053         echo '<h3 class="error">'._("Note for GNU projects").'</h3>';
00054         echo '<p>'._("Currently, since file uploads to ftp.gnu.org are not supported by Savannah at present (You should get in touch with accounts@gnu.org to get permissions to do them), the form below cannot be used.").'</p>';
00055         echo '<p>'._("But, file release system should work if you respect the standard tree explained below.").'</p>';
00056     }
00057 
00058 
00059     printf ('<h2>'._("How does file list work on %s?").'</h2>',$GLOBALS['sys_name']);
00060     echo '<p>'.sprintf(_("On %s, you must use scp, sftp or rsync via SSH to upload your files."),$GLOBALS['sys_name']);
00061         echo _("We prefer this way of managing files for security matters and also because scp and rsync are designed for this kind of usage, unlike a web browser.");
00062         echo ' '._("We want the file management system to be usable with a shell.").'</p>';
00063         echo '<p>'._("The following form won't upload files. It will display a list of commands that you will have to copy and paste in a terminal.").'</p>';
00064         printf ('<p>'._("If you follow the directory organisation outlined below, the %s %s Filelist for your project%s (available once you have checked the corresponding box in your %s Project Public Info %s) will display the versions in a user friendly way. Otherwise, the visitor of your project will be presented a regular directory listing.").'</p>','<a href="'.$GLOBALS['sys_home'].'files/?group_id='.$group_id.'">',$GLOBALS['sys_name'],'</a>','<a href="'.$GLOBALS['sys_home'].'project/admin/editgroupinfo.php?group_id='.$group_id.'">','</a>');
00065     echo '<p>'._("The suggested layout is as follows:").'<br />';
00066     echo '&nbsp;&nbsp;'.$files_dir.' &nbsp;&nbsp;&nbsp;<em>'._("is your dedicated area").'</em><br />';
00067     echo '&nbsp;&nbsp;&nbsp;&nbsp;'.$files_dir.'/unstable.pkg &nbsp;&nbsp;&nbsp;<em>'._("is the package/branch name, since you can have as many packages/branches as you want.").' '._("It must end with .pkg.").'</em><br />';
00068     echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$files_dir.'/unstable.pkg/1.0.0 &nbsp;&nbsp;&nbsp;<em>'._("is the version name/number for the package/branch we call unstable.").'</em><br />';
00069     echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$files_dir.'/unstable.pkg/1.0.0/my_project-1.0.0.tar.gz &nbsp;&nbsp;&nbsp;<em>'._("is a package that users can download for this version of this package/branch.").'</em></p>';
00070 
00071 
00072     echo '<p class="error">'._("Note that the package name should be the name of the .tar.gz file. Or whatever you want, but it must not contain characters as \" \" (whitespace) or \"/\" (slash).").'</p>';
00073 
00074     echo '<p><strong class="error">'._("Help!").'</strong> '.sprintf (_("You may take a look at the %s FAQ about %sHow do I add files in the download area%s, especially the \"Tips\" part.").'</p>',$GLOBALS['sys_name'],'<a href="'.$GLOBALS['sys_home'].'faq/?group_id=11&question=How_do_I_add_files_in_the_download_area.txt">','</a>');
00075 
00076 
00077     echo '<h2>'._("Getting a command list to upload the files:").'</h2>';
00078     echo '<form action="'. $PHP_SELF .'#list" method="post">
00079 <table>';
00080     echo '<input type="hidden" name="group_id" value="'.$group_id.'" />';
00081     echo '<tr><td>'._("Package / Branch:").' </td><td><input type="text" name="pkg" value="'.$pkg.'" size="20" maxlength="30" /> ('._("ex: the project name, or stable / unstable").')</td></tr>';
00082     echo '<tr><td>'._("Version:").' </td><td><input type="text" name="version" value="'.$version.'" size="20" maxlength="30" /> ('._("ex: 1.0.0 or 20020427").')</td></tr>';
00083     echo '<tr><td>'._("1st File:").' </td><td><input type="text" name="input_file1" size="40" value="'.$input_file1.'" /> ('
00084         ._("this should be the absolute path of the file on your machine").')</td></tr>';
00085     echo '<tr><td>'._("2nd File:").' </td><td><input type="text" name="input_file2" size="40" value="'.$input_file2.'" /> ('._("this should be the absolute path of the file on your machine").')</td></tr>';
00086     echo '<tr><td>'._("3rd File:").' </td><td><input type="text" name="input_file3" size="40" value="'.$input_file3.'" /> ('._("this should be the absolute path of the file on your machine").')</td></tr>';
00087     echo '<tr><td>'._("4th File:").' </td><td><input type="text" name="input_file4" size="40" value="'.$input_file4.'" /> ('._("this should be the absolute path of the file on your machine").')</td></tr>';
00088     echo '<tr><td>'._("5th File:").' </td><td><input type="text" name="input_file5" size="40" value="'.$input_file5.'" /> ('._("this should be the absolute path of the file on your machine").')</td></tr>';
00089     echo '<tr><td>'._("6th File:").' </td><td><input type="text" name="input_file6" size="40" value="'.$input_file6.'" /> ('._("this should be the absolute path of the file on your machine").')</td></tr>';
00090     echo '<tr><td>'._("7th File:").' </td><td><input type="text" name="input_file7" size="40" value="'.$input_file7.'" /> ('._("this should be the absolute path of the file on your machine").')</td></tr>';
00091     echo '<tr><td>'._("8th File:").' </td><td><input type="text" name="input_file8" size="40" value="'.$input_file8.'" /> ('._("this should be the absolute path of the file on your machine").')</td></tr>';
00092     echo '<tr><td>'._("9th File:").' </td><td><input type="text" name="input_file9" size="40" value="'.$input_file9.'" /> ('._("this should be the absolute path of the file on your machine").')</td></tr>
00093 </table>';
00094     echo '<br /><input type="submit" name="submit_command_list" value="'._("Show me the commands list").'"" />&nbsp;&nbsp;&nbsp;&nbsp;';
00095 
00096 #echo '<INPUT TYPE="SUBMIT" NAME="submit_last_release" VALUE="Set this version as latest release">';
00097 
00098     echo '<form>';
00099 
00100   function scp_command($input_file,$scp_dir,$pkg,$version){
00101    if ($input_file!=""){
00102      echo '<br />&nbsp;&nbsp;&nbsp;# package '.$input_file;
00103      echo '<br />&nbsp;&nbsp;&nbsp;mkdir -pv /tmp/sv_upload/'.$pkg.'.pkg/'.$version.'/ && cp "'.$input_file.'" /tmp/sv_upload/'.$pkg.'.pkg/'.$version.'/';
00104      echo '<br />&nbsp;&nbsp;&nbsp;scp -vr /tmp/sv_upload/* '.user_getname().'@'.$scp_dir.'/';
00105      echo '<br />&nbsp;&nbsp;&nbsp;rm -rf /tmp/sv_upload';
00106    }
00107  }
00108 
00109  if ($submit_command_list) {
00110    echo '<h3>'._("Here is the command list:").'</h3>';
00111    if($pkg=="") {
00112         echo '<span class="error">'._("You must specify a Package / Branch name.").'</span>';
00113    } elseif($version=="") {
00114         echo '<span class="error">'._("You must specify a Version name.").'</span>';
00115    } else {
00116      echo '<a name="list"></a><p>'._("Here is the result of the information you give.").' '._("Basically, you just have to copy and paste those commands in a terminal.").'';
00117 scp_command($input_file1,$scp_dir,$pkg,$version);
00118 scp_command($input_file2,$scp_dir,$pkg,$version);
00119 scp_command($input_file3,$scp_dir,$pkg,$version);
00120 scp_command($input_file4,$scp_dir,$pkg,$version);
00121 scp_command($input_file5,$scp_dir,$pkg,$version);
00122 scp_command($input_file6,$scp_dir,$pkg,$version);
00123 scp_command($input_file7,$scp_dir,$pkg,$version);
00124 scp_command($input_file8,$scp_dir,$pkg,$version);
00125 scp_command($input_file9,$scp_dir,$pkg,$version);
00126    }
00127  }
00128 
00129 if ($submit_last_release){
00130   echo '<a name="list"></a>';
00131   if(file_exists($files_dir."/".$pkg.".pkg/".$version)) {
00132         $latest_release_is_file = $files_dir."/".$pkg.".pkg/LATEST_RELEASE_IS";
00133         $fopened = fopen($latest_release_is_file,"w");
00134         fputs($fopened,$version);
00135         fclose($fopened);
00136 
00137         echo '<h3 class="error">'._("UPDATED: now the specified version is highlighted").'</h3>';
00138         printf (_("Note that you can also add a #%s to the HTML links to your filelist, as %s"),$pkg.$version,'<a href="'.$GLOBALS['sys_home'].'files/?group='.$group_name.'#'.$pkg.$version.'">http://'.$GLOBALS['sys_default_domain'].$GLOBALS['sys_home'].'files/?group='.$group_name.'#'.$pkg.$version.'</a>');
00139         printf ('<p>'._("Alternatively, you can make a link to %s").'</p>', '<a href="'.$GLOBALS['sys_home'].'files/?group='.$group_name.'#'.pkg.'latest">http://'.$GLOBALS['sys_default_domain'].$GLOBALS['sys_home'].'files/?group='.$group_name.'#'.$pkg.'latest</a>');
00140         echo '<h3>'._("How does it work, how to do this without a web browser?").'</h3>
00141         '._("It just creates a nice LATEST_RELEASE_IS file in the package dir with the version name as content.").'
00142         <p>'._("You can do this job exactly by making a similar file and upload it:").'<br />
00143         <br />&nbsp;&nbsp;&nbsp;echo "'.$version.'" &gt; LATEST_RELEASE_IS
00144         <br />&nbsp;&nbsp;&nbsp;scp LATEST_RELEASE_IS '.user_getname().'@'.$scp_dir.'/'.$pkg.'.pkg/</p>';
00145 
00146   } else {
00147         printf ('<h3 class="error">'._("There is no such Package / Branch or Version online for %s"),$project->getUnixName());
00148         echo '</h3>';
00149   }
00150 
00151 }
00152 
00153 site_project_footer(array());
00154 
00155 } else {
00156   exit_error(_("Error"),_("You do not have the required privileges to access this page"));
00157 }
00158 
00159 } else {
00160   exit_no_group();
00161 }
00162 
00163 ?>

Generated on Sun Feb 26 13:23:03 2006 for Savane PHP Frontend Developer Reference by  doxygen 1.4.4