适用于SP1、SP2系统升级到DedeCMSV6
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.

163 lines
6.6KB

  1. <?php
  2. /**
  3. * @version $Id: common.func.php 2020-11-18 tianya $
  4. * @copyright Copyright (c) 2020, DedeBIZ.COM
  5. * @license https://www.dedebiz.com/license
  6. * @link https://www.dedebiz.com
  7. */
  8. $v6sql = <<<EOT
  9. ALTER TABLE `#@__tagindex`
  10. ADD COLUMN `uptime` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `addtime`,
  11. ADD COLUMN `mktime` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `uptime`;
  12. ALTER TABLE `#@__feedback`
  13. ADD COLUMN `fid` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `aid`;
  14. ALTER TABLE `#@__feedback`
  15. ADD COLUMN `replycount` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `dtime`;
  16. INSERT INTO `#@__sysconfig` (`varname`, `info`, `groupid`, `type`, `value`) VALUES ( 'cfg_feedback_msglen', '评论内容字数限定', 5, 'number', '200');
  17. INSERT INTO `#@__sysconfig` (`varname`, `info`, `groupid`, `type`, `value`) VALUES ( 'cfg_auth_code', '授权码(登录www.dedebiz.com进行商业授权)', 1, 'bstring', '');
  18. INSERT INTO `#@__sysconfig` (`varname`, `info`, `groupid`, `type`, `value`) VALUES ( 'cfg_bizcore_hostname', 'DedeBIZ Core地址', 1, 'string', '127.0.0.1');
  19. INSERT INTO `#@__sysconfig` (`varname`, `info`, `groupid`, `type`, `value`) VALUES ( 'cfg_bizcore_port', 'DedeBIZ Core端口', 1, 'number', '8181');
  20. INSERT INTO `#@__sysconfig` (`varname`, `info`, `groupid`, `type`, `value`) VALUES ( 'cfg_bizcore_appid', 'DedeBIZ Core应用ID', 1, 'string', '');
  21. INSERT INTO `#@__sysconfig` (`varname`, `info`, `groupid`, `type`, `value`) VALUES ( 'cfg_bizcore_key', 'DedeBIZ Core通信密钥', 1, 'string', '');
  22. CREATE TABLE `#@__feedback_goodbad` (
  23. `fgid` INT(11) NOT NULL AUTO_INCREMENT,
  24. `mid` INT(11) NOT NULL DEFAULT '0',
  25. `fid` INT(11) NOT NULL DEFAULT '0',
  26. `fgtype` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '0:good 1:bad',
  27. PRIMARY KEY (`fgid`)
  28. ) TYPE=MyISAM CHARSET=utf8;
  29. CREATE TABLE `#@__search_limits` (
  30. `ip` VARCHAR(200) NOT NULL,
  31. `searchtime` INT(11) NULL DEFAULT NULL,
  32. PRIMARY KEY (`ip`)
  33. ) TYPE=MyISAM CHARSET=utf8;
  34. EOT;
  35. function RpLine($str)
  36. {
  37. $str = str_replace("\r", "\\r", $str);
  38. $str = str_replace("\n", "\\n", $str);
  39. return $str;
  40. }
  41. function PutInfo($msg1,$msg2)
  42. {
  43. $msginfo = "<html>\n<head>
  44. <meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
  45. <title>DedeCMSV6 提示信息</title>
  46. <link rel=\"stylesheet\" href=\"static/css/bootstrap.min.css\"><style>.modal {position: static;}</style><link href=\"static/font-awesome/css/font-awesome.min.css\" rel=\"stylesheet\">
  47. <base target='_self'/>\n</head>\n<body leftmargin='0' topmargin='0'>\n<center>
  48. <br/>
  49. <main class='container'><div class='modal' tabindex='-1' role='dialog' style='display:block'><div class='modal-dialog'><div class='modal-content'><div class='modal-header'><h6 class='modal-title'>DedeCMSV6 提示信息</h6></div><div class='modal-body'>
  50. {$msg1}</div></div></div></div></main>\r\n{$msg2}";
  51. echo $msginfo."</center>\n</body>\n</html>";
  52. }
  53. function ShowMsgV6($msg, $gourl, $onlymsg=0, $limittime=0)
  54. {
  55. if(empty($GLOBALS['cfg_plus_dir'])) $GLOBALS['cfg_plus_dir'] = '..';
  56. $htmlhead = "<html>\r\n<head>\r\n<title>DedeCMSV6 提示信息</title>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">";
  57. $htmlhead .= "<link rel=\"stylesheet\" href=\"static/css/bootstrap.min.css\"><style>.modal {position: static;}</style><link href=\"static/font-awesome/css/font-awesome.min.css\" rel=\"stylesheet\">";
  58. $htmlhead .= "<base target='_self'/></head>\r\n<body leftmargin='0' topmargin='0' bgcolor='#FFFFFF'>".(isset($GLOBALS['ucsynlogin']) ? $GLOBALS['ucsynlogin'] : '')."\r\n<center>\r\n<script>\r\n";
  59. $htmlfoot = "</script>\r\n</center>\r\n</body>\r\n</html>\r\n";
  60. $litime = ($limittime==0 ? 1000 : $limittime);
  61. $func = '';
  62. if($gourl=='-1')
  63. {
  64. if($limittime==0) $litime = 5000;
  65. $gourl = "javascript:history.go(-1);";
  66. }
  67. if($gourl=='' || $onlymsg==1)
  68. {
  69. $msg = "<script>alert(\"".str_replace("\"","“",$msg)."\");</script>";
  70. }
  71. else
  72. {
  73. //当网址为:close::objname 时, 关闭父框架的id=objname元素
  74. if(preg_match('/close::/',$gourl))
  75. {
  76. $tgobj = trim(preg_replace('/close::/', '', $gourl));
  77. $gourl = 'javascript:;';
  78. $func .= "window.parent.document.getElementById('{$tgobj}').style.display='none';\r\n";
  79. }
  80. $func .= " var pgo=0;
  81. function JumpUrl(){
  82. if(pgo==0){ location='$gourl'; pgo=1; }
  83. }\r\n";
  84. $rmsg = $func;
  85. $rmsg .= "document.write(\"<main class='container'><div class='modal' tabindex='-1' role='dialog' style='display:block'><div class='modal-dialog'><div class='modal-content'><div class='modal-header'><h6 class='modal-title'>";
  86. $rmsg .= "DedeCMSV6 提示信息!</h6></div><div class='modal-body'>\");\r\n";
  87. $rmsg .= "document.write(\"".str_replace("\"","“",$msg)."\");\r\n";
  88. $rmsg .= "document.write(\"";
  89. if($onlymsg==0)
  90. {
  91. if( $gourl != 'javascript:;' && $gourl != '')
  92. {
  93. $rmsg .= "<br /><a href='{$gourl}'>如果你的浏览器没反应,请点击这里...</a>";
  94. $rmsg .= "</div></div></div></div></main>\");\r\n";
  95. $rmsg .= "setTimeout('JumpUrl()',$litime);";
  96. }
  97. else
  98. {
  99. $rmsg .= "</div></div></div></div></main>\");\r\n";
  100. }
  101. }
  102. else
  103. {
  104. $rmsg .= "</div></div></div></div></main>\");\r\n";
  105. }
  106. $msg = $htmlhead.$rmsg.$htmlfoot;
  107. }
  108. echo $msg;
  109. }
  110. $configfile = DEDEDATA.'/config.cache.inc.php';
  111. //更新配置函数
  112. function ReWriteConfig($conn)
  113. {
  114. global $configfile;
  115. if(!is_writeable($configfile))
  116. {
  117. echo "配置文件'{$configfile}'不支持写入,无法修改系统配置参数!";
  118. exit();
  119. }
  120. $fp = fopen($configfile,'w');
  121. flock($fp,3);
  122. fwrite($fp,"<"."?php\r\n");
  123. $sql = "SELECT `varname`,`type`,`value`,`groupid` FROM `#@__sysconfig` ORDER BY aid ASC ";
  124. $prefix="#@__";
  125. $sql = str_replace($prefix, $GLOBALS['cfg_dbprefix']."v6_", $sql);
  126. $result=mysqli_query($conn,$sql);
  127. while($row = mysqli_fetch_array($result,MYSQLI_ASSOC))
  128. {
  129. if($row['type']=='number')
  130. {
  131. if($row['value']=='') $row['value'] = 0;
  132. fwrite($fp,"\${$row['varname']} = ".$row['value'].";\r\n");
  133. }
  134. else
  135. {
  136. fwrite($fp,"\${$row['varname']} = '".str_replace("'",'',$row['value'])."';\r\n");
  137. }
  138. }
  139. fwrite($fp,"?".">");
  140. fclose($fp);
  141. }
  142. ?>