国内流行的内容管理系统(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.

572 lines
22KB

  1. <?php
  2. /**
  3. * 模块管理
  4. *
  5. * @version $id:module_main.php 14:17 2010年7月20日 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. if (DEDEBIZ_SAFE_MODE) {
  13. die(DedeAlert("系统已启用安全模式,无法使用当前功能",ALERT_DANGER));
  14. }
  15. CheckPurview('sys_module');
  16. require_once(DEDEINC."/dedemodule.class.php");
  17. require_once(DEDEINC."/libraries/oxwindow.class.php");
  18. if (empty($action)) $action = '';
  19. $mdir = DEDEDATA.'/module';
  20. $mdurl = "";
  21. function TestWriteAble($d)
  22. {
  23. $tfile = '_dedet.txt';
  24. $d = preg_replace("#\/$#", '', $d);
  25. $fp = @fopen($d.'/'.$tfile, 'w');
  26. if (!$fp) return FALSE;
  27. else {
  28. fclose($fp);
  29. $rs = @unlink($d.'/'.$tfile);
  30. if ($rs) return TRUE;
  31. else return FALSE;
  32. }
  33. }
  34. function ReWriteConfigAuto()
  35. {
  36. global $dsql;
  37. $configfile = DEDEDATA.'/config.cache.inc.php';
  38. if (!is_writeable($configfile)) {
  39. echo "配置文件<span class='text-primary'>{$configfile}</span>不支持写入,无法修改系统配置参数";
  40. exit();
  41. }
  42. $fp = fopen($configfile, 'w');
  43. flock($fp, 3);
  44. fwrite($fp, "<"."?php\r\n");
  45. $dsql->SetQuery("SELECT `varname`,`type`,`value`,`groupid` FROM `#@__sysconfig` ORDER BY aid ASC ");
  46. $dsql->Execute();
  47. while ($row = $dsql->GetArray()) {
  48. if (empty($row['value']) && $row['type'] == 'number') $row['value'] = 0;
  49. if ($row['type'] == 'number') fwrite($fp, "\${$row['varname']} = ".$row['value'].";\r\n");
  50. else fwrite($fp, "\${$row['varname']} = '".str_replace("'", '', $row['value'])."';\r\n");
  51. }
  52. fwrite($fp, "?".">");
  53. fclose($fp);
  54. }
  55. /*--------------
  56. function ShowAll();
  57. --------------*/
  58. if ($action == '') {
  59. $types = array('soft' => '模块', 'templets' => '模板', 'plus' => '小插件', 'patch' => '补丁');
  60. $dm = new DedeModule($mdir);
  61. if (empty($moduletype)) $moduletype = '';
  62. $modules_remote = $dm->GetModuleUrlList($moduletype, $mdurl);
  63. $modules = array();
  64. $modules = $dm->GetModuleList($moduletype);
  65. is_array($modules) || $modules = array();
  66. if (is_array($modules_remote) && count($modules_remote) > 0) {
  67. $modules = array_merge($modules, $modules_remote);
  68. }
  69. require_once(dirname(__FILE__)."/templets/module_main.htm");
  70. $dm->Clear();
  71. exit();
  72. }
  73. /*--------------
  74. function ViewDevelopoer();
  75. --------------*/
  76. else if ($action == 'view_developoer') {
  77. //检验开发者信息
  78. $dm = new DedeModule($mdir);
  79. $info = $dm->GetModuleInfo($hash);
  80. if ($info == null) {
  81. ShowMsg("获取模块信息错误,模块文件可能被篡改", -1);
  82. exit;
  83. }
  84. $dev_id = $info['dev_id'];
  85. $devURL = DEDECDNURL."/developers/$dev_id.json";
  86. $dhd = new DedeHttpDown();
  87. $dhd->OpenUrl($devURL);
  88. $devContent = $dhd->GetHtml();
  89. $devInfo = (array)json_decode($devContent);
  90. $offUrl = "";
  91. if ($devInfo['dev_type'] == 1) {
  92. $offUrl = "<p>官方网址:<code>{$devInfo['offurl']}</code><small>(复制在浏览器中打开)</small></p>";
  93. }
  94. $authAt = date("Y-m-d", $devInfo['auth_at']);
  95. if (!isset($info['dev_id'])) {
  96. $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>";
  97. $authAt = "未知";
  98. }
  99. ShowMsg("<p>开发者名称:{$devInfo['dev_name']}</p><p>开发者id:{$devInfo['dev_id']}</p><span>认证于:{$authAt}</span>", "-1");
  100. exit;
  101. }
  102. /*--------------
  103. function Setup();
  104. --------------*/
  105. else if ($action == 'setup') {
  106. $dm = new DedeModule($mdir);
  107. $infos = $dm->GetModuleInfo($hash);
  108. if ($infos == null) {
  109. ShowMsg("获取模块信息错误,模块文件可能被篡改", -1);
  110. exit;
  111. }
  112. $alertMsg = ($infos['lang'] == $cfg_soft_lang ? '' : '<br>(这个模块的语言编码与您系统的编码不一致,请向开发者确认它的兼容性)');
  113. $filelists = (array)$dm->GetFileLists($hash);
  114. $filelist = '';
  115. $prvdirs = array();
  116. $incdir = array();
  117. foreach ($filelists as $v) {
  118. if (empty($v['name'])) continue;
  119. if ($v['type'] == 'dir') {
  120. $v['type'] = '目录';
  121. $incdir[] = $v['name'];
  122. } else {
  123. $v['type'] = '文件';
  124. }
  125. $filelist .= "{$v['type']}|{$v['name']}\r\n";
  126. }
  127. //检测需要的目录权限
  128. foreach ($filelists as $v) {
  129. $prvdir = preg_replace("#\/([^\/]*)$#", '/', $v['name']);
  130. if (!preg_match("#^\.#", $prvdir)) $prvdir = './';
  131. $n = TRUE;
  132. foreach ($incdir as $k => $v) {
  133. if (preg_match("#^".$v."#i", $prvdir)) {
  134. $n = FALSE;
  135. break;
  136. }
  137. }
  138. if (!isset($prvdirs[$prvdir]) && $n && is_dir($prvdir)) {
  139. $prvdirs[$prvdir][0] = 1;
  140. $prvdirs[$prvdir][1] = TestWriteAble($prvdir);
  141. }
  142. }
  143. $prvdir = "<table cellpadding='1' cellspacing='1'>\r\n";
  144. $prvdir .= "<tr bgcolor='#e9ecef'><th width='270'>目录</td><th align='center'>可写</td></tr>\r\n";
  145. foreach ($prvdirs as $k => $v) {
  146. if ($v) $cw = '√';
  147. else $cw = "<span class='text-danger'>×</span>";
  148. $prvdir .= "<tr><td>$k</td>";
  149. $prvdir .= "<td align='center'>$cw</td></tr>\r\n";
  150. }
  151. $prvdir .= "</table>";
  152. $win = new OxWindow();
  153. $win->Init("module_main.php", "js/blank.js", "post");
  154. $wecome_info = "模块管理";
  155. $devURL = DEDECDNURL."/developers/{$infos['dev_id']}.json";
  156. $dhd = new DedeHttpDown();
  157. $dhd->OpenUrl($devURL);
  158. $devContent = $dhd->GetHtml();
  159. $devInfo = (array)json_decode($devContent);
  160. $s = "未认证";
  161. if (($devInfo['dev_id'] == $infos['dev_id']) && !empty($devInfo['dev_id'])) {
  162. $s = "已认证";
  163. }
  164. $win->AddTitle("<a href='module_main.php'>模块管理</a> &gt; 安装模块:{$infos['name']}");
  165. $win->AddHidden("hash", $hash);
  166. $win->AddHidden("action", 'setupstart');
  167. $msg = "<style>.dtb{border-bottom:1px dotted #eee}</style>
  168. <table width='98%' cellspacing='0' cellpadding='0' class='table'>
  169. <tr>
  170. <td width='260' class='dtb'>模块名称:</td>
  171. <td class='dtb'>{$infos['name']}</td>
  172. </tr>
  173. <tr>
  174. <td class='dtb'>语言:</td>
  175. <td class='dtb'>{$infos['lang']} {$alertMsg}</td>
  176. </tr>
  177. <tr>
  178. <td class='dtb'>文件大小:</td>
  179. <td class='dtb'>{$infos['filesize']}</td>
  180. </tr>
  181. <tr>
  182. <td class='dtb'>开发者id:</td>
  183. <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>
  184. </tr>
  185. <tr>
  186. <td class='dtb'>发布时间:</td>
  187. <td class='dtb'>{$infos['time']}</td>
  188. </tr>
  189. <tr>
  190. <td class='dtb'>使用协议:</td>
  191. <td class='dtb'><a href='module_main.php?action=showreadme&hash={$hash}' target='_blank' class='btn btn-success btn-sm'>浏览</a></td>
  192. </tr>
  193. <tr>
  194. <td class='dtb' colspan='2'>
  195. <div class='alert alert-danger mb-0'>注意事项:安装时请确保文件列表中涉及的目录前可写入权限,此外“后台管理目录”、“templets”目录也必须暂时设置可写入权限</div>
  196. </td>
  197. </tr>
  198. <tr>
  199. <td>目录权限检测:<br> ../ 为根目录 <br> ./ 表示当前目录</td>
  200. <td>$prvdir</td>
  201. </tr>
  202. <tr>
  203. <td>模块包含的所有文件列表:</td>
  204. <td></td>
  205. </tr>
  206. <tr>
  207. <td height='160' colspan='2'><textarea name='filelists' id='filelists' class='admin-textarea-xl'>{$filelist}</textarea></td>
  208. </tr>
  209. <tr>
  210. <td>对于已存在文件处理方法:</td>
  211. <td>
  212. <label><input type='radio' name='isreplace' value='1' checked='checked'> 覆盖</label>
  213. <label><input type='radio' name='isreplace' value='3'> 覆盖,保留副本</label>
  214. <label><input type='radio' name='isreplace' value='0'> 保留旧文件</label>
  215. </td>
  216. </tr>
  217. </table>";
  218. $win->AddMsgItem("$msg");
  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` ) 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.php';\r\n";
  277. $rflwft .= "else top.document.getElementById('menufra').src = 'index_menu.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-success 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' class='dtb'>模块名称:</td>
  303. <td class='dtb'>{$infos['name']}</td>
  304. </tr>
  305. <tr>
  306. <td class='dtb'>语言:</td>
  307. <td class='dtb'>{$infos['lang']} {$alertMsg}</td>
  308. </tr>
  309. <tr>
  310. <td class='dtb'>文件大小:</td>
  311. <td class='dtb'>{$infos['filesize']}</td>
  312. </tr>
  313. <tr>
  314. <td class='dtb'>开发者id:</td>
  315. <td class='dtb'>{$dev_id}</td>
  316. </tr>
  317. <tr>
  318. <td class='dtb'>发布时间:</td>
  319. <td class='dtb'>{$infos['time']}</td>
  320. </tr>
  321. <tr>
  322. <td 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 colspan='2'>删除模块仅删除这个模块的安装包文件,如果您已经安装,请执行<a href='module_main.php?hash={$hash}&action=uninstall'>卸载程序</a>来删除</td>
  327. </tr>
  328. </table>";
  329. $win->AddMsgItem("$msg");
  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'] = ' ';
  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-success 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' class='dtb'>模块名称:</td>
  368. <td class='dtb'>{$infos['name']}</td>
  369. </tr>
  370. <tr>
  371. <td class='dtb'>语言:</td>
  372. <td class='dtb'>{$infos['lang']} {$alertMsg}</td>
  373. </tr>
  374. <tr>
  375. <td class='dtb'>文件大小:</td>
  376. <td class='dtb'>{$infos['filesize']}</td>
  377. </tr>
  378. <tr>
  379. <td class='dtb'>开发者id:</td>
  380. <td class='dtb'>{$dev_id}</td>
  381. </tr>
  382. <tr>
  383. <td class='dtb'>发布时间:</td>
  384. <td class='dtb'>{$infos['time']}</td>
  385. </tr>
  386. <tr>
  387. <td 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>模块包含的文件(文件路径相对于当前目录)</td>
  392. <td></td>
  393. </tr>
  394. <tr>
  395. <td height='160' colspan='2'>
  396. <textarea name='filelists' id='filelists' class='admin-textarea-xl'>{$filelist}</textarea>
  397. </td>
  398. </tr>
  399. <tr>
  400. <td>对于模块的文件处理方法:</td>
  401. <td>
  402. <label><input type='radio' name='isreplace' value='0' checked='checked'> 手工删除文件,仅运行卸载程序</label>
  403. <label><input type='radio' name='isreplace' value='2'> 删除模块的所有文件</label>
  404. </td>
  405. </tr>
  406. </table>";
  407. $win->AddMsgItem("$msg");
  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.php';\r\n";
  443. $rflwft .= "else top.document.getElementById('menufra').src = 'index_menu.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("$msg");
  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'] = ' ';
  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-warning btn-sm'>安装</a><a href='{$cfg_biz_dedebizUrl}/developer' target='_blank' class='btn btn-success btn-sm'>{$s}</a>" : "{$infos['dev_id']} <a href='module_main.php?action=setup&hash={$hash}' class='btn btn-warning btn-sm'>安装</a><a href='{$cfg_biz_dedebizUrl}/developer?dev_id={$infos['dev_id']}' target='_blank' class='btn btn-success 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' class='dtb'>模块名称:</td>
  508. <td class='dtb'>{$infos['name']}</td>
  509. </tr>
  510. <tr>
  511. <td class='dtb'>语言:</td>
  512. <td class='dtb'>{$infos['lang']} {$alertMsg}</td>
  513. </tr>
  514. <tr>
  515. <td class='dtb'>文件大小:</td>
  516. <td class='dtb'>{$infos['filesize']}</td>
  517. </tr>
  518. <tr>
  519. <td class='dtb'>开发者id:</td>
  520. <td class='dtb'>{$dev_id}</td>
  521. </tr>
  522. <tr>
  523. <td class='dtb'>发布时间:</td>
  524. <td class='dtb'>{$infos['time']}</td>
  525. </tr>
  526. <tr>
  527. <td 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>模块包含的文件(文件路径相对于当前目录)</td>
  532. <td></td>
  533. </tr>
  534. <tr>
  535. <td height='160' colspan='2'>
  536. <textarea name='filelists' id='filelists' class='admin-textarea-xl'>{$filelist}</textarea>
  537. </td>
  538. </tr>
  539. </table>";
  540. $win->AddMsgItem("$msg");
  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. }
  571. ?>