cert-uplog.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. include "../../system/db.class.php";
  4. if (!empty($_FILES)) {
  5. $filepart = pathinfo($_FILES["file"]["name"]);
  6. $extension = strtolower($filepart["extension"]);
  7. if ($extension == "mobileprovision") {
  8. $json = json_decode(stripslashes($_POST["post"]), true);
  9. $time = $json["_time"];
  10. $aid = intval($json["_aid"]);
  11. $apw = $json["_apw"];
  12. if (!db("admin")->where("in_adminid", $aid)->value("in_adminid") || db("admin")->where("in_adminid", $aid)->value("in_adminpassword") !== $apw) {
  13. exit("-2");
  14. }
  15. $path = IN_ROOT . "data/tmp/" . $time . "/";
  16. creatdir($path);
  17. $dir = basename($_FILES["file"]["name"], ".mobileprovision");
  18. $file = $path . $dir . ".mobileprovision";
  19. @move_uploaded_file($_FILES["file"]["tmp_name"], $file);
  20. $mp = @file_get_contents($file);
  21. $iden = preg_match("/<key>application-identifier<\\/key>([\\s\\S]+?)<string>([\\s\\S]+?)<\\/string>/", $mp, $m) ? $m[2] : NULL;
  22. $name = preg_match("/<key>TeamName<\\/key>([\\s\\S]+?)<string>([\\s\\S]+?)<\\/string>/", $mp, $m) ? mb_convert_encoding($m[2], set_chars(), "HTML-ENTITIES") : NULL;
  23. $pl = @file_get_contents(IN_ROOT . "static/app/cert.plist");
  24. $pl = str_replace(array("[iden]", "\r"), array($iden, ""), $pl);
  25. @fwrite(fopen($path . $dir . ".plist", "w"), $pl);
  26. $sh = @file_get_contents(IN_ROOT . "static/app/cert.sh");
  27. $sh = str_replace(array("[name]", "[cert]", "\r"), array($name, $dir, ""), $sh);
  28. @fwrite(fopen($path . $dir . ".sh", "w"), $sh);
  29. include_once "../zip/zip.php";
  30. $zip = new PclZip(IN_ROOT . "data/cert/" . $dir . ".zip");
  31. if ($zip->create($path, PCLZIP_OPT_REMOVE_PATH, $path)) {
  32. echo "{'iden':'" . $iden . "','name':'" . $name . "','dir':'" . $dir . "'}";
  33. }
  34. } else {
  35. echo "-1";
  36. }
  37. }