From 5dcc4e3ae75ee5dbff658bd5684de5a007e1f2ed Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Sun, 31 Jul 2005 04:23:06 +0000 Subject: [PATCH] Use the url field from appData and not the id as the name of the file in the filesystem. It is only lately that the filenames of images are equal to the id of the row in the appData table --- appimage.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/appimage.php b/appimage.php index 1a59075..792f930 100644 --- a/appimage.php +++ b/appimage.php @@ -24,11 +24,23 @@ if ($_REQUEST['REQUEST_METHOD']='HEAD') errorpage("Bad parameter"); exit; } - $sQuery = "SELECT id FROM appData + $sQuery = "SELECT id, url FROM appData WHERE id = ".$iId." AND type = 'image' LIMIT 1"; - if (!($hResult = query_appdb($sQuery) && - $fImage = fopen(appdb_fullpath("data/screenshots/".$iId), "rb"))) + $hResult = query_appdb($sQuery); + $fImage = 0; + if($hResult) + { + $oRow = mysql_fetch_object($hResult); + + /* we need to use the url field from appData, this is the name of the file */ + /* in the filesystem */ + $fImage = fopen(appdb_fullpath("data/screenshots/".$oRow->id), "rb"); + } + + /* if the query failed or if we didn't find the image, we should */ + /* report a 404 to the browser */ + if(!$hResult || !$fImage) { header("404 No such image"); exit;