config.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <?php
  2. //decode by http://dezend.qiling.org QQ 2859470
  3. function strend($str, $sign)
  4. {
  5. $str = trim($str);
  6. $len = strlen($str);
  7. $signend = substr($str, -1, 1);
  8. if ($signend == $sign) {
  9. return substr($str, 0, $len - 1);
  10. } else {
  11. return $str;
  12. }
  13. }
  14. define('CURSCRIPT', 'config');
  15. @set_time_limit(0);
  16. $part = isset($part) ? trim($part) : 'list';
  17. require_once dirname(__FILE__) . '/global.php';
  18. if ($part != 'phpinfo') {
  19. require_once MYMPS_INC . '/db.class.php';
  20. chk_admin_purview('purview_系统配置');
  21. }
  22. if ($part == 'phpinfo') {
  23. $here = '系统环境';
  24. @phpinfo();
  25. } else {
  26. if ($part == 'list') {
  27. chk_admin_purview('purview_系统配置');
  28. require_once dirname(__FILE__) . '/include/config.inc.php';
  29. $here = 'Mymps 系统参数设置';
  30. $res = $db->query('SELECT description,value FROM ' . $db_mymps . 'config WHERE type = \'config\'');
  31. while ($row = $db->fetchRow($res)) {
  32. $config_global[$row['description']] = $row['value'];
  33. }
  34. include mymps_tpl('mymps_config');
  35. } else {
  36. if ($part == 'update') {
  37. require_once dirname(__FILE__) . '/include/config.inc.php';
  38. mymps_delete('config', 'WHERE type = \'config\' AND description != \'cfg_tpl_dir\' AND description != \'screen_index\' AND description != \'screen_cat\' AND description != \'screen_info\' AND description != \'bodybg\' AND description != \'screen_search\' AND description != \'head_style\' AND description != \'cfg_citiesdir\' AND description != \'cfg_redirectpage\' AND description != \'cfg_independency\' AND description != \'cfg_cityshowtype\'');
  39. foreach ($admin_global as $k => $a) {
  40. $_POST[$k] = str_replace('\'', ' ', $_POST[$k]);
  41. $info_k = mhtmlspecialchars(trim($_POST[$k]));
  42. $info_k = str_replace(',', ',', $info_k);
  43. $db->query('INSERT INTO `' . $db_mymps . 'config` (value,description) VALUES (\'' . $info_k . '\',\'' . $k . '\')');
  44. }
  45. update_config_cache();
  46. unset($admin_global);
  47. write_msg('系统参数设置成功!', CURSCRIPT . '.php', 'record');
  48. } else {
  49. if ($part == 'badwords') {
  50. chk_admin_purview('purview_验证过滤点评');
  51. if (trim($action) == 'dopost') {
  52. $cfg_badwords0 = str_replace(',', ',', trim($cfg_badwords0));
  53. $cfg_badwords0 = strend($cfg_badwords0, ',');
  54. $cfg_badwords1 = str_replace(',', ',', trim($cfg_badwords1));
  55. $cfg_badwords2 = intval($cfg_badwords2);
  56. mymps_delete('badwords');
  57. $db->query('INSERT INTO `' . $db_mymps . 'badwords` (words,view,ifcheck) VALUES (\'' . $cfg_badwords0 . '\',\'' . $cfg_badwords1 . '\',\'' . $cfg_badwords2 . '\')');
  58. clear_cache_files('badwords');
  59. write_msg('词语过滤设置成功!', 'config.php?part=badwords', 'write_record');
  60. } else {
  61. $here = '违禁词语过滤设置';
  62. $res = $db->query('SELECT words,view,ifcheck FROM ' . $db_mymps . 'badwords');
  63. while ($row = $db->fetchRow($res)) {
  64. $filter['words'] = $row['words'];
  65. $filter['view'] = $row['view'];
  66. $filter['ifcheck'] = $row['ifcheck'];
  67. }
  68. include mymps_tpl($part);
  69. }
  70. } else {
  71. if ($part == 'commentsettings') {
  72. if ($action == 'do_post') {
  73. $db->query('DELETE FROM `' . $db_mymps . 'config` WHERE description = \'comment\' AND type = \'comment\'');
  74. $db->query('INSERT INTO `' . $db_mymps . 'config` (description,value,type) values (\'comment\',\'' . serialize($comment) . '\',\'comment\')');
  75. clear_cache_files('commentsettings');
  76. write_msg('网友评论点评设置更新成功!', 'config.php?part=commentsettings', 'WriteRecord');
  77. } else {
  78. $here = '网友评论点评设置';
  79. $comment = $db->getOne('SELECT value FROM `' . $db_mymps . 'config` WHERE type=\'comment\' AND description = \'comment\'');
  80. $comment = $comment ? $charset == 'utf-8' ? utf8_unserialize($comment) : unserialize($comment) : array();
  81. include mymps_tpl($part);
  82. }
  83. } else {
  84. if ($part == 'cache_sys') {
  85. chk_admin_purview('purview_缓存设置');
  86. $here = '数据缓存';
  87. $cachearray = array('write_admin_cache' => '更新管理员缓存', 'updateadvertisement' => '更新广告缓存', 'write_cron_cache' => '更新定时任务缓存', 'write_checkanswer_cache' => '更新验证问答缓存', 'update_checkanswer_settings' => '更新验证问答设置缓存', 'update_jswizard_settings' => '更新数据调用设置缓存', 'write_jswizard_cache' => '更新数据调用项目缓存', 'write_authcode_cache' => '更新验证码设置缓存', 'write_plugin_cache' => '更新插件缓存', 'write_insidelink_cache' => '更新站内文字链接缓存', 'write_qqlogin_cache' => '更新QQ登录接口设置缓存', 'write_wxlogin_cache' => '更新微信登录接口设置缓存', 'write_cats_js' => '更新栏目分类模板JS调用');
  88. include mymps_tpl('cache_sys');
  89. } else {
  90. if ($part == 'cache_update') {
  91. if (is_array($updatecache)) {
  92. foreach ($updatecache as $k => $v) {
  93. if ($v == 'tpl_caches') {
  94. $k1 = clear_tpl_files(5, $ext);
  95. $k2 = clear_tpl_files(4, $ext);
  96. $k3 = clear_tpl_files(2, $ext);
  97. $msg .= '成功清除网页缓存文件' . ($k1 + $k2 + $k3) . '个';
  98. } else {
  99. if ($v == 'tpl_compiles') {
  100. $msg .= '<br />成功清除模板编译文件' . clear_tpl_files(3, $ext) . '个';
  101. }
  102. }
  103. }
  104. }
  105. write_msg($msg, $return_url ? $return_url : '?part=cache');
  106. } else {
  107. if ($part == 'cache_sysupdate') {
  108. @set_time_limit(0);
  109. if (is_array($updatecache)) {
  110. $count = clear_cache_files();
  111. foreach ($updatecache as $k => $v) {
  112. switch ($v) {
  113. case 'write_admin_cache':
  114. write_admin_cache();
  115. break;
  116. case 'updateadvertisement':
  117. updateadvertisement();
  118. break;
  119. case 'write_cron_cache':
  120. write_cron_cache();
  121. break;
  122. case 'write_checkanswer_cache':
  123. write_checkanswer_cache();
  124. break;
  125. case 'update_checkanswer_settings':
  126. update_checkanswer_settings();
  127. break;
  128. case 'update_jswizard_settings':
  129. update_jswizard_settings();
  130. break;
  131. case 'write_jswizard_cache':
  132. write_jswizard_cache();
  133. break;
  134. case 'write_authcode_cache':
  135. write_authcode_cache();
  136. break;
  137. case 'write_plugin_cache':
  138. write_plugin_cache();
  139. break;
  140. case 'write_insidelink_cache':
  141. write_insidelink_cache();
  142. break;
  143. case 'write_qqlogin_cache':
  144. write_qqlogin_cache();
  145. break;
  146. case 'write_wxlogin_cache':
  147. write_wxlogin_cache();
  148. break;
  149. case 'write_cats_js':
  150. write_cats_js();
  151. break;
  152. }
  153. }
  154. }
  155. $updatecache = NULL;
  156. write_msg('系统缓存更新成功!共清除缓存文件' . $count . '个', $return_url ? $return_url : '?part=cache_sys');
  157. } else {
  158. if ($part == 'cache') {
  159. require_once dirname(__FILE__) . '/include/cache.inc.php';
  160. chk_admin_purview('purview_缓存设置');
  161. $cache = get_cache_config();
  162. $here = '页面缓存';
  163. include mymps_tpl('cache');
  164. } else {
  165. if ($part == 'cacheupdate') {
  166. mymps_delete('cache');
  167. clear_cache_files('cache');
  168. require_once dirname(__FILE__) . '/include/cache.inc.php';
  169. foreach ($admin_cache as $q => $w) {
  170. foreach ($w as $k => $a) {
  171. $cpage = $k;
  172. $ctime = intval($_POST[$k . '_time']);
  173. $copen = intval($_POST[$k . '_open']);
  174. $db->query('INSERT INTO `' . $db_mymps . 'cache` (page,time,open) VALUES (\'' . $cpage . '\',\'' . $ctime . '\',\'' . $copen . '\')');
  175. }
  176. }
  177. write_msg('系统缓存设置成功!', 'config.php?part=cache', 'record');
  178. } else {
  179. if ($part == 'imgcode') {
  180. chk_admin_purview('purview_验证过滤点评');
  181. if (trim($action) == 'do_post') {
  182. $db->query('DELETE FROM `' . $db_mymps . 'config` WHERE type = \'authcode\'');
  183. if (is_array($settingsnew['open'])) {
  184. foreach ($settingsnew['open'] as $key => $val) {
  185. $db->query('INSERT INTO `' . $db_mymps . 'config` (description,value,type) values (\'' . $key . '\',\'' . $val . '\',\'authcode\')');
  186. }
  187. }
  188. $settingsnew['type'] = $settingsnew['type'] != '' ? $settingsnew['type'] : 'engber';
  189. $db->query('INSERT INTO `' . $db_mymps . 'config` (description,value,type) values (\'type\',\'' . $settingsnew['type'] . '\',\'authcode\')');
  190. foreach (array('noise', 'line', 'snow', 'distort', 'incline', 'close', 'number') as $key) {
  191. $db->query('INSERT INTO `' . $db_mymps . 'config` (description,value,type) values (\'' . $key . '\',\'' . $settingsnew[$key] . '\',\'authcode\')');
  192. }
  193. write_authcode_cache();
  194. write_msg('验证码设置更新成功!', '?part=imgcode', 'write_record');
  195. } else {
  196. $here = '验证码显示控制';
  197. $query = $db->query('SELECT * FROM `' . $db_mymps . 'config` WHERE type = \'authcode\'');
  198. while ($row = $db->fetchRow($query)) {
  199. $res[$row['description']] = $row['value'];
  200. }
  201. include mymps_tpl('mymps_' . $part);
  202. }
  203. } else {
  204. if ($part == 'checkask') {
  205. chk_admin_purview('purview_验证过滤点评');
  206. if (trim($action) == 'do_post') {
  207. mymps_delete('config', 'WHERE type = \'checkanswe\'');
  208. $db->query('INSERT INTO `' . $db_mymps . 'config` (description,value,type)VALUES(\'whenregister\',\'' . $whenregister . '\',\'checkanswe\')');
  209. $db->query('INSERT INTO `' . $db_mymps . 'config` (description,value,type)VALUES(\'whenpost\',\'' . $whenpost . '\',\'checkanswe\')');
  210. if (is_array($question)) {
  211. foreach ($question as $key => $q) {
  212. $q = trim($q);
  213. $a = cutstr(mhtmlspecialchars(trim($answer[$key])), 50);
  214. if ($q && $a) {
  215. $db->query('UPDATE `' . $db_mymps . 'checkanswer` SET question=\'' . $q . '\', answer=\'' . $a . '\' WHERE id=\'' . $key . '\'');
  216. }
  217. }
  218. }
  219. if (is_array($newquestion) && is_array($newanswer)) {
  220. foreach ($newquestion as $key => $q) {
  221. $q = trim($q);
  222. $a = cutstr(mhtmlspecialchars(trim($newanswer[$key])), 50);
  223. if ($q && $a) {
  224. $db->query('INSERT INTO' . "\t" . '`' . $db_mymps . 'checkanswer` (question, answer) VALUES (\'' . $q . '\', \'' . $a . '\')');
  225. }
  226. }
  227. }
  228. if (is_array($delete)) {
  229. $db->query('DELETE FROM `' . $db_mymps . 'checkanswer` WHERE ' . create_in($delete, 'id'));
  230. }
  231. write_checkanswer_cache();
  232. update_checkanswer_settings();
  233. write_msg('验证问答设置更新成功!', '?part=checkask', 'write_record');
  234. } else {
  235. $here = '验证问答设置';
  236. $c = $db->getAll('SELECT * FROM `' . $db_mymps . 'checkanswer` ORDER BY id DESC');
  237. $res = $db->query('SELECT description,value FROM ' . $db_mymps . 'config WHERE type = \'checkanswe\'');
  238. while ($row = $db->fetchRow($res)) {
  239. $when[$row['description']] = $row['value'];
  240. }
  241. include mymps_tpl('mymps_' . $part);
  242. }
  243. } else {
  244. unknown_err_msg();
  245. }
  246. }
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. }
  254. }
  255. }
  256. }
  257. is_object($db) && $db->Close();
  258. $db = $mymps_global = $part = $action = $here = NULL;