1416 } |
1416 } |
1417 $_POST = strip_nul_chars($_POST); |
1417 $_POST = strip_nul_chars($_POST); |
1418 $_GET = strip_nul_chars($_GET); |
1418 $_GET = strip_nul_chars($_GET); |
1419 $_COOKIE = strip_nul_chars($_COOKIE); |
1419 $_COOKIE = strip_nul_chars($_COOKIE); |
1420 $_REQUEST = strip_nul_chars($_REQUEST); |
1420 $_REQUEST = strip_nul_chars($_REQUEST); |
|
1421 $_POST = decode_unicode_array($_POST); |
|
1422 $_GET = decode_unicode_array($_GET); |
|
1423 $_COOKIE = decode_unicode_array($_COOKIE); |
|
1424 $_REQUEST = decode_unicode_array($_REQUEST); |
1421 } |
1425 } |
1422 |
1426 |
1423 /** |
1427 /** |
1424 * A very basic single-character compression algorithm for binary strings/bitfields |
1428 * A very basic single-character compression algorithm for binary strings/bitfields |
1425 * @param string $bits the text to compress, should be only 1s and 0s |
1429 * @param string $bits the text to compress, should be only 1s and 0s |
2576 } |
2580 } |
2577 } |
2581 } |
2578 return $haystack; |
2582 return $haystack; |
2579 } |
2583 } |
2580 |
2584 |
|
2585 /** |
|
2586 * From http://us2.php.net/urldecode - decode %uXXXX |
|
2587 * @param string The urlencoded string |
|
2588 * @return string |
|
2589 */ |
|
2590 |
|
2591 function decode_unicode_url($str) |
|
2592 { |
|
2593 $res = ''; |
|
2594 |
|
2595 $i = 0; |
|
2596 $max = strlen($str) - 6; |
|
2597 while ($i <= $max) |
|
2598 { |
|
2599 $character = $str[$i]; |
|
2600 if ($character == '%' && $str[$i + 1] == 'u') |
|
2601 { |
|
2602 $value = hexdec(substr($str, $i + 2, 4)); |
|
2603 $i += 6; |
|
2604 |
|
2605 if ($value < 0x0080) |
|
2606 { |
|
2607 // 1 byte: 0xxxxxxx |
|
2608 $character = chr($value); |
|
2609 } |
|
2610 else if ($value < 0x0800) |
|
2611 { |
|
2612 // 2 bytes: 110xxxxx 10xxxxxx |
|
2613 $character = |
|
2614 chr((($value & 0x07c0) >> 6) | 0xc0) |
|
2615 . chr(($value & 0x3f) | 0x80); |
|
2616 } |
|
2617 else |
|
2618 { |
|
2619 // 3 bytes: 1110xxxx 10xxxxxx 10xxxxxx |
|
2620 $character = |
|
2621 chr((($value & 0xf000) >> 12) | 0xe0) |
|
2622 . chr((($value & 0x0fc0) >> 6) | 0x80) |
|
2623 . chr(($value & 0x3f) | 0x80); |
|
2624 } |
|
2625 } |
|
2626 else |
|
2627 { |
|
2628 $i++; |
|
2629 } |
|
2630 |
|
2631 $res .= $character; |
|
2632 } |
|
2633 |
|
2634 return $res . substr($str, $i); |
|
2635 } |
|
2636 |
|
2637 /** |
|
2638 * Recursively decodes an array with UTF-8 characters in its strings |
|
2639 * @param array Can be multi-depth |
|
2640 * @return array |
|
2641 */ |
|
2642 |
|
2643 function decode_unicode_array($array) |
|
2644 { |
|
2645 foreach ( $array as $i => $val ) |
|
2646 { |
|
2647 if ( is_string($val) ) |
|
2648 { |
|
2649 $array[$i] = decode_unicode_url($val); |
|
2650 } |
|
2651 else |
|
2652 { |
|
2653 $array[$i] = decode_unicode_array($val); |
|
2654 } |
|
2655 } |
|
2656 return $array; |
|
2657 } |
|
2658 |
2581 //die('<pre>Original: 01010101010100101010100101010101011010'."\nProcessed: ".uncompress_bitfield(compress_bitfield('01010101010100101010100101010101011010')).'</pre>'); |
2659 //die('<pre>Original: 01010101010100101010100101010101011010'."\nProcessed: ".uncompress_bitfield(compress_bitfield('01010101010100101010100101010101011010')).'</pre>'); |
2582 |
2660 |
2583 ?> |
2661 ?> |