diff --git a/gosa-core/include/smarty/plugins/function.fetch.php b/gosa-core/include/smarty/plugins/function.fetch.php
index 81b1bfc6b9a03f916fcdb62209f6f458c5e712e5..391ff1bb9ab3d12a2fd8405eec8425149323b8d3 100644 (file)
/**
* Smarty plugin
* @package Smarty
- * @subpackage plugins
+ * @subpackage PluginsFunction
*/
* @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
- * @param array
- * @param Smarty
+ * @param array $params parameters
+ * @param object $smarty Smarty object
+ * @param object $template template object
* @return string|null if the assign parameter is passed, Smarty assigns the
* result to a template variable
*/
-function smarty_function_fetch($params, &$smarty)
+function smarty_function_fetch($params, $smarty, $template)
{
if (empty($params['file'])) {
- $smarty->_trigger_fatal_error("[plugin] parameter 'file' cannot be empty");
+ trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE);
return;
}
$content = '';
- if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) {
- $_params = array('resource_type' => 'file', 'resource_name' => $params['file']);
- require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
- if(!smarty_core_is_secure($_params, $smarty)) {
- $smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed');
+ if ($template->security && !preg_match('!^(http|ftp)://!i', $params['file'])) {
+ if(!$smarty->security_handler->isTrustedResourceDir($params['file'])) {
return;
}
}
fclose($fp);
} else {
- $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] . '\'');
+ trigger_error('[plugin] fetch cannot read file \'' . $params['file'] . '\'',E_USER_NOTICE);
return;
}
} else {
case "header":
if(!empty($param_value)) {
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
- $smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'");
+ trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE);
return;
} else {
$extra_headers[] = $param_value;
if(!preg_match('!\D!', $param_value)) {
$proxy_port = (int) $param_value;
} else {
- $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
+ trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
return;
}
break;
if(!preg_match('!\D!', $param_value)) {
$timeout = (int) $param_value;
} else {
- $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
+ trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
return;
}
break;
default:
- $smarty->_trigger_fatal_error("[plugin] unrecognized attribute '".$param_key."'");
+ trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE);
return;
}
}
}
if(!$fp) {
- $smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)");
+ trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE);
return;
} else {
if($_is_proxy) {
$content .= fgets($fp,4096);
}
fclose($fp);
- $csplit = split("\r\n\r\n",$content,2);
+ $csplit = preg_split("!\r\n\r\n!",$content,2);
$content = $csplit[1];
if(!empty($params['assign_headers'])) {
- $smarty->assign($params['assign_headers'],split("\r\n",$csplit[0]));
+ $template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0]));
}
}
} else {
- $smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax");
+ trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE);
return;
}
} else {
}
fclose($fp);
} else {
- $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] .'\'');
+ trigger_error('[plugin] fetch cannot read file \'' . $params['file'] .'\'',E_USER_NOTICE);
return;
}
}
if (!empty($params['assign'])) {
- $smarty->assign($params['assign'],$content);
+ $template->assign($params['assign'],$content);
} else {
return $content;
}
}
-/* vim: set expandtab: */
-
?>