人人商城

front-download.ctrl.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. $_W['page']['title'] = 'APP下载 - APP - 管理';
  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. }
  18. if ($do == 'front_download') {
  19. $appurl = $_W['siteroot'].'/app/index.php';
  20. $uptype = $_GPC['uptype'];
  21. $account_info = phoneapp_version($version_id);
  22. $siteurl = $_W['siteroot'].'app/index.php';
  23. if (!empty($account_info['appdomain'])) {
  24. $siteurl = $account_info['appdomain'];
  25. }
  26. $siteinfo = array(
  27. 'name' => $account_info['name'],
  28. 'm'=> $account_info['modules'][0]['name'],
  29. 'uniacid' => $account_info['uniacid'],
  30. 'acid' => $account_info['acid'],
  31. 'version' => $account_info['version'],
  32. 'siteroot' => $siteurl,
  33. );
  34. template('phoneapp/front-download');
  35. }
  36. if ($do == 'getpackage') {
  37. if (empty($version_id)) {
  38. itoast('参数错误!', '', '');
  39. }
  40. $account_info = phoneapp_version($version_id);
  41. if (empty($account_info)) {
  42. itoast('版本不存在!', referer(), 'error');
  43. }
  44. if (count($account_info['modules']) == 0) {
  45. itoast('请先配置模块');
  46. }
  47. $m = $account_info['modules'][0]['name'];
  48. $type = $_GPC['type'] == 'apk' ? 'apk' : 'ipa';
  49. $result = phoneapp_getpackage(array('m'=>$m, 'type'=>$_GPC['type']));
  50. if (is_error($result)) {
  51. itoast($result['message'], '', '');
  52. } else {
  53. $filename = $m.'.'.$type;
  54. header('content-type: application/zip');
  55. header('content-disposition: attachment; filename='.$filename);
  56. echo $result['message'];
  57. }
  58. exit;
  59. }