admincp_tools.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: admincp_tools.php 33301 2013-05-23 03:10:20Z andyzheng $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. cpheader();
  12. if($operation == 'updatecache') {
  13. $step = max(1, intval($_GET['step']));
  14. shownav('tools', 'nav_updatecache');
  15. showsubmenusteps('nav_updatecache', array(
  16. array('nav_updatecache_confirm', $step == 1),
  17. array('nav_updatecache_verify', $step == 2),
  18. array('nav_updatecache_completed', $step == 3)
  19. ));
  20. showtips('tools_updatecache_tips');
  21. if($step == 1) {
  22. cpmsg("<input type=\"checkbox\" name=\"type[]\" value=\"data\" id=\"datacache\" class=\"checkbox\" checked /><label for=\"datacache\">".$lang[tools_updatecache_data]."</label><input type=\"checkbox\" name=\"type[]\" value=\"tpl\" id=\"tplcache\" class=\"checkbox\" checked /><label for=\"tplcache\">".$lang[tools_updatecache_tpl]."</label><input type=\"checkbox\" name=\"type[]\" value=\"blockclass\" id=\"blockclasscache\" class=\"checkbox\" /><label for=\"blockclasscache\">".$lang[tools_updatecache_blockclass].'</label>', 'action=tools&operation=updatecache&step=2', 'form', '', FALSE);
  23. } elseif($step == 2) {
  24. $type = implode('_', (array)$_GET['type']);
  25. cpmsg(cplang('tools_updatecache_waiting'), "action=tools&operation=updatecache&step=3&type=$type", 'loading', '', FALSE);
  26. } elseif($step == 3) {
  27. $type = explode('_', $_GET['type']);
  28. if(in_array('data', $type)) {
  29. updatecache();
  30. require_once libfile('function/group');
  31. $groupindex['randgroupdata'] = $randgroupdata = grouplist('lastupdate', array('ff.membernum', 'ff.icon'), 80);
  32. $groupindex['topgrouplist'] = $topgrouplist = grouplist('activity', array('f.commoncredits', 'ff.membernum', 'ff.icon'), 10);
  33. $groupindex['updateline'] = TIMESTAMP;
  34. $groupdata = C::t('forum_forum')->fetch_group_counter();
  35. $groupindex['todayposts'] = $groupdata['todayposts'];
  36. $groupindex['groupnum'] = $groupdata['groupnum'];
  37. savecache('groupindex', $groupindex);
  38. C::t('forum_groupfield')->truncate();
  39. savecache('forum_guide', '');
  40. if($_G['setting']['grid']['showgrid']) {
  41. savecache('grids', array());
  42. }
  43. }
  44. if(in_array('tpl', $type) && $_G['config']['output']['tplrefresh']) {
  45. cleartemplatecache();
  46. }
  47. if(in_array('blockclass', $type)) {
  48. include_once libfile('function/block');
  49. blockclass_cache();
  50. }
  51. cpmsg('update_cache_succeed', '', 'succeed', '', FALSE);
  52. }
  53. } elseif($operation == 'fileperms') {
  54. $step = max(1, intval($_GET['step']));
  55. shownav('tools', 'nav_fileperms');
  56. showsubmenusteps('nav_fileperms', array(
  57. array('nav_fileperms_confirm', $step == 1),
  58. array('nav_fileperms_verify', $step == 2),
  59. array('nav_fileperms_completed', $step == 3)
  60. ));
  61. if($step == 1) {
  62. cpmsg(cplang('fileperms_check_note'), 'action=tools&operation=fileperms&step=2', 'button', '', FALSE);
  63. } elseif($step == 2) {
  64. cpmsg(cplang('fileperms_check_waiting'), 'action=tools&operation=fileperms&step=3', 'loading', '', FALSE);
  65. } elseif($step == 3) {
  66. showtips('fileperms_tips');
  67. $entryarray = array(
  68. 'data',
  69. 'data/attachment',
  70. 'data/attachment/album',
  71. 'data/attachment/category',
  72. 'data/attachment/common',
  73. 'data/attachment/forum',
  74. 'data/attachment/group',
  75. 'data/attachment/portal',
  76. 'data/attachment/profile',
  77. 'data/attachment/swfupload',
  78. 'data/attachment/temp',
  79. 'data/cache',
  80. 'data/log',
  81. 'data/template',
  82. 'data/threadcache',
  83. 'data/diy'
  84. );
  85. $result = '';
  86. foreach($entryarray as $entry) {
  87. $fullentry = DISCUZ_ROOT.'./'.$entry;
  88. if(!is_dir($fullentry) && !file_exists($fullentry)) {
  89. continue;
  90. } else {
  91. if(!dir_writeable($fullentry)) {
  92. $result .= '<li class="error">'.(is_dir($fullentry) ? $lang['dir'] : $lang['file'])." ./$entry $lang[fileperms_unwritable]</li>";
  93. }
  94. }
  95. }
  96. $result = $result ? $result : '<li>'.$lang['fileperms_check_ok'].'</li>';
  97. echo '<div class="colorbox"><ul class="fileperms">'.$result.'</ul></div>';
  98. }
  99. }
  100. function jsinsertunit() {
  101. ?>
  102. <script type="text/JavaScript">
  103. function isUndefined(variable) {
  104. return typeof variable == 'undefined' ? true : false;
  105. }
  106. function insertunit(text, obj) {
  107. if(!obj) {
  108. obj = 'jstemplate';
  109. }
  110. $(obj).focus();
  111. if(!isUndefined($(obj).selectionStart)) {
  112. var opn = $(obj).selectionStart + 0;
  113. $(obj).value = $(obj).value.substr(0, $(obj).selectionStart) + text + $(obj).value.substr($(obj).selectionEnd);
  114. } else if(document.selection && document.selection.createRange) {
  115. var sel = document.selection.createRange();
  116. sel.text = text.replace(/\r?\n/g, '\r\n');
  117. sel.moveStart('character', -strlen(text));
  118. } else {
  119. $(obj).value += text;
  120. }
  121. }
  122. </script>
  123. <?php
  124. }
  125. ?>