install.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. include "../../../system/db.class.php";
  4. $id = intval(bees_decrypt(SafeRequest("id", "get")));
  5. $s = SafeRequest("s", "get");
  6. $ssid = SafeRequest("ssid", "get");
  7. $app = db("appid")->where("in_id", $id)->find();
  8. $user = db("user")->where("in_userid", $app["in_uid"])->find();
  9. if (!$app["in_super"]) {
  10. $user["in_points"] >= $app["in_deduct"] || exit(header("location:" . getlink($id)));
  11. }
  12. $salt = md5($id . "|" . time() . "|" . rand(2, pow(2, 24)));
  13. db("salt")->insert(array("in_aid" => $id, "in_salt" => $salt, "in_time" => time()));
  14. $starttime = date("Y-m-d") . " 00:00:00";
  15. $endtime = date("Y-m-d") . " 23:59:59";
  16. if (!$ssid) {
  17. db("downhistory")->where("appid", $id)->where("addtime", ">", $starttime)->where("addtime", "<", $endtime)->inc("down")->update();
  18. db("appid")->where("in_id", $id)->inc("in_downloads")->update();
  19. if ($s != "s") {
  20. db("user")->where("in_userid", $app["in_uid"])->dec("in_points", $app["in_deduct"])->update();
  21. aclog_save($app["in_uid"], $user["in_points"] - $app["in_deduct"], $user["in_points"], "in_points", "[" . $app["in_id"] . "]-" . $app["in_name"] . "-下载扣除");
  22. }
  23. }
  24. if ($app["in_form"] == "iOS") {
  25. $site_url = "https://" . (IN_TZDOMAIN ?: $_SERVER["HTTP_HOST"]);
  26. if ($app["in_super"]) {
  27. if ($ssid) {
  28. $plist_path = db("super_sign")->where("id", $ssid)->value("plist_path");
  29. if ($plist_path && is_file(IN_ROOT . $plist_path)) {
  30. $url = "itms-services://?action=download-manifest&url=" . $site_url . "/" . $plist_path;
  31. header("location:" . $url);
  32. }
  33. exit("下载链接已失效" . $plist_path);
  34. } else {
  35. $mc_url = "https://" . (IN_DOMAIN ?: $_SERVER["HTTP_HOST"]) . "/index/super_sign/mobileconfig?app_id=" . $id;
  36. $embedded1 = $site_url . "/data/cert/public/embedded1.mobileprovision";
  37. header("location:" . $mc_url);
  38. }
  39. } else {
  40. if (substr($app["in_app"], -13) == ".mobileconfig") {
  41. db("salt")->where("in_salt", $salt)->delete();
  42. header("location:" . getapp($id, 1));
  43. } else {
  44. $plist = $site_url . IN_PATH . "source/pack/upload/install/ios.php/" . $salt . ".plist";
  45. header("location:itms-services://?action=download-manifest&url=" . $plist);
  46. }
  47. }
  48. } else {
  49. if (IN_DENIED && getapp($id) == false) {
  50. header("location:" . IN_PATH . "source/pack/upload/install/proxy.php/" . $salt . ".apk");
  51. } else {
  52. db("salt")->where("in_salt", $salt)->delete();
  53. header("location:" . getapp($id, 1));
  54. }
  55. }