...
|
...
|
@@ -689,77 +689,75 @@ class Yohobuy |
|
|
|
|
|
$interfaceShunt = json_decode($interfaceShunt, true);
|
|
|
|
|
|
$uid = 0;
|
|
|
$mod = 0;
|
|
|
|
|
|
if (isset($param['uid'])) {
|
|
|
$uid = intval($param['uid']);
|
|
|
$mod = $uid % 1024;
|
|
|
if (empty($interfaceShunt['cloud'])) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if ($mod > 128 || $uid === 0) {
|
|
|
|
|
|
$paseUrl = parse_url($url);
|
|
|
|
|
|
if (strpos($url, 'api')) {
|
|
|
|
|
|
if (empty($interfaceShunt['aws']) || empty($interfaceShunt['aws']['api.yoho.cn'])) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
$num = array_rand($interfaceShunt['aws']['api.yoho.cn']);
|
|
|
$uid = isset($param['uid']) ? intval($param['uid']) : 0;
|
|
|
$mod = 0;
|
|
|
$cloud = intval($interfaceShunt['cloud']);
|
|
|
$ips = '';
|
|
|
|
|
|
if (empty($interfaceShunt['aws']['api.yoho.cn'][$num]['ip'])) {
|
|
|
return false;
|
|
|
switch ($cloud) {
|
|
|
case 1:
|
|
|
$ips = $interfaceShunt['aws'];
|
|
|
break;
|
|
|
case 2:
|
|
|
$ips = $interfaceShunt['tencent'];
|
|
|
break;
|
|
|
case 3:
|
|
|
if (empty($uid) || empty($interfaceShunt['strategy']) ||
|
|
|
empty($interfaceShunt['strategy']['model']) ||
|
|
|
empty($interfaceShunt['strategy']['tencentMax'])) {
|
|
|
break;
|
|
|
} else {
|
|
|
$ips = $uid % $interfaceShunt['strategy']['model'] > $interfaceShunt['strategy']['tencentMax'] ?
|
|
|
$interfaceShunt['aws'] : $interfaceShunt['tencent'];
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
$ips = '';
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
$url = 'http://' . $interfaceShunt['aws']['api.yoho.cn'][$num]['ip'] . rtrim($paseUrl['path'], '/') . '/';
|
|
|
|
|
|
} else if (strpos($url, 'service')) {
|
|
|
|
|
|
if (empty($interfaceShunt['aws']) || empty($interfaceShunt['aws']['service.yoho.cn'])) {
|
|
|
return false;
|
|
|
}
|
|
|
//未登录情况下
|
|
|
if (empty($uid) && empty($ips) && !empty($interfaceShunt['strategy'] &&
|
|
|
!empty($interfaceShunt['strategy']['notLogin'])) {
|
|
|
$ips = $interfaceShunt[$interfaceShunt['strategy']['notLogin']];
|
|
|
}
|
|
|
|
|
|
$num = array_rand($interfaceShunt['aws']['service.yoho.cn']);
|
|
|
if (empty($ips)) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (empty($interfaceShunt['aws']['service.yoho.cn'][$num]['ip'])) {
|
|
|
return false;
|
|
|
}
|
|
|
$paseUrl = parse_url($url);
|
|
|
if (strpos($url, 'api')) {
|
|
|
|
|
|
$url = 'http://' . $interfaceShunt['aws']['service.yoho.cn'][$num]['ip'] . rtrim($paseUrl['path'], '/') . '/';
|
|
|
if (empty($ips['api.yoho.cn'])) {
|
|
|
return false;
|
|
|
}
|
|
|
} else {
|
|
|
|
|
|
$paseUrl = parse_url($url);
|
|
|
|
|
|
if (strpos($url, 'api')) {
|
|
|
|
|
|
if (empty($interfaceShunt['tencent']) || empty($interfaceShunt['tencent']['api.yoho.cn'])) {
|
|
|
return false;
|
|
|
}
|
|
|
$num = array_rand($ips['api.yoho.cn']);
|
|
|
|
|
|
$num = array_rand($interfaceShunt['tencent']['api.yoho.cn']);
|
|
|
if (empty($ips['api.yoho.cn'][$num]['ip'])) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (empty($interfaceShunt['tencent']['api.yoho.cn'][$num]['ip'])) {
|
|
|
return false;
|
|
|
}
|
|
|
$url = 'http://' . $ips['api.yoho.cn'][$num]['ip'] . rtrim($paseUrl['path'], '/') . '/';
|
|
|
|
|
|
$url = 'http://' . $interfaceShunt['tencent']['api.yoho.cn'][$num]['ip'] . rtrim($paseUrl['path'], '/') . '/';
|
|
|
} else if (strpos($url, 'service')) {
|
|
|
} else if (strpos($url, 'service')) {
|
|
|
|
|
|
if (empty($interfaceShunt['tencent']) || empty($interfaceShunt['tencent']['service.yoho.cn'])) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
$num = array_rand($interfaceShunt['tencent']['service.yoho.cn']);
|
|
|
if (empty($ips['service.yoho.cn'])) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
if (empty($interfaceShunt['tencent']['service.yoho.cn'][$num]['ip'])) {
|
|
|
return false;
|
|
|
}
|
|
|
$num = array_rand($ips['service.yoho.cn']);
|
|
|
|
|
|
$url = 'http://' . $interfaceShunt['tencent']['service.yoho.cn'][$num]['ip'] . rtrim($paseUrl['path'], '/') . '/';
|
|
|
if (empty($ips['service.yoho.cn'][$num]['ip'])) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
$url = 'http://' . $ips['service.yoho.cn'][$num]['ip'] . rtrim($paseUrl['path'], '/') . '/';
|
|
|
}
|
|
|
|
|
|
return $url;
|
...
|
...
|
|