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

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