[Openfirst-cvscommit] downloads getfile.php,NONE,1.1 index.php,NONE,1.1 notfound.php,NONE,1.1
Brought to you by:
xtimg
From: <i-...@us...> - 2003-10-07 01:33:28
|
Update of /cvsroot/openfirst/downloads In directory sc8-pr-cvs1:/tmp/cvs-serv27295 Added Files: getfile.php index.php notfound.php Log Message: Download manager. Initial upload. Needs mssql setup script. --- NEW FILE: getfile.php --- <?php /* * openFIRST.downloads - getfile.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Greg Inozemtsev <gr...@si...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ include("../config/globals.php"); if(isset($_GET["id"])){ $id=$_GET["id"]; } else{ header("Location: notfound.php"); } $query=ofirst_dbquery("SELECT FileData,mime,hits FROM ofirst_downloads WHERE ID='".$id."';"); if (ofirst_dbnum_rows($query)==0){ header("Location: notfound.php"); } else { $file = ofirst_dbfetch_object($query); ofirst_dbquery("UPDATE ofirst_downloads SET hits=".($file->hits+1)." WHERE ID='".$id."';"); if(ereg("location:*",$file->FileData)){ header("Location: ".substr($file->FileData,9)); } else{ header("Content-type: ".$file->mime); echo(base64_decode($file->FileData)); } } ?> --- NEW FILE: index.php --- <?php /* * openFIRST.downloads - index.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Greg Inozemtsev <gr...@si...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ include("../config/globals.php"); include($header); //whether to show images $images=true; //columns per page define("cols",3); //rows per page define("rows",1); $admin=false; if (isset($user->membertype)){ $admin=($user->membertype == "administrator"); } $category=""; if(isset($_GET["cat"])){ $category=$_GET["cat"]; } $page=1; if(isset($_GET["page"])){ if($_GET["page"]>0){ $page=$_GET["page"]; } } if($category==""){ //main page $cattitle="Featured Downloads"; echo("<h1>Downloads Home</h1>"); echo("<div>Welcome to $title download area.</div>"); $query = ofirst_dbquery("SELECT * FROM ofirst_downloadcat ORDER BY Category"); if(ofirst_dbnum_rows($query)!=0){ echo("<div>Please select a category from the list below.<br><br></div>"); echo("<table width=400><tr><th>Categories</th></tr>"); echo('<tr><td><a href="'.$_SERVER["PHP_SELF"].'">'); if($images){ echo('<img border=0 align=absmiddle src="'.$basepath.'/members/icons/filesystems/folder_home.png"> '); } echo('Featured Downloads</a></td></tr>'); while($cat = ofirst_dbfetch_object($query)){ echo('<tr><td><a href="'.$_SERVER["PHP_SELF"].'?cat='.$cat->ID.'">'); if(($images)&&($cat->Icon!="")){ echo('<img border=0 align=absmiddle src="'.$basepath."/".$cat->Icon.'"> '); } else { echo("> "); } echo($cat->Category.'</a></td></tr>'); } echo("</table>"); } } else { $query = ofirst_dbquery("SELECT * FROM ofirst_downloadcat WHERE ID='".$category."'"); if(ofirst_dbnum_rows($query)==0){ echo("<div>The specified category does not exist</div>"); } else{ $cat = ofirst_dbfetch_object($query); echo("<h1>$cat->Category</h1>"); echo("<div>$cat->Description<br><br></div>"); $category=$cat->Category; $cattitle="Category: ".$category; } } $query = ofirst_dbquery("SELECT * FROM ofirst_downloads WHERE Category='".$category."' ORDER BY Title"); $numfiles=ofirst_dbnum_rows($query); if ($numfiles!=0){ echo("<br><br><table><tr><th colspan=".cols.">$cattitle</th></tr><tr><td colspan=".cols.">"); $file = ofirst_dbfetch_object($query); //skip records for($j=1;$j<=cols*rows*($page-1);$j++){ if(!ofirst_dbfetch_object($query)){ break; } } for($j=1;$j<=rows;$j++){ if(!($file==null)){ echo("<tr>"); for($i=1;$i<=cols;$i++){ echo("<td><table height=300 width=250>"); echo('<tr><th colspan=2>'.$file->Title.'</th></tr>'); echo('<tr><td><b>Title</b></td><td>'.$file->Title.'</td></tr>'); echo('<tr><td><b>Description</b></td><td>'.$file->Description.'</td></tr>'); //extension echo('<tr><td><b>Type</b></td><td>'); if($file->ext==""){ $file->ext="unknown"; } $queryext = ofirst_dbquery("SELECT * FROM ofirst_workspace_filetypes WHERE extension='".$file->ext."'"); if(ofirst_dbnum_rows($queryext)==0){ $queryext = ofirst_dbquery("SELECT * FROM ofirst_workspace_filetypes WHERE extension='unknown'");; } $type = ofirst_dbfetch_object($queryext); echo('<img align=absmiddle src="'.$basepath."/members/".$type->image.'"> '); echo($type->description." (".$file->ext.') </td></tr>'); echo('<tr><td><b>Date</b></td><td>'.$file->DateAdded.'</td></tr>'); echo('<tr><td><b>Downloaded</b></td><td>'.$file->hits.' times</td></tr>'); echo('<tr><th colspan=2 align=center><a href="getfile.php?id='.$file->ID.'">Download</a></th></tr>'); if($admin){ echo('<tr><td colspan=2 align=center><a href="admin/killfile.php?id='.$file->ID.'">Delete</a> | <a href="admin/editinfo.php?id='.$file->ID.'">Edit Details</a></td></tr>'); } echo("</table> </td>"); if(!($file = ofirst_dbfetch_object($query))){ if($i<cols){ echo("<td width=* colspan=".(cols-$i)."> </td>"); } break; } } echo("</tr>"); } else { break; } } if($numfiles>cols*rows){ echo("<tr><td colspan=".cols." align=right>"); $curpage=floor($numfiles/(cols*rows))*$page; if($curpage>1){ echo('<a href="'.$_SERVER["PHP_SELF"].'?page='.($curpage-1).'"><< Prev</a> '); } echo("Page ".floor($numfiles/(cols*rows))*$page." of ".ceil($numfiles/(cols*rows))); if($curpage<ceil($numfiles/(cols*rows))){ echo(' <a href="'.$_SERVER["PHP_SELF"].'?page='.($curpage+1).'">Next >></a>'); } echo("</td></tr>"); } echo('<tr><td colspan='.cols.' align=right><br /><a href="'.$_SERVER["PHP_SELF"].'">Downloads Home</a></td></tr></table>'); } if($cattitle!="Featured Downloads"){ echo("<br /><div>Files in this category: $numfiles</div>"); } if($admin){ echo('<br><br><form action=admin/upload.php method=POST enctype="multipart/form-data"> <table width=400><tr><th colspan=2>Add File</th></tr>'); echo('<tr><td> <label for=Title><b>Title</b></label></td><td><input name=Title id=Title></td></tr> <tr><td><label for=newfile><b>File</b></label></td><td><input type=file name=newfile id=newfile> <input name=Category type=hidden value="'.$category.'"></td></tr> <tr><td><label for=Description><b>Description</b></label></td><td><textarea name=Description id=Description></textarea></td></tr> <tr><td> </td><td><input type=checkbox name=db id=db value="1"><label for=db>Store in database</label></td></tr> <tr><td colspan=2 align=center><input type=submit value="Add File"> </td></tr>'); echo("</table></form>"); } include($footer); ?> --- NEW FILE: notfound.php --- <?php /* * openFIRST.downloads - notfound.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Greg Inozemtsev <gr...@si...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ include("../config/globals.php"); include($header); echo("<h1>File Not Found</h1>"); echo("<p>The file you were downloading cannot be found in the system.</p><p>If you followed a link on one of the pages, please report the broken link to the webmaster.</p>"); include($footer); ?> |