admin-apk.php 1.9 KB

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. include "../../system/db.class.php";
  4. include "deapk/examples/autoload.php";
  5. error_reporting(0);
  6. if (empty($_COOKIE["in_adminid"]) || empty($_COOKIE["in_adminname"]) || empty($_COOKIE["in_adminpassword"]) || empty($_COOKIE["in_permission"]) || empty($_COOKIE["in_adminexpire"]) || !db("admin")->where("in_adminid", intval($_COOKIE["in_adminid"]))->value("in_adminid") || md5(db("admin")->where("in_adminid", intval($_COOKIE["in_adminid"]))->value("in_adminpassword")) !== $_COOKIE["in_adminpassword"]) {
  7. exit("-1");
  8. }
  9. $time = $_GET["time"];
  10. $xml_size = $_GET["size"];
  11. $tmp = IN_ROOT . "data/tmp/" . $time . ".apk";
  12. $explode = explode("_", $time);
  13. $icontime = md5($explode[0] . "_" . $explode[1] . "_" . rand(2, pow(2, 24))) . ".png";
  14. $apptime = md5($explode[1] . "_" . $explode[0] . "_" . rand(2, pow(2, 24))) . ".apk";
  15. $apk = new \ApkParser\Parser($tmp);
  16. $xml_mnvs = $apk->getManifest()->getMinSdkLevel();
  17. $xml_bid = $apk->getManifest()->getPackageName();
  18. $xml_bsvs = $apk->getManifest()->getVersionName();
  19. $xml_bvs = $apk->getManifest()->getVersionCode();
  20. $labelResourceId = $apk->getManifest()->getApplication()->getLabel();
  21. $appLabel = $apk->getResources($labelResourceId);
  22. $xml_name = detect_encoding($appLabel[0]);
  23. $resourceId = $apk->getManifest()->getApplication()->getIcon();
  24. $resources = $apk->getResources($resourceId);
  25. foreach ($resources as $resource) {
  26. fwrite(fopen(IN_ROOT . "data/attachment/" . $icontime, "w"), stream_get_contents($apk->getStream($resource)));
  27. }
  28. $function = PHP_OS == "Linux" ? "rename" : "copy";
  29. $function($tmp, IN_ROOT . "data/attachment/" . $apptime);
  30. echo "{'name':'" . $xml_name . "','mnvs':'" . $xml_mnvs . "','bid':'" . $xml_bid . "','bsvs':'" . $xml_bsvs . "','bvs':'" . $xml_bvs . "','form':'Android','nick':'*','type':'0','team':'*','icon':'" . $icontime . "','app':'" . $apptime . "','size':'" . $xml_size . "'}";