国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

571 lines
23KB

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