Update Smarty und RedBean
Smarty: 3.1.30 - Redbean: 5.0.0
This commit is contained in:
parent
eb0835ff74
commit
0795a87ecd
193 changed files with 22035 additions and 14455 deletions
|
@ -24,31 +24,31 @@
|
|||
*/
|
||||
function smarty_function_fetch($params, $template)
|
||||
{
|
||||
if (empty($params['file'])) {
|
||||
if (empty($params[ 'file' ])) {
|
||||
trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// strip file protocol
|
||||
if (stripos($params['file'], 'file://') === 0) {
|
||||
$params['file'] = substr($params['file'], 7);
|
||||
if (stripos($params[ 'file' ], 'file://') === 0) {
|
||||
$params[ 'file' ] = substr($params[ 'file' ], 7);
|
||||
}
|
||||
|
||||
$protocol = strpos($params['file'], '://');
|
||||
$protocol = strpos($params[ 'file' ], '://');
|
||||
if ($protocol !== false) {
|
||||
$protocol = strtolower(substr($params['file'], 0, $protocol));
|
||||
$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($params[ 'file' ])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -57,26 +57,26 @@ function smarty_function_fetch($params, $template)
|
|||
$content = '';
|
||||
if ($protocol == 'http') {
|
||||
// http fetch
|
||||
if ($uri_parts = parse_url($params['file'])) {
|
||||
if ($uri_parts = parse_url($params[ 'file' ])) {
|
||||
// set defaults
|
||||
$host = $server_name = $uri_parts['host'];
|
||||
$host = $server_name = $uri_parts[ 'host' ];
|
||||
$timeout = 30;
|
||||
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
|
||||
$agent = "Smarty Template Engine " . Smarty::SMARTY_VERSION;
|
||||
$referer = "";
|
||||
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
|
||||
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
|
||||
$uri = !empty($uri_parts[ 'path' ]) ? $uri_parts[ 'path' ] : '/';
|
||||
$uri .= !empty($uri_parts[ 'query' ]) ? '?' . $uri_parts[ 'query' ] : '';
|
||||
$_is_proxy = false;
|
||||
if (empty($uri_parts['port'])) {
|
||||
if (empty($uri_parts[ 'port' ])) {
|
||||
$port = 80;
|
||||
} else {
|
||||
$port = $uri_parts['port'];
|
||||
$port = $uri_parts[ 'port' ];
|
||||
}
|
||||
if (!empty($uri_parts['user'])) {
|
||||
$user = $uri_parts['user'];
|
||||
if (!empty($uri_parts[ 'user' ])) {
|
||||
$user = $uri_parts[ 'user' ];
|
||||
}
|
||||
if (!empty($uri_parts['pass'])) {
|
||||
$pass = $uri_parts['pass'];
|
||||
if (!empty($uri_parts[ 'pass' ])) {
|
||||
$pass = $uri_parts[ 'pass' ];
|
||||
}
|
||||
// loop through parameters, setup headers
|
||||
foreach ($params as $param_key => $param_value) {
|
||||
|
@ -163,7 +163,7 @@ function smarty_function_fetch($params, $template)
|
|||
return;
|
||||
} else {
|
||||
if ($_is_proxy) {
|
||||
fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n");
|
||||
fputs($fp, 'GET ' . $params[ 'file' ] . " HTTP/1.0\r\n");
|
||||
} else {
|
||||
fputs($fp, "GET $uri HTTP/1.0\r\n");
|
||||
}
|
||||
|
@ -195,10 +195,10 @@ function smarty_function_fetch($params, $template)
|
|||
fclose($fp);
|
||||
$csplit = preg_split("!\r\n\r\n!", $content, 2);
|
||||
|
||||
$content = $csplit[1];
|
||||
$content = $csplit[ 1 ];
|
||||
|
||||
if (!empty($params['assign_headers'])) {
|
||||
$template->assign($params['assign_headers'], preg_split("!\r\n!", $csplit[0]));
|
||||
if (!empty($params[ 'assign_headers' ])) {
|
||||
$template->assign($params[ 'assign_headers' ], preg_split("!\r\n!", $csplit[ 0 ]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -207,14 +207,14 @@ function smarty_function_fetch($params, $template)
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
$content = @file_get_contents($params['file']);
|
||||
$content = @file_get_contents($params[ 'file' ]);
|
||||
if ($content === false) {
|
||||
throw new SmartyException("{fetch} cannot read resource '" . $params['file'] . "'");
|
||||
throw new SmartyException("{fetch} cannot read resource '" . $params[ 'file' ] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$template->assign($params['assign'], $content);
|
||||
if (!empty($params[ 'assign' ])) {
|
||||
$template->assign($params[ 'assign' ], $content);
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue