root/efio/include/minimambo.php

Revision 1, 4.2 kB (checked in by teiko, 5 years ago)

Added current version of efio

Line 
1 <?php
2
3 define('_CMN_YES','�);
4 define('_CMN_NO','');
5 define('_PN_PAGE','���');
6 define('_PN_OF','');
7 define('_PN_START','[���]');
8 define('_PN_PREVIOUS','[]');
9 define('_PN_NEXT','[]');
10 define('_PN_END','[���');
11 define('_PN_DISPLAY_NR','����� #');
12 define('_PN_RESULTS','����');
13
14 define('_JAN','��');
15 define('_FEB','���');
16 define('_MAR','��);
17 define('_APR','���);
18 define('_MAY','�');
19 define('_JUN','��);
20 define('_JUL','��);
21 define('_AUG','���);
22 define('_SEP','���');
23 define('_OCT','���');
24 define('_NOV','���);
25 define('_DEC','���');
26
27
28 global $config_absolute_path;
29
30 /**
31 * Copy the named array content into the object as properties
32 * only existing properties of object are filled. when undefined in hash, properties wont be deleted
33 * @param array the input array
34 * @param obj byref the object to fill of any class
35 * @param string
36 * @param boolean
37 */
38 function mosBindArrayToObject( $array, &$obj, $prefix=NULL, $checkSlashes=true ) {
39     if (!is_array( $array ) || !is_object( $obj )) {
40         return (false);
41     }
42
43     if ($prefix) {
44         foreach (get_object_vars($obj) as $k => $v) {
45             if (isset($array[$prefix . $k ])) {
46                 $obj->$k = ($checkSlashes && get_magic_quotes_gpc()) ? stripslashes( $array[$k] ) : $array[$k];
47             }
48         }
49     } else {
50         foreach (get_object_vars($obj) as $k => $v) {
51             if (isset($array[$k])) {
52                 $obj->$k = ($checkSlashes && get_magic_quotes_gpc()) ? stripslashes( $array[$k] ) : $array[$k];
53             }
54         }
55     }
56
57     return true;
58 }
59 // ----------------------------------------------------------------------------------   
60
61
62 class mosHTML {
63     function makeOption( $value, $text='' ) {
64         $obj = new stdClass;
65         $obj->value = $value;
66         $obj->text = trim( $text ) ? $text : $value;
67         return $obj;
68     }
69
70     /**
71     * Generates an HTML select list
72     * @param array An array of objects
73     * @param string The value of the HTML name attribute
74     * @param string Additional HTML attributes for the <select> tag
75     * @param string The name of the object variable for the option value
76     * @param string The name of the object variable for the option text
77     * @param mixed The key that is selected
78     * @returns string HTML for the select list
79     */
80     function selectList( &$arr, $tag_name, $tag_attribs, $key, $text, $selected=NULL ) {
81         reset( $arr );
82         $html = "\n<select name=\"$tag_name\" $tag_attribs>";
83         for ($i=0, $n=count( $arr ); $i < $n; $i++ ) {
84             $k = $arr[$i]->$key;
85             $t = $arr[$i]->$text;
86             $id = @$arr[$i]->id;
87
88             $extra = '';
89             $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : '';
90             if (is_array( $selected )) {
91                 foreach ($selected as $obj) {
92                     $k2 = $obj->$key;
93                     if ($k == $k2) {
94                         $extra .= " selected=\"selected\"";
95                         break;
96                     }
97                 }
98             } else {
99                 $extra .= ($k == $selected ? " selected=\"selected\"" : '');
100             }
101             $html .= "\n\t<option value=\"".$k."\"$extra>" . $t . "</option>";
102         }
103         $html .= "\n</select>\n";
104         return $html;
105     }
106
107     function yesnoSelectList( $tag_name, $tag_attribs, $selected, $yes=_CMN_YES, $no=_CMN_NO ) {
108         $arr = array(
109         mosHTML::makeOption( '0', $no ),
110         mosHTML::makeOption( '1', $yes ),
111         );
112
113         return mosHTML::selectList( $arr, $tag_name, $tag_attribs, 'value', 'text', $selected );
114     }
115 }
116
117 function mosRedirect( $url, $msg='' ) {
118     // specific filters
119     $iFilter = new InputFilter();
120     $url = $iFilter->process( $url );
121     $msg = $iFilter->process( $msg );
122
123     if ($iFilter->badAttributeValue( array( 'href', $url ))) {
124         $url = $GLOBALS['mosConfig_live_site'];
125     }
126
127     if (trim( $msg )) {
128          if (strpos( $url, '?' )) {
129             $url .= '&mosmsg=' . urlencode( $msg );
130         } else {
131             $url .= '?mosmsg=' . urlencode( $msg );
132         }
133     }
134
135     if (headers_sent()) {
136         echo "<script>document.location.href='$url';</script>\n";
137     } else {
138         @ob_end_clean(); // clear output buffer
139         header( "Location: $url" );
140     }
141     exit();
142 }
143
144 define( "_MOS_NOTRIM", 0x0001 );
145 define( "_MOS_ALLOWHTML", 0x0002 );
146 function mosGetParam( &$arr, $name, $def=null, $mask=0 ) {
147     $return = null;
148     if (isset( $arr[$name] )) {
149         if (is_string( $arr[$name] )) {
150             if (!($mask&_MOS_NOTRIM)) {
151                 $arr[$name] = trim( $arr[$name] );
152             }
153             if (!($mask&_MOS_ALLOWHTML)) {
154                 $arr[$name] = strip_tags( $arr[$name] );
155             }
156             if (!get_magic_quotes_gpc()) {
157                 $arr[$name] = addslashes( $arr[$name] );
158             }
159         }
160         return $arr[$name];
161     } else {
162         return $def;
163     }
164 }
165
166 ?>
Note: See TracBrowser for help on using the browser.