-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud.php
More file actions
232 lines (216 loc) · 7.98 KB
/
Copy pathcloud.php
File metadata and controls
232 lines (216 loc) · 7.98 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<?php
/**
* ECSHOP 云服务接口
* ============================================================================
* 版权所有 2005-2010 上海商派网络科技有限公司,并保留所有权利。
* 网站地址: http://www.ecshop.com;
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
* 使用;不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* $Author: liubo $
* $Id: cloud.php 17063 2011-07-25 06:35:46Z liubo $
*/
define('IN_ECS', true);
require(dirname(__FILE__) . '/includes/init.php');
require(ROOT_PATH . 'includes/cls_transport.php');
require(ROOT_PATH . 'includes/cls_json.php');
require(ROOT_PATH . 'includes/shopex_json.php');
$data['api_ver'] = '1.0';
$data['version'] = VERSION;
$data['patch'] = file_get_contents(ROOT_PATH.ADMIN_PATH."/patch_num");
$data['ecs_lang'] = $_CFG['lang'];
$data['release'] = RELEASE;
$data['charset'] = strtoupper(EC_CHARSET);
$data['certificate_id'] = $_CFG['certificate_id'];
$data['token'] = md5($_CFG['token']);
$data['certi'] = $_CFG['certi'];
$data['php_ver'] = PHP_VERSION;
$data['mysql_ver'] = $db->version();
$data['shop_url'] = urlencode($ecs->url());
$data['admin_url'] = urlencode($ecs->url().ADMIN_PATH);
$data['sess_id'] = $GLOBALS['sess']->get_session_id();
$data['stamp'] = mktime();
$data['ent_id'] = $_CFG['ent_id'];
$data['ent_ac'] = $_CFG['ent_ac'];
$data['ent_sign'] = $_CFG['ent_sign'];
$data['ent_email'] = $_CFG['ent_email'];
$act = !empty($_REQUEST['act']) ? $_REQUEST['act'] : 'index';
$must = array('version','ecs_lang','charset','patch','stamp','api_ver');
if($act =='menu_api')
{
if (!admin_priv('all','',false))
{
make_json_result('0');
}
$api_data = read_static_cache('menu_api');
if($api_data === false || (isset($api_data['api_time']) && $api_data['api_time']<date('Ymd')))
{
$t = new transport;
$apiget = "ver= $data[version] &ecs_lang= $data[ecs_lang] &charset= $data[charset]&ent_id=$data[ent_id]& certificate_id=$data[certificate_id]";
$api_comment = $t->request('http://cloud.ecshop.com/menu_api.php', $apiget);
$api_str = $api_comment["body"];
if (!empty($api_str))
{
$json = new Services_JSON;
$api_arr = @$json->decode($api_str,1);
if (!empty($api_arr) && $api_arr['error'] == 0 && md5($api_arr['content']) == $api_arr['hash'])
{
$api_arr['content'] = urldecode($api_arr['content']);
if ($data['charset'] != 'UTF-8')
{
$api_arr['content'] = ecs_iconv('UTF-8',$data['charset'],$api_arr['content']);
}
$api_arr['api_time'] = date('Ymd');
write_static_cache('menu_api', $api_arr);
make_json_result($api_arr['content']);
}
else
{
make_json_result('0');
}
}
else
{
make_json_result('0');
}
}
else
{
make_json_result($api_data['content']);
}
}
elseif($act == 'cloud_remind')
{
$api_data = read_static_cache('cloud_remind');
if($api_data === false || (isset($api_data['api_time']) && $api_data['api_time']<date('Ymd')) )
{
$t = new transport('-1',5);
$apiget = "ver=$data[version]&ecs_lang=$data[ecs_lang]&charset=$data[charset]&certificate_id=$data[certificate_id]&ent_id=$data[ent_id]";
$api_comment = $t->request('http://cloud.ecshop.com/cloud_remind.php', $apiget);
$api_str= $api_comment["body"];
$json = new Services_JSON;
$api_arr = @$json->decode($api_str,1);
if(!empty($api_str))
{
if (!empty($api_arr) && $api_arr['error'] == 0 && md5($api_arr['content']) == $api_arr['hash'])
{
$api_arr['content'] = urldecode($api_arr['content']);
$message =explode('|',$api_arr['content']);
$api_arr['content']='<li class="cloud_close">'.$message['0'].'<img onclick="cloud_close('.$message['1'].')" src="images/no.gif"></li>';
if ($data['charset'] != 'UTF-8')
{
$api_arr['content'] = ecs_iconv('UTF-8',$data['charset'],$api_arr['content']);
}
$api_arr['api_time'] = date('Ymd');
write_static_cache('cloud_remind', $api_arr);
make_json_result($api_arr['content']);
}
else
{
make_json_result('0');
}
}
else
{
make_json_result('0');
}
}
else
{
make_json_result($api_data['content']);
}
}
elseif($act == 'close_remind')
{
$remind_id=$_REQUEST['remind_id'];
$t = new transport('-1',5);
$apiget = "ver= $data[version] &ecs_lang= $data[ecs_lang] &charset= $data[charset] &certificate_id=$data[certificate_id]&ent_id=$data[ent_id]&remind_id=$remind_id";
$api_comment = $t->request('http://cloud.ecshop.com/cloud_remind.php', $apiget);
$api_str = $api_comment["body"];
$json = new Services_JSON;
$api_arr = array();
$api_arr = @$json->decode($api_str,1);
if(!empty($api_str))
{
if (!empty($api_arr) && $api_arr['error'] == 0 && md5($api_arr['content']) == $api_arr['hash'])
{
$api_arr['content'] = urldecode($api_arr['content']);
if($data['charset'] != 'UTF-8')
{
$api_arr['content'] = ecs_iconv('UTF-8',$data['charset'],$api_arr['content']);
}
if (admin_priv('all','',false))
{
$apiget.="&act=close_remind&ent_ac=$data[ent_ac]";
$result=$t->request('http://cloud.ecshop.com/cloud_remind.php', $apiget);
$api_str = $result["body"];
//var_dump($api_str);
$api_arr = array();
$api_arr = @$json->decode($api_str,1);
$api_arr['content'] = urldecode($api_arr['content']);
if ($data['charset'] != 'UTF-8')
{
$api_arr['content'] = ecs_iconv('UTF-8',$data['charset'],$api_arr['content']);
}
if($api_arr['error'] == 1)
{
$message =explode('|',$api_arr['content']);
$api_arr['content']='<li class="cloud_close">'.$message['0'].' '.$message['2'].'</li>';
make_json_result($api_arr['content']);
}
else
{
clear_all_files();
make_json_result('0');
}
}
else
{
$message =explode('|',$api_arr['content']);
$api_arr['content']='<li class="cloud_close">'.$message['0'].' '.$_LANG['cloud_no_priv'].'<img onclick="cloud_close( '.$message['1'].')" src="images/no.gif"></li>';
make_json_result($api_arr['content']);
}
}
else
{
make_json_result('0');
}
}
}
else
{
admin_priv('all');
if (empty($_GET['act']))
{
$act = 'index';
}
else
{
$query = '';
$act = trim($_GET['act']);
foreach ($_GET as $k=>$v)
{
if (array_key_exists($k, $data))
{
$query .= '&'.$k.'='.$data[$k];
}
}
}
if (!empty($_GET['link']))
{
$url = parse_url($_GET['link']);
if (!empty($url['host']))
{
ecs_header("Location: ".$url['scheme']."://".$url['host'].$url['path']."?".$url['query'].$query."\n");
exit();
}
}
foreach ($must as $v)
{
$query .= '&'.$v.'='.$data[$v];
}
ecs_header("Location: http://cloud.ecshop.com/api.php?act=".$act.$query."\n");
exit();
}
?>