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

120 lines
3.9KB

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