123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- // by 请勿倒卖,已申请软著,否则追究法律责任
- $GLOBALS["userlogined"] || reJSON("请重新登录!", 404);
- Chk_authkey();
- $apkName = $apptime = SafeRequest("apkName", "post");
- $originalName = SafeRequest("originalName", "post");
- $icon = SafeRequest("icon", "post");
- $hext = SafeRequest("hext", "post");
- $xml_name = SafeRequest("happName", "post");
- $xml_bsvs = SafeRequest("hversion", "post");
- $xml_bid = SafeRequest("hpackageName", "post");
- $xml_bvs = SafeRequest("hversionCode", "post");
- $sDownLink = SafeRequest("sDownLink", "post");
- $xml_size = SafeRequest("iAppSize", "post");
- $xml_mnvs = SafeRequest("MinimumOSVersion", "post");
- $id = bees_decrypt(SafeRequest("iLocalId", "post"));
- $in_form = $hext == "apk" ? "Android" : "iOS";
- $icontime = "";
- if (preg_match("/^(data:\\s*image\\/(\\w+);base64,)/", $icon, $result)) {
- $img_base64 = str_replace($result[1], "", $icon);
- $img_base64 = base64_decode($img_base64);
- $fileext = $result[2];
- if (in_array(strtolower($fileext), array("pjpeg", "jpeg", "jpg", "gif", "bmp", "png"))) {
- $icontime = md5($GLOBALS["xfcms_in_userid"] . "-" . time() . "-" . rand(2, pow(2, 24))) . ".png";
- $basedir = IN_ROOT . "data/image/app";
- $imgdir = date("Y") . "/" . date("m") . "/" . date("d");
- creatdir($basedir . "/" . $imgdir);
- $filepath = $basedir . "/" . $imgdir . "/" . $icontime;
- $in_icon = $imgdir . "/" . $icontime;
- file_put_contents($filepath, $img_base64);
- }
- }
- if ($hext == "ipa") {
- $nick = @implode(",", $_POST["TeamId"]);
- $team = SafeRequest("TeamName", "post");
- $type = SafeRequest("TeamType", "post");
- $udids = @implode(",", $_POST["udids"]);
- } else {
- $nick = $team = $udids = "";
- $type = 0;
- }
- IN_VERIFY > 0 && $GLOBALS["xfcms_in_verify"] != 1 && exit;
- $xml_size + $GLOBALS["xfcms_in_spaceuse"] > $GLOBALS["xfcms_in_spacetotal"] && reJSON("应用空间容量不足,请开通或升级会员!", 404);
- $deduct = getDeduct($xml_size);
- if ($id) {
- db("appid")->where("in_id", $id)->value("in_uid") == $GLOBALS["xfcms_in_userid"] || reJSON("您不能更新别人的应用!", 404);
- db("appid")->where("in_id", $id)->value("in_bid") == $xml_bid && db("appid")->where("in_id", $id)->value("in_name") == $xml_name || reJSON("不是同一个应用无法更新!", 404);
- } else {
- $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");
- }
- if ($id) {
- $old = db("appid")->where("in_id", $id)->find();
- @unlink(IN_ROOT . "data/image/app/" . $old["in_icon"]);
- 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));
- db("app")->where("in_appid", $id)->update(array("in_release" => 0));
- } else {
- $link = creatLink($id);
- $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));
- if (!$id) {
- reJSON("上传文件失败,请稍后重试", 404);
- }
- }
- 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));
- db("user")->where("in_userid", $GLOBALS["xfcms_in_userid"])->inc("in_spaceuse", $xml_size)->update();
- reJSON(array("id" => bees_encrypt($id)), 1);
|