123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- // by 请勿倒卖,已申请软著,否则追究法律责任
- include "../../system/db.class.php";
- include "../../system/user.php";
- $GLOBALS["userlogined"] || reJSON(-1);
- Chk_authkey();
- $id = isset($_GET["id"]) ? intval($_GET["id"]) : 0;
- $sDownLink = SafeRequest("sDownLink", "post");
- if ($sDownLink) {
- $time = $GLOBALS["xfcms_in_userid"] . "-" . time();
- } else {
- $time = SafeRequest("time", "post");
- }
- preg_match("/^(\\d+\\-\\d+)\$/", $time) || reJSON(-2);
- $tmp = IN_ROOT . "data/tmp/" . $time . "/app.mobileconfig";
- if ($sDownLink) {
- saveRemoteFile(gettimestamp($sDownLink), IN_ROOT . "data/tmp/" . $time . "/", "app.mobileconfig");
- }
- is_file($tmp) || reJSON(-2);
- $in_size = intval(filesize($tmp));
- $explode = explode("-", $time);
- $icontime = md5($explode[0] . "-" . $explode[1] . "-" . rand(2, pow(2, 24))) . ".png";
- $in_app = md5($explode[1] . "-" . $explode[0] . "-" . rand(2, pow(2, 24))) . ".mobileconfig";
- is_file(IN_ROOT . "data/attachment/" . $in_app) && reJSON(-2);
- IN_VERIFY > 0 && $GLOBALS["xfcms_in_verify"] != 1 && reJSON(-3);
- $in_size + $GLOBALS["xfcms_in_spaceuse"] > $GLOBALS["xfcms_in_spacetotal"] && reJSON(-4);
- $mc = file_get_contents($tmp);
- $signedfile = IN_ROOT . "data/attachment/" . $in_app;
- rename($tmp, $signedfile);
- $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]) : "*";
- $in_name = preg_match("/<key>Label<\\/key>([\\s\\S]+?)<string>([\\s\\S]+?)<\\/string>/", $mc, $c) ? SafeSql(detect_encoding($c[2])) : NULL;
- if (!$in_name) {
- $in_name = preg_match("/<key>PayloadDisplayName<\\/key>([\\s\\S]+?)<string>([\\s\\S]+?)<\\/string>/", $mc, $c) ? SafeSql(detect_encoding($c[2])) : "*";
- }
- $in_icon = preg_match("/<key>Icon<\\/key>([\\s\\S]+?)<data>([\\s\\S]+?)<\\/data>/", $mc, $c) ? $c[2] : NULL;
- $basedir = IN_ROOT . "data/image/app";
- $imgdir = date("Y") . "/" . date("m") . "/" . date("d");
- creatdir($basedir . "/" . $imgdir);
- $newfile = $basedir . "/" . $imgdir . "/" . $icontime;
- file_put_contents($newfile, base64_decode($in_icon));
- $in_icon = $imgdir . "/" . $icontime;
- $deduct = getDeduct($in_size);
- $in_originalName = $in_app;
- $in_mnvs = "8.0";
- $in_bsvs = "1.0.0";
- $in_bvs = "1";
- $in_nick = $in_team = "*";
- $in_type = 1;
- $in_udids = "";
- $in_form = "iOS";
- $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());
- $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();
- if ($app) {
- $id = $app["in_id"];
- @unlink(IN_ROOT . "data/image/app/" . $app["in_icon"]);
- db("appid")->where("in_id", $id)->update($data);
- db("app")->where(array("in_appid" => $id))->update(array("in_release" => 0));
- } else {
- $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()));
- $id = db("appid")->insertGetId($data);
- }
- $logData = db("appid")->where("in_id", $id)->find();
- $logData["in_appid"] = $logData["in_id"];
- unset($logData["in_id"]);
- $logData["in_addtime"] = time();
- db("app")->strict(false)->insert($logData);
- db("user")->where("in_userid", $GLOBALS["xfcms_in_userid"])->inc("in_spaceuse", $in_size)->update();
- reJSON(array("id" => bees_encrypt($id)), 1);
|