index-mobileconfig.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. include "../../system/db.class.php";
  4. include "../../system/user.php";
  5. $GLOBALS["userlogined"] || reJSON(-1);
  6. Chk_authkey();
  7. $id = isset($_GET["id"]) ? intval($_GET["id"]) : 0;
  8. $sDownLink = SafeRequest("sDownLink", "post");
  9. if ($sDownLink) {
  10. $time = $GLOBALS["xfcms_in_userid"] . "-" . time();
  11. } else {
  12. $time = SafeRequest("time", "post");
  13. }
  14. preg_match("/^(\\d+\\-\\d+)\$/", $time) || reJSON(-2);
  15. $tmp = IN_ROOT . "data/tmp/" . $time . "/app.mobileconfig";
  16. if ($sDownLink) {
  17. saveRemoteFile(gettimestamp($sDownLink), IN_ROOT . "data/tmp/" . $time . "/", "app.mobileconfig");
  18. }
  19. is_file($tmp) || reJSON(-2);
  20. $in_size = intval(filesize($tmp));
  21. $explode = explode("-", $time);
  22. $icontime = md5($explode[0] . "-" . $explode[1] . "-" . rand(2, pow(2, 24))) . ".png";
  23. $in_app = md5($explode[1] . "-" . $explode[0] . "-" . rand(2, pow(2, 24))) . ".mobileconfig";
  24. is_file(IN_ROOT . "data/attachment/" . $in_app) && reJSON(-2);
  25. IN_VERIFY > 0 && $GLOBALS["xfcms_in_verify"] != 1 && reJSON(-3);
  26. $in_size + $GLOBALS["xfcms_in_spaceuse"] > $GLOBALS["xfcms_in_spacetotal"] && reJSON(-4);
  27. $mc = file_get_contents($tmp);
  28. $signedfile = IN_ROOT . "data/attachment/" . $in_app;
  29. rename($tmp, $signedfile);
  30. $in_bid = preg_match_all("/<key>PayloadIdentifier<\\/key>([\\s\\S]+?)<string>([\\s\\S]+?)<\\/string>/", $mc, $c) ? SafeSql(isset($c[2][1]) ? $c[2][1] : $c[2][0]) : "*";
  31. $in_name = preg_match("/<key>Label<\\/key>([\\s\\S]+?)<string>([\\s\\S]+?)<\\/string>/", $mc, $c) ? SafeSql(detect_encoding($c[2])) : NULL;
  32. if (!$in_name) {
  33. $in_name = preg_match("/<key>PayloadDisplayName<\\/key>([\\s\\S]+?)<string>([\\s\\S]+?)<\\/string>/", $mc, $c) ? SafeSql(detect_encoding($c[2])) : "*";
  34. }
  35. $in_icon = preg_match("/<key>Icon<\\/key>([\\s\\S]+?)<data>([\\s\\S]+?)<\\/data>/", $mc, $c) ? $c[2] : NULL;
  36. $basedir = IN_ROOT . "data/image/app";
  37. $imgdir = date("Y") . "/" . date("m") . "/" . date("d");
  38. creatdir($basedir . "/" . $imgdir);
  39. $newfile = $basedir . "/" . $imgdir . "/" . $icontime;
  40. file_put_contents($newfile, base64_decode($in_icon));
  41. $in_icon = $imgdir . "/" . $icontime;
  42. $deduct = getDeduct($in_size);
  43. $in_originalName = $in_app;
  44. $in_mnvs = "8.0";
  45. $in_bsvs = "1.0.0";
  46. $in_bvs = "1";
  47. $in_nick = $in_team = "*";
  48. $in_type = 1;
  49. $in_udids = "";
  50. $in_form = "iOS";
  51. $data = array("in_name" => $in_name, "in_type" => $in_type, "in_size" => $in_size, "in_form" => $in_form, "in_mnvs" => $in_mnvs, "in_bid" => $in_bid, "in_bsvs" => $in_bsvs, "in_bvs" => $in_bvs, "in_nick" => $in_nick, "in_team" => $in_team, "in_udids" => $in_udids, "in_icon" => $in_icon, "in_deduct" => $deduct, "in_app" => $in_app, "in_originalName" => $in_originalName, "in_updatetime" => time());
  52. $app = db("appid")->where("in_uid", $GLOBALS["xfcms_in_userid"])->where("in_form", $in_form)->where("in_bid", $in_bid)->where("in_name", $in_name)->find();
  53. if ($app) {
  54. $id = $app["in_id"];
  55. @unlink(IN_ROOT . "data/image/app/" . $app["in_icon"]);
  56. db("appid")->where("in_id", $id)->update($data);
  57. db("app")->where(array("in_appid" => $id))->update(array("in_release" => 0));
  58. } else {
  59. $data = array_merge($data, array("in_uid" => $GLOBALS["xfcms_in_userid"], "in_uname" => $GLOBALS["xfcms_in_username"], "in_downloads" => "0", "in_link" => creatLink(), "in_addtime" => time()));
  60. $id = db("appid")->insertGetId($data);
  61. }
  62. $logData = db("appid")->where("in_id", $id)->find();
  63. $logData["in_appid"] = $logData["in_id"];
  64. unset($logData["in_id"]);
  65. $logData["in_addtime"] = time();
  66. db("app")->strict(false)->insert($logData);
  67. db("user")->where("in_userid", $GLOBALS["xfcms_in_userid"])->inc("in_spaceuse", $in_size)->update();
  68. reJSON(array("id" => bees_encrypt($id)), 1);