初始化
89
api/360bz/index.php
Normal file
@@ -0,0 +1,89 @@
|
||||
|
||||
<?php
|
||||
require ('../../need.php');//引用封装好的函数文件
|
||||
$n = @$_REQUEST["n"];
|
||||
$p = @$_REQUEST["p"];
|
||||
$type = @$_REQUEST["type"];
|
||||
if($n == '1'){
|
||||
$form = '36';
|
||||
}else
|
||||
if($n == '2'){
|
||||
$form = '6';
|
||||
}else
|
||||
if($n == '3'){
|
||||
$form = '30';
|
||||
}else
|
||||
if($n == '4'){
|
||||
$form = '9';
|
||||
}else
|
||||
if($n == '1'){
|
||||
$form = '36';
|
||||
}else
|
||||
if($n == '5'){
|
||||
$form = '15';
|
||||
}else
|
||||
if($n == '6'){
|
||||
$form = '26';
|
||||
}else
|
||||
if($n == '7'){
|
||||
$form = '11';
|
||||
}else
|
||||
if($n == '8'){
|
||||
$form = '14';
|
||||
}else
|
||||
if($n == '9'){
|
||||
$form = '5';
|
||||
}else
|
||||
if($n == '10'){
|
||||
$form = '12';
|
||||
}else
|
||||
if($n == '11'){
|
||||
$form = '10';
|
||||
}else
|
||||
if($n == '12'){
|
||||
$form = '22';
|
||||
}else
|
||||
if($n == '13'){
|
||||
$form = '16';
|
||||
}else
|
||||
if($n == '14'){
|
||||
$form = '32';
|
||||
}else
|
||||
if($n == '15'){
|
||||
$form = '35';
|
||||
}else
|
||||
if($n == '16'){
|
||||
$form = '1';
|
||||
}else{
|
||||
$form = '26';
|
||||
}
|
||||
// echo 'http://wallpaper.apc.360.cn/index.php?c=WallPaper&a=getAppsByCategory&cid='.$form.'&start='.$p.'&count=200&from=360chrome';exit;
|
||||
$p = mt_rand(1,10);
|
||||
$data = need::teacher_curl('http://wallpaper.apc.360.cn/index.php?c=WallPaper&a=getAppsByCategory&cid='.$form.'&start='.$p.'&count=200&from=360chrome',[
|
||||
'refer'=>' '
|
||||
]);
|
||||
//$JSON = JSON_decode($data
|
||||
$num = preg_match_all('/"url":"(.*?)"/',$data,$date);
|
||||
if(!$num){
|
||||
if($type == 'text'){
|
||||
exit('获取失败请重试');
|
||||
}else{
|
||||
exit(need::json(array('code'=>-1,'text'=>'获取失败请重试')));
|
||||
}
|
||||
}
|
||||
$rand = mt_rand(0,$num-1);
|
||||
$image = str_replace(['\\', 'http:'], ['', 'https:'], $date[1][$rand]);
|
||||
/*
|
||||
if(!stristr($image, 'ssl')){
|
||||
$image = str_replace(['http://', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'], ['https://', 'p1.ssl', 'p2.ssl', 'p3.ssl', 'p4.ssl', 'p5.ssl', 'p6.ssl', 'p7.ssl', 'p8.ssl', 'p9.ssl'], $image);
|
||||
}
|
||||
*/
|
||||
if($type == 'text'){
|
||||
exit($image);
|
||||
}else
|
||||
if($type == 'image'){
|
||||
//$data = file_get_Contents($image);
|
||||
need::send($image, 'location');
|
||||
}else{
|
||||
exit(need::json(array('code'=>1,'text'=>$image)));
|
||||
}
|
||||
1
api/60s/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
10
|
||||
46
api/60s/index.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat", "w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
|
||||
// 设置响应头为JSON格式
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
// 定义要获取的API地址
|
||||
$api_url = 'https://60s.viki.moe/v2/60s';
|
||||
|
||||
// 初始化cURL会话
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $api_url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过SSL证书验证(仅用于测试)
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30); // 设置超时时间
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // 跟随重定向
|
||||
|
||||
// 执行请求并获取响应
|
||||
$response = curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
|
||||
// 关闭cURL资源
|
||||
curl_close($ch);
|
||||
|
||||
// 处理响应
|
||||
if ($http_code === 200 && !empty($response)) {
|
||||
// 直接返回获取到的内容
|
||||
echo $response;
|
||||
} else {
|
||||
// 返回错误信息
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'message' => '获取接口内容失败',
|
||||
'http_code' => $http_code,
|
||||
'curl_error' => $error ?: '无错误信息'
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
||||
1
api/bing/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
4
|
||||
27
api/bing/index.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
|
||||
header('Access-Control-Allow-Origin:*');
|
||||
$str = file_get_contents('http://cn.bing.com/HPImageArchive.aspx?idx=0&n=1');
|
||||
if ($str === false) {
|
||||
exit('Failed to retrieve data from Bing');
|
||||
}
|
||||
$xml = simplexml_load_string($str);
|
||||
if ($xml && isset($xml->image->url)) {
|
||||
$imgurl = 'http://cn.bing.com' . $xml->image->url;
|
||||
}
|
||||
if(isset($imgurl) && $imgurl){
|
||||
header('Content-Type: image/JPEG');
|
||||
ob_end_clean();
|
||||
readfile($imgurl);
|
||||
flush(); ob_flush();
|
||||
exit();
|
||||
}else{
|
||||
exit('error');
|
||||
}
|
||||
?>
|
||||
1
api/douyin/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
4
|
||||
162
api/douyin/index.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
*@Author: JH-Ahua
|
||||
* @CreateTime: 2025/8/5 下午2:13
|
||||
*@email: admin@bugpk.com
|
||||
*@blog: www.jiuhunwl.cn
|
||||
*@Api: api.bugpk.com
|
||||
*@tip: 抖音视频图集去水印解析
|
||||
*/
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header('Content-type: application/json');
|
||||
function douyin($url)
|
||||
{
|
||||
|
||||
// 构造请求数据
|
||||
$header = array('User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1 Edg/122.0.0.0');
|
||||
// 尝试从 URL 中获取视频 ID
|
||||
$id = extractId($url);
|
||||
// 检查 ID 是否有效
|
||||
if (empty($id)) {
|
||||
return array('code' => 400, 'msg' => '无法解析视频 ID');
|
||||
}
|
||||
|
||||
// 发送请求获取视频信息
|
||||
$response = curl('https://www.iesdouyin.com/share/video/' . $id, $header);
|
||||
$pattern = '/window\._ROUTER_DATA\s*=\s*(.*?)\<\/script>/s';
|
||||
preg_match($pattern, $response, $matches);
|
||||
|
||||
if (empty($matches[1])) {
|
||||
return array('code' => 201, 'msg' => '解析数据失败' . $response);
|
||||
}
|
||||
|
||||
$videoInfo = json_decode(trim($matches[1]), true);
|
||||
if (!isset($videoInfo['loaderData'])) {
|
||||
return array('code' => 201, 'msg' => '数据查找失败' . $response);
|
||||
}
|
||||
//替换 "playwm" 为 "play"
|
||||
$videoResUrl = str_replace('playwm', 'play', $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['video']['play_addr']['url_list'][0]);
|
||||
|
||||
$imgurljson = $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['images'];
|
||||
$imgurl = [];
|
||||
if (is_array($imgurljson) && isset($imgurljson[0])) {
|
||||
// 遍历 JSON 数组
|
||||
foreach ($imgurljson as $item) {
|
||||
// 检查当前元素是否包含 url_list 标签
|
||||
if (isset($item['url_list']) && is_array($item['url_list']) && count($item['url_list']) > 0) {
|
||||
// 将 url_list 的第一个值添加到 $imgurl 数组中
|
||||
$imgurl[] = $item['url_list'][0];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['music'])) {
|
||||
$music = array(
|
||||
'title' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['music']['title'],
|
||||
'author' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['music']['author'],
|
||||
'avatar' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['music']['cover_large']['url_list'][0],
|
||||
'url' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['video']['play_addr']['uri'],
|
||||
);
|
||||
}
|
||||
if (empty($videoResUrl) && empty($imgurl)) {
|
||||
$arr = array(
|
||||
'code' => 404,
|
||||
'msg' => '当前分享链接已失效!',
|
||||
'data' => [],
|
||||
);
|
||||
} else {
|
||||
// 构造返回数据
|
||||
$arr = array(
|
||||
'code' => 200,
|
||||
'msg' => '解析成功',
|
||||
'data' => array(
|
||||
'author' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['author']['nickname'],
|
||||
'uid' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['author']['unique_id'],
|
||||
'avatar' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['author']['avatar_medium']['url_list'][0],
|
||||
'like' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['statistics']['digg_count'],
|
||||
'time' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]["create_time"],
|
||||
'title' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['desc'],
|
||||
'cover' => $videoInfo['loaderData']['video_(id)/page']['videoInfoRes']['item_list'][0]['video']['cover']['url_list'][0],
|
||||
'images' => !empty($imgurl) ? $imgurl : '当前为短视频解析模式',
|
||||
'url' => count($imgurl) > 0 ? '当前为图文解析,图文数量为:' . count($imgurl) . '张图片' : $videoResUrl,
|
||||
'music' => $music ?? '音乐为视频原声',
|
||||
)
|
||||
);
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
function extractId($url)
|
||||
{
|
||||
$headers = get_headers($url, true);
|
||||
if ($headers === false) {
|
||||
// 如果获取头信息失败,直接使用原始 URL
|
||||
$loc = $url;
|
||||
} else {
|
||||
// 处理重定向头可能是数组的情况
|
||||
if (isset($headers['Location']) && is_array($headers['Location'])) {
|
||||
$loc = end($headers['Location']);
|
||||
} else {
|
||||
$loc = $headers['Location'] ?? $url;
|
||||
}
|
||||
}
|
||||
|
||||
// 确保 $loc 是字符串
|
||||
if (!is_string($loc)) {
|
||||
$loc = strval($loc);
|
||||
}
|
||||
|
||||
preg_match('/[0-9]+|(?<=video\/)[0-9]+/', $loc, $id);
|
||||
return !empty($id) ? $id[0] : null;
|
||||
}
|
||||
|
||||
|
||||
function curl($url, $header = null, $data = null)
|
||||
{
|
||||
$con = curl_init((string)$url);
|
||||
curl_setopt($con, CURLOPT_HEADER, false);
|
||||
curl_setopt($con, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($con, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($con, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($con, CURLOPT_AUTOREFERER, 1);
|
||||
if (isset($header)) {
|
||||
curl_setopt($con, CURLOPT_HTTPHEADER, $header);
|
||||
}
|
||||
if (isset($data)) {
|
||||
curl_setopt($con, CURLOPT_POST, true);
|
||||
curl_setopt($con, CURLOPT_POSTFIELDS, $data);
|
||||
}
|
||||
curl_setopt($con, CURLOPT_TIMEOUT, 5000);
|
||||
$result = curl_exec($con);
|
||||
if ($result === false) {
|
||||
// 处理 curl 错误
|
||||
$error = curl_error($con);
|
||||
curl_close($con);
|
||||
trigger_error("cURL error: $error", E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
curl_close($con);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
// 使用空合并运算符检查 url 参数
|
||||
$url = $_GET['url'] ?? '';
|
||||
if (empty($url)) {
|
||||
echo json_encode(['code' => 201, 'msg' => 'url为空'], 480);
|
||||
} else {
|
||||
$response = douyin($url);
|
||||
if (empty($response)) {
|
||||
echo json_encode(['code' => 404, 'msg' => '获取失败'], 480);
|
||||
} else {
|
||||
echo json_encode($response, 480);
|
||||
}
|
||||
}
|
||||
?>
|
||||
1
api/dwzrec/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
54
api/dwzrec/index.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
header('Access-Control-Allow-Origin:*');
|
||||
header('Content-type:application/json; charset=utf-8');
|
||||
!empty($_GET['url']) ? $api = $_GET['url'] : exit(json_encode([
|
||||
'code'=>202,
|
||||
"msg"=>"网址不能为空"
|
||||
],JSON_UNESCAPED_UNICODE));
|
||||
/*
|
||||
* 请求
|
||||
*/
|
||||
$json = myCurl($api);
|
||||
/*
|
||||
* 判断
|
||||
*/
|
||||
if($json){
|
||||
echo json_encode(array('code'=>200,'dwz'=>$api,'rec'=>$json),JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
echo json_encode(array('code'=>201,'msg'=>'短网址还原失败'),JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
/***
|
||||
* 万能短网址还原函数
|
||||
* @param $url 短网址
|
||||
* @return 原始网址 | 空(还原失败或非短网址)
|
||||
*/
|
||||
function myCurl($url) {
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0');
|
||||
curl_setopt($curl, CURLOPT_HEADER, true);
|
||||
curl_setopt($curl, CURLOPT_NOBODY, false);
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
|
||||
$data = curl_exec($curl);
|
||||
$curlInfo = curl_getinfo($curl);
|
||||
curl_close($curl);
|
||||
if($curlInfo['http_code'] == 301 || $curlInfo['http_code'] == 302) {
|
||||
return $curlInfo['redirect_url'];
|
||||
}
|
||||
return '';
|
||||
}
|
||||
1
api/favicon/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
3
|
||||
74
api/favicon/index.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
|
||||
header('Content-Type: image/x-icon');
|
||||
|
||||
if (!isset($_GET['url'])) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
exit('URL parameter is required');
|
||||
}
|
||||
|
||||
$url = $_GET['url'];
|
||||
|
||||
// 自动补全协议前缀
|
||||
if (!preg_match('/^https?:\/\//i', $url)) {
|
||||
$url = 'https://' . $url;
|
||||
}
|
||||
|
||||
if (!filter_var($url, FILTER_VALIDATE_URL)) {
|
||||
header('HTTP/1.1 400 Bad Request');
|
||||
exit('Invalid URL format');
|
||||
}
|
||||
|
||||
$domain = parse_url($url, PHP_URL_HOST);
|
||||
$scheme = parse_url($url, PHP_URL_SCHEME);
|
||||
$faviconUrl = $scheme . '://' . $domain . '/favicon.ico';
|
||||
|
||||
// 尝试获取favicon,最多重试3次
|
||||
$maxRetries = 3;
|
||||
$retryCount = 0;
|
||||
$data = null;
|
||||
$httpCode = 0;
|
||||
|
||||
do {
|
||||
$ch = curl_init($faviconUrl);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
// 根据协议设置SSL验证
|
||||
if (parse_url($faviconUrl, PHP_URL_SCHEME) === 'https') {
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 5); // 5秒超时
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); // 3秒连接超时
|
||||
|
||||
$data = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
curl_close($ch);
|
||||
|
||||
$retryCount++;
|
||||
|
||||
if ($httpCode === 200 && !empty($data)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if ($retryCount < $maxRetries) {
|
||||
sleep(1); // 等待1秒后重试
|
||||
}
|
||||
} while ($retryCount < $maxRetries);
|
||||
|
||||
if ($httpCode === 200 && !empty($data)) {
|
||||
echo $data;
|
||||
} else {
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
exit('Favicon not found: ' . ($error ?? 'Unknown error'));
|
||||
}
|
||||
?>
|
||||
1
api/ip/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
7
|
||||
129
api/ip/index.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
?>
|
||||
<?php
|
||||
// IP Geolocation API
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
// Get IP from URL parameter or use visitor's IP
|
||||
$ip = $_GET['ip'] ?? $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
// Validate IP address
|
||||
if (!filter_var($ip, FILTER_VALIDATE_IP)) {
|
||||
http_response_code(400);
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'code' => 400,
|
||||
'message' => 'Invalid IP address',
|
||||
'ip' => $ip
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Try multiple IP geolocation services for better reliability
|
||||
$result = null;
|
||||
$error = null;
|
||||
|
||||
// Method 1: Use ip.sb API
|
||||
$url1 = "https://api.ip.sb/geoip/" . urlencode($ip);
|
||||
$ch1 = curl_init();
|
||||
curl_setopt($ch1, CURLOPT_URL, $url1);
|
||||
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch1, CURLOPT_TIMEOUT, 5);
|
||||
curl_setopt($ch1, CURLOPT_USERAGENT, 'Mozilla/5.0');
|
||||
$response1 = curl_exec($ch1);
|
||||
$http_code1 = curl_getinfo($ch1, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch1);
|
||||
|
||||
if ($http_code1 == 200 && $response1) {
|
||||
$data1 = json_decode($response1, true);
|
||||
if ($data1 && isset($data1['ip'])) {
|
||||
$result = [
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'ip' => $data1['ip'],
|
||||
'country' => $data1['country'] ?? 'Unknown',
|
||||
'country_code' => $data1['country_code'] ?? null,
|
||||
'city' => $data1['city'] ?? 'Unknown',
|
||||
'region' => $data1['region'] ?? 'Unknown',
|
||||
'latitude' => $data1['latitude'] ?? null,
|
||||
'longitude' => $data1['longitude'] ?? null,
|
||||
'isp' => $data1['isp'] ?? 'Unknown',
|
||||
'timezone' => $data1['timezone'] ?? null,
|
||||
'asn' => $data1['asn'] ?? null,
|
||||
'organization' => $data1['organization'] ?? null,
|
||||
'type' => $data1['type'] ?? 'Unknown'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Method 2: Fallback to ipapi.co if Method 1 fails
|
||||
if (!$result) {
|
||||
$url2 = "https://ipapi.co/" . urlencode($ip) . "/json/";
|
||||
$ch2 = curl_init();
|
||||
curl_setopt($ch2, CURLOPT_URL, $url2);
|
||||
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch2, CURLOPT_TIMEOUT, 5);
|
||||
curl_setopt($ch2, CURLOPT_USERAGENT, 'Mozilla/5.0');
|
||||
$response2 = curl_exec($ch2);
|
||||
$http_code2 = curl_getinfo($ch2, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch2);
|
||||
|
||||
if ($http_code2 == 200 && $response2) {
|
||||
$data2 = json_decode($response2, true);
|
||||
if ($data2 && isset($data2['ip'])) {
|
||||
$result = [
|
||||
'status' => 'success',
|
||||
'code' => 200,
|
||||
'ip' => $data2['ip'],
|
||||
'country' => $data2['country_name'] ?? 'Unknown',
|
||||
'country_code' => $data2['country_code'] ?? null,
|
||||
'city' => $data2['city'] ?? 'Unknown',
|
||||
'region' => $data2['region'] ?? 'Unknown',
|
||||
'latitude' => $data2['latitude'] ?? null,
|
||||
'longitude' => $data2['longitude'] ?? null,
|
||||
'isp' => $data2['org'] ?? 'Unknown',
|
||||
'timezone' => $data2['timezone'] ?? null,
|
||||
'postal' => $data2['postal'] ?? null,
|
||||
'currency' => $data2['currency'] ?? null
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If both methods fail, return error
|
||||
if (!$result) {
|
||||
http_response_code(503);
|
||||
$error_data = [
|
||||
'status' => 'error',
|
||||
'code' => 503,
|
||||
'message' => 'Unable to fetch IP information from external services',
|
||||
'ip' => $ip
|
||||
];
|
||||
|
||||
// Support JSONP callback
|
||||
if (!empty($_GET['callback'])) {
|
||||
$callback = preg_replace('/[^a-zA-Z0-9_.]/', '', $_GET['callback']);
|
||||
echo $callback . '(' . json_encode($error_data, JSON_UNESCAPED_UNICODE) . ');';
|
||||
} else {
|
||||
echo json_encode($error_data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
||||
// Support JSONP callback
|
||||
if (!empty($_GET['callback'])) {
|
||||
header('Content-Type: application/javascript; charset=utf-8');
|
||||
$callback = preg_replace('/[^a-zA-Z0-9_.]/', '', $_GET['callback']);
|
||||
echo $callback . '(' . json_encode($result, JSON_UNESCAPED_UNICODE) . ');';
|
||||
} else {
|
||||
echo json_encode($result, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}
|
||||
?>
|
||||
1
api/ipinfo/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
5
|
||||
BIN
api/ipinfo/font/msyh.ttf
Normal file
BIN
api/ipinfo/icon/ico/IP.png
Normal file
|
After Width: | Height: | Size: 251 B |
BIN
api/ipinfo/icon/ico/bro.png
Normal file
|
After Width: | Height: | Size: 457 B |
BIN
api/ipinfo/icon/ico/local.png
Normal file
|
After Width: | Height: | Size: 337 B |
BIN
api/ipinfo/icon/ico/system.png
Normal file
|
After Width: | Height: | Size: 328 B |
BIN
api/ipinfo/icon/ico/time.png
Normal file
|
After Width: | Height: | Size: 260 B |
BIN
api/ipinfo/icon/weather/dyun.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
api/ipinfo/icon/weather/rain.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
api/ipinfo/icon/weather/sha.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
api/ipinfo/icon/weather/snow.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
api/ipinfo/icon/weather/sunny.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
api/ipinfo/icon/weather/unknow.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
api/ipinfo/icon/weather/wu.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
api/ipinfo/icon/weather/yin.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
api/ipinfo/img/bg.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
501
api/ipinfo/index.php
Normal file
@@ -0,0 +1,501 @@
|
||||
<?php
|
||||
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
|
||||
class App
|
||||
{
|
||||
/*高德地图开发者key*/
|
||||
private $key = 'b88cd7d0ad247b8cb9bdac4eae747bb9';
|
||||
/*是否允许空refer,0为不允许,1为允许*/
|
||||
public $referopen = "1";
|
||||
/**路径 */
|
||||
private $path = __DIR__ . "/";
|
||||
|
||||
// 浏览器信息
|
||||
public $browser = null;
|
||||
// 系统信息
|
||||
public $os = null;
|
||||
// 访问者IP
|
||||
public $ip = null;
|
||||
// 城市代码
|
||||
public $adcode = null;
|
||||
// 天气
|
||||
public $weather = null;
|
||||
// 图片
|
||||
public $drawIm = null;
|
||||
// 先定义一个数组
|
||||
public $weekarray = array("日", "一", "二", "三", "四", "五", "六");
|
||||
// 城市
|
||||
public $city = "";
|
||||
// 省份
|
||||
public $province = "";
|
||||
|
||||
|
||||
// 初始化
|
||||
public function init()
|
||||
{
|
||||
// 获取浏览器信息
|
||||
$this->browser = $this->getBrowser();
|
||||
// 获取系统信息
|
||||
$this->os = $this->getOs();
|
||||
// 访问者IP
|
||||
$this->ip = $_SERVER["REMOTE_ADDR"];
|
||||
// $this->ip = '222.216.222.168';
|
||||
// 获取访问者信息
|
||||
$this->getAddress();
|
||||
// 绘制图片
|
||||
$this->picInit()->setWeather()->setIcon()->setInfo();
|
||||
//
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置信息
|
||||
*/
|
||||
public function setInfo()
|
||||
{
|
||||
/*基本项文字位置*/
|
||||
//标语
|
||||
$by_text = ""; //文字标语
|
||||
$by_size = "12"; //文字大小
|
||||
$by_angle = "0"; //角度
|
||||
$by_x = "60";
|
||||
$by_y = "45";
|
||||
$by_font = $this->path . "font/msyh.ttf"; //字体位置
|
||||
$by_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值
|
||||
//自定义文字
|
||||
$diy_size = "20"; //文字大小
|
||||
$diy_angle = "0"; //角度
|
||||
$diy_x = "125";
|
||||
$diy_y = "45";
|
||||
$diy_font = $this->path . "font/msyh.ttf"; //字体位置
|
||||
$diy_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值
|
||||
//日期
|
||||
$time_size = "10"; //文字大小
|
||||
$time_angle = "0"; //角度
|
||||
$time_x = "167";
|
||||
$time_y = "194";
|
||||
$time_font = $this->path . "font/msyh.ttf"; //字体位置
|
||||
$time_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值
|
||||
//位置
|
||||
$local_size = "10"; //文字大小
|
||||
$local_angle = "0"; //角度
|
||||
$local_x = "165";
|
||||
$local_y = "212";
|
||||
$local_font = $this->path . "font/msyh.ttf"; //字体位置
|
||||
$local_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值
|
||||
//IP
|
||||
$ip_size = "10"; //文字大小
|
||||
$ip_angle = "0"; //角度
|
||||
$ip_x = "165";
|
||||
$ip_y = "232";
|
||||
$ip_font = $this->path . "font/msyh.ttf"; //字体位置
|
||||
$ip_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值
|
||||
//系统
|
||||
$system_size = "10"; //文字大小
|
||||
$system_angle = "0"; //角度
|
||||
$system_x = "278";
|
||||
$system_y = "212";
|
||||
$system_font = $this->path . "font/msyh.ttf"; //字体位置
|
||||
$system_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值
|
||||
//浏览器
|
||||
$bro_size = "10"; //文字大小
|
||||
$bro_angle = "0"; //角度
|
||||
$bro_x = "278";
|
||||
$bro_y = "232";
|
||||
$bro_font = $this->path . "font/msyh.ttf"; //字体位置
|
||||
$bro_color = imagecolorallocate($this->drawIm, 0, 51, 78); //这里可以自定义自己需要的颜色,但需要转为RGB值,可将0,51,78修改为自己需要的颜色的RGB值
|
||||
imagettftext($this->drawIm, $time_size, $time_angle, $time_x, $time_y, $time_color, $time_font, date('Y年n月j日') . " 星期" . $this->weekarray[date("w")]);
|
||||
imagettftext($this->drawIm, $local_size, $local_angle, $local_x, $local_y, $local_color, $local_font, $this->province . '-' . $this->city);
|
||||
imagettftext($this->drawIm, $by_size, $by_angle, $by_x, $by_y, $by_color, $by_font, $by_text); //标语添加到图片
|
||||
$_diy = isset($_GET["diy"]) ? $_GET["diy"] : "";
|
||||
imagettftext($this->drawIm, $diy_size, $diy_angle, $diy_x, $diy_y, $diy_color, $diy_font, base64_decode($_diy)); //自定义文字添加到图片
|
||||
imagettftext($this->drawIm, $ip_size, $ip_angle, $ip_x, $ip_y, $ip_color, $ip_font, $this->ip); //IP添加到图片
|
||||
imagettftext($this->drawIm, $system_size, $system_angle, $system_x, $system_y, $system_color, $system_font, $this->os); //系统添加到图片
|
||||
imagettftext($this->drawIm, $bro_size, $bro_angle, $bro_x, $bro_y, $bro_color, $bro_font, $this->browser); //浏览器添加到图片
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化画布
|
||||
*/
|
||||
public function picInit()
|
||||
{
|
||||
//背景图片名称(名称.格式,如"bg.png")
|
||||
$dst_path = $this->path . 'img/bg.png';
|
||||
//传递背景图片
|
||||
$this->drawIm = imagecreatefromstring(file_get_contents($dst_path));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制天气部分
|
||||
*/
|
||||
public function setWeather()
|
||||
{
|
||||
/*基本图标位置*/
|
||||
//天气图标位置
|
||||
$weather_icon_x = "65";
|
||||
$weather_icon_y = "50";
|
||||
//天气图标
|
||||
$sunny_path = $this->path . 'icon/weather/sunny.png';
|
||||
$sunny_im = imagecreatefromstring(file_get_contents($sunny_path));
|
||||
list($sunny_w, $sunny_h) = getimagesize($sunny_path);
|
||||
$rain_path = $this->path . 'icon/weather/rain.png';
|
||||
$rain_im = imagecreatefromstring(file_get_contents($rain_path));
|
||||
list($rain_w, $rain_h) = getimagesize($rain_path);
|
||||
$snow_path = $this->path . 'icon/weather/snow.png';
|
||||
$snow_im = imagecreatefromstring(file_get_contents($snow_path));
|
||||
list($snow_w, $snow_h) = getimagesize($snow_path);
|
||||
$sha_path = $this->path . 'icon/weather/sha.png';
|
||||
$sha_im = imagecreatefromstring(file_get_contents($sha_path));
|
||||
list($sha_w, $sha_h) = getimagesize($sha_path);
|
||||
$wu_path = $this->path . 'icon/weather/wu.png';
|
||||
$wu_im = imagecreatefromstring(file_get_contents($wu_path));
|
||||
list($wu_w, $wu_h) = getimagesize($wu_path);
|
||||
$yin_path = $this->path . 'icon/weather/yin.png';
|
||||
$yin_im = imagecreatefromstring(file_get_contents($yin_path));
|
||||
list($yin_w, $yin_h) = getimagesize($yin_path);
|
||||
$dyun_path = $this->path . 'icon/weather/dyun.png';
|
||||
$dyun_im = imagecreatefromstring(file_get_contents($dyun_path));
|
||||
list($dyun_w, $dyun_h) = getimagesize($dyun_path);
|
||||
$unknow_path = $this->path . 'icon/weather/unknow.png';
|
||||
$unknow_im = imagecreatefromstring(file_get_contents($unknow_path));
|
||||
list($unknow_w, $unknow_h) = getimagesize($unknow_path);
|
||||
// 判断天气
|
||||
if (strpos($this->weather['weather'], '晴') !== false) {
|
||||
imagecopy($this->drawIm, $sunny_im, $weather_icon_x, $weather_icon_y, 0, 0, $sunny_w, $sunny_h);
|
||||
} elseif (strpos($this->weather['weather'], '云') !== false) {
|
||||
imagecopy($this->drawIm, $dyun_im, $weather_icon_x, $weather_icon_y, 0, 0, $dyun_w, $dyun_h);
|
||||
} elseif (strpos($this->weather['weather'], '阴') !== false) {
|
||||
imagecopy($this->drawIm, $yin_im, $weather_icon_x, $weather_icon_y, 0, 0, $yin_w, $yin_h);
|
||||
} elseif (strpos($this->weather['weather'], '雾') !== false) {
|
||||
imagecopy($this->drawIm, $wu_im, $weather_icon_x, $weather_icon_y, 0, 0, $wu_w, $wu_h);
|
||||
} elseif (strpos($this->weather['weather'], '雨') !== false) {
|
||||
imagecopy($this->drawIm, $rain_im, $weather_icon_x, $weather_icon_y, 0, 0, $rain_w, $rain_h);
|
||||
} elseif (strpos($this->weather['weather'], '雪') !== false) {
|
||||
imagecopy($this->drawIm, $snow_im, $weather_icon_x, $weather_icon_y, 0, 0, $snow_w, $snow_h);
|
||||
} elseif (strpos($this->weather['weather'], '风') !== false) {
|
||||
imagecopy($this->drawIm, $sha_im, $weather_icon_x, $weather_icon_y, 0, 0, $sha_w, $sha_h);
|
||||
} else {
|
||||
imagecopy($this->drawIm, $unknow_im, $weather_icon_x, $weather_icon_y, 0, 0, $unknow_w, $unknow_h);
|
||||
}
|
||||
|
||||
imagettftext($this->drawIm, 14, 0, 95, 140, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", $this->weather['weather']); //今天天气添加到图片
|
||||
imagettftext($this->drawIm, 13, 0, 160, 90, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", '温度:' . $this->weather['temp'] . '℃'); //当前温度添加到图片
|
||||
imagettftext($this->drawIm, 13, 0, 237, 90, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", '湿度:' . $this->weather['humidity'] . '%RH'); //当前湿度添加到图片
|
||||
imagettftext($this->drawIm, 11, 0, 160, 115, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", '风向:' . $this->weather['winddirection'] . '方'); //当前风向添加到图片
|
||||
imagettftext($this->drawIm, 11, 0, 237, 115, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", '风力级别:' . $this->weather['windpower'] . '级'); //风力级别添加到图片
|
||||
imagettftext($this->drawIm, 11, 0, 160, 135, imagecolorallocate($this->drawIm, 0, 51, 78), $this->path . "font/msyh.ttf", '更新时间:' . $this->weather['reporttime']); //更新时间添加到图片
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制ICON
|
||||
*/
|
||||
public function setIcon()
|
||||
{
|
||||
//ip图标位置
|
||||
$ip_icon_x = "150";
|
||||
$ip_icon_y = "220";
|
||||
//时间图标位置
|
||||
$time_icon_x = "150";
|
||||
$time_icon_y = "180";
|
||||
//位置图标位置
|
||||
$local_icon_x = "150";
|
||||
$local_icon_y = "200";
|
||||
//系统图标位置
|
||||
$system_icon_x = "260";
|
||||
$system_icon_y = "200";
|
||||
//浏览器图标位置
|
||||
$bro_icon_x = "260";
|
||||
$bro_icon_y = "220";
|
||||
//IP等图标
|
||||
$ip_path = $this->path . 'icon/ico/IP.png';
|
||||
$ip_im = imagecreatefromstring(file_get_contents($ip_path));
|
||||
list($ip_w, $ip_h) = getimagesize($ip_path);
|
||||
$time_path = $this->path . 'icon/ico/time.png';
|
||||
$time_im = imagecreatefromstring(file_get_contents($time_path));
|
||||
list($time_w, $time_h) = getimagesize($time_path);
|
||||
$local_path = $this->path . 'icon/ico/local.png';
|
||||
$local_im = imagecreatefromstring(file_get_contents($local_path));
|
||||
list($local_w, $local_h) = getimagesize($local_path);
|
||||
$system_path = $this->path . 'icon/ico/system.png';
|
||||
$system_im = imagecreatefromstring(file_get_contents($system_path));
|
||||
list($system_w, $system_h) = getimagesize($system_path);
|
||||
$bro_path = $this->path . 'icon/ico/bro.png';
|
||||
$bro_im = imagecreatefromstring(file_get_contents($bro_path));
|
||||
list($bro_w, $bro_h) = getimagesize($bro_path);
|
||||
|
||||
//各图标位置
|
||||
imagecopy($this->drawIm, $ip_im, $ip_icon_x, $ip_icon_y, 0, 0, $ip_w, $ip_h);
|
||||
imagecopy($this->drawIm, $time_im, $time_icon_x, $time_icon_y, 0, 0, $time_w, $time_h);
|
||||
imagecopy($this->drawIm, $local_im, $local_icon_x, $local_icon_y, 0, 0, $local_w, $local_h);
|
||||
imagecopy($this->drawIm, $system_im, $system_icon_x, $system_icon_y, 0, 0, $system_w, $system_h);
|
||||
imagecopy($this->drawIm, $bro_im, $bro_icon_x, $bro_icon_y, 0, 0, $bro_w, $bro_h);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 合成输出图片
|
||||
*/
|
||||
public function suture()
|
||||
{
|
||||
header("Content-type: image/JPEG");
|
||||
|
||||
//输出
|
||||
imagegif($this->drawIm);
|
||||
imagedestroy($this->drawIm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取IP及城市代码
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
//获取IP及城市代码
|
||||
$url = "http://restapi.amap.com/v3/ip?key=" . $this->key . "&ip=" . $this->ip;
|
||||
$UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_ENCODING, '');
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
|
||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
|
||||
$data = curl_exec($curl);
|
||||
$data = json_decode($data, true);
|
||||
$this->province = isset($data['province']) ? $data['province'] : "未知"; //省
|
||||
$this->city = isset($data['city']) ? $data['city'] : "未知"; //市
|
||||
$this->adcode = isset($data['adcode']) ? $data['adcode'] : ""; //城市代码
|
||||
// 不为空获取天气信息
|
||||
if ($this->adcode) {
|
||||
$this->getWeather();
|
||||
}
|
||||
//
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取天气信息
|
||||
*/
|
||||
public function getWeather()
|
||||
{
|
||||
//获取天气信息
|
||||
$tqurl = "http://restapi.amap.com/v3/weather/weatherInfo?key=" . $this->key . "&city=" . $this->adcode;
|
||||
$UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $tqurl);
|
||||
curl_setopt($curl, CURLOPT_HEADER, 0);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curl, CURLOPT_ENCODING, '');
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
|
||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
|
||||
$weatherinfo = curl_exec($curl);
|
||||
$weatherinfo = json_decode($weatherinfo, true);
|
||||
$this->weather['weather'] = $weatherinfo['lives']['0']['weather']; //天气
|
||||
$this->weather['temp'] = $weatherinfo['lives']['0']['temperature']; //温度
|
||||
$this->weather['humidity'] = $weatherinfo['lives']['0']['humidity']; //湿度
|
||||
$this->weather['winddirection'] = $weatherinfo['lives']['0']['winddirection']; //风向
|
||||
$this->weather['windpower'] = $weatherinfo['lives']['0']['windpower']; //风力级别
|
||||
$this->weather['reporttime'] = $weatherinfo['lives']['0']['reporttime']; //更新时间
|
||||
//
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取浏览器信息
|
||||
*/
|
||||
public function getBrowser()
|
||||
{
|
||||
$ua = $_SERVER['HTTP_USER_AGENT']; //获取用户代理字符串
|
||||
if (preg_match('#(Camino|Chimera)[ /]([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Camino(' . $matches[2] . ')';
|
||||
} elseif (preg_match('#SE 2([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = '搜狗(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#360([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = '360(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#QQ/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'QQ(' . $matches[1] . ')内置';
|
||||
} elseif (preg_match('#Maxthon( |\/)([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Maxthon(' . $matches[2] . ')';
|
||||
} elseif (preg_match('#Chrome/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Chrome(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#Safari/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Safari(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#opera mini#i', $ua)) {
|
||||
$browser = 'Opera Mini(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#Opera.([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Opera(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#(j2me|midp)#i', $ua)) {
|
||||
$browser = "J2ME/MIDP Browser";
|
||||
} elseif (preg_match('/GreenBrowser/i', $ua)) {
|
||||
$browser = 'GreenBrowser';
|
||||
} elseif (preg_match('#TencentTraveler ([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = '腾讯TT(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#UCWEB([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'UCWEB(' . $matches[1];
|
||||
} elseif (preg_match('#MSIE ([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Internet Explorer(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#avantbrowser.com#i', $ua)) {
|
||||
$browser = 'Avant Browser';
|
||||
} elseif (preg_match('#PHP#', $ua, $matches)) {
|
||||
$browser = 'PHP';
|
||||
} elseif (preg_match('#danger hiptop#i', $ua, $matches)) {
|
||||
$browser = 'Danger HipTop';
|
||||
} elseif (preg_match('#Shiira[/]([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Shiira(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#Dillo[ /]([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Dillo(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#Epiphany/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Epiphany(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#UP.Browser/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Openwave UP.Browser (' . $matches[1] . ')';
|
||||
} elseif (preg_match('#DoCoMo/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'DoCoMo(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#(Firefox|Phoenix|Firebird|BonEcho|GranParadiso|Minefield|Iceweasel)/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Firefox(' . $matches[2] . ')';
|
||||
} elseif (preg_match('#(SeaMonkey)/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Mozilla SeaMonkey(' . $matches[2] . ')';
|
||||
} elseif (preg_match('#Kazehakase/([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$browser = 'Kazehakase(' . $matches[1] . ')';
|
||||
} else {
|
||||
$browser = '未知';
|
||||
}
|
||||
return $browser;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统信息
|
||||
*/
|
||||
public function getOs()
|
||||
{
|
||||
$ua = $_SERVER['HTTP_USER_AGENT'];
|
||||
$os = false;
|
||||
if (preg_match('/Windows 95/i', $ua) || preg_match('/Win95/', $ua)) {
|
||||
$os = "Windows 95";
|
||||
} elseif (preg_match('/Windows NT 5.0/i', $ua) || preg_match('/Windows 2000/i', $ua)) {
|
||||
$os = "Windows 2000";
|
||||
} elseif (preg_match('/Win 9x 4.90/i', $ua) || preg_match('/Windows ME/i', $ua)) {
|
||||
$os = "Windows ME";
|
||||
} elseif (preg_match('/Windows.98/i', $ua) || preg_match('/Win98/i', $ua)) {
|
||||
$os = "Windows 98";
|
||||
} elseif (preg_match('/Windows NT 6.0/i', $ua)) {
|
||||
$os = "Windows Vista";
|
||||
} elseif (preg_match('/Windows NT 6.1/i', $ua)) {
|
||||
$os = "Windows 7";
|
||||
} elseif (preg_match('/Windows NT 5.1/i', $ua)) {
|
||||
$os = "Windows XP";
|
||||
} elseif (preg_match('/Windows NT 5.2/i', $ua) && preg_match('/Win64/i', $ua)) {
|
||||
$os = "Windows XP 64 bit";
|
||||
} elseif (preg_match('/Windows NT 5.2/i', $ua)) {
|
||||
$os = "Windows Server 2003";
|
||||
} elseif (preg_match('/Mac_PowerPC/i', $ua)) {
|
||||
$os = "Mac OS";
|
||||
} elseif (preg_match('/Windows Phone/i', $ua)) {
|
||||
$os = "Windows Phone7";
|
||||
} elseif (preg_match('/Windows NT 6.2/i', $ua)) {
|
||||
$os = "Windows 8";
|
||||
} elseif (preg_match('/Windows NT 10.0/i', $ua)) {
|
||||
$os = "Windows 10";
|
||||
} elseif (preg_match('/Windows NT 4.0/i', $ua) || preg_match('/WinNT4.0/i', $ua)) {
|
||||
$os = "Windows NT 4.0";
|
||||
} elseif (preg_match('/Windows NT/i', $ua) || preg_match('/WinNT/i', $ua)) {
|
||||
$os = "Windows NT";
|
||||
} elseif (preg_match('/Windows CE/i', $ua)) {
|
||||
$os = "Windows CE";
|
||||
} elseif (preg_match('/ipad/i', $ua)) {
|
||||
if (preg_match("/(?<=CPU OS )[\d\_]{1,}/", $ua, $version)) {
|
||||
$ver = str_replace('_', '.', $version[0]);
|
||||
$os = "IOS(" . $ver . ")";
|
||||
} else {
|
||||
$os = "IOS";
|
||||
}
|
||||
} elseif (preg_match('/Touch/i', $ua)) {
|
||||
$os = "Touchw";
|
||||
} elseif (preg_match('/Symbian/i', $ua) || preg_match('/SymbOS/i', $ua)) {
|
||||
$os = "Symbian OS";
|
||||
} elseif (preg_match('/iPhone/i', $ua)) {
|
||||
if (preg_match("/(?<=CPU iPhone OS )[\d\_]{1,}/", $ua, $version)) {
|
||||
$ver = str_replace('_', '.', $version[0]);
|
||||
$os = "IOS(" . $ver . ")";
|
||||
} else {
|
||||
$os = "IOS";
|
||||
}
|
||||
} elseif (preg_match('/PalmOS/i', $ua)) {
|
||||
$os = "Palm OS";
|
||||
} elseif (preg_match('/QtEmbedded/i', $ua)) {
|
||||
$os = "Qtopia";
|
||||
} elseif (preg_match('/Ubuntu/i', $ua)) {
|
||||
$os = "Ubuntu Linux";
|
||||
} elseif (preg_match('/Gentoo/i', $ua)) {
|
||||
$os = "Gentoo Linux";
|
||||
} elseif (preg_match('/Fedora/i', $ua)) {
|
||||
$os = "Fedora Linux";
|
||||
} elseif (preg_match('/FreeBSD/i', $ua)) {
|
||||
$os = "FreeBSD";
|
||||
} elseif (preg_match('/NetBSD/i', $ua)) {
|
||||
$os = "NetBSD";
|
||||
} elseif (preg_match('/OpenBSD/i', $ua)) {
|
||||
$os = "OpenBSD";
|
||||
} elseif (preg_match('/SunOS/i', $ua)) {
|
||||
$os = "SunOS";
|
||||
} elseif (preg_match('/linux/i', $ua)) {
|
||||
$os = 'Linux';
|
||||
if (preg_match('/Android.([0-9. _]+)/i', $ua, $matches)) {
|
||||
$os = 'Android(' . $matches[1] . ')';
|
||||
} elseif (preg_match('#Ubuntu#i', $ua)) {
|
||||
$os = 'Ubuntu';
|
||||
} elseif (preg_match('#Debian#i', $ua)) {
|
||||
$os = 'Debian';
|
||||
} elseif (preg_match('#Fedora#i', $ua)) {
|
||||
$os = 'Fedora';
|
||||
}
|
||||
} elseif (preg_match('/Mac OS X/i', $ua)) {
|
||||
$os = "Mac OS X";
|
||||
} elseif (preg_match('/Macintosh/i', $ua)) {
|
||||
$os = "Mac OS";
|
||||
} elseif (preg_match('/Unix/i', $ua)) {
|
||||
$os = "Unix";
|
||||
} elseif (preg_match('#Nokia([a-zA-Z0-9.]+)#i', $ua, $matches)) {
|
||||
$os = "Nokia" . $matches[1];
|
||||
} elseif (preg_match('/Mac OS X/i', $ua)) {
|
||||
$os = "Mac OS X";
|
||||
} else {
|
||||
$os = '未知';
|
||||
}
|
||||
return $os;
|
||||
}
|
||||
}
|
||||
|
||||
// 执行
|
||||
$app = new App();
|
||||
|
||||
if (empty($app->referopen)) {
|
||||
die("配置错误!");
|
||||
} else if ($app->referopen == 0) {
|
||||
if (empty($_SERVER['HTTP_REFERER'])) {
|
||||
die("请勿直接访问!");
|
||||
}
|
||||
} else if ($app->referopen == 1) {
|
||||
$app->init()->suture();
|
||||
} else {
|
||||
die("未知错误!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
1
api/lishi/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
2
|
||||
88
api/lishi/index.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
//允许跨域
|
||||
header("Access-Control-Allow-Origin:*");
|
||||
|
||||
$month=date( 'm',time() );
|
||||
$day=date( 'd',time() );
|
||||
//当前年月日
|
||||
$today = date('Y年m月d日');
|
||||
//获取接口数据
|
||||
$url="https://baike.baidu.com/cms/home/eventsOnHistory/".$month.'.json';
|
||||
$data = httpGet($url);
|
||||
$json = json_decode($data,true);
|
||||
//统计当日总数
|
||||
$countnum = count($json[$month][$month.$day])-1;
|
||||
//获取输出数量(可以get调整)
|
||||
$num = $_GET['num'] ? $_GET['num'] : $countnum;
|
||||
$arr = array('code'=>'200','day'=>$today);
|
||||
for ($x=0; $x<=$num; $x++) {
|
||||
$arr['content'][$x].= match_chinese(strip_tags($json[$month][$month.$day][$x]['title']));
|
||||
}
|
||||
//创建随机数
|
||||
$rand = rand(0,$countnum);
|
||||
//下面是输出类型
|
||||
if($_GET['format']=='json'){
|
||||
//输出当日所有 类型为json
|
||||
header('Content-type: application/json');
|
||||
echo json_encode($arr,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
}elseif($_GET['format']=='js'){
|
||||
//以js类型输出一条
|
||||
header('Content-type: text/javascript;charset=utf-8');
|
||||
echo 'function briefing(){document.write("'.$arr['content'][$rand].'");}';
|
||||
}else{
|
||||
//以html类型输出一条
|
||||
header("Content-Type: text/html;charset=utf-8");
|
||||
echo $arr['content'][$rand];
|
||||
}
|
||||
|
||||
|
||||
//下面是需要用到的封装
|
||||
|
||||
function httpGet($a, $b = '', $c = '', $d = ''){
|
||||
//curl模拟get请求
|
||||
$e = curl_init();
|
||||
$f = mt_rand(11, 191) . "." . mt_rand(0, 240) . "." . mt_rand(1, 240) . "." . mt_rand(1, 240);
|
||||
$i[] = "CLIENT-IP:" . $f;
|
||||
$i[] = "X-FORWARDED-FOR:" . $f;
|
||||
$i[] = "User-agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11";
|
||||
$i[] = "X-Requested-With: XMLHttpRequest";
|
||||
if (!empty($d)) {
|
||||
$i[] = "Cookie: " . $d;
|
||||
}
|
||||
curl_setopt($e, CURLOPT_HTTPHEADER, $i);
|
||||
curl_setopt($e, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($e, CURLOPT_TIMEOUT, 180);
|
||||
curl_setopt($e, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($e, CURLOPT_SSL_VERIFYHOST, false);
|
||||
if (!empty($c)) {
|
||||
curl_setopt($e, CURLOPT_REFERER, $c);
|
||||
}
|
||||
if (!empty($b)) {
|
||||
curl_setopt($e, CURLOPT_POST, 1);
|
||||
curl_setopt($e, CURLOPT_POSTFIELDS, $b);
|
||||
}
|
||||
curl_setopt($e, CURLOPT_URL, $a);
|
||||
curl_setopt($e, CURLOPT_ENCODING, "gzip");
|
||||
$j = curl_exec($e);
|
||||
curl_close($e);
|
||||
return $j;
|
||||
}
|
||||
function match_chinese($chars,$encoding='utf8')
|
||||
{
|
||||
//清除正则
|
||||
$pattern =($encoding=='utf8')?'/[\x{4e00}-\x{9fa5}a-zA-Z0-9]/u':'/[\x80-\xFF]/';
|
||||
preg_match_all($pattern,$chars,$result);
|
||||
$temp =join('',$result[0]);
|
||||
return $temp;
|
||||
}
|
||||
1
api/mcstatus/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
2
|
||||
35
api/mcstatus/index.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
?>
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
if (!isset($_GET['host'])) {
|
||||
echo json_encode(['error' => 'Missing host parameter']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$host = $_GET['host'];
|
||||
$url = "https://api.mcstatus.io/v2/status/java/".urlencode($host);
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if ($httpCode !== 200) {
|
||||
echo json_encode(['error' => 'Failed to fetch server status']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo $response;
|
||||
?>
|
||||
1
api/qqimg/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
23
api/qqimg/index.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
?>
|
||||
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
header('Content-Type: text/plain');
|
||||
|
||||
$qq = $_GET['qq'] ?? '';
|
||||
|
||||
if (is_numeric($qq) && $qq !== '') {
|
||||
header('Cache-Control: public, max-age=86400');
|
||||
header('Location: https://q1.qlogo.cn/g?b=qq&nk='.$qq.'&s=100');
|
||||
} else {
|
||||
http_response_code(400);
|
||||
echo '缺少有效的QQ号码参数';
|
||||
}
|
||||
?>
|
||||
1
api/qqzx/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
42
api/qqzx/index.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
?>
|
||||
|
||||
<?php
|
||||
error_reporting(E_ALL & ~E_NOTICE);
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$qq = $_GET['qq'] ?? '';
|
||||
|
||||
if (!is_numeric($qq) || empty($qq)) {
|
||||
http_response_code(400);
|
||||
exit(json_encode(['code' => 40, 'msg' => '缺少有效QQ号码参数']));
|
||||
}
|
||||
|
||||
$context = stream_context_create(['http' => ['timeout' => 5]]);
|
||||
$data = @file_get_contents("http://webpresence.qq.com/getonline?type=1&$qq:", false, $context);
|
||||
|
||||
if ($data === false) {
|
||||
http_response_code(503);
|
||||
exit(json_encode(['code' => 50, 'msg' => '服务暂时不可用']));
|
||||
}
|
||||
|
||||
switch (trim($data)) {
|
||||
case 'online[0]=0;':
|
||||
$response = ['code' => 20, 'msg' => '电脑离线'];
|
||||
break;
|
||||
case 'online[0]=1;':
|
||||
$response = ['code' => 21, 'msg' => '电脑在线'];
|
||||
break;
|
||||
default:
|
||||
http_response_code(500);
|
||||
$response = ['code' => 51, 'msg' => '未知状态'];
|
||||
}
|
||||
|
||||
echo json_encode($response, JSON_UNESCAPED_UNICODE);
|
||||
?>
|
||||
1
api/qrcode/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
3335
api/qrcode/index.php
Normal file
1
api/sfz/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
3706
api/sfz/index.php
Normal file
1
api/sjbz/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
3
|
||||
45
api/sjbz/index.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
?>
|
||||
|
||||
<?php
|
||||
if($_GET["method"] == "mobile"){
|
||||
if($_GET["lx"] == 'dongman'){
|
||||
$imgurl = 'http://api.btstu.cn/sjbz/api.php?method=mobile&lx=dongman';
|
||||
}
|
||||
else if($_GET["lx"] == 'meizi'){
|
||||
$imgurl = 'http://api.btstu.cn/sjbz/api.php?method=mobile&lx=meizi';
|
||||
}
|
||||
else if($_GET["lx"] == 'fengjing'){
|
||||
$imgurl = 'http://api.btstu.cn/sjbz/api.php?method=mobile&lx=fengjing';
|
||||
}
|
||||
else if($_GET["lx"] == 'suiji'){
|
||||
$imgurl = 'http://api.btstu.cn/sjbz/api.php?method=mobile&lx=suiji';
|
||||
}
|
||||
else{
|
||||
$imgurl = 'http://api.btstu.cn/sjbz/api.php?method=mobile&lx=dongman';
|
||||
}
|
||||
}else{
|
||||
if($_GET["lx"] == 'dongman'){
|
||||
$imgurl = 'http://api.btstu.cn/sjbz/api.php?lx=dongman';
|
||||
}
|
||||
else if($_GET["lx"] == 'meizi'){
|
||||
$imgurl = 'http://api.btstu.cn/sjbz/api.php?lx=meizi';
|
||||
}
|
||||
else if($_GET["lx"] == 'fengjing'){
|
||||
$imgurl = 'http://api.btstu.cn/sjbz/api.php?lx=fengjing';
|
||||
}
|
||||
else if($_GET["lx"] == 'suiji'){
|
||||
$imgurl = 'http://api.btstu.cn/sjbz/api.php?lx=suiji';
|
||||
}
|
||||
else{
|
||||
$imgurl = 'http://api.btstu.cn/sjbz/api.php?lx=dongman';
|
||||
}
|
||||
}
|
||||
header("Location:".$imgurl);//跳转输出图片
|
||||
?>
|
||||
1
api/wyy/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
7
|
||||
203
api/wyy/index.php
Normal file
@@ -0,0 +1,203 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
// 辅助类 - HTTP请求和数据处理
|
||||
class NetEaseHelper {
|
||||
/**
|
||||
* 执行CURL请求
|
||||
*/
|
||||
public static function curl($url, $options = []) {
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
|
||||
// 默认User-Agent
|
||||
$ua = isset($options['ua']) ? $options['ua'] : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36';
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
|
||||
|
||||
// POST数据
|
||||
if (!empty($options['post'])) {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $options['post']);
|
||||
}
|
||||
|
||||
// 自定义Headers
|
||||
if (!empty($options['Header'])) {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $options['Header']);
|
||||
}
|
||||
|
||||
// SSL验证
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送数据
|
||||
*/
|
||||
public static function send($data, $type = 'json') {
|
||||
if ($type === 'json') {
|
||||
if (is_array($data)) {
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
echo $data;
|
||||
}
|
||||
} else {
|
||||
echo $data;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
class Music_163_Rand {
|
||||
protected $info = [];
|
||||
protected $Array = [];
|
||||
protected $Msg;
|
||||
protected $id;
|
||||
protected $header = [
|
||||
'Host: music.163.com',
|
||||
'Origin: http://music.163.com',
|
||||
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
|
||||
'Content-Type: application/x-www-form-urlencoded',
|
||||
'Referer: http://music.163.com/search/',
|
||||
];
|
||||
|
||||
public function __construct(Array $Array) {
|
||||
foreach ($Array as $k => $v) {
|
||||
$this->info[$k] = $v;
|
||||
}
|
||||
$this->ParameterException();
|
||||
}
|
||||
|
||||
protected function ParameterException() {
|
||||
$id = $this->info['id'];
|
||||
if (!is_numeric($id)) {
|
||||
$this->Array = ['code' => -1, 'msg' => '请输入正确的歌单id'];
|
||||
$this->returns();
|
||||
return;
|
||||
}
|
||||
$this->getPlaylistSongs();
|
||||
}
|
||||
|
||||
protected function getPlaylistSongs() {
|
||||
$id = $this->info['id'];
|
||||
$post_data = http_build_query(['s' => '100', 'id' => $id, 'n' => '100', 't' => '100']);
|
||||
$url = 'http://music.163.com/api/v6/playlist/detail';
|
||||
|
||||
$data = NetEaseHelper::curl($url, [
|
||||
'post' => $post_data,
|
||||
'ua' => 'NeteaseMusic/8.6.31.211201171945(8006031);Dalvik/2.1.0 (Linux; U; Android 11; PCLM10 Build/RKQ1.200928.002)',
|
||||
'Header' => $this->header
|
||||
]);
|
||||
|
||||
$decoded = json_decode($data, true);
|
||||
|
||||
if (empty($decoded['playlist']['trackIds'])) {
|
||||
$this->Array = ['code' => -1, 'msg' => '无法获取歌单信息'];
|
||||
$this->returns();
|
||||
return;
|
||||
}
|
||||
|
||||
$array = $decoded['playlist']['trackIds'];
|
||||
$rand_song = $array[array_rand($array, 1)];
|
||||
$this->id = $rand_song['id'];
|
||||
|
||||
$this->getSongDetail();
|
||||
}
|
||||
|
||||
protected function getSongDetail() {
|
||||
$id = $this->id;
|
||||
$url = 'http://music.163.com/api/song/detail/?id=' . $id . '&ids=%5B' . $id . '%5D&csrf_token=';
|
||||
|
||||
$data = json_decode(NetEaseHelper::curl($url), true);
|
||||
|
||||
if (empty($data['songs'][0])) {
|
||||
$this->Array = ['code' => -1, 'msg' => '无法获取歌曲信息'];
|
||||
$this->returns();
|
||||
return;
|
||||
}
|
||||
|
||||
$song = $data['songs'][0];
|
||||
$song_name = $song['name'] ?? '未知';
|
||||
$artist_name = $song['artists'][0]['name'] ?? '未知';
|
||||
$cover = $song['album']['picUrl'] ?? '';
|
||||
$music_url = 'http://music.163.com/song/media/outer/url?id=' . $id;
|
||||
$tail = $this->info['tail'] ?? '网易云音乐';
|
||||
|
||||
$this->Array = [
|
||||
'code' => 200,
|
||||
'msg' => '获取成功',
|
||||
'data' => [
|
||||
'id' => $id,
|
||||
'song' => $song_name,
|
||||
'singer' => $artist_name,
|
||||
'cover' => $cover,
|
||||
'music_url' => $music_url,
|
||||
'tail' => $tail
|
||||
]
|
||||
];
|
||||
|
||||
$this->returns();
|
||||
}
|
||||
|
||||
protected function returns() {
|
||||
$type = $this->info['type'] ?? 'json';
|
||||
|
||||
switch ($type) {
|
||||
case 'text':
|
||||
if (isset($this->Array['data'])) {
|
||||
$text = "歌曲:" . $this->Array['data']['song'] . "\n";
|
||||
$text .= "歌手:" . $this->Array['data']['singer'];
|
||||
echo $text;
|
||||
} else {
|
||||
echo $this->Array['msg'];
|
||||
}
|
||||
break;
|
||||
case 'url':
|
||||
if (isset($this->Array['data']['music_url'])) {
|
||||
header('Location: ' . $this->Array['data']['music_url']);
|
||||
} else {
|
||||
echo json_encode($this->Array, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
echo json_encode($this->Array, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
break;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取参数
|
||||
$songId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
|
||||
$tail = isset($_REQUEST['tail']) ? $_REQUEST['tail'] : '网易云音乐';
|
||||
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'json';
|
||||
|
||||
// 如果没提供歌单ID,使用默认热门歌单
|
||||
if (empty($songId) || $songId <= 0) {
|
||||
$playlists = [71385702, 2884035, 3778678, 3779629, 19723756];
|
||||
$songId = $playlists[array_rand($playlists, 1)];
|
||||
}
|
||||
|
||||
// 执行查询
|
||||
new Music_163_Rand([
|
||||
'id' => $songId,
|
||||
'type' => $type,
|
||||
'tail' => $tail
|
||||
]);
|
||||
?>
|
||||
1
api/yiyan/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
2
|
||||
3386
api/yiyan/hitokoto.txt
Normal file
92
api/yiyan/index.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat","w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
if ($_GET['charset']=='GBK' ||$_GET['charset']=='gbk' || $_GET['charset']=='gb2312'){
|
||||
$array=file('hitokoto.txt');
|
||||
$rand=rand(0,3388);
|
||||
|
||||
function utf8_to_gbk($str){
|
||||
return mb_convert_encoding($str, 'gbk', 'utf-8');
|
||||
}
|
||||
$string=$array[$rand];
|
||||
header('Content-Type: text/html; charset=GBK');
|
||||
if ($_GET['code']==='js' || $_GET['code']==='javascript' || $_GET['code']==='JavaScript') {
|
||||
header('Content-type: application/x-javascript; charset=GBK');
|
||||
echo "function xjhitokoto(){document.write(\"";
|
||||
echo trim(utf8_to_gbk($string)) . "\");}";
|
||||
} elseif ($_GET['code']==='array' || $_GET['code']==='Array' || $_GET['code']==='arr' || $_GET['code']==='Arr') {
|
||||
$arr = array(
|
||||
'code' => 200 ,
|
||||
'msg' => trim(utf8_to_gbk($string))
|
||||
);
|
||||
var_dump($arr);
|
||||
}else{
|
||||
echo trim(utf8_to_gbk($string));
|
||||
}
|
||||
}else{
|
||||
|
||||
$array=file('hitokoto.txt');
|
||||
$rand=rand(0,3388);
|
||||
$string=$array[$rand];
|
||||
function arrayToXml($arr,$dom=null,$node=null,$root='xml',$cdata=false){
|
||||
if (!$dom){
|
||||
$dom = new DOMDocument('1.0','utf-8');
|
||||
}
|
||||
if(!$node){
|
||||
$node = $dom->createElement($root);
|
||||
$dom->appendChild($node);
|
||||
}
|
||||
foreach ($arr as $key=>$value){
|
||||
$child_node = $dom->createElement(is_string($key) ? $key : 'node');
|
||||
$node->appendChild($child_node);
|
||||
if (!is_array($value)){
|
||||
if (!$cdata) {
|
||||
$data = $dom->createTextNode($value);
|
||||
}else{
|
||||
$data = $dom->createCDATASection($value);
|
||||
}
|
||||
$child_node->appendChild($data);
|
||||
}else {
|
||||
arrayToXml($value,$dom,$child_node,$root,$cdata);
|
||||
}
|
||||
}
|
||||
return $dom->saveXML();
|
||||
}
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
if ($_GET['code']==='js' || $_GET['code']==='javascript' || $_GET['code']==='JavaScript') {
|
||||
header('Content-type: application/x-javascript; charset=UTF-8');
|
||||
echo "function xjhitokoto(){document.write(\"";
|
||||
echo trim($string);
|
||||
echo "\");}";
|
||||
} elseif ($_GET['code']==='json' || $_GET['code']==='JSON') {
|
||||
header('Content-type: application/json; charset=UTF-8');
|
||||
$json = json_encode(array(
|
||||
'code' => 200 ,
|
||||
'msg' => trim($string)
|
||||
));
|
||||
echo $json;
|
||||
} elseif ($_GET['code']==='xml' || $_GET['code']==='XML') {
|
||||
$xml = arrayToXml(array(
|
||||
'msg' => trim($string)
|
||||
));
|
||||
echo $xml;
|
||||
} elseif ($_GET['code']==='array' || $_GET['code']==='Array' || $_GET['code']==='arr' || $_GET['code']==='Arr') {
|
||||
$arr = array(
|
||||
'code' => 200 ,
|
||||
'msg' => trim($string)
|
||||
);
|
||||
var_dump($arr);
|
||||
}else{
|
||||
echo trim($string);
|
||||
}
|
||||
}
|
||||
?>
|
||||
1
api/zhihu/counter.dat
Normal file
@@ -0,0 +1 @@
|
||||
2
|
||||
45
api/zhihu/index.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
$counter = intval(file_get_contents("counter.dat"));
|
||||
$_SESSION['#'] = true;
|
||||
$counter++;
|
||||
$fp = fopen("counter.dat", "w");
|
||||
fwrite($fp, $counter);
|
||||
fclose($fp);
|
||||
|
||||
// 设置响应头为JSON格式
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
// 定义要获取的API地址
|
||||
$api_url = 'http://news-at.zhihu.com/api/2/news/latest';
|
||||
|
||||
// 初始化cURL会话
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $api_url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过SSL证书验证(仅用于测试)
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30); // 设置超时时间
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // 跟随重定向
|
||||
|
||||
// 执行请求并获取响应
|
||||
$response = curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$error = curl_error($ch);
|
||||
|
||||
// 关闭cURL资源
|
||||
curl_close($ch);
|
||||
|
||||
// 处理响应
|
||||
if ($http_code === 200 && !empty($response)) {
|
||||
// 直接返回获取到的内容
|
||||
echo $response;
|
||||
} else {
|
||||
// 返回错误信息
|
||||
http_response_code(500);
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'message' => '获取接口内容失败',
|
||||
'http_code' => $http_code,
|
||||
'curl_error' => $error ?: '无错误信息'
|
||||
]);
|
||||
}
|
||||
?>
|
||||