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

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