123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- // by 请勿倒卖,已申请软著,否则追究法律责任
- error_reporting(0);
- include "../../system/db.class.php";
- include "../../system/user.php";
- Chk_authkey();
- $GLOBALS["userlogined"] || reJSON(-1);
- $id = $_POST["id"] ? bees_decrypt(SafeRequest("id", "post")) : 0;
- $time = SafeRequest("time", "post");
- $filename = SafeRequest("filename", "post");
- preg_match("/^(\\d+\\-\\d+)\$/", $time) || reJSON(-2);
- $tmp = IN_ROOT . "data/tmp/" . $time . "/app.apk";
- 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";
- $apptime = md5($explode[1] . "-" . $explode[0] . "-" . rand(2, pow(2, 24))) . ".apk";
- is_file(IN_ROOT . "data/attachment/" . $apptime) && reJSON(-2);
- $in_size + $GLOBALS["xfcms_in_spaceuse"] > $GLOBALS["xfcms_in_spacetotal"] && reJSON(-4);
- $originalName = SafeRequest("originalName", "post");
- $icon = SafeRequest("icon", "post");
- if (strpos($icon, "data:image/png;base64") === false) {
- $icon = pack("H*", $icon);
- }
- $ext = SafeRequest("ext", "post");
- $in_name = SafeRequest("appName", "post");
- $in_bsvs = SafeRequest("version", "post");
- $in_bid = SafeRequest("packageName", "post");
- $in_bvs = SafeRequest("versionCode", "post");
- $in_size = SafeRequest("fileSize", "post");
- $in_mnvs = SafeRequest("minSdkVersion", "post");
- $in_form = $ext == "apk" ? "Android" : "iOS";
- 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"))) {
- $basedir = IN_ROOT . "data/image/app";
- $imgdir = date("Y/m/d");
- creatdir($basedir . "/" . $imgdir);
- $filepath = $basedir . "/" . $imgdir . "/" . $icontime;
- $in_icon = $imgdir . "/" . $icontime;
- file_put_contents($filepath, $img_base64);
- }
- }
- $in_nick = $in_team = $in_udids = "";
- $type = 0;
- $function = PHP_OS == "Linux" ? "rename" : "copy";
- $function($tmp, IN_ROOT . "data/attachment/" . $apptime);
- $deduct = getDeduct($in_size);
- $data = array("in_name" => $in_name, "in_type" => $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_icon" => $in_icon, "in_app" => $apptime, "in_deduct" => $deduct, "in_originalName" => $filename, "in_updatetime" => time(), "remote" => 0);
- $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"];
- db("app")->where("in_appid", $id)->update(array("in_release" => "0"));
- db("appid")->where("in_id", $id)->update($data);
- @unlink(IN_ROOT . "data/image/app/" . $app["in_icon"]);
- } else {
- $data = array_merge($data, array("in_uid" => $GLOBALS["xfcms_in_userid"], "in_uname" => $GLOBALS["xfcms_in_username"], "in_udids" => $in_udids, "in_link" => creatLink(), "in_deduct" => $deduct, "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);
|