人人商城

compat.func.php 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. if (!function_exists('json_encode')) {
  8. function json_encode($value) {
  9. static $jsonobj;
  10. if (!isset($jsonobj)) {
  11. include_once (IA_ROOT . '/framework/library/json/JSON.php');
  12. $jsonobj = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
  13. }
  14. return $jsonobj->encode($value);
  15. }
  16. }
  17. if (!function_exists('json_decode')) {
  18. function json_decode($jsonString) {
  19. static $jsonobj;
  20. if (!isset($jsonobj)) {
  21. include_once (IA_ROOT . '/framework/library/json/JSON.php');
  22. $jsonobj = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
  23. }
  24. return $jsonobj->decode($jsonString);
  25. }
  26. }
  27. if (!function_exists('http_build_query')) {
  28. function http_build_query($formdata, $numeric_prefix = null, $arg_separator = null) {
  29. if (!is_array($formdata))
  30. return false;
  31. if ($arg_separator == null)
  32. $arg_separator = '&';
  33. return http_build_recursive($formdata, $arg_separator);
  34. }
  35. function http_build_recursive($formdata, $separator, $key = '', $prefix = '') {
  36. $rlt = '';
  37. foreach ($formdata as $k => $v) {
  38. if (is_array($v)) {
  39. if ($key)
  40. $rlt .= http_build_recursive($v, $separator, $key . '[' . $k . ']', $prefix);
  41. else
  42. $rlt .= http_build_recursive($v, $separator, $k, $prefix);
  43. } else {
  44. if ($key)
  45. $rlt .= $prefix . $key . '[' . urlencode($k) . ']=' . urldecode($v) . '&';
  46. else
  47. $rlt .= $prefix . urldecode($k) . '=' . urldecode($v) . '&';
  48. }
  49. }
  50. return $rlt;
  51. }
  52. }
  53. if (!function_exists('file_put_contents')) {
  54. function file_put_contents($file, $string) {
  55. $fp = @fopen($file, 'w') or exit("Can not open $file");
  56. flock($fp, LOCK_EX);
  57. $stringlen = @fwrite($fp, $string);
  58. flock($fp, LOCK_UN);
  59. @fclose($fp);
  60. return $stringlen;
  61. }
  62. }
  63. if (!function_exists('getimagesizefromstring')) {
  64. function getimagesizefromstring($string_data) {
  65. $uri = 'data://application/octet-stream;base64,' . base64_encode($string_data);
  66. return getimagesize($uri);
  67. }
  68. }
  69. if (!defined('JSON_UNESCAPED_UNICODE')) {
  70. define('JSON_UNESCAPED_UNICODE', 256);
  71. }
  72. if (!function_exists('hex2bin')) {
  73. function hex2bin($str) {
  74. $sbin = '';
  75. $len = strlen($str);
  76. for ($i = 0; $i < $len; $i += 2) {
  77. $sbin .= pack("H*", substr($str, $i, 2));
  78. }
  79. return $sbin;
  80. }
  81. }
  82. if (!function_exists('mb_strlen')) {
  83. function mb_strlen($string, $charset = '') {
  84. return istrlen($string, $charset);
  85. }
  86. }
  87. if (!interface_exists('SessionHandlerInterface')) {
  88. interface SessionHandlerInterface {}
  89. }
  90. if (!function_exists("fastcgi_finish_request")) {
  91. function fastcgi_finish_request() {
  92. return error(-1, 'Not npm or fast cgi');
  93. }
  94. }