saveInfo.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. // by 请勿倒卖,已申请软著,否则追究法律责任
  3. $GLOBALS["userlogined"] || reJSON("请重新登录!", 404);
  4. Chk_authkey();
  5. $apkName = $apptime = SafeRequest("apkName", "post");
  6. $originalName = SafeRequest("originalName", "post");
  7. $icon = SafeRequest("icon", "post");
  8. $hext = SafeRequest("hext", "post");
  9. $xml_name = SafeRequest("happName", "post");
  10. $xml_bsvs = SafeRequest("hversion", "post");
  11. $xml_bid = SafeRequest("hpackageName", "post");
  12. $xml_bvs = SafeRequest("hversionCode", "post");
  13. $sDownLink = SafeRequest("sDownLink", "post");
  14. $xml_size = SafeRequest("iAppSize", "post");
  15. $xml_mnvs = SafeRequest("MinimumOSVersion", "post");
  16. $id = bees_decrypt(SafeRequest("iLocalId", "post"));
  17. $in_form = $hext == "apk" ? "Android" : "iOS";
  18. $icontime = "";
  19. if (preg_match("/^(data:\\s*image\\/(\\w+);base64,)/", $icon, $result)) {
  20. $img_base64 = str_replace($result[1], "", $icon);
  21. $img_base64 = base64_decode($img_base64);
  22. $fileext = $result[2];
  23. if (in_array(strtolower($fileext), array("pjpeg", "jpeg", "jpg", "gif", "bmp", "png"))) {
  24. $icontime = md5($GLOBALS["xfcms_in_userid"] . "-" . time() . "-" . rand(2, pow(2, 24))) . ".png";
  25. $basedir = IN_ROOT . "data/image/app";
  26. $imgdir = date("Y") . "/" . date("m") . "/" . date("d");
  27. creatdir($basedir . "/" . $imgdir);
  28. $filepath = $basedir . "/" . $imgdir . "/" . $icontime;
  29. $in_icon = $imgdir . "/" . $icontime;
  30. file_put_contents($filepath, $img_base64);
  31. }
  32. }
  33. if ($hext == "ipa") {
  34. $nick = @implode(",", $_POST["TeamId"]);
  35. $team = SafeRequest("TeamName", "post");
  36. $type = SafeRequest("TeamType", "post");
  37. $udids = @implode(",", $_POST["udids"]);
  38. } else {
  39. $nick = $team = $udids = "";
  40. $type = 0;
  41. }
  42. IN_VERIFY > 0 && $GLOBALS["xfcms_in_verify"] != 1 && exit;
  43. $xml_size + $GLOBALS["xfcms_in_spaceuse"] > $GLOBALS["xfcms_in_spacetotal"] && reJSON("应用空间容量不足,请开通或升级会员!", 404);
  44. $deduct = getDeduct($xml_size);
  45. if ($id) {
  46. db("appid")->where("in_id", $id)->value("in_uid") == $GLOBALS["xfcms_in_userid"] || reJSON("您不能更新别人的应用!", 404);
  47. db("appid")->where("in_id", $id)->value("in_bid") == $xml_bid && db("appid")->where("in_id", $id)->value("in_name") == $xml_name || reJSON("不是同一个应用无法更新!", 404);
  48. } else {
  49. $id = db("appid")->where("in_bid", $xml_bid)->where("in_name", $xml_name)->where("in_form", $in_form)->where("in_uid", $GLOBALS["xfcms_in_userid"])->value("in_id");
  50. }
  51. if ($id) {
  52. $old = db("appid")->where("in_id", $id)->find();
  53. @unlink(IN_ROOT . "data/image/app/" . $old["in_icon"]);
  54. db("appid")->where("in_id", $id)->update(array("in_name" => $xml_name, "in_icon" => $in_icon, "in_form" => $in_form, "in_bid" => $xml_bid, "in_mnvs" => $xml_mnvs, "in_bsvs" => $xml_bsvs, "in_bvs" => $xml_bvs, "in_type" => $type, "in_team" => $team, "in_app" => $apptime, "in_originalName" => $originalName, "in_size" => $xml_size, "in_updatetime" => time(), "remote" => 1));
  55. db("app")->where("in_appid", $id)->update(array("in_release" => 0));
  56. } else {
  57. $link = creatLink($id);
  58. $id = db("appid")->insertGetId(array("in_uid" => $GLOBALS["xfcms_in_userid"], "in_uname" => $GLOBALS["xfcms_in_username"], "in_name" => $xml_name, "in_icon" => $in_icon, "in_form" => $in_form, "in_bid" => $xml_bid, "in_mnvs" => $xml_mnvs, "in_bsvs" => $xml_bsvs, "in_bvs" => $xml_bvs, "in_type" => $type, "in_nick" => $nick, "in_team" => $team, "in_udids" => $udids, "in_app" => $apptime, "in_originalName" => $originalName, "in_downloads" => 0, "in_deduct" => $deduct, "in_size" => $xml_size, "in_link" => $link, "in_addtime" => time(), "in_updatetime" => time(), "remote" => 1));
  59. if (!$id) {
  60. reJSON("上传文件失败,请稍后重试", 404);
  61. }
  62. }
  63. db("app")->strict(false)->insert(array("in_uid" => $GLOBALS["xfcms_in_userid"], "in_uname" => $GLOBALS["xfcms_in_username"], "in_name" => $xml_name, "in_appid" => $id, "in_form" => $in_form, "in_bid" => $xml_bid, "in_mnvs" => $xml_mnvs, "in_bsvs" => $xml_bsvs, "in_bvs" => $xml_bvs, "in_type" => $type, "in_nick" => $nick, "in_team" => $team, "in_udids" => $udids, "in_app" => $apptime, "in_originalName" => $originalName, "in_deduct" => $deduct, "in_size" => $xml_size, "in_addtime" => time(), "remote" => 1));
  64. db("user")->where("in_userid", $GLOBALS["xfcms_in_userid"])->inc("in_spaceuse", $xml_size)->update();
  65. reJSON(array("id" => bees_encrypt($id)), 1);