where("in_adminid", $aid)->value("in_adminid") || db("admin")->where("in_adminid", $aid)->value("in_adminpassword") !== $apw) { exit("-2"); } $path = IN_ROOT . "data/tmp/" . $time . "/"; creatdir($path); $dir = basename($_FILES["file"]["name"], ".mobileprovision"); $file = $path . $dir . ".mobileprovision"; @move_uploaded_file($_FILES["file"]["tmp_name"], $file); $mp = @file_get_contents($file); $iden = preg_match("/application-identifier<\\/key>([\\s\\S]+?)([\\s\\S]+?)<\\/string>/", $mp, $m) ? $m[2] : NULL; $name = preg_match("/TeamName<\\/key>([\\s\\S]+?)([\\s\\S]+?)<\\/string>/", $mp, $m) ? mb_convert_encoding($m[2], set_chars(), "HTML-ENTITIES") : NULL; $pl = @file_get_contents(IN_ROOT . "static/app/cert.plist"); $pl = str_replace(array("[iden]", "\r"), array($iden, ""), $pl); @fwrite(fopen($path . $dir . ".plist", "w"), $pl); $sh = @file_get_contents(IN_ROOT . "static/app/cert.sh"); $sh = str_replace(array("[name]", "[cert]", "\r"), array($name, $dir, ""), $sh); @fwrite(fopen($path . $dir . ".sh", "w"), $sh); include_once "../zip/zip.php"; $zip = new PclZip(IN_ROOT . "data/cert/" . $dir . ".zip"); if ($zip->create($path, PCLZIP_OPT_REMOVE_PATH, $path)) { echo "{'iden':'" . $iden . "','name':'" . $name . "','dir':'" . $dir . "'}"; } } else { echo "-1"; } }