mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
update file generation, replace crc32() '-' with 'N'
This commit is contained in:
2
NEWS
2
NEWS
@@ -1,3 +1,5 @@
|
|||||||
|
- changed crc32() generated values, replace '-' with 'N' (Monte)
|
||||||
|
- added support for +/- N syntax in html_select_date year values (Monte)
|
||||||
- fixed behavior of inserts with script attribute. (Andrei)
|
- fixed behavior of inserts with script attribute. (Andrei)
|
||||||
- fixed bug with $smarty.cookies and $smarty.server. (Andrei)
|
- fixed bug with $smarty.cookies and $smarty.server. (Andrei)
|
||||||
- wordwrap and indent are missing from 2.0 release, now fixed. (Monte)
|
- wordwrap and indent are missing from 2.0 release, now fixed. (Monte)
|
||||||
|
@@ -1252,9 +1252,9 @@ function _run_insert_handler($args)
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _get_auto_filename($auto_base, $auto_source, $auto_id = null)
|
function _get_auto_filename($auto_base, $auto_source, $auto_id = null)
|
||||||
{
|
{
|
||||||
$source_hash = crc32($auto_source);
|
$source_hash = str_replace('-','N',crc32($auto_source));
|
||||||
$res = $auto_base . '/' . substr($source_hash, 0, 3) . '/' .
|
$res = $auto_base . '/' . substr($source_hash, 0, 3) . '/' .
|
||||||
$source_hash . '/' . crc32($auto_id) . '.php';
|
$source_hash . '/' . str_replace('-','N',crc32($auto_id)) . '.php';
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
@@ -1275,7 +1275,7 @@ function _run_insert_handler($args)
|
|||||||
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
|
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
|
||||||
$res = is_file($tname) && unlink( $tname);
|
$res = is_file($tname) && unlink( $tname);
|
||||||
} else {
|
} else {
|
||||||
$source_hash = crc32($auto_source);
|
$source_hash = str_replace('-','N',crc32($auto_source));
|
||||||
$tname = $auto_base . '/' . substr($source_hash, 0, 3) . '/' . $source_hash;
|
$tname = $auto_base . '/' . substr($source_hash, 0, 3) . '/' . $source_hash;
|
||||||
$res = $this->_rmdir($tname);
|
$res = $this->_rmdir($tname);
|
||||||
}
|
}
|
||||||
|
@@ -3036,14 +3036,16 @@ OUTPUT:
|
|||||||
<entry>string</entry>
|
<entry>string</entry>
|
||||||
<entry>No</entry>
|
<entry>No</entry>
|
||||||
<entry>current year</entry>
|
<entry>current year</entry>
|
||||||
<entry>the first year in the dropdown</entry>
|
<entry>the first year in the dropdown, either
|
||||||
|
year number, or relative to current year (+/- N)</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>end_year</entry>
|
<entry>end_year</entry>
|
||||||
<entry>string</entry>
|
<entry>string</entry>
|
||||||
<entry>No</entry>
|
<entry>No</entry>
|
||||||
<entry>same as start_year</entry>
|
<entry>same as start_year</entry>
|
||||||
<entry>the last year in the dropdown</entry>
|
<entry>the last year in the dropdown, either
|
||||||
|
year number, or relative to current year (+/- N)</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>display_days</entry>
|
<entry>display_days</entry>
|
||||||
@@ -3249,9 +3251,10 @@ OUTPUT:
|
|||||||
<title>html_select_date</title>
|
<title>html_select_date</title>
|
||||||
<programlisting>
|
<programlisting>
|
||||||
|
|
||||||
{html_select_date prefix="StartDate" time=$time start_year=1995 end_year=2001 display_days=false}
|
{* start and end year can be relative to current year *}
|
||||||
|
{html_select_date prefix="StartDate" time=$time start_year="-5" end_year="+1" display_days=false}
|
||||||
|
|
||||||
OUTPUT:
|
OUTPUT: (current year is 2000)
|
||||||
|
|
||||||
<select name="StartDateMonth">
|
<select name="StartDateMonth">
|
||||||
<option value="1">January</option>
|
<option value="1">January</option>
|
||||||
|
@@ -1252,9 +1252,9 @@ function _run_insert_handler($args)
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _get_auto_filename($auto_base, $auto_source, $auto_id = null)
|
function _get_auto_filename($auto_base, $auto_source, $auto_id = null)
|
||||||
{
|
{
|
||||||
$source_hash = crc32($auto_source);
|
$source_hash = str_replace('-','N',crc32($auto_source));
|
||||||
$res = $auto_base . '/' . substr($source_hash, 0, 3) . '/' .
|
$res = $auto_base . '/' . substr($source_hash, 0, 3) . '/' .
|
||||||
$source_hash . '/' . crc32($auto_id) . '.php';
|
$source_hash . '/' . str_replace('-','N',crc32($auto_id)) . '.php';
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
@@ -1275,7 +1275,7 @@ function _run_insert_handler($args)
|
|||||||
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
|
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
|
||||||
$res = is_file($tname) && unlink( $tname);
|
$res = is_file($tname) && unlink( $tname);
|
||||||
} else {
|
} else {
|
||||||
$source_hash = crc32($auto_source);
|
$source_hash = str_replace('-','N',crc32($auto_source));
|
||||||
$tname = $auto_base . '/' . substr($source_hash, 0, 3) . '/' . $source_hash;
|
$tname = $auto_base . '/' . substr($source_hash, 0, 3) . '/' . $source_hash;
|
||||||
$res = $this->_rmdir($tname);
|
$res = $this->_rmdir($tname);
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
$file = $params['file'];
|
$file = $params['file'];
|
||||||
|
|
||||||
if (empty($file)) {
|
if (empty($file)) {
|
||||||
$smarty->trigger_error("parameter 'file' cannot be empty");
|
$smarty->_trigger_plugin_error("parameter 'file' cannot be empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,11 +26,11 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$resource_is_secure) {
|
if (!$resource_is_secure) {
|
||||||
$smarty->trigger_error("(secure mode) fetch '$file' is not allowed");
|
$smarty->_trigger_plugin_error("(secure mode) fetch '$file' is not allowed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!@is_readable($file)) {
|
if (!@is_readable($file)) {
|
||||||
$smarty->trigger_error("fetch cannot read file '$file'");
|
$smarty->_trigger_plugin_error("fetch cannot read file '$file'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// fetch the file
|
// fetch the file
|
||||||
@@ -89,7 +89,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
case "header":
|
case "header":
|
||||||
if(!empty($param_value)) {
|
if(!empty($param_value)) {
|
||||||
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
|
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
|
||||||
$smarty->trigger_error("invalid header format '".$param_value."'");
|
$smarty->_trigger_plugin_error("invalid header format '".$param_value."'");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$extra_headers[] = $param_value;
|
$extra_headers[] = $param_value;
|
||||||
@@ -105,7 +105,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
if(!preg_match('!\D!', $param_value)) {
|
if(!preg_match('!\D!', $param_value)) {
|
||||||
$proxy_port = (int) $param_value;
|
$proxy_port = (int) $param_value;
|
||||||
} else {
|
} else {
|
||||||
$smarty->trigger_error("invalid value for attribute '".$param_key."'");
|
$smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -123,7 +123,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
if(!preg_match('!\D!', $param_value)) {
|
if(!preg_match('!\D!', $param_value)) {
|
||||||
$timeout = (int) $param_value;
|
$timeout = (int) $param_value;
|
||||||
} else {
|
} else {
|
||||||
$smarty->trigger_error("invalid value for attribute '".$param_key."'");
|
$smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -134,7 +134,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$smarty->trigger_error("unrecognized attribute '".$param_key."'");
|
$smarty->_trigger_plugin_error("unrecognized attribute '".$param_key."'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$fp) {
|
if(!$fp) {
|
||||||
$smarty->trigger_error("unable to fetch: $errstr ($errno)");
|
$smarty->_trigger_plugin_error("unable to fetch: $errstr ($errno)");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if($_is_proxy) {
|
if($_is_proxy) {
|
||||||
@@ -189,7 +189,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$smarty->trigger_error("unable to parse URL, check syntax");
|
$smarty->_trigger_plugin_error("unable to parse URL, check syntax");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -5,7 +5,13 @@
|
|||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
* Type: function
|
* Type: function
|
||||||
* Name: html_select_date
|
* Name: html_select_date
|
||||||
|
* Version: 1.1
|
||||||
* Purpose: Prints the dropdowns for date selection.
|
* Purpose: Prints the dropdowns for date selection.
|
||||||
|
* Author: Andrei Zmievski
|
||||||
|
*
|
||||||
|
* ChangeLog: 1.0 initial release
|
||||||
|
* 1.1 added support for +/- N syntax for begin
|
||||||
|
* and end year values. (Monte)
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
require_once SMARTY_DIR . 'plugins/.make_timestamp.php';
|
require_once SMARTY_DIR . 'plugins/.make_timestamp.php';
|
||||||
@@ -49,6 +55,22 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||||||
|
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
|
// make syntax "+N" or "-N" work with start_year and end_year
|
||||||
|
if(preg_match('!(\+|\-)\s*(\d+)!',$end_year,$match)) {
|
||||||
|
if($match[1] == '+') {
|
||||||
|
$end_year = $match[2] + strftime("%Y");
|
||||||
|
} else {
|
||||||
|
$end_year = $match[2] - strftime("%Y");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(preg_match('!(\+|\-)\s*(\d+)!',$start_year,$match)) {
|
||||||
|
if($match[1] == '+') {
|
||||||
|
$start_year = $match[2] + strftime("%Y");
|
||||||
|
} else {
|
||||||
|
$start_year = $match[2] - strftime("%Y");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$time = smarty_make_timestamp($time);
|
$time = smarty_make_timestamp($time);
|
||||||
$field_order = strtoupper($field_order);
|
$field_order = strtoupper($field_order);
|
||||||
|
|
||||||
|
@@ -13,7 +13,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
$file = $params['file'];
|
$file = $params['file'];
|
||||||
|
|
||||||
if (empty($file)) {
|
if (empty($file)) {
|
||||||
$smarty->trigger_error("parameter 'file' cannot be empty");
|
$smarty->_trigger_plugin_error("parameter 'file' cannot be empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,11 +26,11 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$resource_is_secure) {
|
if (!$resource_is_secure) {
|
||||||
$smarty->trigger_error("(secure mode) fetch '$file' is not allowed");
|
$smarty->_trigger_plugin_error("(secure mode) fetch '$file' is not allowed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!@is_readable($file)) {
|
if (!@is_readable($file)) {
|
||||||
$smarty->trigger_error("fetch cannot read file '$file'");
|
$smarty->_trigger_plugin_error("fetch cannot read file '$file'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// fetch the file
|
// fetch the file
|
||||||
@@ -89,7 +89,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
case "header":
|
case "header":
|
||||||
if(!empty($param_value)) {
|
if(!empty($param_value)) {
|
||||||
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
|
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
|
||||||
$smarty->trigger_error("invalid header format '".$param_value."'");
|
$smarty->_trigger_plugin_error("invalid header format '".$param_value."'");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$extra_headers[] = $param_value;
|
$extra_headers[] = $param_value;
|
||||||
@@ -105,7 +105,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
if(!preg_match('!\D!', $param_value)) {
|
if(!preg_match('!\D!', $param_value)) {
|
||||||
$proxy_port = (int) $param_value;
|
$proxy_port = (int) $param_value;
|
||||||
} else {
|
} else {
|
||||||
$smarty->trigger_error("invalid value for attribute '".$param_key."'");
|
$smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -123,7 +123,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
if(!preg_match('!\D!', $param_value)) {
|
if(!preg_match('!\D!', $param_value)) {
|
||||||
$timeout = (int) $param_value;
|
$timeout = (int) $param_value;
|
||||||
} else {
|
} else {
|
||||||
$smarty->trigger_error("invalid value for attribute '".$param_key."'");
|
$smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -134,7 +134,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$smarty->trigger_error("unrecognized attribute '".$param_key."'");
|
$smarty->_trigger_plugin_error("unrecognized attribute '".$param_key."'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$fp) {
|
if(!$fp) {
|
||||||
$smarty->trigger_error("unable to fetch: $errstr ($errno)");
|
$smarty->_trigger_plugin_error("unable to fetch: $errstr ($errno)");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if($_is_proxy) {
|
if($_is_proxy) {
|
||||||
@@ -189,7 +189,7 @@ function smarty_function_fetch($params, &$smarty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$smarty->trigger_error("unable to parse URL, check syntax");
|
$smarty->_trigger_plugin_error("unable to parse URL, check syntax");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -5,7 +5,13 @@
|
|||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
* Type: function
|
* Type: function
|
||||||
* Name: html_select_date
|
* Name: html_select_date
|
||||||
|
* Version: 1.1
|
||||||
* Purpose: Prints the dropdowns for date selection.
|
* Purpose: Prints the dropdowns for date selection.
|
||||||
|
* Author: Andrei Zmievski
|
||||||
|
*
|
||||||
|
* ChangeLog: 1.0 initial release
|
||||||
|
* 1.1 added support for +/- N syntax for begin
|
||||||
|
* and end year values. (Monte)
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
require_once SMARTY_DIR . 'plugins/.make_timestamp.php';
|
require_once SMARTY_DIR . 'plugins/.make_timestamp.php';
|
||||||
@@ -49,6 +55,22 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||||||
|
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
|
// make syntax "+N" or "-N" work with start_year and end_year
|
||||||
|
if(preg_match('!(\+|\-)\s*(\d+)!',$end_year,$match)) {
|
||||||
|
if($match[1] == '+') {
|
||||||
|
$end_year = $match[2] + strftime("%Y");
|
||||||
|
} else {
|
||||||
|
$end_year = $match[2] - strftime("%Y");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(preg_match('!(\+|\-)\s*(\d+)!',$start_year,$match)) {
|
||||||
|
if($match[1] == '+') {
|
||||||
|
$start_year = $match[2] + strftime("%Y");
|
||||||
|
} else {
|
||||||
|
$start_year = $match[2] - strftime("%Y");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$time = smarty_make_timestamp($time);
|
$time = smarty_make_timestamp($time);
|
||||||
$field_order = strtoupper($field_order);
|
$field_order = strtoupper($field_order);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user