|
@@ 473-488 (lines=16) @@
|
| 470 |
|
* @param array|string $var A string or array of strings to escape |
| 471 |
|
* @return array|string The escaped string or array of escaped strings |
| 472 |
|
*/ |
| 473 |
|
function escapestring__recursive($var) |
| 474 |
|
{ |
| 475 |
|
global $smcFunc; |
| 476 |
|
|
| 477 |
|
if (!is_array($var)) |
| 478 |
|
return $smcFunc['db_escape_string']($var); |
| 479 |
|
|
| 480 |
|
// Reindex the array with slashes. |
| 481 |
|
$new_var = array(); |
| 482 |
|
|
| 483 |
|
// Add slashes to every element, even the indexes! |
| 484 |
|
foreach ($var as $k => $v) |
| 485 |
|
$new_var[$smcFunc['db_escape_string']($k)] = escapestring__recursive($v); |
| 486 |
|
|
| 487 |
|
return $new_var; |
| 488 |
|
} |
| 489 |
|
|
| 490 |
|
/** |
| 491 |
|
* Adds html entities to the array/variable. Uses two underscores to guard against overloading. |
|
@@ 550-565 (lines=16) @@
|
| 547 |
|
* @param array|string $var The string or array of strings to unescape |
| 548 |
|
* @return array|string The unescaped string or array of unescaped strings |
| 549 |
|
*/ |
| 550 |
|
function unescapestring__recursive($var) |
| 551 |
|
{ |
| 552 |
|
global $smcFunc; |
| 553 |
|
|
| 554 |
|
if (!is_array($var)) |
| 555 |
|
return $smcFunc['db_unescape_string']($var); |
| 556 |
|
|
| 557 |
|
// Reindex the array without slashes, this time. |
| 558 |
|
$new_var = array(); |
| 559 |
|
|
| 560 |
|
// Strip the slashes from every element. |
| 561 |
|
foreach ($var as $k => $v) |
| 562 |
|
$new_var[$smcFunc['db_unescape_string']($k)] = unescapestring__recursive($v); |
| 563 |
|
|
| 564 |
|
return $new_var; |
| 565 |
|
} |
| 566 |
|
|
| 567 |
|
/** |
| 568 |
|
* Remove slashes recursively. Uses two underscores to guard against overloading. |