国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

module_main.php 23KB

2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
2年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. <?php
  2. /**
  3. * 模块管理
  4. *
  5. * @version $Id: module_main.php 1 14:17 2010年7月20日Z tianya $
  6. * @package DedeBIZ.Administrator
  7. * @copyright Copyright (c) 2022, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. CheckPurview('sys_module');
  13. require_once(DEDEINC."/dedemodule.class.php");
  14. require_once(DEDEINC."/libraries/oxwindow.class.php");
  15. if (empty($action)) $action = '';
  16. require_once(DEDEDATA."/admin/config_update.php");
  17. $mdir = DEDEDATA.'/module';
  18. $mdurl = "";
  19. function TestWriteAble($d)
  20. {
  21. $tfile = '_dedet.txt';
  22. $d = preg_replace("#\/$#", '', $d);
  23. $fp = @fopen($d.'/'.$tfile, 'w');
  24. if (!$fp) return FALSE;
  25. else {
  26. fclose($fp);
  27. $rs = @unlink($d.'/'.$tfile);
  28. if ($rs) return TRUE;
  29. else return FALSE;
  30. }
  31. }
  32. function ReWriteConfigAuto()
  33. {
  34. global $dsql;
  35. $configfile = DEDEDATA.'/config.cache.inc.php';
  36. if (!is_writeable($configfile)) {
  37. echo "配置文件 {$configfile} 不支持写入,无法修改系统配置参数";
  38. exit();
  39. }
  40. $fp = fopen($configfile, 'w');
  41. flock($fp, 3);
  42. fwrite($fp, "<"."?php\r\n");
  43. $dsql->SetQuery("SELECT `varname`,`type`,`value`,`groupid` FROM `#@__sysconfig` ORDER BY aid ASC ");
  44. $dsql->Execute();
  45. while ($row = $dsql->GetArray()) {
  46. if(empty($row['value']) && $row['type'] == 'number') $row['value'] = 0;
  47. if ($row['type'] == 'number') fwrite($fp, "\${$row['varname']} = ".$row['value'].";\r\n");
  48. else fwrite($fp, "\${$row['varname']} = '".str_replace("'", '', $row['value'])."';\r\n");
  49. }
  50. fwrite($fp, "?".">");
  51. fclose($fp);
  52. }
  53. /*--------------
  54. function ShowAll();
  55. --------------*/
  56. if ($action == '') {
  57. $types = array('soft' => '模块', 'templets' => '模板', 'plus' => '小插件', 'patch' => '补丁');
  58. $dm = new DedeModule($mdir);
  59. if (empty($moduletype)) $moduletype = '';
  60. $modules_remote = $dm->GetModuleUrlList($moduletype, $mdurl);
  61. $modules = array();
  62. $modules = $dm->GetModuleList($moduletype);
  63. is_array($modules) || $modules = array();
  64. if (is_array($modules_remote) && count($modules_remote) > 0) {
  65. $modules = array_merge($modules, $modules_remote);
  66. }
  67. require_once(dirname(__FILE__)."/templets/module_main.htm");
  68. $dm->Clear();
  69. exit();
  70. }
  71. /*--------------
  72. function ViewDevelopoer();
  73. --------------*/
  74. else if ($action == 'view_developoer') {
  75. //检验开发者信息
  76. $dm = new DedeModule($mdir);
  77. $info = $dm->GetModuleInfo($hash);
  78. if ($info == null) {
  79. ShowMsg("获取模块信息错误,模块文件可能被篡改", -1);
  80. exit;
  81. }
  82. $dev_id = $info['dev_id'];
  83. $devURL = DEDECDNURL."/developers/$dev_id.json";
  84. $dhd = new DedeHttpDown();
  85. $dhd->OpenUrl($devURL);
  86. $devContent = $dhd->GetHtml();
  87. $devInfo = (array)json_decode($devContent);
  88. $offUrl = "";
  89. if ($devInfo['dev_type'] == 1) {
  90. $offUrl = "<p>官方网址:<code>{$devInfo['offurl']}</code><small>(复制在浏览器中打开)</small></p>";
  91. }
  92. $authAt = date("Y-m-d", $devInfo['auth_at']);
  93. if (!isset($info['dev_id'])) {
  94. $devInfo['dev_name'] = $info['team']."<span style='display:inline-block;margin-left:10px;padding:.25rem .5rem;line-height:1.5;font-size:12px;color:#fff;background:#dc3545;border-color:#dc3545;border-radius:.2rem'>未认证</span>";
  95. $authAt = "未知";
  96. }
  97. ShowMsg("<p>开发者名称:{$devInfo['dev_name']}</p><p>开发者ID:{$devInfo['dev_id']}</p><span>认证于:{$authAt}</span>", "-1");
  98. exit;
  99. }
  100. /*--------------
  101. function Setup();
  102. --------------*/
  103. else if ($action == 'setup') {
  104. $dm = new DedeModule($mdir);
  105. $infos = $dm->GetModuleInfo($hash);
  106. if ($infos == null) {
  107. ShowMsg("获取模块信息错误,模块文件可能被篡改", -1);
  108. exit;
  109. }
  110. $alertMsg = ($infos['lang'] == $cfg_soft_lang ? '' : '<br>(这个模块的语言编码与您系统的编码不一致,请向开发者确认它的兼容性)');
  111. $filelists = (array)$dm->GetFileLists($hash);
  112. $filelist = '';
  113. $prvdirs = array();
  114. $incdir = array();
  115. foreach ($filelists as $v) {
  116. if (empty($v['name'])) continue;
  117. if ($v['type'] == 'dir') {
  118. $v['type'] = '目录';
  119. $incdir[] = $v['name'];
  120. } else {
  121. $v['type'] = '文件';
  122. }
  123. $filelist .= "{$v['type']}|{$v['name']}\r\n";
  124. }
  125. //检测需要的目录权限
  126. foreach ($filelists as $v) {
  127. $prvdir = preg_replace("#\/([^\/]*)$#", '/', $v['name']);
  128. if (!preg_match("#^\.#", $prvdir)) $prvdir = './';
  129. $n = TRUE;
  130. foreach ($incdir as $k => $v) {
  131. if (preg_match("#^".$v."#i", $prvdir)) {
  132. $n = FALSE;
  133. break;
  134. }
  135. }
  136. if (!isset($prvdirs[$prvdir]) && $n && is_dir($prvdir)) {
  137. $prvdirs[$prvdir][0] = 1;
  138. $prvdirs[$prvdir][1] = TestWriteAble($prvdir);
  139. }
  140. }
  141. $prvdir = "<table cellpadding='1' cellspacing='1' width='350' style='margin-top:10px'>\r\n";
  142. $prvdir .= "<tr style='background:#F8FCF1'><th width='270'>目录</td><th align='center'>可写</td></tr>\r\n";
  143. foreach ($prvdirs as $k => $v) {
  144. if ($v) $cw = '√';
  145. else $cw = '<span style="color:#dc3545">×</span>';
  146. $prvdir .= "<tr><td>$k</td>";
  147. $prvdir .= "<td align='center'>$cw</td></tr>\r\n";
  148. }
  149. $prvdir .= "</table>";
  150. $win = new OxWindow();
  151. $win->Init("module_main.php", "js/blank.js", "post");
  152. $wecome_info = "模块管理";
  153. $devURL = DEDECDNURL."/developers/{$infos['dev_id']}.json";
  154. $dhd = new DedeHttpDown();
  155. $dhd->OpenUrl($devURL);
  156. $devContent = $dhd->GetHtml();
  157. $devInfo = (array)json_decode($devContent);
  158. $s = "未认证";
  159. if (($devInfo['dev_id'] == $infos['dev_id']) && !empty($devInfo['dev_id'])) {
  160. $s = "已认证";
  161. }
  162. $win->AddTitle("&nbsp;<a href='module_main.php'>模块管理</a> &gt; 安装模块:{$infos['name']}");
  163. $win->AddHidden("hash", $hash);
  164. $win->AddHidden("action", 'setupstart');
  165. $msg = "<style>.dtb{border-bottom:1px dotted #eee}</style>
  166. <table width='98%' cellspacing='0' cellpadding='0' class='table'>
  167. <tr>
  168. <td width='260' height='26' class='dtb'>模块名称:</td>
  169. <td class='dtb'>{$infos['name']}</td>
  170. </tr>
  171. <tr>
  172. <td height='26' class='dtb'>语言:</td>
  173. <td class='dtb'>{$infos['lang']} {$alertMsg}</td>
  174. </tr>
  175. <tr>
  176. <td height='26' class='dtb'>文件大小:</td>
  177. <td class='dtb'>{$infos['filesize']}</td>
  178. </tr>
  179. <tr>
  180. <td height='26' class='dtb'>开发者ID:</td>
  181. <td class='dtb'>{$infos['dev_id']} <a href='{$cfg_biz_dedebizUrl}/developer?dev_id={$infos['dev_id']}' target='_blank' class='btn btn-success btn-sm'>{$s}</a></td>
  182. </tr>
  183. <tr>
  184. <td height='26' class='dtb'>发布时间:</td>
  185. <td class='dtb'>{$infos['time']}</td>
  186. </tr>
  187. <tr>
  188. <td height='26' class='dtb'>使用协议:</td>
  189. <td class='dtb'><a href='module_main.php?action=showreadme&hash={$hash}' target='_blank' class='btn btn-success btn-sm'>浏览</a></td>
  190. </tr>
  191. <tr>
  192. <td height='26' class='dtb' colspan='2'>
  193. <div class='alert alert-danger'>注意事项:安装时请确保文件列表中涉及的目录前可写入权限,此外“后台管理目录”、“后台管理目录/templets”目录也必须暂时设置可写入权限</div>
  194. </td>
  195. </tr>
  196. <tr>
  197. <td height='26'>目录权限检测:<br> ../ 为根目录 <br> ./ 表示当前目录</td>
  198. <td>$prvdir</td>
  199. </tr>
  200. <tr>
  201. <td height='26'>模块包含的所有文件列表:</td>
  202. <td></td>
  203. </tr>
  204. <tr>
  205. <td height='160' colspan='2'>
  206. <textarea name='filelists' id='filelists' style='width:90%;height:200px'>{$filelist}</textarea>
  207. </td>
  208. </tr>
  209. <tr>
  210. <td height='26'>对于已存在文件处理方法:</td>
  211. <td>
  212. <label><input name='isreplace' type='radio' value='1' checked='checked'> 覆盖</label>
  213. <label><input name='isreplace' type='radio' value='3'> 覆盖,保留副本</label>
  214. <label><input type='radio' name='isreplace' value='0'> 保留旧文件</label>
  215. </td>
  216. </tr>
  217. </table>";
  218. $win->AddMsgItem("<div style='padding-left:10px;line-height:26px'>$msg</div>");
  219. $winform = $win->GetWindow("ok", "");
  220. $win->Display();
  221. $dm->Clear();
  222. exit();
  223. }
  224. /*---------------
  225. function SetupRun()
  226. --------------*/
  227. else if ($action == 'setupstart') {
  228. if (!is_writeable($mdir)) {
  229. ShowMsg("目录 {$mdir} 不支持写入,这将导致程序安装没法正常创建", "-1");
  230. exit();
  231. }
  232. $dm = new DedeModule($mdir);
  233. $minfos = (array)$dm->GetModuleInfo($hash);
  234. extract($minfos, EXTR_SKIP);
  235. $menustring = addslashes($dm->GetSystemFile($hash, 'menustring'));
  236. $indexurl = str_replace('**', '=', $indexurl);
  237. $query = "INSERT INTO `#@__sys_module`(`hashcode` , `modname` , `indexname` , `indexurl` , `ismember` , `menustring` )
  238. VALUES ('$hash' , '$name' , '$indexname' , '$indexurl' , '$ismember' , '$menustring' ) ";
  239. $rs = $dsql->ExecuteNoneQuery("DELETE FROM `#@__sys_module` WHERE hashcode LIKE '$hash' ");
  240. $rs = $dsql->ExecuteNoneQuery($query);
  241. if (!$rs) {
  242. ShowMsg('保存数据库信息失败,无法完成安装'.$dsql->GetError(), 'javascript:;');
  243. exit();
  244. }
  245. $dm->WriteFiles($hash, $isreplace);
  246. $filename = '';
  247. if (!isset($autosetup) || $autosetup == 0) $filename = $dm->WriteSystemFile($hash, 'setup');
  248. if (!isset($autodel) || $autodel == 0) $dm->WriteSystemFile($hash, 'uninstall');
  249. $dm->WriteSystemFile($hash, 'readme');
  250. $dm->Clear();
  251. //用模块的程序安装安装
  252. if (!isset($autosetup) || $autosetup == 0) {
  253. include(DEDEDATA.'/module/'.$filename);
  254. exit();
  255. }
  256. //系统自动安装
  257. else {
  258. $mysql_version = $dsql->GetVersion(TRUE);
  259. //默认使用MySQL 4.1 以下版本的SQL语句,对大于4.1版本采用替换处理 TYPE=MyISAM ==> ENGINE=MyISAM DEFAULT CHARSET=#~lang~#
  260. $setupsql = $dm->GetSystemFile($hash, 'setupsql40');
  261. $setupsql = preg_replace("#ENGINE=MyISAM#i", 'TYPE=MyISAM', $setupsql);
  262. $sql41tmp = 'ENGINE=MyISAM DEFAULT CHARSET='.$cfg_db_language;
  263. if ($mysql_version >= 4.1) {
  264. $setupsql = preg_replace("#TYPE=MyISAM#i", $sql41tmp, $setupsql);
  265. }
  266. //_ROOTURL_
  267. if ($cfg_cmspath == '/') $cfg_cmspath = '';
  268. $rooturl = $cfg_basehost.$cfg_cmspath;
  269. $setupsql = preg_replace("#_ROOTURL_#i", $rooturl, $setupsql);
  270. $setupsql = preg_replace("#[\r\n]{1,}#", "\n", $setupsql);
  271. $sqls = @split(";[ \t]{0,}\n", $setupsql);
  272. foreach ($sqls as $sql) {
  273. if (trim($sql) != '') $dsql->ExecuteNoneQuery($sql);
  274. }
  275. ReWriteConfigAuto();
  276. $rflwft = "<script language='javascript' type='text/javascript'>\r\n";
  277. $rflwft .= "if(window.navigator.userAgent.indexOf('MSIE')>=1) top.document.frames.menu.location = 'index_menu_module.php';\r\n";
  278. $rflwft .= "else top.document.getElementById('menufra').src = 'index_menu_module.php';\r\n";
  279. $rflwft .= "</script>";
  280. echo $rflwft;
  281. UpDateCatCache();
  282. ShowMsg('模块安装完成', 'module_main.php');
  283. exit();
  284. }
  285. }
  286. /*--------------
  287. function DelModule();
  288. --------------*/
  289. else if ($action == 'del') {
  290. $dm = new DedeModule($mdir);
  291. $infos = $dm->GetModuleInfo($hash);
  292. $alertMsg = ($infos['lang'] == $cfg_soft_lang ? '' : '<br>(这个模块的语言编码与您系统的编码不一致,请向开发者确认它的兼容性)');
  293. $dev_id = empty($infos['dev_id'])? "<a href='{$cfg_biz_dedebizUrl}/developer' target='_blank' class='btn btn-danger btn-sm'>未认证</a>" : "{$infos['dev_id']} <a href='{$cfg_biz_dedebizUrl}/developer?dev_id={$infos['dev_id']}' target='_blank' class='btn btn-danger btn-sm'>已认证</a>";
  294. $win = new OxWindow();
  295. $win->Init("module_main.php", "js/blank.js", "post");
  296. $wecome_info = "模块管理";
  297. $win->AddTitle("<a href='module_main.php'>模块管理</a> &gt; 删除模块:{$infos['name']}");
  298. $win->AddHidden('hash', $hash);
  299. $win->AddHidden('action', 'delok');
  300. $msg = "<style>.dtb{border-bottom:1px dotted #eee}</style>
  301. <table width='98%' cellspacing='0' cellpadding='0' class='table'>
  302. <tr>
  303. <td width='260' height='26' class='dtb'>模块名称:</td>
  304. <td class='dtb'>{$infos['name']}</td>
  305. </tr>
  306. <tr>
  307. <td height='26' class='dtb'>语言:</td>
  308. <td class='dtb'>{$infos['lang']} {$alertMsg}</td>
  309. </tr>
  310. <tr>
  311. <td height='26' class='dtb'>文件大小:</td>
  312. <td class='dtb'>{$infos['filesize']}</td>
  313. </tr>
  314. <tr>
  315. <td height='26' class='dtb'>开发者ID:</td>
  316. <td class='dtb'>{$dev_id}</td>
  317. </tr>
  318. <tr>
  319. <td height='26' class='dtb'>发布时间:</td>
  320. <td class='dtb'>{$infos['time']}</td>
  321. </tr>
  322. <tr>
  323. <td height='26' class='dtb'>使用协议:</td>
  324. <td class='dtb'><a href='module_main.php?action=showreadme&hash={$hash}' target='_blank' class='btn btn-success btn-sm'>浏览</a></td>
  325. </tr>
  326. <tr>
  327. <td height='26' colspan='2'>删除模块仅删除这个模块的安装包文件,如果您已经安装,请执行<a href='module_main.php?hash={$hash}&action=uninstall'>卸载程序</a>来删除</td>
  328. </tr>
  329. </table>";
  330. $win->AddMsgItem("<div style='padding-left:10px;line-height:26px'>$msg</div>");
  331. $winform = $win->GetWindow("ok", "");
  332. $win->Display();
  333. $dm->Clear();
  334. exit();
  335. } else if ($action == 'delok') {
  336. $dm = new DedeModule($mdir);
  337. $modfile = $mdir."/".$dm->GetHashFile($hash);
  338. unlink($modfile) or die("删除文件 {$modfile} 失败");
  339. ShowMsg("成功删除一个模块文件", "module_main.php");
  340. exit();
  341. }
  342. /*--------------
  343. function UnInstall();
  344. --------------*/
  345. else if ($action == 'uninstall') {
  346. $dm = new DedeModule($mdir);
  347. $infos = $dm->GetModuleInfo($hash);
  348. if ($infos['url'] == '') $infos['url'] = '&nbsp;';
  349. $alertMsg = ($infos['lang'] == $cfg_soft_lang ? '' : '<br>(这个模块的语言编码与您系统的编码不一致,请向开发者确认它的兼容性)');
  350. $filelists = (array)$dm->GetFileLists($hash);
  351. $filelist = '';
  352. foreach ($filelists as $v) {
  353. if (empty($v['name'])) continue;
  354. if ($v['type'] == 'dir') $v['type'] = '目录';
  355. else $v['type'] = '文件';
  356. $filelist .= "{$v['type']}|{$v['name']}\r\n";
  357. }
  358. $dev_id = empty($infos['dev_id'])? "<a href='{$cfg_biz_dedebizUrl}/developer' target='_blank' class='btn btn-danger btn-sm'>未认证</a>" : "{$infos['dev_id']} <a href='{$cfg_biz_dedebizUrl}/developer?dev_id={$infos['dev_id']}' target='_blank' class='btn btn-danger btn-sm'>已认证</a>";
  359. $win = new OxWindow();
  360. $win->Init("module_main.php", "js/blank.js", "post");
  361. $wecome_info = "模块管理";
  362. $win->AddTitle("<a href='module_main.php'>模块管理</a> &gt; 卸载模块:{$infos['name']}");
  363. $win->AddHidden("hash", $hash);
  364. $win->AddHidden("action", 'uninstallok');
  365. $msg = "<style>.dtb{border-bottom:1px dotted #eee}</style>
  366. <table width='98%' cellspacing='0' cellpadding='0' class='table'>
  367. <tr>
  368. <td width='260' height='26' class='dtb'>模块名称:</td>
  369. <td class='dtb'>{$infos['name']}</td>
  370. </tr>
  371. <tr>
  372. <td height='26' class='dtb'>语言:</td>
  373. <td class='dtb'>{$infos['lang']} {$alertMsg}</td>
  374. </tr>
  375. <tr>
  376. <td height='26' class='dtb'>文件大小:</td>
  377. <td class='dtb'>{$infos['filesize']}</td>
  378. </tr>
  379. <tr>
  380. <td height='26' class='dtb'>开发者ID:</td>
  381. <td class='dtb'>{$dev_id}</td>
  382. </tr>
  383. <tr>
  384. <td height='26' class='dtb'>发布时间:</td>
  385. <td class='dtb'>{$infos['time']}</td>
  386. </tr>
  387. <tr>
  388. <td height='26' class='dtb'>使用协议:</td>
  389. <td class='dtb'><a href='module_main.php?action=showreadme&hash={$hash}' target='_blank' class='btn btn-success btn-sm'>浏览</a></td>
  390. </tr>
  391. <tr>
  392. <td height='26'>模块包含的文件(文件路径相对于当前目录)</td>
  393. <td></td>
  394. </tr>
  395. <tr>
  396. <td height='160' colspan='2'>
  397. <textarea name='filelists' id='filelists' style='width:90%;height:200px'>{$filelist}</textarea>
  398. </td>
  399. </tr>
  400. <tr>
  401. <td height='26'>对于模块的文件处理方法:</td>
  402. <td>
  403. <label><input type='radio' name='isreplace' value='0' checked='checked'> 手工删除文件,仅运行卸载程序</label>
  404. <label><input name='isreplace' type='radio' value='2'> 删除模块的所有文件</label>
  405. </td>
  406. </tr>
  407. </table>";
  408. $win->AddMsgItem("<div style='padding-left:10px;line-height:26px'>$msg</div>");
  409. $winform = $win->GetWindow("ok", "");
  410. $win->Display();
  411. $dm->Clear();
  412. exit();
  413. }
  414. /*--------------
  415. function UnInstallRun();
  416. --------------*/
  417. else if ($action == 'uninstallok') {
  418. $dsql->ExecuteNoneQuery("DELETE FROM `#@__sys_module` WHERE hashcode LIKE '$hash' ");
  419. $dm = new DedeModule($mdir);
  420. $minfos = (array)$dm->GetModuleInfo($hash);
  421. extract($minfos, EXTR_SKIP);
  422. if (!isset($moduletype) || $moduletype != 'patch') {
  423. $dm->DeleteFiles($hash, $isreplace);
  424. }
  425. @$dm->DelSystemFile($hash, 'readme');
  426. @$dm->DelSystemFile($hash, 'setup');
  427. $dm->Clear();
  428. if (!isset($autodel) || $autodel == 0) {
  429. include(DEDEDATA."/module/{$hash}-uninstall.php");
  430. @unlink(DEDEDATA."/module/{$hash}-uninstall.php");
  431. exit();
  432. } else {
  433. @$dm->DelSystemFile($hash, 'uninstall');
  434. $delsql = $dm->GetSystemFile($hash, 'delsql');
  435. if (trim($delsql) != '') {
  436. $sqls = explode(';', $delsql);
  437. foreach ($sqls as $sql) {
  438. if (trim($sql) != '') $dsql->ExecuteNoneQuery($sql);
  439. }
  440. }
  441. ReWriteConfigAuto();
  442. $rflwft = "<script language='javascript' type='text/javascript'>\r\n";
  443. $rflwft .= "if(window.navigator.userAgent.indexOf('MSIE')>=1) top.document.frames.menu.location = 'index_menu_module.php';\r\n";
  444. $rflwft .= "else top.document.getElementById('menufra').src = 'index_menu_module.php';\r\n";
  445. $rflwft .= "</script>";
  446. echo $rflwft;
  447. ShowMsg('模块卸载完成', 'module_main.php');
  448. exit();
  449. }
  450. }
  451. /*--------------
  452. function ShowReadme();
  453. --------------*/
  454. else if ($action == 'showreadme') {
  455. $dm = new DedeModule($mdir);
  456. $msg = $dm->GetSystemFile($hash, 'readme');
  457. $msg = preg_replace("/(.*)<body/isU", "", $msg);
  458. $msg = preg_replace("/<\/body>(.*)/isU", "", $msg);
  459. $dm->Clear();
  460. $win = new OxWindow();
  461. $win->Init("module_main.php", "js/blank.js", "post");
  462. $wecome_info = "模块管理";
  463. $win->AddTitle("<a href='module_main.php'>模块管理</a> &gt; 使用说明:");
  464. $win->AddMsgItem("<div style='padding-left:10px;line-height:26px'>$msg</div>");
  465. $winform = $win->GetWindow("hand");
  466. $win->Display();
  467. exit();
  468. }
  469. /*--------------
  470. function ViewOne();
  471. --------------*/
  472. else if ($action == 'view') {
  473. $dm = new DedeModule($mdir);
  474. $infos = $dm->GetModuleInfo($hash);
  475. if ($infos['url'] == '') $infos['url'] = '&nbsp;';
  476. $alertMsg = ($infos['lang'] == $cfg_soft_lang ? '' : '<br>(这个模块的语言编码与您系统的编码不一致,请向开发者确认它的兼容性)');
  477. $filelists = (array)$dm->GetFileLists($hash);
  478. $filelist = '';
  479. $setupinfo = '';
  480. $devURL = DEDECDNURL."/developers/{$infos['dev_id']}.json";
  481. $dhd = new DedeHttpDown();
  482. $dhd->OpenUrl($devURL);
  483. $devContent = $dhd->GetHtml();
  484. $devInfo = (array)json_decode($devContent);
  485. $s = "未认证";
  486. if (($devInfo['dev_id'] == $infos['dev_id']) && !empty($devInfo['dev_id'])) {
  487. $s = "已认证";
  488. }
  489. foreach ($filelists as $v) {
  490. if (empty($v['name'])) continue;
  491. if ($v['type'] == 'dir') $v['type'] = '目录';
  492. else $v['type'] = '文件';
  493. $filelist .= "{$v['type']}|{$v['name']}\r\n";
  494. }
  495. if (file_exists(DEDEDATA."/module/{$hash}-readme.php")) {
  496. $setupinfo = "已安装 <a href='module_main.php?action=uninstall&hash={$hash}'>卸载</a>";
  497. } else {
  498. $setupinfo = "未安装 <a href='module_main.php?action=setup&hash={$hash}'>安装</a>";
  499. }
  500. $dev_id = empty($infos['dev_id'])? "<a href='module_main.php?action=setup&hash={$hash}' class='btn btn-success btn-sm'>安装</a><a href='{$cfg_biz_dedebizUrl}/developer' target='_blank' class='btn btn-danger btn-sm'>{$s}</a>" : "{$infos['dev_id']} <a href='module_main.php?action=setup&hash={$hash}' class='btn btn-success btn-sm'>安装</a><a href='{$cfg_biz_dedebizUrl}/developer?dev_id={$infos['dev_id']}' target='_blank' class='btn btn-danger btn-sm'>{$s}</a>";
  501. $win = new OxWindow();
  502. $win->Init("", "js/blank.js", "");
  503. $wecome_info = "模块管理";
  504. $win->AddTitle("<a href='module_main.php'>模块管理</a> &gt; 模块详情:{$infos['name']}");
  505. $msg = "<style>.dtb{border-bottom:1px dotted #eee}</style>
  506. <table width='98%' cellspacing='0' cellpadding='0'>
  507. <tr>
  508. <td width='260' height='26' class='dtb'>模块名称:</td>
  509. <td class='dtb'>{$infos['name']}</td>
  510. </tr>
  511. <tr>
  512. <td height='26' class='dtb'>语言:</td>
  513. <td class='dtb'>{$infos['lang']} {$alertMsg}</td>
  514. </tr>
  515. <tr>
  516. <td height='26' class='dtb'>文件大小:</td>
  517. <td class='dtb'>{$infos['filesize']}</td>
  518. </tr>
  519. <tr>
  520. <td height='26' class='dtb'>开发者ID:</td>
  521. <td class='dtb'>{$dev_id}</td>
  522. </tr>
  523. <tr>
  524. <td height='26' class='dtb'>发布时间:</td>
  525. <td class='dtb'>{$infos['time']}</td>
  526. </tr>
  527. <tr>
  528. <td height='26' class='dtb'>使用协议:</td>
  529. <td class='dtb'><a href='module_main.php?action=showreadme&hash={$hash}' target='_blank' class='btn btn-success btn-sm'>浏览</a></td>
  530. </tr>
  531. <tr>
  532. <td height='26'>模块包含的文件(文件路径相对于当前目录)</td>
  533. <td></td>
  534. </tr>
  535. <tr>
  536. <td height='160' colspan='2'>
  537. <textarea name='filelists' id='filelists' style='width:90%;height:200px'>{$filelist}</textarea>
  538. </td>
  539. </tr>
  540. </table>";
  541. $win->AddMsgItem("<div style='padding-left:10px;line-height:26px'>$msg</div>");
  542. $winform = $win->GetWindow('hand', '');
  543. $win->Display();
  544. $dm->Clear();
  545. exit();
  546. }
  547. /*--------------
  548. function Edit();
  549. --------------*/
  550. else if ($action == 'edit') {
  551. $dm = new DedeModule($mdir);
  552. $minfos = (array)$dm->GetModuleInfo($hash);
  553. extract($minfos, EXTR_SKIP);
  554. if (!isset($lang)) $lang = 'gb2312';
  555. if (!isset($moduletype)) $moduletype = 'soft';
  556. $menustring = $dm->GetSystemFile($hash, 'menustring');
  557. $setupsql40 = dede_htmlspecialchars($dm->GetSystemFile($hash, 'setupsql40'));
  558. $readmetxt = $dm->GetSystemFile($hash, 'readme');
  559. $delsql = $dm->GetSystemFile($hash, 'delsql');
  560. $filelist = $dm->GetSystemFile($hash, 'oldfilelist', false);
  561. $indexurl = str_replace('**', '=', $indexurl);
  562. $dm->Clear();
  563. require_once(dirname(__FILE__).'/templets/module_edit.htm');
  564. exit();
  565. }
  566. /*--------------
  567. function Download();
  568. --------------*/
  569. else if ($action == 'download') {
  570. ShowMsg("暂不支持模块下载功能", "javascript:;");
  571. }