| 416 | | |
| 417 | | |
| 418 | | // ---------------------------------------------- |
| 419 | | // Utility and compatibility functions |
| 420 | | // ---------------------------------------------- |
| 421 | | |
| 422 | | /** |
| 423 | | * Calculate page generation time. |
| 424 | | */ |
| 425 | | function getmicrotime() { |
| 426 | | list($usec, $sec) = explode(" ", microtime()); |
| 427 | | return ((float)$usec + (float)$sec); |
| 428 | | } |
| 429 | | |
| 430 | | if (!function_exists('mysql_real_escape_string')) |
| 431 | | { |
| 432 | | /** |
| 433 | | * Escape special characters in a string for use in a SQL statement. |
| 434 | | * |
| 435 | | * This function is added for back-compatibility with MySQL 3.23. |
| 436 | | * @param string $string the string to be escaped |
| 437 | | * @return string a string with special characters escaped |
| 438 | | */ |
| 439 | | function mysql_real_escape_string($string) |
| 440 | | { |
| 441 | | return mysql_escape_string($string); |
| 442 | | } |
| 443 | | } |
| 444 | | |
| 445 | | /** |
| 446 | | * Workaround for the amazingly annoying magic quotes. |
| 447 | | */ |
| 448 | | function magicQuotesWorkaround(&$a) |
| 449 | | { |
| 450 | | if (is_array($a)) |
| 451 | | { |
| 452 | | foreach ($a as $k => $v) |
| 453 | | { |
| 454 | | if (is_array($v)) |
| 455 | | magicQuotesWorkaround($a[$k]); |
| 456 | | else |
| 457 | | $a[$k] = stripslashes($v); |
| 458 | | } |
| 459 | | } |
| 460 | | } |
| 461 | | |