mirror of
https://github.com/mosbth/cimage.git
synced 2025-07-31 21:40:12 +02:00
Improved codestyle and added to start using phpcs to check code style, fix #95.
This commit is contained in:
20
CImage.php
20
CImage.php
@@ -445,7 +445,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whitelist for valid hostnames from where remote source can be
|
* Set whitelist for valid hostnames from where remote source can be
|
||||||
* downloaded.
|
* downloaded.
|
||||||
*
|
*
|
||||||
* @param array $whitelist with regexp hostnames to allow download from.
|
* @param array $whitelist with regexp hostnames to allow download from.
|
||||||
@@ -462,7 +462,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the hostname for the remote image, is on a whitelist,
|
* Check if the hostname for the remote image, is on a whitelist,
|
||||||
* if the whitelist is defined.
|
* if the whitelist is defined.
|
||||||
*
|
*
|
||||||
* @param string $src the remote source.
|
* @param string $src the remote source.
|
||||||
@@ -779,7 +779,7 @@ class CImage
|
|||||||
$info = list($this->width, $this->height, $this->fileType, $this->attr) = getimagesize($file);
|
$info = list($this->width, $this->height, $this->fileType, $this->attr) = getimagesize($file);
|
||||||
if (empty($info)) {
|
if (empty($info)) {
|
||||||
throw new Exception("The file doesn't seem to be a valid image.");
|
throw new Exception("The file doesn't seem to be a valid image.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->verbose) {
|
if ($this->verbose) {
|
||||||
$this->log("Loading image details for: {$file}");
|
$this->log("Loading image details for: {$file}");
|
||||||
@@ -976,7 +976,7 @@ class CImage
|
|||||||
$this->cropHeight = round($height / $ratio);
|
$this->cropHeight = round($height / $ratio);
|
||||||
$this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
|
$this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
|
||||||
|
|
||||||
} else if ($this->fillToFit) {
|
} elseif ($this->fillToFit) {
|
||||||
|
|
||||||
// Use newWidth and newHeigh as defined width/height,
|
// Use newWidth and newHeigh as defined width/height,
|
||||||
// image should fit the area.
|
// image should fit the area.
|
||||||
@@ -1204,7 +1204,7 @@ class CImage
|
|||||||
|
|
||||||
$this->extension = isset($this->extension)
|
$this->extension = isset($this->extension)
|
||||||
? $this->extension
|
? $this->extension
|
||||||
: (isset($parts['extension'])
|
: (isset($parts['extension'])
|
||||||
? $parts['extension']
|
? $parts['extension']
|
||||||
: null);
|
: null);
|
||||||
|
|
||||||
@@ -1276,7 +1276,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load image from disk. Try to load image without verbose error message,
|
* Load image from disk. Try to load image without verbose error message,
|
||||||
* if fail, load again and display error messages.
|
* if fail, load again and display error messages.
|
||||||
*
|
*
|
||||||
* @param string $src of image.
|
* @param string $src of image.
|
||||||
@@ -1509,7 +1509,7 @@ class CImage
|
|||||||
$this->width = $this->newWidth;
|
$this->width = $this->newWidth;
|
||||||
$this->height = $this->newHeight;
|
$this->height = $this->newHeight;
|
||||||
|
|
||||||
} else if ($this->fillToFit) {
|
} elseif ($this->fillToFit) {
|
||||||
|
|
||||||
// Resize by fill to fit
|
// Resize by fill to fit
|
||||||
$this->log("Resizing using strategy - Fill to fit");
|
$this->log("Resizing using strategy - Fill to fit");
|
||||||
@@ -1548,7 +1548,7 @@ class CImage
|
|||||||
$this->width = $this->newWidth;
|
$this->width = $this->newWidth;
|
||||||
$this->height = $this->newHeight;
|
$this->height = $this->newHeight;
|
||||||
|
|
||||||
} else if (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {
|
} elseif (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {
|
||||||
|
|
||||||
// Resize it
|
// Resize it
|
||||||
$this->log("Resizing, new height and/or width");
|
$this->log("Resizing, new height and/or width");
|
||||||
@@ -1569,10 +1569,10 @@ class CImage
|
|||||||
if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
|
if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
|
||||||
$posX = round(($this->newWidth - $this->width) / 2);
|
$posX = round(($this->newWidth - $this->width) / 2);
|
||||||
$posY = round(($this->newHeight - $this->height) / 2);
|
$posY = round(($this->newHeight - $this->height) / 2);
|
||||||
} else if ($this->newWidth > $this->width) {
|
} elseif ($this->newWidth > $this->width) {
|
||||||
$posX = round(($this->newWidth - $this->width) / 2);
|
$posX = round(($this->newWidth - $this->width) / 2);
|
||||||
$cropY = round(($this->height - $this->newHeight) / 2);
|
$cropY = round(($this->height - $this->newHeight) / 2);
|
||||||
} else if ($this->newHeight > $this->height) {
|
} elseif ($this->newHeight > $this->height) {
|
||||||
$posY = round(($this->newHeight - $this->height) / 2);
|
$posY = round(($this->newHeight - $this->height) / 2);
|
||||||
$cropX = round(($this->width - $this->newWidth) / 2);
|
$cropX = round(($this->width - $this->newWidth) / 2);
|
||||||
}
|
}
|
||||||
|
@@ -145,7 +145,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setHeaderFields() {
|
public function setHeaderFields()
|
||||||
|
{
|
||||||
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
||||||
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
||||||
|
|
||||||
@@ -164,8 +165,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to saved file or false if not saved.
|
* @return string as path to saved file or false if not saved.
|
||||||
*/
|
*/
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$this->cache = array();
|
$this->cache = array();
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
@@ -201,8 +202,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to cached file.
|
* @return string as path to cached file.
|
||||||
*/
|
*/
|
||||||
function updateCacheDetails() {
|
public function updateCacheDetails()
|
||||||
|
{
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
$lastModified = $this->http->getLastModified();
|
$lastModified = $this->http->getLastModified();
|
||||||
@@ -227,8 +228,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to downloaded file or false if failed.
|
* @return string as path to downloaded file or false if failed.
|
||||||
*/
|
*/
|
||||||
function download($url) {
|
public function download($url)
|
||||||
|
{
|
||||||
$this->http = new CHttpGet();
|
$this->http = new CHttpGet();
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
|
||||||
@@ -252,7 +253,7 @@ class CRemoteImage
|
|||||||
if ($this->status === 200) {
|
if ($this->status === 200) {
|
||||||
$this->isCacheWritable();
|
$this->isCacheWritable();
|
||||||
return $this->save();
|
return $this->save();
|
||||||
} else if ($this->status === 304) {
|
} elseif ($this->status === 304) {
|
||||||
$this->isCacheWritable();
|
$this->isCacheWritable();
|
||||||
return $this->updateCacheDetails();
|
return $this->updateCacheDetails();
|
||||||
}
|
}
|
||||||
|
@@ -13,10 +13,10 @@ class CWhitelist
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the whitelist from an array of strings, each item in the
|
* Set the whitelist from an array of strings, each item in the
|
||||||
* whitelist should be a regexp without the surrounding / or #.
|
* whitelist should be a regexp without the surrounding / or #.
|
||||||
*
|
*
|
||||||
* @param array $whitelist with all valid options,
|
* @param array $whitelist with all valid options,
|
||||||
* default is to clear the whitelist.
|
* default is to clear the whitelist.
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
@@ -44,8 +44,8 @@ class CWhitelist
|
|||||||
public function check($item, $whitelist = null)
|
public function check($item, $whitelist = null)
|
||||||
{
|
{
|
||||||
if ($whitelist !== null) {
|
if ($whitelist !== null) {
|
||||||
$this->set($whitelist);
|
$this->set($whitelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($item) or empty($this->whitelist)) {
|
if (empty($item) or empty($this->whitelist)) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -8,6 +8,7 @@ Revision history
|
|||||||
v0.7.0.x (latest)
|
v0.7.0.x (latest)
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
|
* Improved codestyle and added `phpcs.xml` to start using phpcs to check code style, fix #95.
|
||||||
* Adding `composer.json` for publishing on packagist.
|
* Adding `composer.json` for publishing on packagist.
|
||||||
* Add permalink to setup for comparing images with `webroot/compare/compare.php`, fix #92.
|
* Add permalink to setup for comparing images with `webroot/compare/compare.php`, fix #92.
|
||||||
* Allow space in filename by using `urlencode()` and allow space as valid filenam character. fix #91.
|
* Allow space in filename by using `urlencode()` and allow space as valid filenam character. fix #91.
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
spl_autoload_register(function ($class) {
|
spl_autoload_register(function ($class) {
|
||||||
//$path = CIMAGE_SOURCE_PATH . "/{$class}.php";
|
//$path = CIMAGE_SOURCE_PATH . "/{$class}.php";
|
||||||
$path = __DIR__ . "/{$class}.php";
|
$path = __DIR__ . "/{$class}.php";
|
||||||
if(is_file($path)) {
|
if (is_file($path)) {
|
||||||
require($path);
|
require($path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
32
phpcs.xml
Normal file
32
phpcs.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<ruleset name="PHPCS rule set">
|
||||||
|
<description>Custom rule set.</description>
|
||||||
|
|
||||||
|
<file>.</file>
|
||||||
|
<file>test</file>
|
||||||
|
<file>autoload.php</file>
|
||||||
|
|
||||||
|
<exclude-pattern>docs/*</exclude-pattern>
|
||||||
|
<exclude-pattern>coverage/*</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/imgs.php</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/imgp.php</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/imgd.php</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/test/*</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/js/*</exclude-pattern>
|
||||||
|
<exclude-pattern>webroot/compare/*</exclude-pattern>
|
||||||
|
|
||||||
|
<arg name="encoding" value="utf-8"/>
|
||||||
|
<!--<arg name="extensions" value=".php"/>-->
|
||||||
|
<!--<arg name="colors" value="1"/>-->
|
||||||
|
<!--<arg name="warning-severity" value="5"/>-->
|
||||||
|
|
||||||
|
<rule ref="PSR2">
|
||||||
|
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" /> <exclude name="Squiz.Commenting.FileComment" />
|
||||||
|
<exclude name="Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
|
||||||
|
-->
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
</ruleset>
|
@@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* A testclass
|
* A testclass
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class CImage_RemoteDownloadTest extends \PHPUnit_Framework_TestCase
|
class CImageRemoteDownloadTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* remote_whitelist
|
* remote_whitelist
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* A testclass
|
* A testclass
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class CWhitelistTest extends \PHPUnit_Framework_TestCase
|
class CWhitelistTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
@@ -10,4 +10,4 @@ CImage.compare({
|
|||||||
});
|
});
|
||||||
EOD;
|
EOD;
|
||||||
|
|
||||||
include __DIR__ . "/compare.php";
|
include __DIR__ . "/compare.php";
|
||||||
|
@@ -101,7 +101,7 @@ input[type=text] {
|
|||||||
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
|
||||||
<script src="../js/cimage.js"></script>
|
<script src="../js/cimage.js"></script>
|
||||||
<script>
|
<script>
|
||||||
<?php
|
<?php
|
||||||
if (isset($_GET['input1'])) {
|
if (isset($_GET['input1'])) {
|
||||||
// Use incoming from querystring as defaults
|
// Use incoming from querystring as defaults
|
||||||
?>
|
?>
|
||||||
@@ -114,9 +114,9 @@ if (isset($_GET['input1'])) {
|
|||||||
"stack": <?=$_GET['stack']?>
|
"stack": <?=$_GET['stack']?>
|
||||||
});
|
});
|
||||||
<?php
|
<?php
|
||||||
} else if (isset($script)) {
|
} elseif (isset($script)) {
|
||||||
// Use default setup from js configuration
|
// Use default setup from js configuration
|
||||||
echo $script;
|
echo $script;
|
||||||
} else {
|
} else {
|
||||||
// Use defaults
|
// Use defaults
|
||||||
echo "CImage.compare({});";
|
echo "CImage.compare({});";
|
||||||
|
@@ -135,7 +135,7 @@ $configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';
|
|||||||
|
|
||||||
if (is_file($configFile)) {
|
if (is_file($configFile)) {
|
||||||
$config = require $configFile;
|
$config = require $configFile;
|
||||||
} else if (!isset($config)) {
|
} elseif (!isset($config)) {
|
||||||
$config = array();
|
$config = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,14 +171,14 @@ if ($mode == 'strict') {
|
|||||||
ini_set('log_errors', 1);
|
ini_set('log_errors', 1);
|
||||||
$verbose = false;
|
$verbose = false;
|
||||||
|
|
||||||
} else if ($mode == 'production') {
|
} elseif ($mode == 'production') {
|
||||||
|
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
ini_set('display_errors', 0);
|
ini_set('display_errors', 0);
|
||||||
ini_set('log_errors', 1);
|
ini_set('log_errors', 1);
|
||||||
$verbose = false;
|
$verbose = false;
|
||||||
|
|
||||||
} else if ($mode == 'development') {
|
} elseif ($mode == 'development') {
|
||||||
|
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
@@ -200,7 +200,7 @@ $defaultTimezone = getConfig('default_timezone', null);
|
|||||||
|
|
||||||
if ($defaultTimezone) {
|
if ($defaultTimezone) {
|
||||||
date_default_timezone_set($defaultTimezone);
|
date_default_timezone_set($defaultTimezone);
|
||||||
} else if (!ini_get('default_timezone')) {
|
} elseif (!ini_get('default_timezone')) {
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,13 +247,13 @@ $refererHost = parse_url($referer, PHP_URL_HOST);
|
|||||||
if (!$allowHotlinking) {
|
if (!$allowHotlinking) {
|
||||||
if ($passwordMatch) {
|
if ($passwordMatch) {
|
||||||
; // Always allow when password match
|
; // Always allow when password match
|
||||||
} else if ($passwordMatch === false) {
|
} elseif ($passwordMatch === false) {
|
||||||
errorPage("Hotlinking/leeching not allowed when password missmatch.");
|
errorPage("Hotlinking/leeching not allowed when password missmatch.");
|
||||||
} else if (!$referer) {
|
} elseif (!$referer) {
|
||||||
errorPage("Hotlinking/leeching not allowed and referer is missing.");
|
errorPage("Hotlinking/leeching not allowed and referer is missing.");
|
||||||
} else if (strcmp($serverName, $refererHost) == 0) {
|
} elseif (strcmp($serverName, $refererHost) == 0) {
|
||||||
; // Allow when serverName matches refererHost
|
; // Allow when serverName matches refererHost
|
||||||
} else if (!empty($hotlinkingWhitelist)) {
|
} elseif (!empty($hotlinkingWhitelist)) {
|
||||||
|
|
||||||
$allowedByWhitelist = false;
|
$allowedByWhitelist = false;
|
||||||
foreach ($hotlinkingWhitelist as $val) {
|
foreach ($hotlinkingWhitelist as $val) {
|
||||||
@@ -285,7 +285,7 @@ $cimageClass = getConfig('cimage_class', false);
|
|||||||
|
|
||||||
if ($autoloader) {
|
if ($autoloader) {
|
||||||
require $autoloader;
|
require $autoloader;
|
||||||
} else if ($cimageClass) {
|
} elseif ($cimageClass) {
|
||||||
require $cimageClass;
|
require $cimageClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +355,7 @@ if ($allowRemote && $img->isRemoteSource($srcImage)) {
|
|||||||
|
|
||||||
// If source is a remote file, ignore local file checks.
|
// If source is a remote file, ignore local file checks.
|
||||||
|
|
||||||
} else if ($imagePathConstraint) {
|
} elseif ($imagePathConstraint) {
|
||||||
|
|
||||||
// Check that the image is a file below the directory 'image_path'.
|
// Check that the image is a file below the directory 'image_path'.
|
||||||
$pathToImage = realpath($imagePath . $srcImage);
|
$pathToImage = realpath($imagePath . $srcImage);
|
||||||
@@ -807,7 +807,7 @@ if ($alias && $aliasPath && $passwordMatch) {
|
|||||||
preg_match($validAliasname, $alias)
|
preg_match($validAliasname, $alias)
|
||||||
or errorPage('Filename for alias contains invalid characters. Do not add extension.');
|
or errorPage('Filename for alias contains invalid characters. Do not add extension.');
|
||||||
|
|
||||||
} else if ($alias) {
|
} elseif ($alias) {
|
||||||
errorPage('Alias is not enabled in the config file or password not matching.');
|
errorPage('Alias is not enabled in the config file or password not matching.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -62,22 +62,22 @@ return array(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow or disallow downloading of remote images available on
|
* Allow or disallow downloading of remote images available on
|
||||||
* remote servers. Default is to disallow remote download.
|
* remote servers. Default is to disallow remote download.
|
||||||
*
|
|
||||||
* When enabling remote download, the default is to allow download any
|
|
||||||
* link starting with http or https. This can be changed using
|
|
||||||
* remote_pattern.
|
|
||||||
*
|
*
|
||||||
* When enabling remote_whitelist a check is made that the hostname of the
|
* When enabling remote download, the default is to allow download any
|
||||||
* source to download matches the whitelist. By default the check is
|
* link starting with http or https. This can be changed using
|
||||||
|
* remote_pattern.
|
||||||
|
*
|
||||||
|
* When enabling remote_whitelist a check is made that the hostname of the
|
||||||
|
* source to download matches the whitelist. By default the check is
|
||||||
* disabled and thereby allowing download from any hosts.
|
* disabled and thereby allowing download from any hosts.
|
||||||
*
|
*
|
||||||
* Default values.
|
* Default values.
|
||||||
* remote_allow: false
|
* remote_allow: false
|
||||||
* remote_pattern: null // use default values from CImage which is to
|
* remote_pattern: null // use default values from CImage which is to
|
||||||
* // allow download from any http- and
|
* // allow download from any http- and
|
||||||
* // https-source.
|
* // https-source.
|
||||||
* remote_whitelist: null // use default values from CImage which is to
|
* remote_whitelist: null // use default values from CImage which is to
|
||||||
* // allow download from any hosts.
|
* // allow download from any hosts.
|
||||||
*/
|
*/
|
||||||
//'remote_allow' => true,
|
//'remote_allow' => true,
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* Resize and crop images on the fly, store generated images in a cache.
|
* Resize and crop images on the fly, store generated images in a cache.
|
||||||
*
|
*
|
||||||
* This version is a all-in-one version of img.php, it is not dependant an any other file
|
* This version is a all-in-one version of img.php, it is not dependant an any other file
|
||||||
* so you can simply copy it to any place you want it.
|
* so you can simply copy it to any place you want it.
|
||||||
*
|
*
|
||||||
* @author Mikael Roos mos@dbwebb.se
|
* @author Mikael Roos mos@dbwebb.se
|
||||||
* @example http://dbwebb.se/opensource/cimage
|
* @example http://dbwebb.se/opensource/cimage
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change configuration details in the array below or create a separate file
|
* Change configuration details in the array below or create a separate file
|
||||||
* where you store the configuration details.
|
* where you store the configuration details.
|
||||||
*
|
*
|
||||||
* The configuration file should be named the same name as this file and then
|
* The configuration file should be named the same name as this file and then
|
||||||
* add '_config.php'. If this file is named 'img.php' then name the
|
* add '_config.php'. If this file is named 'img.php' then name the
|
||||||
* config file should be named 'img_config.php'.
|
* config file should be named 'img_config.php'.
|
||||||
*
|
*
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* Resize and crop images on the fly, store generated images in a cache.
|
* Resize and crop images on the fly, store generated images in a cache.
|
||||||
*
|
*
|
||||||
* This version is a all-in-one version of img.php, it is not dependant an any other file
|
* This version is a all-in-one version of img.php, it is not dependant an any other file
|
||||||
* so you can simply copy it to any place you want it.
|
* so you can simply copy it to any place you want it.
|
||||||
*
|
*
|
||||||
* @author Mikael Roos mos@dbwebb.se
|
* @author Mikael Roos mos@dbwebb.se
|
||||||
* @example http://dbwebb.se/opensource/cimage
|
* @example http://dbwebb.se/opensource/cimage
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change configuration details in the array below or create a separate file
|
* Change configuration details in the array below or create a separate file
|
||||||
* where you store the configuration details.
|
* where you store the configuration details.
|
||||||
*
|
*
|
||||||
* The configuration file should be named the same name as this file and then
|
* The configuration file should be named the same name as this file and then
|
||||||
* add '_config.php'. If this file is named 'img.php' then name the
|
* add '_config.php'. If this file is named 'img.php' then name the
|
||||||
* config file should be named 'img_config.php'.
|
* config file should be named 'img_config.php'.
|
||||||
*
|
*
|
||||||
@@ -433,7 +433,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setHeaderFields() {
|
public function setHeaderFields()
|
||||||
|
{
|
||||||
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
||||||
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
||||||
|
|
||||||
@@ -452,8 +453,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to saved file or false if not saved.
|
* @return string as path to saved file or false if not saved.
|
||||||
*/
|
*/
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$this->cache = array();
|
$this->cache = array();
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
@@ -489,8 +490,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to cached file.
|
* @return string as path to cached file.
|
||||||
*/
|
*/
|
||||||
function updateCacheDetails() {
|
public function updateCacheDetails()
|
||||||
|
{
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
$lastModified = $this->http->getLastModified();
|
$lastModified = $this->http->getLastModified();
|
||||||
@@ -515,8 +516,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to downloaded file or false if failed.
|
* @return string as path to downloaded file or false if failed.
|
||||||
*/
|
*/
|
||||||
function download($url) {
|
public function download($url)
|
||||||
|
{
|
||||||
$this->http = new CHttpGet();
|
$this->http = new CHttpGet();
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
|
||||||
@@ -540,7 +541,7 @@ class CRemoteImage
|
|||||||
if ($this->status === 200) {
|
if ($this->status === 200) {
|
||||||
$this->isCacheWritable();
|
$this->isCacheWritable();
|
||||||
return $this->save();
|
return $this->save();
|
||||||
} else if ($this->status === 304) {
|
} elseif ($this->status === 304) {
|
||||||
$this->isCacheWritable();
|
$this->isCacheWritable();
|
||||||
return $this->updateCacheDetails();
|
return $this->updateCacheDetails();
|
||||||
}
|
}
|
||||||
@@ -1042,7 +1043,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whitelist for valid hostnames from where remote source can be
|
* Set whitelist for valid hostnames from where remote source can be
|
||||||
* downloaded.
|
* downloaded.
|
||||||
*
|
*
|
||||||
* @param array $whitelist with regexp hostnames to allow download from.
|
* @param array $whitelist with regexp hostnames to allow download from.
|
||||||
@@ -1059,7 +1060,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the hostname for the remote image, is on a whitelist,
|
* Check if the hostname for the remote image, is on a whitelist,
|
||||||
* if the whitelist is defined.
|
* if the whitelist is defined.
|
||||||
*
|
*
|
||||||
* @param string $src the remote source.
|
* @param string $src the remote source.
|
||||||
@@ -1376,7 +1377,7 @@ class CImage
|
|||||||
$info = list($this->width, $this->height, $this->fileType, $this->attr) = getimagesize($file);
|
$info = list($this->width, $this->height, $this->fileType, $this->attr) = getimagesize($file);
|
||||||
if (empty($info)) {
|
if (empty($info)) {
|
||||||
throw new Exception("The file doesn't seem to be a valid image.");
|
throw new Exception("The file doesn't seem to be a valid image.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->verbose) {
|
if ($this->verbose) {
|
||||||
$this->log("Loading image details for: {$file}");
|
$this->log("Loading image details for: {$file}");
|
||||||
@@ -1573,7 +1574,7 @@ class CImage
|
|||||||
$this->cropHeight = round($height / $ratio);
|
$this->cropHeight = round($height / $ratio);
|
||||||
$this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
|
$this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
|
||||||
|
|
||||||
} else if ($this->fillToFit) {
|
} elseif ($this->fillToFit) {
|
||||||
|
|
||||||
// Use newWidth and newHeigh as defined width/height,
|
// Use newWidth and newHeigh as defined width/height,
|
||||||
// image should fit the area.
|
// image should fit the area.
|
||||||
@@ -1801,7 +1802,7 @@ class CImage
|
|||||||
|
|
||||||
$this->extension = isset($this->extension)
|
$this->extension = isset($this->extension)
|
||||||
? $this->extension
|
? $this->extension
|
||||||
: (isset($parts['extension'])
|
: (isset($parts['extension'])
|
||||||
? $parts['extension']
|
? $parts['extension']
|
||||||
: null);
|
: null);
|
||||||
|
|
||||||
@@ -1873,7 +1874,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load image from disk. Try to load image without verbose error message,
|
* Load image from disk. Try to load image without verbose error message,
|
||||||
* if fail, load again and display error messages.
|
* if fail, load again and display error messages.
|
||||||
*
|
*
|
||||||
* @param string $src of image.
|
* @param string $src of image.
|
||||||
@@ -2106,7 +2107,7 @@ class CImage
|
|||||||
$this->width = $this->newWidth;
|
$this->width = $this->newWidth;
|
||||||
$this->height = $this->newHeight;
|
$this->height = $this->newHeight;
|
||||||
|
|
||||||
} else if ($this->fillToFit) {
|
} elseif ($this->fillToFit) {
|
||||||
|
|
||||||
// Resize by fill to fit
|
// Resize by fill to fit
|
||||||
$this->log("Resizing using strategy - Fill to fit");
|
$this->log("Resizing using strategy - Fill to fit");
|
||||||
@@ -2145,7 +2146,7 @@ class CImage
|
|||||||
$this->width = $this->newWidth;
|
$this->width = $this->newWidth;
|
||||||
$this->height = $this->newHeight;
|
$this->height = $this->newHeight;
|
||||||
|
|
||||||
} else if (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {
|
} elseif (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {
|
||||||
|
|
||||||
// Resize it
|
// Resize it
|
||||||
$this->log("Resizing, new height and/or width");
|
$this->log("Resizing, new height and/or width");
|
||||||
@@ -2166,10 +2167,10 @@ class CImage
|
|||||||
if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
|
if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
|
||||||
$posX = round(($this->newWidth - $this->width) / 2);
|
$posX = round(($this->newWidth - $this->width) / 2);
|
||||||
$posY = round(($this->newHeight - $this->height) / 2);
|
$posY = round(($this->newHeight - $this->height) / 2);
|
||||||
} else if ($this->newWidth > $this->width) {
|
} elseif ($this->newWidth > $this->width) {
|
||||||
$posX = round(($this->newWidth - $this->width) / 2);
|
$posX = round(($this->newWidth - $this->width) / 2);
|
||||||
$cropY = round(($this->height - $this->newHeight) / 2);
|
$cropY = round(($this->height - $this->newHeight) / 2);
|
||||||
} else if ($this->newHeight > $this->height) {
|
} elseif ($this->newHeight > $this->height) {
|
||||||
$posY = round(($this->newHeight - $this->height) / 2);
|
$posY = round(($this->newHeight - $this->height) / 2);
|
||||||
$cropX = round(($this->width - $this->newWidth) / 2);
|
$cropX = round(($this->width - $this->newWidth) / 2);
|
||||||
}
|
}
|
||||||
@@ -2991,10 +2992,10 @@ class CWhitelist
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the whitelist from an array of strings, each item in the
|
* Set the whitelist from an array of strings, each item in the
|
||||||
* whitelist should be a regexp without the surrounding / or #.
|
* whitelist should be a regexp without the surrounding / or #.
|
||||||
*
|
*
|
||||||
* @param array $whitelist with all valid options,
|
* @param array $whitelist with all valid options,
|
||||||
* default is to clear the whitelist.
|
* default is to clear the whitelist.
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
@@ -3022,8 +3023,8 @@ class CWhitelist
|
|||||||
public function check($item, $whitelist = null)
|
public function check($item, $whitelist = null)
|
||||||
{
|
{
|
||||||
if ($whitelist !== null) {
|
if ($whitelist !== null) {
|
||||||
$this->set($whitelist);
|
$this->set($whitelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($item) or empty($this->whitelist)) {
|
if (empty($item) or empty($this->whitelist)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -3177,7 +3178,7 @@ $configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';
|
|||||||
|
|
||||||
if (is_file($configFile)) {
|
if (is_file($configFile)) {
|
||||||
$config = require $configFile;
|
$config = require $configFile;
|
||||||
} else if (!isset($config)) {
|
} elseif (!isset($config)) {
|
||||||
$config = array();
|
$config = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3213,14 +3214,14 @@ if ($mode == 'strict') {
|
|||||||
ini_set('log_errors', 1);
|
ini_set('log_errors', 1);
|
||||||
$verbose = false;
|
$verbose = false;
|
||||||
|
|
||||||
} else if ($mode == 'production') {
|
} elseif ($mode == 'production') {
|
||||||
|
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
ini_set('display_errors', 0);
|
ini_set('display_errors', 0);
|
||||||
ini_set('log_errors', 1);
|
ini_set('log_errors', 1);
|
||||||
$verbose = false;
|
$verbose = false;
|
||||||
|
|
||||||
} else if ($mode == 'development') {
|
} elseif ($mode == 'development') {
|
||||||
|
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
@@ -3242,7 +3243,7 @@ $defaultTimezone = getConfig('default_timezone', null);
|
|||||||
|
|
||||||
if ($defaultTimezone) {
|
if ($defaultTimezone) {
|
||||||
date_default_timezone_set($defaultTimezone);
|
date_default_timezone_set($defaultTimezone);
|
||||||
} else if (!ini_get('default_timezone')) {
|
} elseif (!ini_get('default_timezone')) {
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3289,13 +3290,13 @@ $refererHost = parse_url($referer, PHP_URL_HOST);
|
|||||||
if (!$allowHotlinking) {
|
if (!$allowHotlinking) {
|
||||||
if ($passwordMatch) {
|
if ($passwordMatch) {
|
||||||
; // Always allow when password match
|
; // Always allow when password match
|
||||||
} else if ($passwordMatch === false) {
|
} elseif ($passwordMatch === false) {
|
||||||
errorPage("Hotlinking/leeching not allowed when password missmatch.");
|
errorPage("Hotlinking/leeching not allowed when password missmatch.");
|
||||||
} else if (!$referer) {
|
} elseif (!$referer) {
|
||||||
errorPage("Hotlinking/leeching not allowed and referer is missing.");
|
errorPage("Hotlinking/leeching not allowed and referer is missing.");
|
||||||
} else if (strcmp($serverName, $refererHost) == 0) {
|
} elseif (strcmp($serverName, $refererHost) == 0) {
|
||||||
; // Allow when serverName matches refererHost
|
; // Allow when serverName matches refererHost
|
||||||
} else if (!empty($hotlinkingWhitelist)) {
|
} elseif (!empty($hotlinkingWhitelist)) {
|
||||||
|
|
||||||
$allowedByWhitelist = false;
|
$allowedByWhitelist = false;
|
||||||
foreach ($hotlinkingWhitelist as $val) {
|
foreach ($hotlinkingWhitelist as $val) {
|
||||||
@@ -3327,7 +3328,7 @@ $cimageClass = getConfig('cimage_class', false);
|
|||||||
|
|
||||||
if ($autoloader) {
|
if ($autoloader) {
|
||||||
require $autoloader;
|
require $autoloader;
|
||||||
} else if ($cimageClass) {
|
} elseif ($cimageClass) {
|
||||||
require $cimageClass;
|
require $cimageClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3397,7 +3398,7 @@ if ($allowRemote && $img->isRemoteSource($srcImage)) {
|
|||||||
|
|
||||||
// If source is a remote file, ignore local file checks.
|
// If source is a remote file, ignore local file checks.
|
||||||
|
|
||||||
} else if ($imagePathConstraint) {
|
} elseif ($imagePathConstraint) {
|
||||||
|
|
||||||
// Check that the image is a file below the directory 'image_path'.
|
// Check that the image is a file below the directory 'image_path'.
|
||||||
$pathToImage = realpath($imagePath . $srcImage);
|
$pathToImage = realpath($imagePath . $srcImage);
|
||||||
@@ -3849,7 +3850,7 @@ if ($alias && $aliasPath && $passwordMatch) {
|
|||||||
preg_match($validAliasname, $alias)
|
preg_match($validAliasname, $alias)
|
||||||
or errorPage('Filename for alias contains invalid characters. Do not add extension.');
|
or errorPage('Filename for alias contains invalid characters. Do not add extension.');
|
||||||
|
|
||||||
} else if ($alias) {
|
} elseif ($alias) {
|
||||||
errorPage('Alias is not enabled in the config file or password not matching.');
|
errorPage('Alias is not enabled in the config file or password not matching.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* Resize and crop images on the fly, store generated images in a cache.
|
* Resize and crop images on the fly, store generated images in a cache.
|
||||||
*
|
*
|
||||||
* This version is a all-in-one version of img.php, it is not dependant an any other file
|
* This version is a all-in-one version of img.php, it is not dependant an any other file
|
||||||
* so you can simply copy it to any place you want it.
|
* so you can simply copy it to any place you want it.
|
||||||
*
|
*
|
||||||
* @author Mikael Roos mos@dbwebb.se
|
* @author Mikael Roos mos@dbwebb.se
|
||||||
* @example http://dbwebb.se/opensource/cimage
|
* @example http://dbwebb.se/opensource/cimage
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change configuration details in the array below or create a separate file
|
* Change configuration details in the array below or create a separate file
|
||||||
* where you store the configuration details.
|
* where you store the configuration details.
|
||||||
*
|
*
|
||||||
* The configuration file should be named the same name as this file and then
|
* The configuration file should be named the same name as this file and then
|
||||||
* add '_config.php'. If this file is named 'img.php' then name the
|
* add '_config.php'. If this file is named 'img.php' then name the
|
||||||
* config file should be named 'img_config.php'.
|
* config file should be named 'img_config.php'.
|
||||||
*
|
*
|
||||||
@@ -433,7 +433,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setHeaderFields() {
|
public function setHeaderFields()
|
||||||
|
{
|
||||||
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
||||||
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
||||||
|
|
||||||
@@ -452,8 +453,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to saved file or false if not saved.
|
* @return string as path to saved file or false if not saved.
|
||||||
*/
|
*/
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$this->cache = array();
|
$this->cache = array();
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
@@ -489,8 +490,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to cached file.
|
* @return string as path to cached file.
|
||||||
*/
|
*/
|
||||||
function updateCacheDetails() {
|
public function updateCacheDetails()
|
||||||
|
{
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
$lastModified = $this->http->getLastModified();
|
$lastModified = $this->http->getLastModified();
|
||||||
@@ -515,8 +516,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to downloaded file or false if failed.
|
* @return string as path to downloaded file or false if failed.
|
||||||
*/
|
*/
|
||||||
function download($url) {
|
public function download($url)
|
||||||
|
{
|
||||||
$this->http = new CHttpGet();
|
$this->http = new CHttpGet();
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
|
||||||
@@ -540,7 +541,7 @@ class CRemoteImage
|
|||||||
if ($this->status === 200) {
|
if ($this->status === 200) {
|
||||||
$this->isCacheWritable();
|
$this->isCacheWritable();
|
||||||
return $this->save();
|
return $this->save();
|
||||||
} else if ($this->status === 304) {
|
} elseif ($this->status === 304) {
|
||||||
$this->isCacheWritable();
|
$this->isCacheWritable();
|
||||||
return $this->updateCacheDetails();
|
return $this->updateCacheDetails();
|
||||||
}
|
}
|
||||||
@@ -1042,7 +1043,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whitelist for valid hostnames from where remote source can be
|
* Set whitelist for valid hostnames from where remote source can be
|
||||||
* downloaded.
|
* downloaded.
|
||||||
*
|
*
|
||||||
* @param array $whitelist with regexp hostnames to allow download from.
|
* @param array $whitelist with regexp hostnames to allow download from.
|
||||||
@@ -1059,7 +1060,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the hostname for the remote image, is on a whitelist,
|
* Check if the hostname for the remote image, is on a whitelist,
|
||||||
* if the whitelist is defined.
|
* if the whitelist is defined.
|
||||||
*
|
*
|
||||||
* @param string $src the remote source.
|
* @param string $src the remote source.
|
||||||
@@ -1376,7 +1377,7 @@ class CImage
|
|||||||
$info = list($this->width, $this->height, $this->fileType, $this->attr) = getimagesize($file);
|
$info = list($this->width, $this->height, $this->fileType, $this->attr) = getimagesize($file);
|
||||||
if (empty($info)) {
|
if (empty($info)) {
|
||||||
throw new Exception("The file doesn't seem to be a valid image.");
|
throw new Exception("The file doesn't seem to be a valid image.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->verbose) {
|
if ($this->verbose) {
|
||||||
$this->log("Loading image details for: {$file}");
|
$this->log("Loading image details for: {$file}");
|
||||||
@@ -1573,7 +1574,7 @@ class CImage
|
|||||||
$this->cropHeight = round($height / $ratio);
|
$this->cropHeight = round($height / $ratio);
|
||||||
$this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
|
$this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
|
||||||
|
|
||||||
} else if ($this->fillToFit) {
|
} elseif ($this->fillToFit) {
|
||||||
|
|
||||||
// Use newWidth and newHeigh as defined width/height,
|
// Use newWidth and newHeigh as defined width/height,
|
||||||
// image should fit the area.
|
// image should fit the area.
|
||||||
@@ -1801,7 +1802,7 @@ class CImage
|
|||||||
|
|
||||||
$this->extension = isset($this->extension)
|
$this->extension = isset($this->extension)
|
||||||
? $this->extension
|
? $this->extension
|
||||||
: (isset($parts['extension'])
|
: (isset($parts['extension'])
|
||||||
? $parts['extension']
|
? $parts['extension']
|
||||||
: null);
|
: null);
|
||||||
|
|
||||||
@@ -1873,7 +1874,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load image from disk. Try to load image without verbose error message,
|
* Load image from disk. Try to load image without verbose error message,
|
||||||
* if fail, load again and display error messages.
|
* if fail, load again and display error messages.
|
||||||
*
|
*
|
||||||
* @param string $src of image.
|
* @param string $src of image.
|
||||||
@@ -2106,7 +2107,7 @@ class CImage
|
|||||||
$this->width = $this->newWidth;
|
$this->width = $this->newWidth;
|
||||||
$this->height = $this->newHeight;
|
$this->height = $this->newHeight;
|
||||||
|
|
||||||
} else if ($this->fillToFit) {
|
} elseif ($this->fillToFit) {
|
||||||
|
|
||||||
// Resize by fill to fit
|
// Resize by fill to fit
|
||||||
$this->log("Resizing using strategy - Fill to fit");
|
$this->log("Resizing using strategy - Fill to fit");
|
||||||
@@ -2145,7 +2146,7 @@ class CImage
|
|||||||
$this->width = $this->newWidth;
|
$this->width = $this->newWidth;
|
||||||
$this->height = $this->newHeight;
|
$this->height = $this->newHeight;
|
||||||
|
|
||||||
} else if (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {
|
} elseif (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {
|
||||||
|
|
||||||
// Resize it
|
// Resize it
|
||||||
$this->log("Resizing, new height and/or width");
|
$this->log("Resizing, new height and/or width");
|
||||||
@@ -2166,10 +2167,10 @@ class CImage
|
|||||||
if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
|
if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
|
||||||
$posX = round(($this->newWidth - $this->width) / 2);
|
$posX = round(($this->newWidth - $this->width) / 2);
|
||||||
$posY = round(($this->newHeight - $this->height) / 2);
|
$posY = round(($this->newHeight - $this->height) / 2);
|
||||||
} else if ($this->newWidth > $this->width) {
|
} elseif ($this->newWidth > $this->width) {
|
||||||
$posX = round(($this->newWidth - $this->width) / 2);
|
$posX = round(($this->newWidth - $this->width) / 2);
|
||||||
$cropY = round(($this->height - $this->newHeight) / 2);
|
$cropY = round(($this->height - $this->newHeight) / 2);
|
||||||
} else if ($this->newHeight > $this->height) {
|
} elseif ($this->newHeight > $this->height) {
|
||||||
$posY = round(($this->newHeight - $this->height) / 2);
|
$posY = round(($this->newHeight - $this->height) / 2);
|
||||||
$cropX = round(($this->width - $this->newWidth) / 2);
|
$cropX = round(($this->width - $this->newWidth) / 2);
|
||||||
}
|
}
|
||||||
@@ -2991,10 +2992,10 @@ class CWhitelist
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the whitelist from an array of strings, each item in the
|
* Set the whitelist from an array of strings, each item in the
|
||||||
* whitelist should be a regexp without the surrounding / or #.
|
* whitelist should be a regexp without the surrounding / or #.
|
||||||
*
|
*
|
||||||
* @param array $whitelist with all valid options,
|
* @param array $whitelist with all valid options,
|
||||||
* default is to clear the whitelist.
|
* default is to clear the whitelist.
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
@@ -3022,8 +3023,8 @@ class CWhitelist
|
|||||||
public function check($item, $whitelist = null)
|
public function check($item, $whitelist = null)
|
||||||
{
|
{
|
||||||
if ($whitelist !== null) {
|
if ($whitelist !== null) {
|
||||||
$this->set($whitelist);
|
$this->set($whitelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($item) or empty($this->whitelist)) {
|
if (empty($item) or empty($this->whitelist)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -3177,7 +3178,7 @@ $configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';
|
|||||||
|
|
||||||
if (is_file($configFile)) {
|
if (is_file($configFile)) {
|
||||||
$config = require $configFile;
|
$config = require $configFile;
|
||||||
} else if (!isset($config)) {
|
} elseif (!isset($config)) {
|
||||||
$config = array();
|
$config = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3213,14 +3214,14 @@ if ($mode == 'strict') {
|
|||||||
ini_set('log_errors', 1);
|
ini_set('log_errors', 1);
|
||||||
$verbose = false;
|
$verbose = false;
|
||||||
|
|
||||||
} else if ($mode == 'production') {
|
} elseif ($mode == 'production') {
|
||||||
|
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
ini_set('display_errors', 0);
|
ini_set('display_errors', 0);
|
||||||
ini_set('log_errors', 1);
|
ini_set('log_errors', 1);
|
||||||
$verbose = false;
|
$verbose = false;
|
||||||
|
|
||||||
} else if ($mode == 'development') {
|
} elseif ($mode == 'development') {
|
||||||
|
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
@@ -3242,7 +3243,7 @@ $defaultTimezone = getConfig('default_timezone', null);
|
|||||||
|
|
||||||
if ($defaultTimezone) {
|
if ($defaultTimezone) {
|
||||||
date_default_timezone_set($defaultTimezone);
|
date_default_timezone_set($defaultTimezone);
|
||||||
} else if (!ini_get('default_timezone')) {
|
} elseif (!ini_get('default_timezone')) {
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3289,13 +3290,13 @@ $refererHost = parse_url($referer, PHP_URL_HOST);
|
|||||||
if (!$allowHotlinking) {
|
if (!$allowHotlinking) {
|
||||||
if ($passwordMatch) {
|
if ($passwordMatch) {
|
||||||
; // Always allow when password match
|
; // Always allow when password match
|
||||||
} else if ($passwordMatch === false) {
|
} elseif ($passwordMatch === false) {
|
||||||
errorPage("Hotlinking/leeching not allowed when password missmatch.");
|
errorPage("Hotlinking/leeching not allowed when password missmatch.");
|
||||||
} else if (!$referer) {
|
} elseif (!$referer) {
|
||||||
errorPage("Hotlinking/leeching not allowed and referer is missing.");
|
errorPage("Hotlinking/leeching not allowed and referer is missing.");
|
||||||
} else if (strcmp($serverName, $refererHost) == 0) {
|
} elseif (strcmp($serverName, $refererHost) == 0) {
|
||||||
; // Allow when serverName matches refererHost
|
; // Allow when serverName matches refererHost
|
||||||
} else if (!empty($hotlinkingWhitelist)) {
|
} elseif (!empty($hotlinkingWhitelist)) {
|
||||||
|
|
||||||
$allowedByWhitelist = false;
|
$allowedByWhitelist = false;
|
||||||
foreach ($hotlinkingWhitelist as $val) {
|
foreach ($hotlinkingWhitelist as $val) {
|
||||||
@@ -3327,7 +3328,7 @@ $cimageClass = getConfig('cimage_class', false);
|
|||||||
|
|
||||||
if ($autoloader) {
|
if ($autoloader) {
|
||||||
require $autoloader;
|
require $autoloader;
|
||||||
} else if ($cimageClass) {
|
} elseif ($cimageClass) {
|
||||||
require $cimageClass;
|
require $cimageClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3397,7 +3398,7 @@ if ($allowRemote && $img->isRemoteSource($srcImage)) {
|
|||||||
|
|
||||||
// If source is a remote file, ignore local file checks.
|
// If source is a remote file, ignore local file checks.
|
||||||
|
|
||||||
} else if ($imagePathConstraint) {
|
} elseif ($imagePathConstraint) {
|
||||||
|
|
||||||
// Check that the image is a file below the directory 'image_path'.
|
// Check that the image is a file below the directory 'image_path'.
|
||||||
$pathToImage = realpath($imagePath . $srcImage);
|
$pathToImage = realpath($imagePath . $srcImage);
|
||||||
@@ -3849,7 +3850,7 @@ if ($alias && $aliasPath && $passwordMatch) {
|
|||||||
preg_match($validAliasname, $alias)
|
preg_match($validAliasname, $alias)
|
||||||
or errorPage('Filename for alias contains invalid characters. Do not add extension.');
|
or errorPage('Filename for alias contains invalid characters. Do not add extension.');
|
||||||
|
|
||||||
} else if ($alias) {
|
} elseif ($alias) {
|
||||||
errorPage('Alias is not enabled in the config file or password not matching.');
|
errorPage('Alias is not enabled in the config file or password not matching.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* Resize and crop images on the fly, store generated images in a cache.
|
* Resize and crop images on the fly, store generated images in a cache.
|
||||||
*
|
*
|
||||||
* This version is a all-in-one version of img.php, it is not dependant an any other file
|
* This version is a all-in-one version of img.php, it is not dependant an any other file
|
||||||
* so you can simply copy it to any place you want it.
|
* so you can simply copy it to any place you want it.
|
||||||
*
|
*
|
||||||
* @author Mikael Roos mos@dbwebb.se
|
* @author Mikael Roos mos@dbwebb.se
|
||||||
* @example http://dbwebb.se/opensource/cimage
|
* @example http://dbwebb.se/opensource/cimage
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Change configuration details in the array below or create a separate file
|
* Change configuration details in the array below or create a separate file
|
||||||
* where you store the configuration details.
|
* where you store the configuration details.
|
||||||
*
|
*
|
||||||
* The configuration file should be named the same name as this file and then
|
* The configuration file should be named the same name as this file and then
|
||||||
* add '_config.php'. If this file is named 'img.php' then name the
|
* add '_config.php'. If this file is named 'img.php' then name the
|
||||||
* config file should be named 'img_config.php'.
|
* config file should be named 'img_config.php'.
|
||||||
*
|
*
|
||||||
@@ -433,7 +433,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
function setHeaderFields() {
|
public function setHeaderFields()
|
||||||
|
{
|
||||||
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
$this->http->setHeader("User-Agent", "CImage/0.7.0 (PHP/". phpversion() . " cURL)");
|
||||||
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
$this->http->setHeader("Accept", "image/jpeg,image/png,image/gif");
|
||||||
|
|
||||||
@@ -452,8 +453,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to saved file or false if not saved.
|
* @return string as path to saved file or false if not saved.
|
||||||
*/
|
*/
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$this->cache = array();
|
$this->cache = array();
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
@@ -489,8 +490,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to cached file.
|
* @return string as path to cached file.
|
||||||
*/
|
*/
|
||||||
function updateCacheDetails() {
|
public function updateCacheDetails()
|
||||||
|
{
|
||||||
$date = $this->http->getDate(time());
|
$date = $this->http->getDate(time());
|
||||||
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
$maxAge = $this->http->getMaxAge($this->defaultMaxAge);
|
||||||
$lastModified = $this->http->getLastModified();
|
$lastModified = $this->http->getLastModified();
|
||||||
@@ -515,8 +516,8 @@ class CRemoteImage
|
|||||||
*
|
*
|
||||||
* @return string as path to downloaded file or false if failed.
|
* @return string as path to downloaded file or false if failed.
|
||||||
*/
|
*/
|
||||||
function download($url) {
|
public function download($url)
|
||||||
|
{
|
||||||
$this->http = new CHttpGet();
|
$this->http = new CHttpGet();
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
|
||||||
@@ -540,7 +541,7 @@ class CRemoteImage
|
|||||||
if ($this->status === 200) {
|
if ($this->status === 200) {
|
||||||
$this->isCacheWritable();
|
$this->isCacheWritable();
|
||||||
return $this->save();
|
return $this->save();
|
||||||
} else if ($this->status === 304) {
|
} elseif ($this->status === 304) {
|
||||||
$this->isCacheWritable();
|
$this->isCacheWritable();
|
||||||
return $this->updateCacheDetails();
|
return $this->updateCacheDetails();
|
||||||
}
|
}
|
||||||
@@ -1042,7 +1043,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whitelist for valid hostnames from where remote source can be
|
* Set whitelist for valid hostnames from where remote source can be
|
||||||
* downloaded.
|
* downloaded.
|
||||||
*
|
*
|
||||||
* @param array $whitelist with regexp hostnames to allow download from.
|
* @param array $whitelist with regexp hostnames to allow download from.
|
||||||
@@ -1059,7 +1060,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the hostname for the remote image, is on a whitelist,
|
* Check if the hostname for the remote image, is on a whitelist,
|
||||||
* if the whitelist is defined.
|
* if the whitelist is defined.
|
||||||
*
|
*
|
||||||
* @param string $src the remote source.
|
* @param string $src the remote source.
|
||||||
@@ -1376,7 +1377,7 @@ class CImage
|
|||||||
$info = list($this->width, $this->height, $this->fileType, $this->attr) = getimagesize($file);
|
$info = list($this->width, $this->height, $this->fileType, $this->attr) = getimagesize($file);
|
||||||
if (empty($info)) {
|
if (empty($info)) {
|
||||||
throw new Exception("The file doesn't seem to be a valid image.");
|
throw new Exception("The file doesn't seem to be a valid image.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->verbose) {
|
if ($this->verbose) {
|
||||||
$this->log("Loading image details for: {$file}");
|
$this->log("Loading image details for: {$file}");
|
||||||
@@ -1573,7 +1574,7 @@ class CImage
|
|||||||
$this->cropHeight = round($height / $ratio);
|
$this->cropHeight = round($height / $ratio);
|
||||||
$this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
|
$this->log("Crop width, height, ratio: $this->cropWidth x $this->cropHeight ($ratio).");
|
||||||
|
|
||||||
} else if ($this->fillToFit) {
|
} elseif ($this->fillToFit) {
|
||||||
|
|
||||||
// Use newWidth and newHeigh as defined width/height,
|
// Use newWidth and newHeigh as defined width/height,
|
||||||
// image should fit the area.
|
// image should fit the area.
|
||||||
@@ -1801,7 +1802,7 @@ class CImage
|
|||||||
|
|
||||||
$this->extension = isset($this->extension)
|
$this->extension = isset($this->extension)
|
||||||
? $this->extension
|
? $this->extension
|
||||||
: (isset($parts['extension'])
|
: (isset($parts['extension'])
|
||||||
? $parts['extension']
|
? $parts['extension']
|
||||||
: null);
|
: null);
|
||||||
|
|
||||||
@@ -1873,7 +1874,7 @@ class CImage
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load image from disk. Try to load image without verbose error message,
|
* Load image from disk. Try to load image without verbose error message,
|
||||||
* if fail, load again and display error messages.
|
* if fail, load again and display error messages.
|
||||||
*
|
*
|
||||||
* @param string $src of image.
|
* @param string $src of image.
|
||||||
@@ -2106,7 +2107,7 @@ class CImage
|
|||||||
$this->width = $this->newWidth;
|
$this->width = $this->newWidth;
|
||||||
$this->height = $this->newHeight;
|
$this->height = $this->newHeight;
|
||||||
|
|
||||||
} else if ($this->fillToFit) {
|
} elseif ($this->fillToFit) {
|
||||||
|
|
||||||
// Resize by fill to fit
|
// Resize by fill to fit
|
||||||
$this->log("Resizing using strategy - Fill to fit");
|
$this->log("Resizing using strategy - Fill to fit");
|
||||||
@@ -2145,7 +2146,7 @@ class CImage
|
|||||||
$this->width = $this->newWidth;
|
$this->width = $this->newWidth;
|
||||||
$this->height = $this->newHeight;
|
$this->height = $this->newHeight;
|
||||||
|
|
||||||
} else if (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {
|
} elseif (!($this->newWidth == $this->width && $this->newHeight == $this->height)) {
|
||||||
|
|
||||||
// Resize it
|
// Resize it
|
||||||
$this->log("Resizing, new height and/or width");
|
$this->log("Resizing, new height and/or width");
|
||||||
@@ -2166,10 +2167,10 @@ class CImage
|
|||||||
if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
|
if ($this->newWidth > $this->width && $this->newHeight > $this->height) {
|
||||||
$posX = round(($this->newWidth - $this->width) / 2);
|
$posX = round(($this->newWidth - $this->width) / 2);
|
||||||
$posY = round(($this->newHeight - $this->height) / 2);
|
$posY = round(($this->newHeight - $this->height) / 2);
|
||||||
} else if ($this->newWidth > $this->width) {
|
} elseif ($this->newWidth > $this->width) {
|
||||||
$posX = round(($this->newWidth - $this->width) / 2);
|
$posX = round(($this->newWidth - $this->width) / 2);
|
||||||
$cropY = round(($this->height - $this->newHeight) / 2);
|
$cropY = round(($this->height - $this->newHeight) / 2);
|
||||||
} else if ($this->newHeight > $this->height) {
|
} elseif ($this->newHeight > $this->height) {
|
||||||
$posY = round(($this->newHeight - $this->height) / 2);
|
$posY = round(($this->newHeight - $this->height) / 2);
|
||||||
$cropX = round(($this->width - $this->newWidth) / 2);
|
$cropX = round(($this->width - $this->newWidth) / 2);
|
||||||
}
|
}
|
||||||
@@ -2991,10 +2992,10 @@ class CWhitelist
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the whitelist from an array of strings, each item in the
|
* Set the whitelist from an array of strings, each item in the
|
||||||
* whitelist should be a regexp without the surrounding / or #.
|
* whitelist should be a regexp without the surrounding / or #.
|
||||||
*
|
*
|
||||||
* @param array $whitelist with all valid options,
|
* @param array $whitelist with all valid options,
|
||||||
* default is to clear the whitelist.
|
* default is to clear the whitelist.
|
||||||
*
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
@@ -3022,8 +3023,8 @@ class CWhitelist
|
|||||||
public function check($item, $whitelist = null)
|
public function check($item, $whitelist = null)
|
||||||
{
|
{
|
||||||
if ($whitelist !== null) {
|
if ($whitelist !== null) {
|
||||||
$this->set($whitelist);
|
$this->set($whitelist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($item) or empty($this->whitelist)) {
|
if (empty($item) or empty($this->whitelist)) {
|
||||||
return false;
|
return false;
|
||||||
@@ -3177,7 +3178,7 @@ $configFile = __DIR__.'/'.basename(__FILE__, '.php').'_config.php';
|
|||||||
|
|
||||||
if (is_file($configFile)) {
|
if (is_file($configFile)) {
|
||||||
$config = require $configFile;
|
$config = require $configFile;
|
||||||
} else if (!isset($config)) {
|
} elseif (!isset($config)) {
|
||||||
$config = array();
|
$config = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3213,14 +3214,14 @@ if ($mode == 'strict') {
|
|||||||
ini_set('log_errors', 1);
|
ini_set('log_errors', 1);
|
||||||
$verbose = false;
|
$verbose = false;
|
||||||
|
|
||||||
} else if ($mode == 'production') {
|
} elseif ($mode == 'production') {
|
||||||
|
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
ini_set('display_errors', 0);
|
ini_set('display_errors', 0);
|
||||||
ini_set('log_errors', 1);
|
ini_set('log_errors', 1);
|
||||||
$verbose = false;
|
$verbose = false;
|
||||||
|
|
||||||
} else if ($mode == 'development') {
|
} elseif ($mode == 'development') {
|
||||||
|
|
||||||
error_reporting(-1);
|
error_reporting(-1);
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
@@ -3242,7 +3243,7 @@ $defaultTimezone = getConfig('default_timezone', null);
|
|||||||
|
|
||||||
if ($defaultTimezone) {
|
if ($defaultTimezone) {
|
||||||
date_default_timezone_set($defaultTimezone);
|
date_default_timezone_set($defaultTimezone);
|
||||||
} else if (!ini_get('default_timezone')) {
|
} elseif (!ini_get('default_timezone')) {
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3289,13 +3290,13 @@ $refererHost = parse_url($referer, PHP_URL_HOST);
|
|||||||
if (!$allowHotlinking) {
|
if (!$allowHotlinking) {
|
||||||
if ($passwordMatch) {
|
if ($passwordMatch) {
|
||||||
; // Always allow when password match
|
; // Always allow when password match
|
||||||
} else if ($passwordMatch === false) {
|
} elseif ($passwordMatch === false) {
|
||||||
errorPage("Hotlinking/leeching not allowed when password missmatch.");
|
errorPage("Hotlinking/leeching not allowed when password missmatch.");
|
||||||
} else if (!$referer) {
|
} elseif (!$referer) {
|
||||||
errorPage("Hotlinking/leeching not allowed and referer is missing.");
|
errorPage("Hotlinking/leeching not allowed and referer is missing.");
|
||||||
} else if (strcmp($serverName, $refererHost) == 0) {
|
} elseif (strcmp($serverName, $refererHost) == 0) {
|
||||||
; // Allow when serverName matches refererHost
|
; // Allow when serverName matches refererHost
|
||||||
} else if (!empty($hotlinkingWhitelist)) {
|
} elseif (!empty($hotlinkingWhitelist)) {
|
||||||
|
|
||||||
$allowedByWhitelist = false;
|
$allowedByWhitelist = false;
|
||||||
foreach ($hotlinkingWhitelist as $val) {
|
foreach ($hotlinkingWhitelist as $val) {
|
||||||
@@ -3327,7 +3328,7 @@ $cimageClass = getConfig('cimage_class', false);
|
|||||||
|
|
||||||
if ($autoloader) {
|
if ($autoloader) {
|
||||||
require $autoloader;
|
require $autoloader;
|
||||||
} else if ($cimageClass) {
|
} elseif ($cimageClass) {
|
||||||
require $cimageClass;
|
require $cimageClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3397,7 +3398,7 @@ if ($allowRemote && $img->isRemoteSource($srcImage)) {
|
|||||||
|
|
||||||
// If source is a remote file, ignore local file checks.
|
// If source is a remote file, ignore local file checks.
|
||||||
|
|
||||||
} else if ($imagePathConstraint) {
|
} elseif ($imagePathConstraint) {
|
||||||
|
|
||||||
// Check that the image is a file below the directory 'image_path'.
|
// Check that the image is a file below the directory 'image_path'.
|
||||||
$pathToImage = realpath($imagePath . $srcImage);
|
$pathToImage = realpath($imagePath . $srcImage);
|
||||||
@@ -3849,7 +3850,7 @@ if ($alias && $aliasPath && $passwordMatch) {
|
|||||||
preg_match($validAliasname, $alias)
|
preg_match($validAliasname, $alias)
|
||||||
or errorPage('Filename for alias contains invalid characters. Do not add extension.');
|
or errorPage('Filename for alias contains invalid characters. Do not add extension.');
|
||||||
|
|
||||||
} else if ($alias) {
|
} elseif ($alias) {
|
||||||
errorPage('Alias is not enabled in the config file or password not matching.');
|
errorPage('Alias is not enabled in the config file or password not matching.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user