人人商城

welcome.ctrl.php 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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('welcome');
  8. load()->model('module');
  9. load()->model('system');
  10. load()->model('user');
  11. load()->model('miniapp');
  12. load()->model('account');
  13. load()->model('message');
  14. load()->model('visit');
  15. $dos = array('platform', 'system', 'ext', 'get_fans_kpi', 'get_last_modules', 'get_system_upgrade', 'get_upgrade_modules', 'get_module_statistics', 'get_ads', 'get_not_installed_modules', 'system_home', 'set_top', 'add_welcome', 'ignore_update_module');
  16. $do = in_array($do, $dos) ? $do : 'platform';
  17. if ($do == 'get_not_installed_modules') {
  18. $not_installed_modules = module_uninstall_list();
  19. iajax(0, $not_installed_modules);
  20. }
  21. if ($do == 'ext' && $_GPC['m'] != 'store' && !$_GPC['system_welcome']) {
  22. if (!empty($_GPC['version_id'])) {
  23. $version_info = miniapp_version($_GPC['version_id']);
  24. }
  25. $account_api = WeAccount::createByUniacid();
  26. if (is_error($account_api)) {
  27. message($account_api['message'], url('account/display'));
  28. }
  29. $check_manange = $account_api->checkIntoManage();
  30. if (is_error($check_manange)) {
  31. itoast('', $account_api->displayUrl);
  32. }
  33. }
  34. if ($do == 'platform') {
  35. define('FRAME', 'account');
  36. if (!empty($_W['account']['endtime']) && $_W['account']['endtime'] < time() && !user_is_founder($_W['uid'], true)) {
  37. itoast('公众号已到服务期限,请联系管理员并续费', url('account/manage'), 'info');
  38. }
  39. $notices = welcome_notices_get();
  40. template('home/welcome');
  41. }
  42. if ($do == 'system') {
  43. define('FRAME', 'system');
  44. $_W['page']['title'] = '欢迎页 - 系统管理';
  45. if(!$_W['isfounder'] || user_is_vice_founder()){
  46. header('Location: ' . url('account/manage', array('account_type' => 1)), true);
  47. exit;
  48. }
  49. $reductions = system_database_backup();
  50. if (!empty($reductions)) {
  51. $last_backup = array_shift($reductions);
  52. $last_backup_time = $last_backup['time'];
  53. $backup_days = welcome_database_backup_days($last_backup_time);
  54. } else {
  55. $backup_days = 0;
  56. }
  57. template('home/welcome-system');
  58. }
  59. if ($do =='get_module_statistics') {
  60. $install_modules = module_installed_list();
  61. $module_statistics = array(
  62. 'account' => array(
  63. 'total' => array(
  64. 'uninstall' => module_uninstall_total('account'),
  65. 'upgrade' => module_upgrade_total('account'),
  66. 'all' => 0
  67. ),
  68. ),
  69. 'wxapp' => array(
  70. 'total' => array(
  71. 'uninstall' => module_uninstall_total('wxapp'),
  72. 'upgrade' => module_upgrade_total('wxapp'),
  73. 'all' => 0,
  74. )
  75. ),
  76. );
  77. $module_statistics['account']['total']['all'] = $module_statistics['account']['total']['uninstall'] + count((array)$install_modules['account']);
  78. $module_statistics['wxapp']['total']['all'] = $module_statistics['wxapp']['total']['uninstall'] + count((array)$install_modules['wxapp']);
  79. iajax(0, $module_statistics, '');
  80. }
  81. if ($do == 'ext') {
  82. $modulename = $_GPC['m'];
  83. if (!empty($modulename)) {
  84. $_W['current_module'] = module_fetch($modulename);
  85. }
  86. define('FRAME', 'account');
  87. define('IN_MODULE', $modulename);
  88. if ($_GPC['system_welcome'] && $_W['isfounder']) {
  89. define('SYSTEM_WELCOME_MODULE', true);
  90. $frames = buildframes('system_welcome');
  91. } else {
  92. $site = WeUtility::createModule($modulename);
  93. if (!is_error($site)) {
  94. $method = 'welcomeDisplay';
  95. if(method_exists($site, $method)){
  96. define('FRAME', 'module_welcome');
  97. $entries = module_entries($modulename, array('menu', 'home', 'profile', 'shortcut', 'cover', 'mine'));
  98. $site->$method($entries);
  99. exit;
  100. }
  101. }
  102. $frames = buildframes('account');
  103. }
  104. foreach ($frames['section'] as $secion) {
  105. foreach ($secion['menu'] as $menu) {
  106. if (!empty($menu['url'])) {
  107. if (!empty($_W['current_module']['config']['default_entry']) && !strpos($menu['url'], '&eid=' . $_W['current_module']['config']['default_entry'])) {
  108. continue;
  109. }
  110. header('Location: ' . $_W['siteroot'] . 'web/' . $menu['url']);
  111. exit;
  112. }
  113. }
  114. }
  115. template('home/welcome-ext');
  116. }
  117. if ($do == 'get_fans_kpi') {
  118. uni_update_week_stat();
  119. $yesterday = date('Ymd', strtotime('-1 days'));
  120. $yesterday_stat = pdo_get('stat_fans', array('date' => $yesterday, 'uniacid' => $_W['uniacid']));
  121. $yesterday_stat['new'] = intval($yesterday_stat['new']);
  122. $yesterday_stat['cancel'] = intval($yesterday_stat['cancel']);
  123. $yesterday_stat['jing_num'] = intval($yesterday_stat['new']) - intval($yesterday_stat['cancel']);
  124. $yesterday_stat['cumulate'] = intval($yesterday_stat['cumulate']);
  125. $today_stat = pdo_get('stat_fans', array('date' => date('Ymd'), 'uniacid' => $_W['uniacid']));
  126. $today_stat['new'] = intval($today_stat['new']);
  127. $today_stat['cancel'] = intval($today_stat['cancel']);
  128. $today_stat['jing_num'] = $today_stat['new'] - $today_stat['cancel'];
  129. $today_stat['cumulate'] = intval($today_stat['jing_num']) + $yesterday_stat['cumulate'];
  130. if($today_stat['cumulate'] < 0) {
  131. $today_stat['cumulate'] = 0;
  132. }
  133. iajax(0, array('yesterday' => $yesterday_stat, 'today' => $today_stat), '');
  134. }
  135. if ($do == 'get_last_modules') {
  136. $last_modules = welcome_get_last_modules();
  137. if (is_error($last_modules)) {
  138. iajax(1, $last_modules['message'], '');
  139. } else {
  140. iajax(0, $last_modules, '');
  141. }
  142. }
  143. if ($do == 'get_system_upgrade') {
  144. $upgrade = welcome_get_cloud_upgrade();
  145. iajax(0, $upgrade, '');
  146. } elseif ($do == 'get_upgrade_modules') {
  147. module_upgrade_info();
  148. $upgrade_modules = module_upgrade_list();
  149. iajax(0, $upgrade_modules, '');
  150. }
  151. if ($do == 'get_ads') {
  152. $ads = welcome_get_ads();
  153. if (is_error($ads)) {
  154. iajax(1, $ads['message']);
  155. } else {
  156. iajax(0, $ads);
  157. }
  158. }
  159. if ($do == 'system_home') {
  160. define('FRAME', '');
  161. $user_info = user_single($_W['uid']);
  162. $account_num = permission_user_account_num();
  163. $last_accounts_modules = pdo_getall('system_stat_visit', array('uid' => $_W['uid']), array(), '', array('displayorder desc', 'updatetime desc'), 20);
  164. if (!empty($last_accounts_modules)) {
  165. foreach ($last_accounts_modules as &$info) {
  166. if (!empty($info['uniacid'])) {
  167. $info['account'] = uni_fetch($info['uniacid']);
  168. }
  169. if (!empty($info['modulename'])) {
  170. $info['account'] = module_fetch($info['modulename']);
  171. $info['account']['switchurl'] = url('module/display/switch', array('module_name' => $info['modulename']));
  172. unset($info['account']['type']);
  173. }
  174. }
  175. unset($info);
  176. }
  177. $types = array(MESSAGE_ACCOUNT_EXPIRE_TYPE, MESSAGE_WECHAT_EXPIRE_TYPE, MESSAGE_WEBAPP_EXPIRE_TYPE, MESSAGE_USER_EXPIRE_TYPE, MESSAGE_WXAPP_MODULE_UPGRADE);
  178. $messages = pdo_getall('message_notice_log', array('uid' => $_W['uid'], 'type' => $types, 'is_read' => MESSAGE_NOREAD), array(), '', array('id desc'), 10);
  179. $messages = message_list_detail($messages);
  180. template('home/welcome-system-home');
  181. }
  182. if ($do == 'set_top') {
  183. $id = intval($_GPC['id']);
  184. $system_visit_info = pdo_get('system_stat_visit', array('id' => $id));
  185. visit_system_update($system_visit_info, true);
  186. iajax(0, '设置成功', referer());
  187. }
  188. if ($do == 'add_welcome') {
  189. visit_system_update(array('uid' => $_W['uid'], 'uniacid' => intval($_GPC['uniacid']), 'modulename' => safe_gpc_string($_GPC['module'])), true);
  190. itoast(0, referer());
  191. }
  192. if ($do == 'ignore_update_module') {
  193. if (empty($_GPC['name'])) {
  194. iajax(1, '参数错误');
  195. }
  196. $module_info = module_fetch($_GPC['name']);
  197. if (empty($module_info)) {
  198. iajax(1, '参数错误');
  199. }
  200. $upgrade_version = table('modules_cloud')->getByName($module_info['name']);
  201. table('modules_ignore')->add($module_info['name'], $upgrade_version['version']);
  202. iajax(0, '');
  203. }