Fix situation where AppDB is not at DocumentRoot
This commit is contained in:
@@ -21,8 +21,7 @@ class Image {
|
|||||||
*/
|
*/
|
||||||
function Image($sRelativePath)
|
function Image($sRelativePath)
|
||||||
{
|
{
|
||||||
$this->file = $_SERVER['DOCUMENT_ROOT'].$sRelativePath;
|
$this->file = appdb_fullpath($sRelativePath);
|
||||||
|
|
||||||
$info = @getimagesize($this->file);
|
$info = @getimagesize($this->file);
|
||||||
|
|
||||||
if( empty($info) )
|
if( empty($info) )
|
||||||
|
|||||||
@@ -36,9 +36,13 @@ function apidb_fullurl($path = "")
|
|||||||
return BASE.$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class Screenshot {
|
|||||||
{
|
{
|
||||||
$this->oScreenshotImage->delete();
|
$this->oScreenshotImage->delete();
|
||||||
$this->oThumbnailImage->delete();
|
$this->oThumbnailImage->delete();
|
||||||
unlink($_SERVER['DOCUMENT_ROOT']."/data/screenshots/originals/".$this->iScreenshotId);
|
unlink(appdb_fullpath("/data/screenshots/originals/".$this->iScreenshotId));
|
||||||
if(!$bSilent)
|
if(!$bSilent)
|
||||||
$this->mailMaintainers(true);
|
$this->mailMaintainers(true);
|
||||||
}
|
}
|
||||||
@@ -208,7 +208,7 @@ class Screenshot {
|
|||||||
}
|
}
|
||||||
$this->oThumbnailImage->make_thumb(0,0,1,'#000000');
|
$this->oThumbnailImage->make_thumb(0,0,1,'#000000');
|
||||||
// store the image
|
// 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
|
// now we'll process the screenshot image for watermarking
|
||||||
// load the screenshot
|
// load the screenshot
|
||||||
@@ -217,7 +217,7 @@ class Screenshot {
|
|||||||
// resize the image
|
// resize the image
|
||||||
$this->oScreenshotImage->make_full();
|
$this->oScreenshotImage->make_full();
|
||||||
// store the resized image
|
// 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
|
// reload the resized screenshot
|
||||||
$this->oScreenshotImage = new Image("/data/screenshots/".$this->sUrl);
|
$this->oScreenshotImage = new Image("/data/screenshots/".$this->sUrl);
|
||||||
if(!$this->oScreenshotImage->isLoaded()) return false;
|
if(!$this->oScreenshotImage->isLoaded()) return false;
|
||||||
@@ -225,7 +225,7 @@ class Screenshot {
|
|||||||
// add the watermark to the screenshot
|
// add the watermark to the screenshot
|
||||||
$this->oScreenshotImage->add_watermark($watermark->get_image_resource());
|
$this->oScreenshotImage->add_watermark($watermark->get_image_resource());
|
||||||
// store the watermarked image
|
// 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;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -321,7 +321,7 @@ function get_screenshot_img($iAppId = null, $iVersionId = null)
|
|||||||
}
|
}
|
||||||
if(!$hResult || !mysql_num_rows($hResult))
|
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
|
} else
|
||||||
{
|
{
|
||||||
$oRow = mysql_fetch_object($hResult);
|
$oRow = mysql_fetch_object($hResult);
|
||||||
|
|||||||
Reference in New Issue
Block a user