display.ctrl.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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('phoneapp');
  9. $dos = array('rank', 'display', 'switch', 'platform');
  10. $do = in_array($_GPC['do'], $dos) ? $do : 'display';
  11. if ($do == 'platform') {
  12. $url = url('account/display');
  13. $last_uniacid = switch_get_account_display();
  14. if (empty($last_uniacid)) {
  15. itoast('', $url, 'info');
  16. }
  17. if (!empty($last_uniacid) && $last_uniacid != $_W['uniacid']) {
  18. switch_save_account_display($last_uniacid);
  19. }
  20. $permission = permission_account_user_role($_W['uid'], $last_uniacid);
  21. if (empty($permission)) {
  22. itoast('', $url, 'info');
  23. }
  24. $account_info = uni_fetch($last_uniacid);
  25. if ($account_info['type_sign'] == ACCOUNT_TYPE_SIGN || $account_info['type_sign'] == XZAPP_TYPE_SIGN) {
  26. $url = url('home/welcome');
  27. } elseif ($account_info['type_sign'] == WEBAPP_TYPE_SIGN) {
  28. $url = url('webapp/home/display');
  29. } else {
  30. $last_version = miniapp_fetch($last_uniacid);
  31. if (!empty($last_version)) {
  32. $url = url('miniapp/version/home', array('version_id' => $last_version['version']['id']));
  33. }
  34. }
  35. itoast('', $url);
  36. }
  37. if ($do == 'display') {
  38. $account_info = permission_user_account_num($_W['uid']);
  39. $user_founder_info = table('users_founder_own_users')->getFounderByUid($_W['uid']);
  40. $user_founder_uid = !empty($user_founder_info) && !empty($user_founder_info['founder_uid']) ? $user_founder_info['founder_uid'] : 0;
  41. if (user_is_founder($_W['uid'], true)) {
  42. $founders = pdo_getall('users', array('founder_groupid' => 2), array('uid', 'username'), 'uid');
  43. $founder_id = intval($_GPC['founder_id']);
  44. }
  45. $pindex = max(1, intval($_GPC['page']));
  46. $psize = 20;
  47. $title = safe_gpc_string($_GPC['title']);
  48. $type = in_array($_GPC['type'], array_keys($account_all_type_sign)) ? $_GPC['type'] : 'all';
  49. if ($type == 'all') {
  50. $condition = array_keys($account_all_type);
  51. } else {
  52. $condition = $account_all_type_sign[$type]['contain_type'];
  53. }
  54. $table = table('account');
  55. $table->searchWithType($condition);
  56. $keyword = safe_gpc_string($_GPC['keyword']);
  57. if (!empty($keyword)) {
  58. $table->searchWithKeyword($keyword);
  59. }
  60. $letter = safe_gpc_string($_GPC['letter']);
  61. if (!empty($letter) && $letter != '全部') {
  62. $table->searchWithLetter($letter);
  63. }
  64. if ($type == 'all') {
  65. $total_list = array();
  66. foreach ($account_all_type as $account_type) {
  67. $total_list[$account_type['type_sign']] = 0;
  68. }
  69. if (!empty($founder_id)) {
  70. $table->searchWithViceFounder($founder_id);
  71. }
  72. $account_total = $table->searchAccounTotal(false);
  73. $table->searchWithType($condition);
  74. $table->searchWithKeyword($keyword);
  75. $table->searchWithLetter($letter);
  76. foreach ($account_total as $row) {
  77. if (in_array($row['type'], array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH))) {
  78. $total_list['account'] += $row['total'];
  79. } elseif (in_array($row['type'], array(ACCOUNT_TYPE_XZAPP_NORMAL, ACCOUNT_TYPE_XZAPP_AUTH))) {
  80. $total_list['xzapp'] += $row['total'];
  81. } elseif (in_array($row['type'], array(ACCOUNT_TYPE_APP_NORMAL, ACCOUNT_TYPE_APP_AUTH))) {
  82. $total_list['wxapp'] += $row['total'];
  83. } else {
  84. foreach ($account_all_type as $type_key => $type_info) {
  85. if ($type_key == $row['type']) {
  86. $total_list[$type_info['type_sign']] += $row['total'];
  87. }
  88. }
  89. }
  90. }
  91. }
  92. $table->accountRankOrder();
  93. $table->accountUniacidOrder();
  94. $table->searchWithPage($pindex, $psize);
  95. $list = $table->searchAccountList(false);
  96. $total = $table->getLastQueryTotal();
  97. if (!empty($list)) {
  98. if (!user_is_founder($_W['uid'])) {
  99. $account_user_roles = table('uni_account_users')->where('uid', $_W['uid'])->getall('uniacid');
  100. }
  101. foreach($list as $k => &$account) {
  102. $account = uni_fetch($account['uniacid']);
  103. $account['support_version'] = $account->supportVersion;
  104. $account['type_name'] = $account->typeName;
  105. $account['user_role'] = $account_user_roles[$account['uniacid']]['role'];
  106. if ($account['user_role'] == ACCOUNT_MANAGE_NAME_CLERK) {
  107. unset($list[$k]);
  108. continue;
  109. }
  110. if ($account['endtime'] != USER_ENDTIME_GROUP_EMPTY_TYPE && $account['endtime'] != USER_ENDTIME_GROUP_UNLIMIT_TYPE && $account['endtime'] < TIMESTAMP) {
  111. $account['endtime_status'] = 1;
  112. } else {
  113. $account['endtime_status'] = 0;
  114. }
  115. if ($account->typeSign == WXAPP_TYPE_SIGN) {
  116. $version_info = miniapp_version_all($account['uniacid']);
  117. if (empty($version_info)) {
  118. continue;
  119. }
  120. foreach ($version_info as $version_key => $version_val) {
  121. $last_modules = $version_val['last_modules'] ? current($version_val['last_modules']) : array();
  122. }
  123. $modules = current($version_info[0]['modules']);
  124. $account['need_upload'] = $last_modules['version'] < $modules['version'] ? 1 : 0;
  125. }
  126. switch ($account['type']) {
  127. case ACCOUNT_TYPE_APP_NORMAL :
  128. case ACCOUNT_TYPE_APP_AUTH :
  129. case ACCOUNT_TYPE_ALIAPP_NORMAL :
  130. case ACCOUNT_TYPE_BAIDUAPP_NORMAL :
  131. case ACCOUNT_TYPE_TOUTIAOAPP_NORMAL :
  132. $account['versions'] = miniapp_get_some_lastversions($account['uniacid']);
  133. if (!empty($account['versions'])) {
  134. foreach ($account['versions'] as $version) {
  135. if (!empty($version['current'])) {
  136. $account['current_version'] = $version;
  137. }
  138. }
  139. }
  140. break;
  141. case ACCOUNT_TYPE_PHONEAPP_NORMAL :
  142. $account['versions'] = phoneapp_get_some_lastversions($account['uniacid']);
  143. if (!empty($account['versions'])) {
  144. foreach ($account['versions'] as $version) {
  145. if (!empty($version['current'])) {
  146. $account['current_version'] = $version;
  147. }
  148. }
  149. }
  150. break;
  151. }
  152. }
  153. if (!empty($list)) {
  154. $list = array_values($list);
  155. }
  156. }
  157. if ($_W['ispost']) {
  158. iajax(0, $list);
  159. }
  160. template('account/display');
  161. }
  162. if ($do == 'rank' && $_W['isajax'] && $_W['ispost']) {
  163. $uniacid = intval($_GPC['uniacid']);
  164. if (!empty($uniacid)) {
  165. $exist = uni_fetch($uniacid);
  166. if (!$exist) {
  167. iajax(1, '账号信息不存在', '');
  168. }
  169. }
  170. uni_account_rank_top($uniacid);
  171. iajax(0, '更新成功!', '');
  172. }
  173. if ($do == 'switch') {
  174. $uniacid = intval($_GPC['uniacid']);
  175. if (!empty($uniacid)) {
  176. $role = permission_account_user_role($_W['uid'], $uniacid);
  177. if(empty($role)) {
  178. itoast('操作失败, 非法访问.', '', 'error');
  179. }
  180. $account_info = uni_fetch($uniacid);
  181. if ($account_info['endtime'] != USER_ENDTIME_GROUP_EMPTY_TYPE && $account_info['endtime'] != USER_ENDTIME_GROUP_UNLIMIT_TYPE && TIMESTAMP > $account_info['endtime'] && !user_is_founder($_W['uid'], true)) {
  182. $type_sign = $account_info->typeSign;
  183. $expired_message_settings = setting_load('account_expired_message');
  184. $expired_message_settings = $expired_message_settings['account_expired_message'][$type_sign];
  185. if (!empty($expired_message_settings) && !empty($expired_message_settings['status']) && !empty($expired_message_settings['message'])) {
  186. itoast($expired_message_settings['message']);
  187. } else {
  188. itoast('抱歉,您的平台账号服务已过期,请及时联系管理员');
  189. }
  190. }
  191. $type = $account_info['type'];
  192. $module_name = safe_gpc_string($_GPC['module_name']);
  193. $version_id = intval($_GPC['version_id']);
  194. if ($account_info->supportVersion != STATUS_ON) {
  195. if (empty($module_name)) {
  196. $url = url('home/welcome');
  197. if ($type == ACCOUNT_TYPE_WEBAPP_NORMAL) {
  198. $url = url('webapp/home/display');
  199. }
  200. } else {
  201. $url = url('home/welcome/ext', array('m' => $module_name));
  202. $main_uniacid = table('uni_link_uniacid')->getMainUniacid($uniacid, $module_name);
  203. if (!empty($main_uniacid)) {
  204. $uniacid = $main_uniacid;
  205. $account_info = uni_fetch($main_uniacid);
  206. }
  207. }
  208. } else {
  209. if (empty($version_id)) {
  210. if ($type == ACCOUNT_TYPE_PHONEAPP_NORMAL) {
  211. $versions = phoneapp_get_some_lastversions($uniacid);
  212. } else {
  213. $versions = miniapp_get_some_lastversions($uniacid);
  214. }
  215. foreach ($versions as $val) {
  216. if ($val['current']) {
  217. $version_id = $val['id'];
  218. }
  219. }
  220. }
  221. if (!empty($module_name) && !empty($version_id)) {
  222. $url = url('home/welcome/ext/', array('m' => $module_name));
  223. $main_uniacid = table('uni_link_uniacid')->getMainUniacid($uniacid, $module_name);
  224. if (!empty($main_uniacid)) {
  225. $uniacid = $main_uniacid;
  226. $account_info = uni_fetch($main_uniacid);
  227. } else {
  228. $url .= '&version_id=' . $version_id;
  229. }
  230. } else {
  231. miniapp_update_last_use_version($uniacid, $version_id);
  232. $url = url('miniapp/version/home', array('version_id' => $version_id));
  233. }
  234. }
  235. $url .= '&uniacid=' . $uniacid;
  236. if (empty($_GPC['switch_uniacid'])) {
  237. switch_save_account_display($uniacid);
  238. } else {
  239. switch_save_uniacid($uniacid);
  240. }
  241. if (!empty($_GPC['tohome'])) {
  242. $url .= '&tohome=1';
  243. }
  244. if (!empty($_GPC['miniapp_version_referer'])) {
  245. $url .= '&miniapp_version_referer=1';
  246. }
  247. itoast('', $url);
  248. }
  249. }