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

672 lines
23KB

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