Created
October 29, 2018 08:42
-
-
Save simon511000/201661ab553d715b364d91a78a02f191 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/************************************* | |
* BY : simon511000 (simon511000.fr) * | |
*************************************/ | |
$config = json_decode(file_get_contents("config.json"),true); | |
if(isset($_GET["plugin/appList"])&&isset($_POST["lang"])){ | |
$start = microtime(true); | |
function LNG($value,$pluginFile){ | |
$lang = "en"; | |
if(is_dir("plugins/unzip/".basename($pluginFile,".zip")."/i18n")){ | |
$lang = $_POST["lang"]; | |
if($lang=="zh"){$lang="zh-CN";} | |
if($lang=="zh-tw"){$lang="zh-TW";} | |
if(!file_exists("plugins/unzip/".basename($pluginFile,".zip")."/i18n/".$lang.".php")){ | |
if(file_exists("plugins/unzip/".basename($pluginFile,".zip")."/i18n/en.php")){ | |
$lang = "en"; | |
} | |
} | |
} | |
$iWantTheIdOkay = explode("{{LNG.".basename($pluginFile,".zip").".",$value)[1]; | |
$id = explode("}}",$iWantTheIdOkay)[0]; | |
$langFile = require("plugins/unzip/".basename($pluginFile,".zip")."/i18n/".$lang.".php"); | |
return $langFile[basename($pluginFile,".zip").".".$id]; | |
} | |
function forEachValue($array,$pluginFile){ | |
global $config; | |
foreach($array as $key => $value){ | |
if(is_array($value)){ | |
$array[$key] = forEachValue($value,$pluginFile); | |
}else{ | |
$array[$key] = str_replace("{{pluginHost}}",$config["rootUrl"]."plugins/unzip/".basename($pluginFile,".zip")."/",$value); | |
if(strstr($array[$key],"{{LNG.".basename($pluginFile,".zip"))){ | |
$array[$key] = LNG($array[$key],$pluginFile); | |
} | |
} | |
} | |
return $array; | |
} | |
$return = array(); | |
$pluginsFiles = scandir("plugins/unzip"); | |
foreach ($pluginsFiles as $pluginFile) { | |
if($pluginFile!=".."&&$pluginFile!="."){ | |
$pluginBad = json_decode(file_get_contents("plugins/unzip/".basename($pluginFile,".zip")."/package.json"),true); | |
$pluginGood = forEachValue($pluginBad,$pluginFile); | |
$pluginGood["server"] = [ | |
"version"=>"1.0", | |
"versionTime"=>"2018/10/9", | |
"network"=>1, | |
"downloadCount"=>0, | |
"commentCount"=>0, | |
"userScore"=>0, | |
"sort"=>0, | |
"size"=>4352 | |
]; | |
$return["data"][] = $pluginGood; | |
} | |
} | |
$return["code"] = true; | |
$end = microtime(true); | |
$return["use_time"] = $end - $start; | |
echo json_encode($return); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment