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