manage-account.ctrl.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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('module');
  8. load()->model('account');
  9. load()->model('user');
  10. load()->model('cloud');
  11. load()->model('cache');
  12. load()->model('extension');
  13. $dos = array('display', 'setting', 'shortcut', 'enable', 'check_status');
  14. $do = !empty($_GPC['do']) ? $_GPC['do'] : 'display';
  15. $modulelist = uni_modules();
  16. if ($do == 'check_status') {
  17. $modulename = $_GPC['module'];
  18. if (empty($modulename)) {
  19. iajax(0, '', '');
  20. }
  21. $module_status = module_status($modulename);
  22. if (!empty($module_status)) {
  23. isetcookie('module_status:' . $modulename, json_encode($module_status));
  24. }
  25. if ($module_status['ban']) {
  26. iajax(1, '您的站点存在盗版模块, 请删除文件后联系客服');
  27. }
  28. if ($module_status['upgrade']['has_upgrade']) {
  29. iajax(2, $module_status['upgrade']['name'] . '检测最新版为' . $module_status['upgrade']['version'] . ',请尽快更新');
  30. }
  31. iajax(0, '', '');
  32. }
  33. if($do == 'display') {
  34. $pageindex = max(1, intval($_GPC['page']));
  35. $pagesize = 30;
  36. $modules = $displayorder = array();
  37. if (!empty($modulelist)) {
  38. foreach ($modulelist as $name => $row) {
  39. if (!empty($row['issystem'])) {
  40. continue;
  41. }
  42. if (!empty($_GPC['keyword']) && !strexists($row['title'], $_GPC['keyword'])) {
  43. continue;
  44. }
  45. if (!empty($_GPC['letter']) && $row['title_initial'] != $_GPC['letter']) {
  46. continue;
  47. }
  48. $displayorder[$name] = $row['displayorder'];
  49. $modules[$name] = $row;
  50. }
  51. }
  52. array_multisort($displayorder, SORT_DESC, $modules);
  53. template ('module/manage-account');
  54. } elseif ($do == 'shortcut') {
  55. $status = intval($_GPC['shortcut']);
  56. $modulename = $_GPC['modulename'];
  57. $module_enabled = uni_account_module_shortcut_enabled($modulename, $status);
  58. if (is_error($module_enabled)) {
  59. itoast($module_enabled['message'], referer(), 'error');
  60. }
  61. itoast(($status ? '添加' : '取消') . '添加模块快捷操作成功!', referer(), 'success');
  62. } elseif ($do == 'enable') {
  63. $modulename = $_GPC['modulename'];
  64. if(empty($modulelist[$modulename])) {
  65. itoast('抱歉,你操作的模块不能被访问!', '', '');
  66. }
  67. pdo_update('uni_account_modules', array(
  68. 'enabled' => empty($_GPC['enabled']) ? STATUS_OFF : STATUS_ON,
  69. ), array(
  70. 'module' => $modulename,
  71. 'uniacid' => $_W['uniacid']
  72. ));
  73. cache_build_module_info($modulename);
  74. itoast('模块操作成功!', referer(), 'success');
  75. } elseif ($do == 'top') {
  76. $modulename = $_GPC['modulename'];
  77. $module = $modulelist[$modulename];
  78. if(empty($module)) {
  79. itoast('抱歉,你操作的模块不能被访问!', '', '');
  80. }
  81. $max_displayorder = (int)pdo_getcolumn('uni_account_modules', array('uniacid' => $_W['uniacid']), 'MAX(displayorder)');
  82. $module_profile = pdo_get('uni_account_modules', array('module' => $modulename, 'uniacid' => $_W['uniacid']));
  83. if (!empty($module_profile)) {
  84. pdo_update('uni_account_modules', array('displayorder' => ++$max_displayorder), array('id' => $module_profile['id'], 'uniacid' => $_W['uniacid']));
  85. } else {
  86. pdo_insert('uni_account_modules', array(
  87. 'displayorder' => ++$max_displayorder,
  88. 'module' => $modulename,
  89. 'uniacid' => $_W['uniacid'],
  90. 'enabled' => STATUS_ON,
  91. 'shortcut' => STATUS_OFF,
  92. ));
  93. }
  94. cache_build_module_info($modulename);
  95. cache_build_account_modules($_W['uniacid']);
  96. itoast('模块置顶成功', referer(), 'success');
  97. } elseif ($do == 'setting') {
  98. $modulename = $_GPC['m'];
  99. $module = $_W['current_module'] = $modulelist[$modulename];
  100. if(empty($module)) {
  101. itoast('抱歉,你操作的模块不能被访问!', '', '');
  102. }
  103. if(!permission_check_account_user_module($modulename.'_settings', $modulename)) {
  104. itoast('您没有权限进行该操作', '', '');
  105. }
  106. define('IN_MODULE', $modulename);
  107. define('CRUMBS_NAV', 1);
  108. $config = empty($module['config']) ? array() : $module['config'];
  109. if (($module['settings'] == 2) && !is_file(IA_ROOT."/addons/{$module['name']}/developer.cer")) {
  110. if (empty($_W['setting']['site']['key']) || empty($_W['setting']['site']['token'])) {
  111. itoast('站点未注册,请先注册站点。', url('cloud/profile'), 'info');
  112. }
  113. template('module/manage-account-setting');
  114. exit();
  115. }
  116. $obj = WeUtility::createModule($module['name']);
  117. $obj->settingsDisplay($config);
  118. exit();
  119. } elseif ($do == 'setting_params') {
  120. $modulename = safe_gpc_string(trim($_GPC['m']));
  121. $module = module_fetch($modulename);
  122. if (empty($module)) {
  123. iajax(-1, '抱歉,你操作的模块不能被访问!');
  124. }
  125. if ($module['settings'] != 2 || is_file(IA_ROOT."/addons/{$module['name']}/developer.cer")) {
  126. iajax(-1, '模块未开启云参数');
  127. }
  128. if (!permission_check_account_user_module($modulename.'_settings', $modulename)) {
  129. iajax(-1, '您没有权限进行该操作');
  130. }
  131. if (empty($_W['setting']['site']['key']) || empty($_W['setting']['site']['token'])) {
  132. iajax(-1,'站点未注册,请先注册站点。');
  133. }
  134. if (checksubmit('submit')) {
  135. $post = array(
  136. 'setting' => safe_gpc_array($_GPC['setting']),
  137. 'params' => safe_gpc_array($_GPC['params']),
  138. );
  139. if (is_array($post['params'])) {
  140. foreach ($post['params'] as $param) {
  141. if ($param['type'] == 'richtext' && !empty($post['setting'][$param['name']])) {
  142. $post['setting'][$param['name']] = safe_gpc_html(htmlspecialchars_decode($post['setting'][$param['name']], ENT_QUOTES));
  143. }
  144. }
  145. }
  146. $result = cloud_module_setting_save($_W['uniacid'], $module['name'], $post['setting']);
  147. if (is_error($result)) {
  148. iajax(-1, $result['message']);
  149. }
  150. iajax(0, $result);
  151. }
  152. $setting = cloud_module_setting($_W['uniacid'], $module);
  153. if (is_error($setting)) {
  154. iajax(-1, $setting['message']);
  155. }
  156. $setting['setting'] = $module['config'];
  157. iajax(0, $setting);
  158. }