update index.php.
This commit is contained in:
parent
d78860fe69
commit
ec9517d79a
58
index.php
58
index.php
@ -69,7 +69,7 @@ function check_file_update_json($file,$dir,$url,$time){
|
||||
if($replace_mode==true){
|
||||
$file=str_replace('?','/',$file);
|
||||
}
|
||||
header('Content-Disposition: attachment; filename="'.basename($file).'"');
|
||||
header('Content-Disposition: attachment; filename="'.basename($file).'.json"');
|
||||
$time=time()-@filemtime($file.'/index.json');
|
||||
if($time<$time){//检查文件是否超出过期期限(1天,86400秒)
|
||||
echo file_get_contents($file.'/index.json');
|
||||
@ -86,6 +86,28 @@ function check_file_update_json($file,$dir,$url,$time){
|
||||
}
|
||||
}
|
||||
}
|
||||
function check_file_update_jar($file,$dir,$url,$time){
|
||||
global $replace_mode;
|
||||
if($replace_mode==true){
|
||||
$file=str_replace('?','/',$file);
|
||||
}
|
||||
header('Content-Disposition: attachment; filename="'.basename($file).'.jar"');
|
||||
$time=time()-@filemtime($file.'/index.jar');
|
||||
if($time<$time){//检查文件是否超出过期期限(1天,86400秒)
|
||||
echo file_get_contents($file.'/index.jar');
|
||||
}else{
|
||||
if(url_exists($url.'/'.str_replace($dir,'',$file))){//防止源无法访问而损坏文件
|
||||
if(file_get_contents($url.'/'.str_replace($dir,'',$file))==@file_get_contents($file.'/index.jar')){
|
||||
echo file_get_contents($file);
|
||||
}else{
|
||||
echo file_get_contents($url.'/'.str_replace($dir,'',$file));
|
||||
download_file($url.'/'.str_replace($dir,'',$file),$file.'/index.jar','');
|
||||
}
|
||||
}else{
|
||||
echo file_get_contents($file.'/index.jar');
|
||||
}
|
||||
}
|
||||
}
|
||||
function check_file_update_adv($file,$url,$check_url){
|
||||
global $replace_mode;
|
||||
if($replace_mode==true){
|
||||
@ -134,11 +156,11 @@ if($_GET['error']!=""){
|
||||
}
|
||||
}elseif(strstr($_GET['path'],'forge/')!=False){//目录分组
|
||||
if(strstr($_GET['path'],'forge/last')!=False){
|
||||
check_file_update_adv('forge/last','https://download.mcbbs.net/forge/last','https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
check_file_update_adv('forge/last/index.json','https://download.mcbbs.net/forge/last','https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}
|
||||
}elseif(strstr($_GET['path'],'optifine/')!=False){//目录分组
|
||||
if(strstr($_GET['path'],'optifine/versionlist')!=False){
|
||||
check_file_update_adv('optifine/versionlist','https://download.mcbbs.net/optifine/versionlist','https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
check_file_update_adv('optifine/versionlist/index.json','https://download.mcbbs.net/optifine/versionlist','https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}
|
||||
}elseif(strstr($_GET['path'],'liteloader/')!=False){//目录分组
|
||||
if(strstr($_GET['path'],'liteloader/dl/versions')!=False){
|
||||
@ -155,12 +177,14 @@ if($_GET['error']!=""){
|
||||
}elseif(is_dir($_GET['path'])){
|
||||
//目录存在
|
||||
if(strstr($_GET['path'],'forge/minecraft')!=False){//特殊目录返回
|
||||
check_file_update_adv('forge/minecraft/index.json','https://download.mcbbs.net/forge/minecraft','https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
check_file_update_adv('forge/minecraft/minecraft.json','https://download.mcbbs.net/forge/minecraft','https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}elseif(strstr($_GET['path'],'yushi/authlib-injector')!=False){
|
||||
check_file_update_adv('yushi/authlib-injector/index.json','https://authlib-injector.yushi.moe','https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
check_file_update_adv('yushi/authlib-injector/list.json','https://authlib-injector.yushi.moe','https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
//此处暂时使用bmclapi源检测文件欺骗检测authlib-injector,原因见底部注释
|
||||
}elseif(is_file($_GET['path'].'/index.json')){
|
||||
check_file_update($_GET['path'],get_main_domain($_GET['path']).'/'.get_sub_domain($_GET['path']).'/',get_online_domain($_GET['path'],$id),86400);
|
||||
check_file_update_json($_GET['path'],get_main_domain($_GET['path']).'/'.get_sub_domain($_GET['path']).'/',get_online_domain($_GET['path'],$id),86400);
|
||||
}elseif(is_file($_GET['path'].'/index.jar')){
|
||||
check_file_update_jar($_GET['path'],get_main_domain($_GET['path']).'/'.get_sub_domain($_GET['path']).'/',get_online_domain($_GET['path'],$id),31536000);
|
||||
}else{
|
||||
header('Content-Disposition: attachment; filename="'.basename($_GET['path']).'"');
|
||||
echo file_get_contents($_GET['path']);
|
||||
@ -171,10 +195,12 @@ if($_GET['error']!=""){
|
||||
if(url_exists('https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar')){
|
||||
if(strstr($_GET['path'],'forge/minecraft')!=False){//forge/minecraft目录特殊同步
|
||||
if($_GET['path']=='forge/minecraft'){
|
||||
check_file_update_adv('forge/minecraft/index.json','https://download.mcbbs.net/forge/minecraft','https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
check_file_update_adv('forge/minecraft/minecraft.json','https://download.mcbbs.net/forge/minecraft','https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}else{
|
||||
check_file_update_adv($_GET['path'].'/index.json','https://download.mcbbs.net/'.$_GET['path'],'https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}
|
||||
}elseif(strstr($_GET['path'],'forge/last')!=False){
|
||||
check_file_update_adv($_GET['path'].'/index.json','https://download.mcbbs.net/'.$_GET['path'],'https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}elseif(strstr($_GET['path'],'forge/download')!=False){//forge/download目录特殊同步
|
||||
check_file_update_adv($_GET['path'].'/index.jar','https://download.mcbbs.net/'.$_GET['path'],'https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}else{
|
||||
@ -190,14 +216,24 @@ if($_GET['error']!=""){
|
||||
if($_GET['path']=='optifine'){
|
||||
echo '{"wikis":"https://gitee.com/ghink/gemcapi/wikis","code":404,"server_time":'.time().'}';
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
}elseif(strstr($_GET['path'],'optifine/versionlist')!=False){
|
||||
check_file_update_adv(str_replace('?','/',$_GET['path']).'/index.json','https://download.mcbbs.net/'.$_GET['path'],'https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}else{
|
||||
check_file_update_adv($_GET['path'],'https://download.mcbbs.net/'.$_GET['path'],'https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
if(@file_get_contents(get_online_url($_GET['path'],$id)=="")){
|
||||
check_file_update_adv($_GET['path'].'/index.jar','https://download.mcbbs.net/'.$_GET['path'],'https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}else{
|
||||
if(strstr($_GET['path'],'HD_U')!=False){
|
||||
check_file_update_adv($_GET['path'].'/index.jar','https://download.mcbbs.net/'.$_GET['path'],'https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}else{
|
||||
check_file_update_adv($_GET['path'].'/index.json','https://download.mcbbs.net/'.$_GET['path'],'https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}
|
||||
}
|
||||
}
|
||||
}elseif(strstr($_GET['path'],'liteloader/')!=False){//Liteloader同步
|
||||
if(strstr($_GET['path'],'liteloader/list')!=False){
|
||||
check_file_update_adv(str_replace('?','/',$_GET['path']).'/index.json','https://download.mcbbs.net/'.$_GET['path'],'https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}elseif(strstr($_GET['path'],'liteloader/download')!=False){
|
||||
check_file_update_advstr_replace('?','/',($_GET['path']).'/index.jar','https://download.mcbbs.net/'.$_GET['path'],'https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
check_file_update_adv(str_replace('?','/',$_GET['path']).'/index.jar','https://download.mcbbs.net/'.$_GET['path'],'https://download.mcbbs.net/maven/net/minecraftforge/forge/1.7.10-10.13.0.1151/forge-1.7.10-10.13.0.1151-installer.jar');
|
||||
}else{
|
||||
check_file_update_adv($_GET['path'],get_online_url($_GET['path'],$id),'http://dl.liteloader.com/versions/versions.json');
|
||||
}
|
||||
@ -214,9 +250,9 @@ if($_GET['error']!=""){
|
||||
}
|
||||
}elseif(get_main_domain($_GET['path'])=='yushi'){
|
||||
//暂不明确为何authlib-injector的服务器即使存活文件存在也会被判定为不存在
|
||||
download_file(get_online_url($_GET['path'],$id),$_GET['path'].'/index.json','');
|
||||
download_file(get_online_url($_GET['path'],$id),$_GET['path'].'/list.json','');
|
||||
header('Content-Disposition: attachment; filename="'.basename($_GET['path']).'"');
|
||||
echo file_get_contents($_GET['path'].'/index.json');
|
||||
echo file_get_contents($_GET['path'].'/list.json');
|
||||
}else{
|
||||
echo '{"wikis":"https://gitee.com/ghink/gemcapi/wikis","code":404,"server_time":'.time().'}';
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
|
Reference in New Issue
Block a user