sign.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. inapi = ['/source/index/api.php', '/index/ajax_sign/api'];
  2. incert = ['/source/index/cert.php', '/index/ajax_sign/cert'];
  3. var isIE = function () {
  4. if (!!window.ActiveXObject || "ActiveXObject" in window) {
  5. return true;
  6. } else {
  7. return false;
  8. }
  9. };
  10. var ajax = function (conf) {
  11. var xhr = null;
  12. try {
  13. xhr = new ActiveXObject("Msxml2.XMLHTTP");
  14. } catch (e) {
  15. try {
  16. xhr = new ActiveXObject("Microsoft.XMLHTTP");
  17. } catch (e) {
  18. xhr = new XMLHttpRequest();
  19. }
  20. }
  21. xhr.open("GET", conf.url, true);
  22. if (!isIE()) {
  23. xhr.withCredentials = true;
  24. }
  25. xhr.send(null);
  26. xhr.onreadystatechange = function () {
  27. if (xhr.readyState == 4 && xhr.status == 200) {
  28. conf.success(xhr.responseText);
  29. }
  30. };
  31. };
  32. var api_resign = function (_status) {
  33. if (_status < 2) {
  34. var _url = oauth["api"] + inapi[IN_API_VER] + "?status=" + _status + "&site=" + oauth["site"] + "&uid=" + oauth["uid"] + "&id=" + in_id + "&ssl=" + oauth["ssl"] + "&path=" + oauth["path"] + "&ipa=" + oauth["ipa"] + "&replace=" + $("#in_replace").val() + "&suo=" + $("#in_suo").val() + "&yololib=" + oauth["yololib"] + "&newname=" + $("#in_newname").val() + "&cert=" + $("#in_cert").val() + "&charset=" + oauth["charset"] + "&name=" + oauth["name"];
  35. } else {
  36. var _url = oauth["api"] + inapi[IN_API_VER] + "?status=" + _status + "&site=" + oauth["site"] + "&uid=" + oauth["uid"] + "&id=" + in_id;
  37. }
  38. ajax({
  39. url: _url,
  40. success: function (_data) {
  41. if (_data == -1) {
  42. layer.msg("站点未通过授权验证!", 3, 8);
  43. } else if (_data == 1) {
  44. _status < 2 ? sign(0) : location.reload();
  45. }
  46. }
  47. });
  48. };
  49. var get_cert_list = function () {
  50. $.get(oauth["api"] + incert[IN_API_VER], {
  51. uid: oauth["uid"],
  52. type: cert_type
  53. },
  54. function (ret) {
  55. var reg = RegExp('没有');
  56. if (ret.match(reg)) {
  57. $("#in_certs").html(ret);
  58. }
  59. $("#in_cert").html(ret);
  60. });
  61. };
  62. function reset_sign_confirm() {
  63. $.layer({
  64. shade: [0],
  65. area: ["auto", "auto"],
  66. dialog: {
  67. msg: "确定要重置签名吗?",
  68. btns: 2,
  69. type: 4,
  70. btn: ["确定", "取消"],
  71. yes: function () {
  72. reset_sign();
  73. },
  74. no: function () {
  75. layer.msg("已取消重置", 1, 0);
  76. }
  77. }
  78. });
  79. }
  80. function reset_sign() {
  81. var xhr = new XMLHttpRequest();
  82. xhr.open("GET", in_path + "index/ajax_sign/reset?aid=" + in_id, true);
  83. xhr.onreadystatechange = function () {
  84. if (xhr.readyState == 4) {
  85. if (xhr.status == 200) {
  86. if (xhr.responseText == -1) {
  87. layer.msg("请先登录后再操作!", 3, 11);
  88. } else if (xhr.responseText == -2) {
  89. layer.msg("应用不存在或已被删除!", 3, 11);
  90. } else if (xhr.responseText == -3) {
  91. layer.msg("您不能重置别人的应用!", 3, 8);
  92. } else if (xhr.responseText == -4) {
  93. layer.msg("该应用未在进行签名!", 3, 8);
  94. } else {
  95. location.reload();
  96. }
  97. } else {
  98. layer.msg("通讯异常,请检查网络设置!", 3, 3);
  99. }
  100. }
  101. };
  102. xhr.send(null);
  103. }
  104. function sign_confirm() {
  105. $.layer({
  106. shade: [0],
  107. area: ["auto", "auto"],
  108. dialog: {
  109. //msg: '<font color="#000fff">签名将会去除下列文件名注入的签名锁 <br>功能性动态库请勿使用下列文件名注入<br>否则您注入的动态库将失效!<br> sign.data <br> sign.dylib <br> embedded.dylib<br> embedded.png <br> XXGamePlugin <br>如已注入以上名称的动态库请取消签名 <br>并修改功能文件注入名称后重新上传ipa <br>再重新签名!<br><br>确定要开始签名吗?</font>',
  110. msg: '确定要开始签名吗?',
  111. btns: 2,
  112. type: 4,
  113. btn: ["确定", "取消"],
  114. yes: function () {
  115. $("#in_cert").val() == "" ? layer.msg("请选择企业证书", 1, 0) : sign(1);
  116. },
  117. no: function () {
  118. layer.msg("已取消签名", 1, 0);
  119. }
  120. }
  121. });
  122. }
  123. function sign(_check) {
  124. if (remote > 0) {
  125. //layer.msg("不支持云存储签名!", 3, 8);
  126. //return false;
  127. }
  128. var cert = $("#cert_" + $("#in_cert").val()).text();
  129. var xhr = new XMLHttpRequest();
  130. xhr.open("GET", in_path + "index/ajax_sign/sign?check=" + _check + "&cert=" + encodeURIComponent(cert) + "&aid=" + in_id, true);
  131. xhr.onreadystatechange = function () {
  132. if (xhr.readyState == 4) {
  133. if (xhr.status == 200) {
  134. if (xhr.responseText == -1) {
  135. layer.msg("请先登录后再操作!", 3, 11);
  136. } else if (xhr.responseText == -2) {
  137. layer.msg("应用不存在或已被删除!", 3, 11);
  138. } else if (xhr.responseText == -3) {
  139. layer.msg("您不能签名别人的应用!", 3, 8);
  140. } else if (xhr.responseText == -4) {
  141. layer.msg("不能签名Android应用!", 3, 8);
  142. } else if (xhr.responseText == -5) {
  143. layer.msg("该应用未开通企业签名!", 3, 8);
  144. } else if (xhr.responseText == -6) {
  145. layer.msg("该应用补签名额不足!", 3, 8);
  146. } else if (xhr.responseText == -7) {
  147. layer.msg("该应用正在进行签名!", 3, 8);
  148. } else {
  149. _check > 0 ? api_resign(1) : location.reload();
  150. }
  151. } else {
  152. layer.msg("通讯异常,请检查网络设置!", 3, 3);
  153. }
  154. }
  155. };
  156. xhr.send(null);
  157. }
  158. function listen() {
  159. var xhr = new XMLHttpRequest();
  160. xhr.open("GET", in_path + "index/ajax_sign/listen?aid=" + in_id, true);
  161. xhr.onreadystatechange = function () {
  162. if (xhr.readyState == 4 && xhr.status == 200) {
  163. var data = eval("(" + xhr.responseText + ")");
  164. if (xhr.responseText == -1) {
  165. $("#_listen").text("请先登录后再操作!");
  166. } else if (data["status"] == 2) {
  167. api_resign(2);
  168. } else if (data["step"] == "download") {
  169. $("#_listen").text("正在解析文件,请稍等..." + data["percent"] + "%");
  170. } else if (data["step"] == "sign") {
  171. $("#_listen").text("正在进行签名,请稍等..." + data["percent"] + "%");
  172. } else if (data["step"] == "upload") {
  173. $("#_listen").text("正在进行回传,请稍等..." + data["percent"] + "%");
  174. }
  175. }
  176. };
  177. xhr.send(null);
  178. }
  179. function download() {
  180. var xhr = new XMLHttpRequest();
  181. xhr.open("GET", in_path + "index/ajax_sign/download?aid=" + in_id, true);
  182. xhr.onreadystatechange = function () {
  183. if (xhr.readyState == 4) {
  184. if (xhr.status == 200) {
  185. if (xhr.responseText == -1) {
  186. layer.msg("请先登录后再操作!", 3, 11);
  187. } else if (xhr.responseText == -2) {
  188. layer.msg("应用不存在或已被删除!", 3, 11);
  189. } else if (xhr.responseText == -3) {
  190. layer.msg("您不能下载别人的应用!", 3, 8);
  191. } else if (xhr.responseText == -4) {
  192. layer.msg("该应用暂未完成签名!", 3, 8);
  193. } else {
  194. location.href = xhr.responseText;
  195. }
  196. } else {
  197. layer.msg("通讯异常,请检查网络设置!", 3, 3);
  198. }
  199. }
  200. };
  201. xhr.send(null);
  202. }
  203. function purchase(_key) {
  204. var xhr = new XMLHttpRequest();
  205. xhr.open("GET", in_path + "index/ajax_sign/purchase?aid=" + in_id + "&key=" + _key, true);
  206. xhr.onreadystatechange = function () {
  207. if (xhr.readyState == 4) {
  208. if (xhr.status == 200) {
  209. if (xhr.responseText == -1) {
  210. layer.msg("请先登录后再操作!", 3, 11);
  211. } else if (xhr.responseText == -2) {
  212. layer.msg("应用不存在或已被删除!", 3, 11);
  213. } else if (xhr.responseText == -3) {
  214. layer.msg("密钥不正确或已被使用!", 3, 8);
  215. } else if (xhr.responseText == 1) {
  216. location.reload();
  217. }
  218. } else {
  219. layer.msg("通讯异常,请检查网络设置!", 3, 3);
  220. }
  221. }
  222. };
  223. xhr.send(null);
  224. }
  225. function tishi() {
  226. alert('签名开始后请勿切换到其他页面或刷新\n否则可能签名失败,请耐心等待!');
  227. }
  228. function tishi1() {
  229. alert('签名将会去除下列文件名注入的签名锁 \n功能性动态库请勿使用下列文件名注入\n否则您注入的动态库将失效!\n sign.data \n sign.dylib \n embedded.dylib\n embedded.png \n XXGamePlugin \n如已注入以上名称的动态库请取消签名 \n并修改功能文件注入名称后重新上传ipa \n再重新签名!');
  230. }
  231. function change(type) {
  232. var inre = $("#in_replace").val();
  233. if (type == 1) {
  234. $('#check').html('<input type="text" class="col-sm-9 linkform-control" value="*.*|*" id="in_replace" style="display:none;" readonly="true">');
  235. }
  236. if (inre == '*.*|*') {
  237. $('#check').html('<input type="text" class="col-sm-9 link" placeholder="指定特殊签名文件,默认留空!多文件以 | 隔开" id="in_replace"><br><br>');
  238. }
  239. }