aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty/libs/plugins/function.html_image.php
diff options
context:
space:
mode:
authorThomas Willingham <beardyunixer@beardyunixer.com>2014-12-11 20:15:27 +0000
committerThomas Willingham <beardyunixer@beardyunixer.com>2014-12-11 20:15:27 +0000
commit967ab871b836f618107fe144978bd1453c3c6634 (patch)
tree1bcb1b4bb1b25c904a2bc06f5c6d526d29909eaa /library/Smarty/libs/plugins/function.html_image.php
parent960c35bad3a0dbaa7a1f2191aef60ad014d926ca (diff)
downloadvolse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.tar.gz
volse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.tar.bz2
volse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.zip
Update Smarty
Diffstat (limited to 'library/Smarty/libs/plugins/function.html_image.php')
-rw-r--r--library/Smarty/libs/plugins/function.html_image.php68
1 files changed, 36 insertions, 32 deletions
diff --git a/library/Smarty/libs/plugins/function.html_image.php b/library/Smarty/libs/plugins/function.html_image.php
index 6521966bb..5037e8bd1 100644
--- a/library/Smarty/libs/plugins/function.html_image.php
+++ b/library/Smarty/libs/plugins/function.html_image.php
@@ -1,14 +1,13 @@
<?php
/**
* Smarty plugin
- *
- * @package Smarty
+ *
+ * @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_image} function plugin
- *
* Type: function<br>
* Name: html_image<br>
* Date: Feb 24, 2003<br>
@@ -23,21 +22,24 @@
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
* - path_prefix - prefix for path output (optional, default empty)
* </pre>
- *
- * @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
- * (Smarty online manual)
- * @author Monte Ohrt <monte at ohrt dot com>
- * @author credits to Duda <duda@big.hu>
+ *
+ * @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
+ * (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
+ * @author credits to Duda <duda@big.hu>
* @version 1.0
+ *
* @param array $params parameters
* @param Smarty_Internal_Template $template template object
- * @return string
- * @uses smarty_function_escape_special_chars()
+ *
+ * @throws SmartyException
+ * @return string
+ * @uses smarty_function_escape_special_chars()
*/
function smarty_function_html_image($params, $template)
{
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
-
+
$alt = '';
$file = '';
$height = '';
@@ -47,7 +49,7 @@ function smarty_function_html_image($params, $template)
$suffix = '';
$path_prefix = '';
$basedir = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['DOCUMENT_ROOT'] : '';
- foreach($params as $_key => $_val) {
+ foreach ($params as $_key => $_val) {
switch ($_key) {
case 'file':
case 'height':
@@ -63,7 +65,7 @@ function smarty_function_html_image($params, $template)
$$_key = smarty_function_escape_special_chars($_val);
} else {
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
- }
+ }
break;
case 'link':
@@ -77,41 +79,42 @@ function smarty_function_html_image($params, $template)
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else {
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
- }
+ }
break;
- }
- }
+ }
+ }
if (empty($file)) {
trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
+
return;
- }
+ }
if ($file[0] == '/') {
$_image_path = $basedir . $file;
} else {
$_image_path = $file;
}
-
+
// strip file protocol
if (stripos($params['file'], 'file://') === 0) {
$params['file'] = substr($params['file'], 7);
}
-
+
$protocol = strpos($params['file'], '://');
if ($protocol !== false) {
$protocol = strtolower(substr($params['file'], 0, $protocol));
}
-
+
if (isset($template->smarty->security_policy)) {
if ($protocol) {
// remote resource (or php stream, …)
- if(!$template->smarty->security_policy->isTrustedUri($params['file'])) {
+ if (!$template->smarty->security_policy->isTrustedUri($params['file'])) {
return;
}
} else {
// local file
- if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) {
+ if (!$template->smarty->security_policy->isTrustedResourceDir($_image_path)) {
return;
}
}
@@ -122,23 +125,26 @@ function smarty_function_html_image($params, $template)
if (!$_image_data = @getimagesize($_image_path)) {
if (!file_exists($_image_path)) {
trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
+
return;
- } else if (!is_readable($_image_path)) {
+ } elseif (!is_readable($_image_path)) {
trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
+
return;
} else {
trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
+
return;
- }
+ }
}
if (!isset($params['width'])) {
$width = $_image_data[0];
- }
+ }
if (!isset($params['height'])) {
$height = $_image_data[1];
- }
- }
+ }
+ }
if (isset($params['dpi'])) {
if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mac')) {
@@ -147,13 +153,11 @@ function smarty_function_html_image($params, $template)
$dpi_default = 72;
} else {
$dpi_default = 96;
- }
+ }
$_resize = $dpi_default / $params['dpi'];
$width = round($width * $_resize);
$height = round($height * $_resize);
- }
+ }
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"' . $extra . ' />' . $suffix;
-}
-
-?> \ No newline at end of file
+}