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

117 lines
3.3KB

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