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

121 lines
4.1KB

  1. <?php
  2. /**
  3. * @version $Id: module-install.php 1 13:41 2010年7月26日Z tianya $
  4. * @package DedeCMS.Install
  5. * @copyright Copyright (c) 2007 - 2018, DesDev, Inc.
  6. * @copyright Copyright (c) 2020, DedeBIZ.COM
  7. * @license https://www.dedebiz.com/license/v6
  8. * @link https://www.dedebiz.com
  9. */
  10. require_once(dirname(__FILE__).'/../include/common.inc.php');
  11. @set_time_limit(0);
  12. $verMsg = ' V5.8 UTF-8';
  13. $errmsg = '';
  14. $insLockfile = dirname(__FILE__).'/install_lock.txt';
  15. $moduleCacheFile = dirname(__FILE__).'/modules.tmp.inc';
  16. $moduleDir = DEDEROOT.'/data/module';
  17. $AdminBaseDir = DEDEROOT.'/dede/';
  18. if(file_exists($insLockfile))
  19. {
  20. exit(" 程序已运行安装,如果你确定要重新安装,请先从FTP中删除 install/install_lock.txt!");
  21. }
  22. require_once(DEDEINC.'/dedemodule.class.php');
  23. require_once(dirname(__FILE__).'/modulescache.php');
  24. require_once(dirname(__FILE__).'/install.inc.php');
  25. if(empty($step)) $step = 0;
  26. //完成安装
  27. if($step==9999)
  28. {
  29. ReWriteConfigAuto();
  30. UpDateCatCache();
  31. include('./templates/step-5.html');
  32. exit();
  33. }
  34. //用户选择的模块列表缓存文件
  35. if(!file_exists($moduleCacheFile))
  36. {
  37. $msg = "<font color='red'>由于无法找到模块缓存文件,安装可选模块失败,请登录后在模块管理处安装。</font><br /><br />";
  38. $msg .= "<a href='module-install.php?step=9999' target='_top'>点击此完成安装 &gt;&gt;</a>";
  39. ShowMsg($msg,'javascript:;');
  40. exit();
  41. }
  42. //模块文件夹权限
  43. if(!TestWrite($moduleDir))
  44. {
  45. $msg = "<font color='red'>目录 {$moduleDir} 不支持写入,不能安装模块,请登录后在模块管理处安装。</font><br /><br />";
  46. $msg .= "<a href='module-install.php?step=9999' target='_top'>点击此完成安装 &gt;&gt;</a>";
  47. ShowMsg($msg,"javascript:;");
  48. exit();
  49. }
  50. include($moduleCacheFile);
  51. $modules = split(',',$selModule);
  52. $totalMod = count($modules);
  53. if($step >= $totalMod)
  54. {
  55. $msg = "<font color='red'>完成所有模块的安装!</font><br /><br />";
  56. $msg .= "<a href='module-install.php?step=9999' target='_top'>点击此进行下一步操作 &gt;&gt;</a>";
  57. ShowMsg($msg,'javascript:;');
  58. exit();
  59. }
  60. $moduleHash = $modules[$step];
  61. $moduleFile = $allmodules[$moduleHash];
  62. $dm = new DedeModule($moduleDir);
  63. $minfos = $dm->GetModuleInfo($moduleHash);
  64. extract($minfos, EXTR_SKIP);
  65. $menustring = addslashes($dm->GetSystemFile($moduleHash,'menustring'));
  66. $query = "INSERT INTO `#@__sys_module`(`hashcode` , `modname` , `indexname` , `indexurl` , `ismember` , `menustring` )
  67. VALUES ('$moduleHash' , '$name' , '$indexname' , '$indexurl' , '$ismember' , '$menustring' ) ";
  68. $rs = $dsql->ExecuteNoneQuery("Delete From `#@__sys_module` where hashcode like '$moduleHash' ");
  69. $rs = $dsql->ExecuteNoneQuery($query);
  70. if(!$rs)
  71. {
  72. $msg = "<font color='red'>保存数据库信息失败,无法完成你选择的模块安装!</font><br /><br />";
  73. $msg .= "<a href='module-install.php?step=9999' target='_top'>点击此进行下一步操作 &gt;&gt;</a>";
  74. exit();
  75. }
  76. //写文件
  77. $dm->WriteFiles($moduleHash,1);
  78. $dm->WriteSystemFile($moduleHash,'readme');
  79. $setupsql = $dm->GetSystemFile($moduleHash,'setupsql40');
  80. //运行SQL
  81. $mysql_version = $dsql->GetVersion(TRUE);
  82. $setupsql = preg_replace("#ENGINE=MyISAM#i", 'TYPE=MyISAM', $setupsql);
  83. $sql41tmp = 'ENGINE=MyISAM DEFAULT CHARSET='.$cfg_db_language;
  84. if($mysql_version >= 4.1) {
  85. $setupsql = preg_replace("#TYPE=MyISAM#i", $sql41tmp, $setupsql);
  86. }
  87. //_ROOTURL_
  88. if($cfg_cmspath=='/') $cfg_cmspath = '';
  89. $rooturl = $cfg_basehost.$cfg_cmspath;
  90. $setupsql = preg_replace("#_ROOTURL_#i", $rooturl, $setupsql);
  91. $setupsql = preg_replace("#[\r\n]{1,}#", "\n", $setupsql);
  92. $sqls = preg_split("#;[ \t]{0,}\n#", $setupsql);
  93. foreach($sqls as $sql) {
  94. if(trim($sql)!='') $dsql->executenonequery($sql);
  95. }
  96. $dm->Clear();
  97. $step = $step + 1;
  98. ShowMsg("模块 {$name} 安装完成,准备下一模块安装...", "module-install.php?step={$step}");
  99. exit();