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. 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ require_once('init.php'); $db = new dbcon(); $id = (int) mysql_real_escape_string($_GET['id']); $code = mysql_real_escape_string($_GET['code']); if (!$simpleurl) { $sql = "SELECT `path`,`mime` FROM `files` WHERE `id` = '$id' AND `code` = '$code'"; } else { $sql = "SELECT `path`,`mime` FROM `files` WHERE `id` = '$id'"; } $db->query($sql); if (mysql_num_rows($db->result) === '0') { /* Zero rows returned means that the image was not in the database. Return a 404. */ header("HTTP/1.1 404 Not Found"); echo "The image was not found on this server. It might have been deleted."; die("Please prepare barf-bag..."); } $farray = mysql_fetch_array($db->result); // Should get a unique reply, since id is unique. if ($_GET['t'] != '1') { header("Pragma: cache"); header("Cache-Control: public"); header("Expires: Sun, 17 Jan 2038 19:14:07 GMT"); header("Content-type: $farray[mime]"); // header("Content-length: $farray[size]"; readfile("$uploaddir/$farray[path]"); } else { header("Pragma: cache"); header("Cache-Control: public"); header("Expires: Sun, 17 Jan 2038 19:14:07 GMT"); header("Content-type: image/jpeg"); // header("Content-length: $farray[size]"; readfile("$uploaddir/$farray[path].jpg"); } ?>