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

113 lines
3.4KB

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