home.ctrl.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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('miniapp');
  8. load()->model('mc');
  9. $dos = array('nav', 'slide', 'commend', 'wxapp_web', 'wxappweb_pay', 'wxappweb_pay_result', 'package_app', 'go_paycenter', 'oauth', 'credit_info');
  10. $do = in_array($_GPC['do'], $dos) ? $_GPC['do'] : 'nav';
  11. $multiid = intval($_GPC['t']);
  12. if ($do == 'nav') {
  13. $navs = pdo_getall('site_nav', array(
  14. 'uniacid' => $_W['uniacid'],
  15. 'multiid' => $multiid,
  16. 'status' => 1,
  17. 'icon !=' => '',
  18. ), array('url', 'name', 'icon'), '', 'displayorder DESC');
  19. if (!empty($navs)) {
  20. foreach ($navs as $i => &$row) {
  21. $row['icon'] = tomedia($row['icon']);
  22. }
  23. }
  24. message(error(0, $navs), '', 'ajax');
  25. } elseif ($do == 'slide') {
  26. $slide = pdo_getall('site_slide', array(
  27. 'uniacid' => $_W['uniacid'],
  28. 'multiid' => $multiid,
  29. ), array('url', 'title', 'thumb'), '', 'displayorder DESC');
  30. if (!empty($slide)) {
  31. foreach ($slide as $i => &$row) {
  32. $row['thumb'] = tomedia($row['thumb']);
  33. }
  34. }
  35. message(error(0, $slide), '', 'ajax');
  36. } elseif ($do == 'commend') {
  37. //获取一级分类
  38. $category = pdo_getall('site_category', array(
  39. 'uniacid' => $_W['uniacid'],
  40. 'multiid' => $multiid,
  41. ), array('id', 'name', 'parentid'), '', 'displayorder DESC');
  42. //一级分类不能添加文章,推荐时获取到其子类
  43. if (!empty($category)) {
  44. foreach ($category as $id => &$category_row) {
  45. if (empty($category_row['parentid'])) {
  46. $condition['pcate'] = $category_row['id'];
  47. } else {
  48. $condition['ccate'] = $category_row['id'];
  49. }
  50. $category_row['article'] = pdo_getall('site_article', $condition, array('id', 'title', 'thumb'), '', 'displayorder DESC', array(8));
  51. if (!empty($category_row['article'])) {
  52. foreach ($category_row['article'] as &$row) {
  53. $row['thumb'] = tomedia($row['thumb']);
  54. }
  55. } else {
  56. unset($category[$id]);
  57. }
  58. }
  59. }
  60. message(error(0, $category), '', 'ajax');
  61. }
  62. if ($do == 'wxapp_web') {
  63. $version = trim($_GPC['v']);
  64. $version_info = miniapp_version_by_version($version);
  65. $url = $_GPC['url'];
  66. if (empty($url)) {
  67. //无需查询绑定域名 因为本do方法就是根据小程序域名访问的
  68. if (count($version_info['modules']) > 1) {
  69. //多模块打包入口
  70. $url = murl('wxapp/home/package_app', array('v'=>$version)); } else {
  71. if (!empty($version_info['modules'])) {
  72. foreach ($version_info['modules'] as $module) {
  73. if (!empty($module['account']) && intval($module['account']['uniacid']) > 0) {
  74. $_W['uniacid'] = $module['account']['uniacid'];
  75. $_W['account']['link_uniacid'] = $module['account']['uniacid'];
  76. }
  77. }
  78. }
  79. $url = murl('entry', array('eid'=>$version_info['entry_id']), true, true);
  80. }
  81. }
  82. if ($url) {
  83. setcookie(session_name(), $_W['session_id']);
  84. header('Location:' . $url);
  85. exit;
  86. }
  87. message('找不到模块入口', 'refresh', 'error');
  88. }
  89. if ($do == 'package_app') {
  90. $version = trim($_GPC['v']);
  91. $version_info = miniapp_version_by_version($version);
  92. $version_info['modules'] = array_map(function($module) {
  93. $module['url'] = murl('entry', array('eid'=>$module['defaultentry']), true, true);
  94. return $module;
  95. }, $version_info['modules']);
  96. $version_info['quickmenu']['menus'] = array_map(function($menu){
  97. $menu['url'] = murl('entry', array('eid'=>$menu['defaultentry']), true, true);
  98. return $menu;
  99. }, $version_info['quickmenu']['menus']);
  100. template('wxapp/wxapp');
  101. }
  102. if ($do == 'wxappweb_pay') {
  103. $site = WeUtility::createModuleWxapp('core');
  104. $site->doPagePay();
  105. }
  106. if ($do == 'wxappweb_pay_result') {
  107. $site = WeUtility::createModuleWxapp('core');
  108. $site->doPagePayResult();
  109. }
  110. if ($do == 'go_paycenter') {
  111. $plid = intval($_GPC['plid']);
  112. $params = pdo_get('core_paylog', array('plid' => $plid));
  113. $params['title'] = safe_gpc_string($_GPC['title']);
  114. template('common/paycenter');
  115. }
  116. if ($do == 'oauth') {
  117. $url = safe_gpc_url($_GPC['url'], false);
  118. $oauth_userinfo = mc_oauth_account_userinfo($url);
  119. if (is_error($oauth_userinfo)) {
  120. message($oauth_userinfo['message'], $url, 'info');
  121. }
  122. header('Location: ' . $url);
  123. }
  124. if ($do == 'credit_info') {
  125. $member_info = mc_fetch($_W['member']['uid'], array('credit2'));
  126. $credit2 = !empty($member_info['credit2']) ? $member_info['credit2'] : 0;
  127. message(error(0, $credit2), '', 'ajax');
  128. }