| | 398 | /* ---------------------- */ |
|---|
| | 399 | /** Fonctions necessaires au nouveau bureau */ |
|---|
| | 400 | |
|---|
| | 401 | function getFields($fields, $requestOnly = false) |
|---|
| | 402 | { |
|---|
| | 403 | $vars = array(); |
|---|
| | 404 | $methodType = array ("get", "post", "request", "files"); |
|---|
| | 405 | |
|---|
| | 406 | foreach ($fields AS $name => $options) |
|---|
| | 407 | { |
|---|
| | 408 | if (in_array($options[0], $methodType) === false) |
|---|
| | 409 | die ("Illegal method type used for field " . $name . " : " . $options[0]); |
|---|
| | 410 | |
|---|
| | 411 | if ($requestOnly === true) |
|---|
| | 412 | $method = "_REQUEST"; |
|---|
| | 413 | else |
|---|
| | 414 | $method = "_" . strtoupper($options[0]); |
|---|
| | 415 | |
|---|
| | 416 | switch ($options[1]) |
|---|
| | 417 | { |
|---|
| | 418 | case "integer": |
|---|
| | 419 | |
|---|
| | 420 | $vars[$name] = (isset($GLOBALS[$method][$name]) && is_numeric($GLOBALS[$method][$name]) ? intval($GLOBALS[$method][$name]) : $options[2]); |
|---|
| | 421 | break; |
|---|
| | 422 | |
|---|
| | 423 | case "float": |
|---|
| | 424 | |
|---|
| | 425 | $vars[$name] = (isset($GLOBALS[$method][$name]) && is_numeric($GLOBALS[$method][$name]) ? floatval($GLOBALS[$method][$name]) : $options[2]); |
|---|
| | 426 | break; |
|---|
| | 427 | |
|---|
| | 428 | case "string": |
|---|
| | 429 | |
|---|
| | 430 | $vars[$name] = (isset($GLOBALS[$method][$name]) ? trim($GLOBALS[$method][$name]) : $options[2]); |
|---|
| | 431 | break; |
|---|
| | 432 | |
|---|
| | 433 | case "array": |
|---|
| | 434 | |
|---|
| | 435 | $vars[$name] = (isset($GLOBALS[$method][$name]) && is_array($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]); |
|---|
| | 436 | break; |
|---|
| | 437 | |
|---|
| | 438 | case "boolean": |
|---|
| | 439 | |
|---|
| | 440 | $vars[$name] = (isset($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]); |
|---|
| | 441 | break; |
|---|
| | 442 | |
|---|
| | 443 | case "file": |
|---|
| | 444 | |
|---|
| | 445 | $vars[$name] = (isset($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]); |
|---|
| | 446 | break; |
|---|
| | 447 | |
|---|
| | 448 | default: |
|---|
| | 449 | die ("Illegal method type used for field " . $name . " : " . $options[1]); |
|---|
| | 450 | } |
|---|
| | 451 | } |
|---|
| | 452 | |
|---|
| | 453 | // Insert into $GLOBALS |
|---|
| | 454 | foreach ($vars AS $var => $value) |
|---|
| | 455 | $GLOBALS[$var] = $value; |
|---|
| | 456 | |
|---|
| | 457 | return $vars; |
|---|
| | 458 | } |
|---|
| | 459 | |
|---|
| | 460 | function printVar($array) |
|---|
| | 461 | { |
|---|
| | 462 | echo "<pre style=\"border: 1px solid black; text-align: left; font-size: 9px\">\n"; |
|---|
| | 463 | print_r($array); |
|---|
| | 464 | echo "</pre>\n"; |
|---|
| | 465 | } |
|---|
| | 466 | |
|---|
| | 467 | function startBox($boxClass) |
|---|
| | 468 | { |
|---|
| | 469 | echo "<table class=\"" . $boxClass . "\">"; |
|---|
| | 470 | echo "<tr>"; |
|---|
| | 471 | echo "<td class=\"boxTopLeft\"></td>"; |
|---|
| | 472 | echo "<td class=\"boxTop\"></td>"; |
|---|
| | 473 | echo "<td class=\"boxTopRight\"></td>"; |
|---|
| | 474 | echo "</tr>"; |
|---|
| | 475 | echo "<tr>"; |
|---|
| | 476 | echo "<td class=\"boxLeft\"></td>"; |
|---|
| | 477 | echo "<td class=\"boxContent\">"; |
|---|
| | 478 | } |
|---|
| | 479 | |
|---|
| | 480 | function endBox() |
|---|
| | 481 | { |
|---|
| | 482 | echo "</td>"; |
|---|
| | 483 | echo "<td class=\"boxRight\"></td>"; |
|---|
| | 484 | echo "</tr>"; |
|---|
| | 485 | echo "<tr>"; |
|---|
| | 486 | echo "<td class=\"boxBottomLeft\"></td>"; |
|---|
| | 487 | echo "<td class=\"boxBottom\"></td>"; |
|---|
| | 488 | echo "<td class=\"boxBottomRight\"></td>"; |
|---|
| | 489 | echo "</tr>"; |
|---|
| | 490 | echo "</table>"; |
|---|
| | 491 | } |
|---|
| | 492 | |
|---|
| | 493 | function microtimeFloat() |
|---|
| | 494 | { |
|---|
| | 495 | return array_sum(explode(" ", microtime())); |
|---|
| | 496 | } |
|---|
| | 497 | |
|---|