| 3 |
// $Id$ |
// $Id$ |
| 4 |
// ----------------------------------------------------------------------------- |
// ----------------------------------------------------------------------------- |
| 5 |
// $Log$ |
// $Log$ |
| 6 |
|
// Revision 1.4 2002/12/22 13:29:54 jonen |
| 7 |
|
// + added number format helper functions: |
| 8 |
|
// + number_format_locale() |
| 9 |
|
// + is_amount() |
| 10 |
|
// |
| 11 |
|
// Revision 1.3 2002/12/11 01:00:22 joko |
| 12 |
|
// + renamed function 'sai' to 'array_init' |
| 13 |
|
// |
| 14 |
// Revision 1.2 2002/12/01 04:49:54 joko |
// Revision 1.2 2002/12/01 04:49:54 joko |
| 15 |
// + function Dumper (from function dumpVar) |
// + function Dumper (from function dumpVar) |
| 16 |
// |
// |
| 62 |
} |
} |
| 63 |
|
|
| 64 |
// ------------------------------------------------- |
// ------------------------------------------------- |
| 65 |
// sophisticated array init |
// array initializer |
| 66 |
// initializes passed variable (taken by reference) with an empty array |
// initializes passed variable (taken by reference) with an empty array |
| 67 |
// does this only if it doesn't exist yet or initialization is explicitely requested ($clear = 1) |
// does this only if it doesn't exist yet or initialization is explicitely requested ($clear = 1) |
| 68 |
function sai(&$var, $clear = 0) { |
function array_init(&$var, $clear = 0) { |
| 69 |
if (!is_array($var) || $clear) { $var = array(); } |
if (!is_array($var) || $clear) { $var = array(); } |
| 70 |
} |
} |
| 71 |
|
|
| 72 |
|
|
| 73 |
// format functions |
// format functions |
| 74 |
function isvalidemailaddress($mail) { |
function isvalidemailaddress($mail) { |
| 75 |
|
// TODO: review for regex process load |
| 76 |
//return ((($string = trim($string)) != '') && (($atpos = strpos($string, '@' , 1)) > 1) && (($rdotpos = strrpos($string, '.')) > ($atpos + 2)) && (strlen($string) > $rdotpos + 2)); |
//return ((($string = trim($string)) != '') && (($atpos = strpos($string, '@' , 1)) > 1) && (($rdotpos = strrpos($string, '.')) > ($atpos + 2)) && (strlen($string) > $rdotpos + 2)); |
| 77 |
if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"."@([a-z0-9]+([\.-][a-z0-9]+))*$",$mail, $regs) ) { |
if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"."@([a-z0-9]+([\.-][a-z0-9]+))*$",$mail, $regs) ) { |
| 78 |
return "format"; |
return "format"; |
| 158 |
} |
} |
| 159 |
*/ |
*/ |
| 160 |
|
|
| 161 |
|
function number_format_storage($string) { |
| 162 |
|
$locale_info = localeconv(); |
| 163 |
|
$string = str_replace($locale_info["decimal_point"], ".", $string); |
| 164 |
|
return $string; |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
function number_format_locale1($string) { |
| 168 |
|
$locale_info = localeconv(); |
| 169 |
|
$string = str_replace(".", $locale_info["decimal_point"], $string); |
| 170 |
|
return $string; |
| 171 |
|
} |
| 172 |
|
|
| 173 |
|
|
| 174 |
|
function number_format_locale ($num, $decimals = null) { |
| 175 |
|
$locale = localeconv(); |
| 176 |
|
if(!isset($decimals)) $decimals = $locale['frac_digits']; |
| 177 |
|
return number_format($num, $decimals, $locale['decimal_point'], $locale['thousands_sep']); |
| 178 |
|
} |
| 179 |
|
|
| 180 |
|
|
| 181 |
|
function is_amount($amount) { |
| 182 |
|
//if( (number_format_locale((string)doubleval($amount)) === number_format_locale((string)$amount)) && number_format_locale((doubleval($amount)) >number_format_locale(0)) ) { |
| 183 |
|
if( ((string)doubleval($amount) === (string)$amount) && (doubleval($amount) > 0) ) { |
| 184 |
|
return 1; |
| 185 |
|
} |
| 186 |
|
} |
| 187 |
|
|
| 188 |
?> |
?> |