新增json返回模式
This commit is contained in:
parent
c6b7c0e5c9
commit
019c334186
@ -1,25 +1,32 @@
|
||||
<?php
|
||||
session_start();
|
||||
if($_SERVER['HTTP_HOST'] == 'gemcapi.ghink.net'){
|
||||
if($_GET['path'] == null){
|
||||
echo '{"wikis": "https://gitee.com/ghink/gemcapi/wikis","serverid": "cn-19;gemcapi-rqdeal-s1","servertime": "'.date('Y-m-d H:i:s').'"}';
|
||||
}else{
|
||||
if($_GET['token'] == null){
|
||||
if($_SESSION['times1'] < 11){
|
||||
header('Location: http://1.free.gemcapi.ghink.net:10000/'.$_GET['path']);
|
||||
$_SESSION['times1'] = $_SESSION['times1'] + 1;
|
||||
$_SESSION['times2'] = 0;
|
||||
}else{
|
||||
header('Location: http://2.free.gemcapi.ghink.net:10000/'.$_GET['path']);
|
||||
$_SESSION['times2'] = $_SESSION['times2'] + 1;
|
||||
if($_SESSION['times2'] = 10){
|
||||
$_SESSION['times1'] = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
header('Location: http://1.free.gemcapi.ghink.net:10000/'.$_GET['path']);
|
||||
}
|
||||
}
|
||||
//Deal the request
|
||||
if($_GET['path'] == null){
|
||||
echo '{"wikis": "https://gitee.com/ghink/gemcapi/wikis","serverid": "cn-19;gemcapi-rqdeal-s1","servertime": "'.date('Y-m-d H:i:s').'"}';
|
||||
}else{
|
||||
if($_GET['token'] == null){
|
||||
if($_SESSION['times1'] < 11){
|
||||
$rqresult='http://1.free.gemcapi.ghink.net:10000/'.$_GET['path'];
|
||||
$_SESSION['times1'] = $_SESSION['times1'] + 1;
|
||||
$_SESSION['times2'] = 0;
|
||||
}else{
|
||||
$rqresult='http://2.free.gemcapi.ghink.net:10000/'.$_GET['path'];
|
||||
$_SESSION['times2'] = $_SESSION['times2'] + 1;
|
||||
if($_SESSION['times2'] = 10){
|
||||
$_SESSION['times1'] = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$rqresult='http://1.free.gemcapi.ghink.net:10000/'.$_GET['path'];
|
||||
}
|
||||
}
|
||||
|
||||
//Return the result
|
||||
if($_GET['type'] == 'json'){
|
||||
echo '{"address": "'.$rqresult.'","serverid": "cn-19;gemcapi-rqdeal-s1","servertime": "'.date('Y-m-d H:i:s').'"}';
|
||||
}elseif($_GET['type'] == 'redirect'){
|
||||
header('Location: '.$rqresult);
|
||||
}else{
|
||||
}
|
||||
|
||||
//Get which kind of the connection is.
|
||||
@ -1175,7 +1182,7 @@ if(empty(mysqli_fetch_array($result))){
|
||||
}
|
||||
|
||||
//Output the site logs.
|
||||
$logs="[GEMCAPI-RQDEAL-1][".date('Y-m-d H:i:d')."][HOST:".$_SERVER['HTTP_HOST']."][IP:".$_SERVER['HTTP_X_FORWARDED_FOR']."][PRO:".$pro."][GET:path=".$_GET['path']."&type=".$_GET['type']."]\n";
|
||||
$logs="[GEMCAPI-RQDEAL-S1][".date('Y-m-d H:i:d')."][HOST:".$_SERVER['HTTP_HOST']."][IP:".$_SERVER['HTTP_X_FORWARDED_FOR']."][PRO:".$pro."][GET:path=".$_GET['path']."&type=".$_GET['type']."][RQRESULT:".$rqsult."\n";
|
||||
$fd = fopen("logs/".date('Y-m-d').".txt",'a');
|
||||
fwrite($fd,$logs);
|
||||
fclose($fd);
|
||||
|
Reference in New Issue
Block a user