00001 <?php
00002
00003
00004
00005
00006
00007
00011
00012 require_once('fields.php');
00013 require_once('text.php');
00014
00031
00032 function db_query_mysql($link, $q, $kw) {
00033
00034 foreach ($kw as $k => $v) {
00035 $kw[$k] = mysql_escape_string($v);
00036 }
00037
00038 $q = strtr($q, $kw);
00039
00040
00041
00042 ($r = @ mysql_query($q, $link)) or db_error_mysql();
00043
00044 $result = array(); $i = 1;
00045
00046 if (@ mysql_num_rows($r) > 0) {
00047 while ($row = @ mysql_fetch_array($r)) {
00048 $result[$i++] = $row;
00049 }
00050 }
00051
00052 return $result;
00053 }
00061
00062
00063 function link_maybe($text, $url, $condition) {
00064 if ($condition)
00065 print "<a href=\"$url\">$text</a>";
00066 else
00067 print "<strong>$text</strong>";
00068 }
00069
00076
00077 function redirect($url) {
00078 global $text;
00079
00080 $kw = array ('@bodyattr@' => "",
00081 '@notabene@' => "",
00082 '@url@' => "$url",
00083 '@url-de@' => "$url",
00084 '@url-en@' => "$url");
00085
00086 header("Location: " . $url);
00087
00088
00089
00090 print_header($kw);
00091 print strtr($text['redirect'], $kw);
00092 print_footer($kw);
00093 exit(0);
00094 }
00095
00096
00112
00113 function param_ok($allowed, $k, $v) {
00114
00115 $ok = TRUE;
00116
00117 if (!isset($allowed[$k]))
00118 $ok = FALSE;
00119 else if (!preg_match($allowed[$k], $v))
00120 $ok = FALSE;
00121
00122 return $ok;
00123
00124 }
00125
00138
00139 function print_table($table, $cols, $attr, $dblink, $subst) {
00140
00141 print "<table width=\"100%\" " . $attr . " >\n<tr>\n";
00142
00143 $c = 1;
00144
00145
00146
00147
00148 if (empty($table))
00149 return(TRUE);
00150
00151 foreach ($table as $row ) {
00152
00153
00154
00155
00156 if (isset ($row["value"])) {
00157
00158 print "<td width=\"30%\"><strong>" . $row["label"] ;
00159 print "</strong></td>\n" ;
00160 print "<td>" . htmlentities(strtr($row["value"], $subst)) . "</td>";
00161
00162 } else if (isset ($row["query"])) {
00163
00164 $r = db_query_mysql($dblink, $row["query"] , $subst);
00165
00166 if (empty($r)) {
00167 print "<td> </td>\n";
00168 print "<td> </td>\n";
00169 } else {
00170
00171 print "<td width=\"30%\"><strong>";
00172 print $row["label"] . "</strong></td>\n";
00173
00174 print "<td>";
00175
00176 foreach ($r[1] as $k => $v) {
00177 if (is_numeric($k))
00178 print htmlentities($v) . " ";
00179 }
00180
00181 print " </td>\n";
00182 }
00183 } else if (isset($row["fields"])) {
00184 global $fields;
00185
00186
00187
00188 print "<td><strong>" . $row["label"] ;
00189 print "</strong></td>\n" ;
00190
00191
00192
00193 print "<td>";
00194
00195 foreach ($row["fields"] as $f) {
00196
00197
00198 $fk = $f;
00199 $fv = (isset($_SESSION[$fk])) ?
00200 $_SESSION[$fk] : "";
00201
00202 print input_control($f, $fk, $fv );
00203 print " ";
00204 }
00205 print "</td>\n";
00206
00207 } else {
00208 print "<td> </td>\n";
00209 print "<td> </td>\n";
00210 }
00211
00212 if ($c < $cols){
00213 $c++;
00214 } else {
00215 print "</tr>\n<tr>\n";
00216 $c = 1;
00217 }
00218 }
00219
00220 print "</tr></table>";
00221
00222 }
00223
00232
00233 function normalize_input($v) {
00234 $v = preg_replace("/\\s+/", " ", $v);
00235 $v = preg_replace("/^ /", "", $v);
00236 $v = preg_replace("/ $/", "", $v);
00237
00238 $v = strtr($v, 'ÀÁÂÃÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕØÙÚÛÝàáâãåæçèéêëìíîïñòóôõøùúûýÿ',
00239 'AAAAAACEEEEIIIIDNOOOOOUUUYaaaaaaceeeeiiiinooooouuuyy');
00240
00241 return $v;
00242 }
00243
00244 function print_header($kw) {
00245 global $text;
00246
00247 header("Content-Type: text/html; charset=ISO-8859-1");
00248
00249 if (!isset ($_SESSION['in_body']))
00250 print strtr($text['html_header'], $kw);
00251
00252 $_SESSION['in_body'] = TRUE;
00253 }
00254
00255 function print_footer($kw) {
00256
00257 global $text;
00258
00259 if (isset ($_SESSION['in_body']))
00260 print strtr($text['html_footer'], $kw);
00261
00262 unset ($_SESSION['in_body']);
00263 }
00264
00265
00270
00271 function db_error_mysql() {
00272 error_msg( "MYSQL: " . mysql_error() . " [" . mysql_errno() . "]" );
00273 exit(0);
00274 }
00275
00276 function error_msg($msg) {
00277 global $text;
00278
00279 $kw = array ( '@bodyattr@' => "",
00280 '@notabene@' => "",
00281 '@url-de@' => "index.php?lang=de",
00282 '@url-en@' => "index.php?lang=en",
00283 '@msg@' => $msg );
00284
00285 print_header($kw);
00286 print strtr($text['generic_error'],$kw);
00287 print_footer($kw);
00288
00289 exit(0);
00290 }
00291
00292
00293 ?>