front-download.ctrl.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('phoneapp');
  8. load()->classs('cloudapi');
  9. load()->classs('uploadedfile');
  10. $dos = array('front_download', 'getpackage');
  11. $do = in_array($do, $dos) ? $do : 'front_download';
  12. $type = $_GPC['type'] == 'ipa' ? 'ipa' : 'apk';
  13. $version_id = intval($_GPC['version_id']);
  14. $is_module_wxapp = false;
  15. if (!empty($version_id)) {
  16. $version_info = phoneapp_version($version_id);
  17. $module = current($version_info['modules']);
  18. }
  19. if ($do == 'front_download') {
  20. $appurl = $_W['siteroot'].'/app/index.php';
  21. $uptype = $_GPC['uptype'];
  22. $account_info = phoneapp_version($version_id);
  23. $siteurl = $_W['siteroot'].'app/index.php';
  24. if (!empty($account_info['appdomain'])) {
  25. $siteurl = $account_info['appdomain'];
  26. }
  27. $siteinfo = array(
  28. 'name' => $account_info['name'],
  29. 'm'=> $account_info['modules'][0]['name'],
  30. 'uniacid' => $account_info['uniacid'],
  31. 'acid' => $account_info['acid'],
  32. 'version' => $account_info['version'],
  33. 'siteroot' => $siteurl,
  34. );
  35. template('phoneapp/front-download');
  36. }
  37. if ($do == 'getpackage') {
  38. if (empty($version_id)) {
  39. itoast('参数错误!', '', '');
  40. }
  41. $account_info = phoneapp_version($version_id);
  42. if (empty($account_info)) {
  43. itoast('版本不存在!', referer(), 'error');
  44. }
  45. if (count($account_info['modules']) == 0) {
  46. itoast('请先配置模块');
  47. }
  48. $m = current($account_info['modules']);
  49. $m = $m['name'];
  50. $type = $_GPC['type'] == 'apk' ? 'apk' : 'ipa';
  51. $result = phoneapp_getpackage(array('m'=>$m, 'type'=>$_GPC['type']));
  52. if (is_error($result)) {
  53. itoast($result['message'], '', '');
  54. } else {
  55. $filename = $m.'.'.$type;
  56. header('content-type: application/zip');
  57. header('content-disposition: attachment; filename='.$filename);
  58. echo $result['message'];
  59. }
  60. exit;
  61. }