/[cvs]/nfo/php/libs/org.netfrag.flib/utils/helper.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.flib/utils/helper.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Tue Nov 12 05:42:31 2002 UTC (21 years, 10 months ago) by joko
Branch: MAIN
+ initial checkin

1 <?
2 // -----------------------------------------------------------------------------
3 // $Id: helper.php,v 1.1 2002/10/29 19:15:57 cvsjoko Exp $
4 // -----------------------------------------------------------------------------
5 // $Log: helper.php,v $
6 // Revision 1.1 2002/10/29 19:15:57 cvsjoko
7 // + new checkin
8 //
9 // Revision 1.4 2002/10/26 18:24:54 cvsmax
10 // + add note to care about UTC!
11 //
12 // Revision 1.3 2002/10/25 12:05:30 cvsmax
13 // + bugfix: some db related functions wasn`t updated to new structure, done.
14 // + bugfix: reworked function validate_idle()
15 //
16 // Revision 1.2 2002/10/17 03:37:40 cvsmax
17 // - removed unused function cont_auth()
18 //
19 // Revision 1.1 2002/10/10 02:53:55 cvsmax
20 // + create new partly from old 'func_main.inc'
21 //
22 //
23 // -----------------------------------------------------------------------------
24
25
26 function get_date_forDisplay($arg_date) {
27 $date = new Date($arg_date);
28 // TODO:
29 // - determine this constant by asking $site->user->country, i believe we'll need some kind of mapping here
30 // - or can it be integrated with TimeZone? no, it's a locale setting (localization/preferences), isn't it?
31 return $date->getDate( DATE_FORMAT_GERMAN_SHORT );
32 }
33
34 function get_date_forStorage($arg_date) {
35
36 // was:
37 //$unixtime = mktime(0, 0, 0, $arg_date[1], $arg_date[0], $arg_date[2]);
38 //return date("Y-m-d", $unixtime); // english format
39
40 // if $arg_date is an array, it is in "german"-format (really in locale format, isn't it?)
41 // TODO: check this! (do a generic reverse-map!)
42 if (is_array($arg_date)) {
43 $arg_date = join('.', $arg_date);
44 }
45 $date = new Date($arg_date);
46 $date_res = $date->getDate( DATE_FORMAT_ENGLISH_SHORT );
47 return $date_res;
48 }
49
50 // -------------------------------------------------
51 // sophisticated array init
52 // initializes passed variable (taken by reference) with an empty array
53 // does this only if it doesn't exist yet or initialization is explicitely requested ($clear = 1)
54 function sai(&$var, $clear = 0) {
55 if (!is_array($var) || $clear) { $var = array(); }
56 }
57
58
59 // format functions
60 function isvalidemailaddress($mail) {
61 //return ((($string = trim($string)) != '') && (($atpos = strpos($string, '@' , 1)) > 1) && (($rdotpos = strrpos($string, '.')) > ($atpos + 2)) && (strlen($string) > $rdotpos + 2));
62 if( !eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*"."@([a-z0-9]+([\.-][a-z0-9]+))*$",$mail, $regs) ) {
63 return "format";
64 }
65 elseif( gethostbyname($regs[2]) == $regs[2] ) {
66 return "host";
67 }
68 return "valid";
69 }
70
71 function dumpVar($var) {
72 ob_start();
73 print_r($var);
74 $var_dump = ob_get_contents();
75 ob_end_clean();
76 $var_dump = str_replace("\n", "<br>", $var_dump);
77 $var_dump = str_replace(" ", "&nbsp;", $var_dump);
78 return $var_dump;
79 }
80
81 function session_register_safe($varname) {
82 if (!session_is_registered($varname)) {
83 session_register($varname);
84 return 1;
85 }
86 }
87
88 //------------ getMonths ---------------------
89 // TODO: localize!
90 function getMonthNames() {
91 for ($i=1;$i<=12;$i++) {
92 $utime = strtotime("2001-$i-24 12:00:00");
93 $name = date("F",$utime);
94 $months[$i] = $name;
95 }
96 return $months;
97 }
98
99 function null2nbsp_string($arg) {
100 if ($arg == '') {
101 $arg = '&nbsp;';
102 }
103 return $arg;
104 }
105
106 function null2nbsp_arraywalker(&$item, $key) {
107 $item = null2nbsp_string($item);
108 }
109
110 function null2nbsp($arg) {
111 if (is_array($arg)) {
112 array_walk($arg, 'null2nbsp_arraywalker');
113 $result = $arg;
114 } else {
115 $result = null2nbsp_string($arg);
116 }
117 return $result;
118 }
119
120 //------------ en- and decode Birthdate -----------
121 function getEncodedBirthdate($birthdate) {
122 print "birthday: $birthdate<br>";
123 if($birthdate) {
124 $utime = strtotime($birthdate);
125 print "utime: $utime<br>";
126 $birthday = array ( date("d",$utime), date("m",$utime), date("Y",$utime) );
127 }
128 else {
129 $birthday = array('', '', '1960');
130 }
131 return $birthday;
132 }
133
134 /*
135 function dprint($message) {
136 print '<span style="font-family:Verdana,Helvetica;font-size:7pt;">';
137 print $message;
138 print '</span><br>';
139 }
140 */
141
142 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed