| 3 |
// $Id$ |
// $Id$ |
| 4 |
// ----------------------------------------------------------------------------- |
// ----------------------------------------------------------------------------- |
| 5 |
// $Log$ |
// $Log$ |
| 6 |
|
// Revision 1.8 2003/03/03 21:21:43 joko |
| 7 |
|
// refactored most reusable code to org.netfrag.glib/php_extensions.php |
| 8 |
|
// |
| 9 |
|
// Revision 1.7 2003/03/01 05:05:55 joko |
| 10 |
|
// minor modification to 'Dumper' |
| 11 |
|
// |
| 12 |
|
// Revision 1.6 2003/02/09 17:49:53 joko |
| 13 |
|
// - removed old code |
| 14 |
|
// |
| 15 |
|
// Revision 1.5 2003/02/04 08:22:34 joko |
| 16 |
|
// + function is_hash |
| 17 |
|
// + function array_join_merge |
| 18 |
|
// |
| 19 |
|
// Revision 1.4 2002/12/22 13:29:54 jonen |
| 20 |
|
// + added number format helper functions: |
| 21 |
|
// + number_format_locale() |
| 22 |
|
// + is_amount() |
| 23 |
|
// |
| 24 |
// Revision 1.3 2002/12/11 01:00:22 joko |
// Revision 1.3 2002/12/11 01:00:22 joko |
| 25 |
// + renamed function 'sai' to 'array_init' |
// + renamed function 'sai' to 'array_init' |
| 26 |
// |
// |
| 74 |
return $date_res; |
return $date_res; |
| 75 |
} |
} |
| 76 |
|
|
|
// ------------------------------------------------- |
|
|
// array initializer |
|
|
// initializes passed variable (taken by reference) with an empty array |
|
|
// does this only if it doesn't exist yet or initialization is explicitely requested ($clear = 1) |
|
|
function array_init(&$var, $clear = 0) { |
|
|
if (!is_array($var) || $clear) { $var = array(); } |
|
|
} |
|
| 77 |
|
|
| 78 |
|
|
| 79 |
// format functions |
// format functions |
| 80 |
|
// refactor to org.netfrag.glib::php??? |
| 81 |
|
// refactor to Data::Validator??? |
| 82 |
function isvalidemailaddress($mail) { |
function isvalidemailaddress($mail) { |
| 83 |
|
// TODO: review for regex process load |
| 84 |
//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)); |
| 85 |
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) ) { |
| 86 |
return "format"; |
return "format"; |
| 91 |
return "valid"; |
return "valid"; |
| 92 |
} |
} |
| 93 |
|
|
|
function dumpVar($var) { |
|
|
return Dumper($var); |
|
|
} |
|
|
|
|
|
function Dumper($var) { |
|
|
ob_start(); |
|
|
print_r($var); |
|
|
$var_dump = ob_get_contents(); |
|
|
ob_end_clean(); |
|
|
$var_dump = str_replace("\n", "<br>", $var_dump); |
|
|
$var_dump = str_replace(" ", " ", $var_dump); |
|
|
return $var_dump; |
|
|
} |
|
|
|
|
|
function session_register_safe($varname) { |
|
|
if (!session_is_registered($varname)) { |
|
|
session_register($varname); |
|
|
return 1; |
|
|
} |
|
|
} |
|
| 94 |
|
|
| 95 |
//------------ getMonths --------------------- |
//------------ getMonths --------------------- |
| 96 |
// TODO: localize! |
// TODO: localize! |
| 103 |
return $months; |
return $months; |
| 104 |
} |
} |
| 105 |
|
|
| 106 |
|
|
| 107 |
|
// refactor to Data::Lift??? |
| 108 |
function null2nbsp_string($arg) { |
function null2nbsp_string($arg) { |
| 109 |
if ($arg == '') { |
if ($arg == '') { |
| 110 |
$arg = ' '; |
$arg = ' '; |
| 112 |
return $arg; |
return $arg; |
| 113 |
} |
} |
| 114 |
|
|
| 115 |
|
// refactor to Data::Lift??? |
| 116 |
function null2nbsp_arraywalker(&$item, $key) { |
function null2nbsp_arraywalker(&$item, $key) { |
| 117 |
$item = null2nbsp_string($item); |
$item = null2nbsp_string($item); |
| 118 |
} |
} |
| 119 |
|
|
| 120 |
|
// refactor to Data::Lift??? |
| 121 |
function null2nbsp($arg) { |
function null2nbsp($arg) { |
| 122 |
if (is_array($arg)) { |
if (is_array($arg)) { |
| 123 |
array_walk($arg, 'null2nbsp_arraywalker'); |
array_walk($arg, 'null2nbsp_arraywalker'); |
| 142 |
return $birthday; |
return $birthday; |
| 143 |
} |
} |
| 144 |
|
|
| 145 |
/* |
function number_format_storage($string) { |
| 146 |
function dprint($message) { |
$locale_info = localeconv(); |
| 147 |
print '<span style="font-family:Verdana,Helvetica;font-size:7pt;">'; |
$string = str_replace($locale_info["decimal_point"], ".", $string); |
| 148 |
print $message; |
return $string; |
| 149 |
print '</span><br>'; |
} |
| 150 |
|
|
| 151 |
|
function number_format_locale1($string) { |
| 152 |
|
$locale_info = localeconv(); |
| 153 |
|
$string = str_replace(".", $locale_info["decimal_point"], $string); |
| 154 |
|
return $string; |
| 155 |
|
} |
| 156 |
|
|
| 157 |
|
|
| 158 |
|
function number_format_locale ($num, $decimals = null) { |
| 159 |
|
$locale = localeconv(); |
| 160 |
|
if(!isset($decimals)) $decimals = $locale['frac_digits']; |
| 161 |
|
return number_format($num, $decimals, $locale['decimal_point'], $locale['thousands_sep']); |
| 162 |
|
} |
| 163 |
|
|
| 164 |
|
|
| 165 |
|
// refactor to org.netfrag.glib::php??? |
| 166 |
|
// rename to 'check_amount'? |
| 167 |
|
// move to Data::Validator??? |
| 168 |
|
function is_amount($amount) { |
| 169 |
|
//if( (number_format_locale((string)doubleval($amount)) === number_format_locale((string)$amount)) && number_format_locale((doubleval($amount)) >number_format_locale(0)) ) { |
| 170 |
|
if( ((string)doubleval($amount) === (string)$amount) && (doubleval($amount) > 0) ) { |
| 171 |
|
return 1; |
| 172 |
|
} |
| 173 |
} |
} |
| 174 |
*/ |
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
?> |
?> |