123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- // by 请勿倒卖,已申请软著,否则追究法律责任
- namespace PngFile;
- require_once "depng/pngCompote.php";
- namespace CFPropertyList;
- require_once "deplist/CFPropertyList.php";
- include "../../system/db.class.php";
- error_reporting(0);
- if (empty($_COOKIE["in_adminid"]) || empty($_COOKIE["in_adminname"]) || empty($_COOKIE["in_adminpassword"]) || empty($_COOKIE["in_permission"]) || empty($_COOKIE["in_adminexpire"]) || !db("admin")->where("in_adminid", intval($_COOKIE["in_adminid"]))->value("in_adminid") || md5(db("admin")->where("in_adminid", intval($_COOKIE["in_adminid"]))->value("in_adminpassword")) !== $_COOKIE["in_adminpassword"]) {
- exit("-1");
- }
- $time = $_GET["time"];
- $tmp = IN_ROOT . "data/tmp/" . $time . ".ipa";
- $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))) . ".ipa";
- $dir = IN_ROOT . "data/tmp/" . $time . "/Payload";
- if (is_dir($dir)) {
- rename($tmp, IN_ROOT . "data/attachment/" . $apptime);
- $d = NULL;
- $h = opendir($dir);
- while ($f = readdir($h)) {
- if ($f != "." && $f != ".." && is_dir($dir . "/" . $f)) {
- $d = $dir . "/" . $f;
- }
- }
- closedir($h);
- $info = file_get_contents($d . "/Info.plist");
- $plist = new CFPropertyList();
- $plist->parse($info);
- $plist = $plist->toArray();
- $xml_size = $_GET["size"];
- $xml_name = detect_encoding(isset($plist["CFBundleDisplayName"]) ? $plist["CFBundleDisplayName"] : $plist["CFBundleName"]);
- $xml_mnvs = $plist["MinimumOSVersion"];
- $xml_bid = $plist["CFBundleIdentifier"];
- $xml_bsvs = $plist["CFBundleShortVersionString"];
- $xml_bvs = $plist["CFBundleVersion"];
- $newfile = IN_ROOT . "data/attachment/" . $icontime;
- $icon = $plist["CFBundleIcons"]["CFBundlePrimaryIcon"]["CFBundleIconFiles"];
- if (!$icon) {
- $icon = $plist["CFBundleIconFiles"];
- if (!$icon) {
- $icon = $plist["CFBundleIconFiles~ipad"];
- }
- }
- if (preg_match("/\\./", $icon[0])) {
- $cvt = is_file($d . "/" . $icon[0]) ? "trim" : "strtolower";
- for ($i = 0; $i < count($icon); $i++) {
- if (is_file($d . "/" . $cvt($icon[$i]))) {
- $big[] = filesize($d . "/" . $cvt($icon[$i]));
- $small[] = filesize($d . "/" . $cvt($icon[$i]));
- }
- }
- rsort($big);
- sort($small);
- for ($p = 0; $p < count($icon); $p++) {
- if ($big[0] == filesize($d . "/" . $cvt($icon[$p]))) {
- $bigfile = $d . "/" . $cvt($icon[$p]);
- }
- if ($small[0] == filesize($d . "/" . $cvt($icon[$p]))) {
- $smallfile = $d . "/" . $cvt($icon[$p]);
- }
- }
- } else {
- $ext = is_file($d . "/" . $icon[0] . ".png") ? ".png" : "@2x.png";
- for ($i = 0; $i < count($icon); $i++) {
- if (is_file($d . "/" . $icon[$i] . $ext)) {
- $big[] = filesize($d . "/" . $icon[$i] . $ext);
- $small[] = filesize($d . "/" . $icon[$i] . $ext);
- }
- }
- rsort($big);
- sort($small);
- for ($p = 0; $p < count($icon); $p++) {
- if ($big[0] == filesize($d . "/" . $icon[$p] . $ext)) {
- $bigfile = is_file($d . "/" . $icon[$p] . "@3x.png") ? $d . "/" . $icon[$p] . "@3x.png" : $d . "/" . $icon[$p] . $ext;
- }
- if ($small[0] == filesize($d . "/" . $icon[$p] . $ext)) {
- $smallfile = preg_match("/AppIcon20x20/", $icon[$p]) ? $d . "/" . $icon[$p] . "@3x.png" : $d . "/" . $icon[$p] . $ext;
- }
- }
- }
- $png = new \PngFile\PngFile($smallfile);
- if (!$png->revertIphone($newfile)) {
- if (!rename($bigfile, $newfile)) {
- if ($plist["CFBundleIconFile"]) {
- if (preg_match("/\\./", $plist["CFBundleIconFile"])) {
- rename($d . "/" . $plist["CFBundleIconFile"], $newfile);
- } else {
- rename($d . "/" . $plist["CFBundleIconFile"] . ".png", $newfile);
- }
- } else {
- copy(IN_ROOT . "static/index/image/iOS.png", $newfile);
- }
- }
- }
- $em = file_get_contents($d . "/embedded.mobileprovision");
- rename($d . "/embedded.mobileprovision", str_replace(".png", ".mobileprovision", $newfile));
- $xml_nick = preg_match("/<key>Name<\\/key>\r\n([\\s\\S]+?)<string>([\\s\\S]+?)<\\/string>/", $em, $m) ? mb_convert_encoding($m[2], set_chars(), "HTML-ENTITIES") : "*";
- $xml_type = preg_match("/^iOS Team Provisioning Profile:/", $xml_nick) ? 0 : 1;
- $xml_team = preg_match("/<key>TeamName<\\/key>\r\n([\\s\\S]+?)<string>([\\s\\S]+?)<\\/string>/", $em, $m) ? mb_convert_encoding($m[2], set_chars(), "HTML-ENTITIES") : "*";
- echo "{'name':'" . $xml_name . "','mnvs':'" . $xml_mnvs . "','bid':'" . $xml_bid . "','bsvs':'" . $xml_bsvs . "','bvs':'" . $xml_bvs . "','form':'iOS','nick':'" . $xml_nick . "','type':'" . $xml_type . "','team':'" . $xml_team . "','icon':'" . $icontime . "','app':'" . $apptime . "','size':'" . $xml_size . "'}";
- }
|