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

118 lines
3.4KB

  1. <?php
  2. /**
  3. * @version $Id: install.inc.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. function RunMagicQuotes(&$str)
  11. {
  12. if(!get_magic_quotes_gpc()) {
  13. if( is_array($str) )
  14. foreach($str as $key => $val) $str[$key] = RunMagicQuotes($val);
  15. else
  16. $str = addslashes($str);
  17. }
  18. return $str;
  19. }
  20. function gdversion()
  21. {
  22. //没启用php.ini函数的情况下如果有GD默认视作2.0以上版本
  23. if(!function_exists('phpinfo'))
  24. {
  25. if(function_exists('imagecreate')) return '2.0';
  26. else return 0;
  27. }
  28. else
  29. {
  30. ob_start();
  31. phpinfo(8);
  32. $module_info = ob_get_contents();
  33. ob_end_clean();
  34. if(preg_match("/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i", $module_info,$matches)) { $gdversion_h = $matches[1]; }
  35. else { $gdversion_h = 0; }
  36. return $gdversion_h;
  37. }
  38. }
  39. function GetBackAlert($msg,$isstop=0)
  40. {
  41. global $s_lang;
  42. $msg = str_replace('"','`',$msg);
  43. if($isstop==1) $msg = "<script>\r\n<!--\r\n alert(\"{$msg}\");\r\n-->\r\n</script>\r\n";
  44. else $msg = "<script>\r\n<!--\r\n alert(\"{$msg}\");history.go(-1);\r\n-->\r\n</script>\r\n";
  45. $msg = "<meta http-equiv=content-type content='text/html; charset={$s_lang}'>\r\n".$msg;
  46. return $msg;
  47. }
  48. function TestWrite($d)
  49. {
  50. $tfile = '_dedet.txt';
  51. $d = preg_replace("#\/$#", '', $d);
  52. $fp = @fopen($d.'/'.$tfile,'w');
  53. if(!$fp) return false;
  54. else
  55. {
  56. fclose($fp);
  57. $rs = @unlink($d.'/'.$tfile);
  58. if($rs) return true;
  59. else return false;
  60. }
  61. }
  62. function ReWriteConfigAuto()
  63. {
  64. global $dsql;
  65. $configfile = DEDEDATA.'/config.cache.inc.php';
  66. if(!is_writeable($configfile))
  67. {
  68. echo "配置文件'{$configfile}'不支持写入,无法修改系统配置参数!";
  69. //ClearAllLink();
  70. exit();
  71. }
  72. $fp = fopen($configfile,'w');
  73. flock($fp,3);
  74. fwrite($fp,"<"."?php\r\n");
  75. $dsql->SetQuery("Select `varname`,`type`,`value`,`groupid` From `#@__sysconfig` order by aid asc ");
  76. $dsql->Execute();
  77. while($row = $dsql->GetArray())
  78. {
  79. if($row['type']=='number') fwrite($fp,"\${$row['varname']} = ".$row['value'].";\r\n");
  80. else fwrite($fp,"\${$row['varname']} = '".str_replace("'",'',$row['value'])."';\r\n");
  81. }
  82. fwrite($fp,"?".">");
  83. fclose($fp);
  84. }
  85. //更新栏目缓存
  86. function UpDateCatCache()
  87. {
  88. global $conn,$cfg_multi_site,$dbprefix;
  89. $cache1 = DEDEDATA."/cache/inc_catalog_base.inc";
  90. $rs = mysql_query("Select id,reid,channeltype,issend,typename From `".$dbprefix."arctype`", $conn);
  91. $fp1 = fopen($cache1,'w');
  92. $phph = '?';
  93. $fp1Header = "<{$phph}php\r\nglobal \$cfg_Cs;\r\n\$cfg_Cs=array();\r\n";
  94. fwrite($fp1,$fp1Header);
  95. while($row=mysql_fetch_array($rs))
  96. {
  97. $row['typename'] = base64_encode($row['typename']);
  98. fwrite($fp1,"\$cfg_Cs[{$row['id']}]=array({$row['reid']},{$row['channeltype']},{$row['issend']},'{$row['typename']}');\r\n");
  99. }
  100. fwrite($fp1,"{$phph}>");
  101. fclose($fp1);
  102. }
  103. function IsDownLoad($url)
  104. {
  105. if(file_exists($url.'.xml')){
  106. return true;
  107. }else{
  108. return false;
  109. }
  110. }