Fix situation where AppDB is not at DocumentRoot

This commit is contained in:
Tony Lambregts
2005-07-27 02:10:56 +00:00
committed by WineHQ
parent a45a1fa869
commit 324ed66eae
3 changed files with 12 additions and 9 deletions

View File

@@ -21,8 +21,7 @@ class Image {
*/
function Image($sRelativePath)
{
$this->file = $_SERVER['DOCUMENT_ROOT'].$sRelativePath;
$this->file = appdb_fullpath($sRelativePath);
$info = @getimagesize($this->file);
if( empty($info) )

View File

@@ -36,9 +36,13 @@ function apidb_fullurl($path = "")
return BASE.$path;
}
function apidb_fullpath($path)
function appdb_fullpath($path)
{
return $_SERVER['DOCUMENT_ROOT'].BASE.$path;
/* IE: we know this file is in /yyy/xxx/include, we want to get the /yyy/xxx
/* so we call dirname on this file path twice */
$fullpath = dirname(dirname(__FILE__))."//".$path;
/* get rid of potential double slashes due to string concat */
return str_replace("//", "/", $fullpath);
}

View File

@@ -134,7 +134,7 @@ class Screenshot {
{
$this->oScreenshotImage->delete();
$this->oThumbnailImage->delete();
unlink($_SERVER['DOCUMENT_ROOT']."/data/screenshots/originals/".$this->iScreenshotId);
unlink(appdb_fullpath("/data/screenshots/originals/".$this->iScreenshotId));
if(!$bSilent)
$this->mailMaintainers(true);
}
@@ -208,7 +208,7 @@ class Screenshot {
}
$this->oThumbnailImage->make_thumb(0,0,1,'#000000');
// store the image
$this->oThumbnailImage->output_to_file($_SERVER['DOCUMENT_ROOT']."/data/screenshots/thumbnails/".$this->sUrl);
$this->oThumbnailImage->output_to_file(appdb_fullpath("/data/screenshots/thumbnails/".$this->sUrl));
// now we'll process the screenshot image for watermarking
// load the screenshot
@@ -217,7 +217,7 @@ class Screenshot {
// resize the image
$this->oScreenshotImage->make_full();
// store the resized image
$this->oScreenshotImage->output_to_file($_SERVER['DOCUMENT_ROOT']."/data/screenshots/".$this->sUrl);
$this->oScreenshotImage->output_to_file(appdb_fullpath("/data/screenshots/".$this->sUrl));
// reload the resized screenshot
$this->oScreenshotImage = new Image("/data/screenshots/".$this->sUrl);
if(!$this->oScreenshotImage->isLoaded()) return false;
@@ -225,7 +225,7 @@ class Screenshot {
// add the watermark to the screenshot
$this->oScreenshotImage->add_watermark($watermark->get_image_resource());
// store the watermarked image
$this->oScreenshotImage->output_to_file($_SERVER['DOCUMENT_ROOT']."/data/screenshots/".$this->sUrl);
$this->oScreenshotImage->output_to_file(appdb_fullpath("/data/screenshots/".$this->sUrl));
return true;
}
@@ -321,7 +321,7 @@ function get_screenshot_img($iAppId = null, $iVersionId = null)
}
if(!$hResult || !mysql_num_rows($hResult))
{
$sImgFile = '<center><img src="'.BASE.'images/no_screenshot.png" alt="No Screenshot" /></center>';
$sImgFile = '<center><img src="'.appdb_fullpath("images/no_screenshot.png").'" alt="No Screenshot" /></center>';
} else
{
$oRow = mysql_fetch_object($hResult);