update file generation, replace crc32() '-' with 'N'

This commit is contained in:
mohrt
2002-03-20 16:44:17 +00:00
parent 4b0e85ea94
commit de9503ac16
8 changed files with 77 additions and 28 deletions

2
NEWS
View File

@@ -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 bug with $smarty.cookies and $smarty.server. (Andrei)
- wordwrap and indent are missing from 2.0 release, now fixed. (Monte)

View File

@@ -1252,9 +1252,9 @@ function _run_insert_handler($args)
\*======================================================================*/
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) . '/' .
$source_hash . '/' . crc32($auto_id) . '.php';
$source_hash . '/' . str_replace('-','N',crc32($auto_id)) . '.php';
return $res;
}
@@ -1275,7 +1275,7 @@ function _run_insert_handler($args)
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
$res = is_file($tname) && unlink( $tname);
} else {
$source_hash = crc32($auto_source);
$source_hash = str_replace('-','N',crc32($auto_source));
$tname = $auto_base . '/' . substr($source_hash, 0, 3) . '/' . $source_hash;
$res = $this->_rmdir($tname);
}

View File

@@ -3036,14 +3036,16 @@ OUTPUT:
<entry>string</entry>
<entry>No</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>
<entry>end_year</entry>
<entry>string</entry>
<entry>No</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>
<entry>display_days</entry>
@@ -3249,9 +3251,10 @@ OUTPUT:
<title>html_select_date</title>
<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)
&lt;select name="StartDateMonth"&gt;
&lt;option value="1"&gt;January&lt;/option&gt;

View File

@@ -1252,9 +1252,9 @@ function _run_insert_handler($args)
\*======================================================================*/
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) . '/' .
$source_hash . '/' . crc32($auto_id) . '.php';
$source_hash . '/' . str_replace('-','N',crc32($auto_id)) . '.php';
return $res;
}
@@ -1275,7 +1275,7 @@ function _run_insert_handler($args)
$tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id);
$res = is_file($tname) && unlink( $tname);
} else {
$source_hash = crc32($auto_source);
$source_hash = str_replace('-','N',crc32($auto_source));
$tname = $auto_base . '/' . substr($source_hash, 0, 3) . '/' . $source_hash;
$res = $this->_rmdir($tname);
}

View File

@@ -13,7 +13,7 @@ function smarty_function_fetch($params, &$smarty)
$file = $params['file'];
if (empty($file)) {
$smarty->trigger_error("parameter 'file' cannot be empty");
$smarty->_trigger_plugin_error("parameter 'file' cannot be empty");
return;
}
@@ -26,11 +26,11 @@ function smarty_function_fetch($params, &$smarty)
}
}
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;
}
if (!@is_readable($file)) {
$smarty->trigger_error("fetch cannot read file '$file'");
$smarty->_trigger_plugin_error("fetch cannot read file '$file'");
return;
}
// fetch the file
@@ -89,7 +89,7 @@ function smarty_function_fetch($params, &$smarty)
case "header":
if(!empty($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;
} else {
$extra_headers[] = $param_value;
@@ -105,7 +105,7 @@ function smarty_function_fetch($params, &$smarty)
if(!preg_match('!\D!', $param_value)) {
$proxy_port = (int) $param_value;
} else {
$smarty->trigger_error("invalid value for attribute '".$param_key."'");
$smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
return;
}
break;
@@ -123,7 +123,7 @@ function smarty_function_fetch($params, &$smarty)
if(!preg_match('!\D!', $param_value)) {
$timeout = (int) $param_value;
} else {
$smarty->trigger_error("invalid value for attribute '".$param_key."'");
$smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
return;
}
break;
@@ -134,7 +134,7 @@ function smarty_function_fetch($params, &$smarty)
}
break;
default:
$smarty->trigger_error("unrecognized attribute '".$param_key."'");
$smarty->_trigger_plugin_error("unrecognized attribute '".$param_key."'");
return;
}
}
@@ -146,7 +146,7 @@ function smarty_function_fetch($params, &$smarty)
}
if(!$fp) {
$smarty->trigger_error("unable to fetch: $errstr ($errno)");
$smarty->_trigger_plugin_error("unable to fetch: $errstr ($errno)");
return;
} else {
if($_is_proxy) {
@@ -189,7 +189,7 @@ function smarty_function_fetch($params, &$smarty)
}
}
} else {
$smarty->trigger_error("unable to parse URL, check syntax");
$smarty->_trigger_plugin_error("unable to parse URL, check syntax");
return;
}
} else {

View File

@@ -5,7 +5,13 @@
* -------------------------------------------------------------
* Type: function
* Name: html_select_date
* Version: 1.1
* 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';
@@ -49,6 +55,22 @@ function smarty_function_html_select_date($params, &$smarty)
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);
$field_order = strtoupper($field_order);

View File

@@ -13,7 +13,7 @@ function smarty_function_fetch($params, &$smarty)
$file = $params['file'];
if (empty($file)) {
$smarty->trigger_error("parameter 'file' cannot be empty");
$smarty->_trigger_plugin_error("parameter 'file' cannot be empty");
return;
}
@@ -26,11 +26,11 @@ function smarty_function_fetch($params, &$smarty)
}
}
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;
}
if (!@is_readable($file)) {
$smarty->trigger_error("fetch cannot read file '$file'");
$smarty->_trigger_plugin_error("fetch cannot read file '$file'");
return;
}
// fetch the file
@@ -89,7 +89,7 @@ function smarty_function_fetch($params, &$smarty)
case "header":
if(!empty($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;
} else {
$extra_headers[] = $param_value;
@@ -105,7 +105,7 @@ function smarty_function_fetch($params, &$smarty)
if(!preg_match('!\D!', $param_value)) {
$proxy_port = (int) $param_value;
} else {
$smarty->trigger_error("invalid value for attribute '".$param_key."'");
$smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
return;
}
break;
@@ -123,7 +123,7 @@ function smarty_function_fetch($params, &$smarty)
if(!preg_match('!\D!', $param_value)) {
$timeout = (int) $param_value;
} else {
$smarty->trigger_error("invalid value for attribute '".$param_key."'");
$smarty->_trigger_plugin_error("invalid value for attribute '".$param_key."'");
return;
}
break;
@@ -134,7 +134,7 @@ function smarty_function_fetch($params, &$smarty)
}
break;
default:
$smarty->trigger_error("unrecognized attribute '".$param_key."'");
$smarty->_trigger_plugin_error("unrecognized attribute '".$param_key."'");
return;
}
}
@@ -146,7 +146,7 @@ function smarty_function_fetch($params, &$smarty)
}
if(!$fp) {
$smarty->trigger_error("unable to fetch: $errstr ($errno)");
$smarty->_trigger_plugin_error("unable to fetch: $errstr ($errno)");
return;
} else {
if($_is_proxy) {
@@ -189,7 +189,7 @@ function smarty_function_fetch($params, &$smarty)
}
}
} else {
$smarty->trigger_error("unable to parse URL, check syntax");
$smarty->_trigger_plugin_error("unable to parse URL, check syntax");
return;
}
} else {

View File

@@ -5,7 +5,13 @@
* -------------------------------------------------------------
* Type: function
* Name: html_select_date
* Version: 1.1
* 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';
@@ -49,6 +55,22 @@ function smarty_function_html_select_date($params, &$smarty)
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);
$field_order = strtoupper($field_order);