00001 <? 00002 /************************************************************************************** 00003 Studentski Informacijski servis, 2004 00004 ************************************************************************************** 00005 downupload.php 00006 download generalnih downloada 00007 00008 00009 Srdjan Segvic - srle 00010 ************************************************************************************** 00011 ************************************************************************************** 00012 This program is free software; you can redistribute it and/or modify 00013 it under the terms of the GNU General Public License as published by 00014 the Free Software Foundation; either version 2 of the License, or 00015 (at your option) any later version. 00016 00017 This program is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 GNU Library General Public License for more details. 00021 00022 You should have received a copy of the GNU General Public License 00023 along with this program; if not, write to the Free Software 00024 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00025 **************************************************************************************/ 00026 session_start(); 00027 $id = $_SESSION['id']; 00028 00029 if (isset($_GET['file_id'])) { 00030 $id_files = $_GET['file_id']; 00031 $pid =$_GET['pid']; 00032 include ('../connect.php'); 00033 $sql = "SELECT * 00034 FROM upload 00035 WHERE upload_ID = '$id_files' 00036 AND predmet_id='$pid'"; 00037 00038 $result = @mysql_query($sql) or die(mysql_error()); 00039 $nr = mysql_num_rows($result); 00040 if ($nr==1){ 00041 $data = @mysql_result($result, 0, "upload"); 00042 $name = @mysql_result($result, 0, "naziv_dokumenta"); 00043 $size = @mysql_result($result, 0, "velicina"); 00044 // $type = @mysql_result($result, 0, "down_tip"); 00045 //$data = stripslashes($data); 00046 00047 $name = str_replace(" ", "_", $name); 00048 00049 //header("Content-type: $type"); 00050 header("Content-length: $size"); 00051 header("Content-Disposition: octet/stream; filename=$name"); 00052 00053 echo $data; 00054 } 00055 else { 00056 echo "GRESKA!"; 00057 } 00058 } 00059 ?>