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

common.inc.php 9.6KB

2 年之前
2 年之前
2 年之前
4 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
4 年之前
2 年之前
2 年之前
2 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <?php
  2. /**
  3. * @version $Id: common.inc.php 3 17:44 2010-11-23 tianya $
  4. * @package DedeBIZ.Libraries
  5. * @copyright Copyright (c) 2022, DedeBIZ.COM
  6. * @license https://www.dedebiz.com/license
  7. * @link https://www.dedebiz.com
  8. */
  9. //生产环境使用production,如果采用dev模式,会有一些php的报错信息提示,便于开发调试
  10. if (!defined('DEDE_ENVIRONMENT')) {
  11. define('DEDE_ENVIRONMENT', 'production');
  12. }
  13. if (!defined('DEBUG_LEVEL')) {
  14. define('DEBUG_LEVEL', FALSE);//如果设置为TRUE则会打印执行SQL的时间和标签加载时间方便调试
  15. }
  16. if (DEDE_ENVIRONMENT == 'production') {
  17. ini_set('display_errors', 0);
  18. if (version_compare(PHP_VERSION, '5.3', '>='))
  19. {
  20. error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
  21. } else {
  22. error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
  23. }
  24. } else {
  25. error_reporting(-1);
  26. ini_set('display_errors', 1);
  27. }
  28. define('DEDEINC', str_replace("\\", '/', dirname(__FILE__)));
  29. define('DEDEROOT', str_replace("\\", '/', substr(DEDEINC, 0, -6))); // 站点根目录
  30. define('DEDEDATA', substr(DEDEINC, 0, -6).'data');
  31. define('DEDESTATIC', DEDEROOT.'/static');
  32. define('DEDEMEMBER', DEDEROOT.'/user');
  33. define('DEDETEMPLATE', DEDEROOT.'/theme');
  34. define('DEDEBIZURL', "https://www.dedebiz.com");//Dede商业支持
  35. define('DEDEVER', 6);//当前系统大版本
  36. define('DEDEPUB', '-----BEGIN PUBLIC KEY-----
  37. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvupO2Lixns34bBqwTzK0
  38. 9wA9sfGBdgc03zh1sUacieJBikx08e7xmkJbMF81jb/YfNGW/+iJ3qHULdc9Dtd3
  39. +FsnHG+tUDnzjkPnVVmnrjucQqfHRRVKKAgXOWxtuRKUVF3NDjiJtDAf5Y2BMAhw
  40. oqzeepye5I4mWyO4A8/V2ougO+xDK426MIf1dq+W59NVZj8k+zeZrbPh7+fPFw4u
  41. PwAMpkTJJ9nwNOO6saH2eMGaQ3oxZIQ+SmminDB8miI/+hwIn2hNmaHFuur0OGlB
  42. NQabUzX9JoYtXqPcpZRT7ymHrppU0KFdUSEJiW0utTWJo0HrDOBIT5qWlM0MP9p/
  43. PwIDAQAB
  44. -----END PUBLIC KEY-----');//DedeBIZ系统公钥
  45. define('DEDECDNURL', 'https://cdn.dedebiz.com'); //默认静态资源地址
  46. if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
  47. if (!function_exists('session_register')) {
  48. function session_register()
  49. {
  50. $args = func_get_args();
  51. foreach ($args as $key) {
  52. $_SESSION[$key] = $GLOBALS[$key];
  53. }
  54. }
  55. function session_is_registered($key)
  56. {
  57. return isset($_SESSION[$key]);
  58. }
  59. function session_unregister($key)
  60. {
  61. unset($_SESSION[$key]);
  62. }
  63. }
  64. }
  65. //是否启用mb_substr替换cn_substr来提高效率
  66. $cfg_is_mb = $cfg_is_iconv = FALSE;
  67. if (function_exists('mb_substr')) $cfg_is_mb = TRUE;
  68. if (function_exists('iconv_substr')) $cfg_is_iconv = TRUE;
  69. function _RunMagicQuotes(&$svar)
  70. {
  71. if (is_array($svar)) {
  72. foreach ($svar as $_k => $_v) {
  73. if ($_k == 'nvarname') continue;
  74. _RunMagicQuotes($_k);
  75. $svar[$_k] = _RunMagicQuotes($_v);
  76. }
  77. } else {
  78. if (strlen($svar) > 0 && preg_match('#^(cfg_|GLOBALS|_GET|_REQUEST|_POST|_COOKIE|_SESSION)#', $svar)) {
  79. exit('Request var not allow!');
  80. }
  81. $svar = addslashes($svar);
  82. }
  83. return $svar;
  84. }
  85. foreach (array('_GET', '_POST', '_COOKIE') as $_req) {
  86. foreach ($$_req as $_k => $_v) {
  87. if ($_k == 'nvarname') ${$_k} = $_v;
  88. else ${$_k} = _RunMagicQuotes($_v);
  89. }
  90. }
  91. //系统相关变量检测
  92. if (!isset($needFilter)) {
  93. $needFilter = false;
  94. }
  95. $registerGlobals = @ini_get("register_globals");
  96. $isUrlOpen = @ini_get("allow_url_fopen");
  97. $isSafeMode = @ini_get("safe_mode");
  98. if (preg_match('/windows/i', @getenv('OS'))) {
  99. $isSafeMode = false;
  100. }
  101. //系统配置参数
  102. require_once(DEDEDATA."/config.cache.inc.php");
  103. //Session保存路径
  104. $sessSaveHandler = @ini_get("session.save_handler");
  105. if ($sessSaveHandler !== "files") {
  106. @ini_set("session.save_handler", "files");
  107. }
  108. $enkey = substr(md5(substr($cfg_cookie_encode, 0, 5)), 0, 10);
  109. $sessSavePath = DEDEDATA."/sessions_{$enkey}";
  110. if (!is_dir($sessSavePath)) mkdir($sessSavePath);
  111. if (is_writeable($sessSavePath) && is_readable($sessSavePath)) {
  112. session_save_path($sessSavePath);
  113. }
  114. //转换上传的文件相关的变量及安全处理、并引用前台通用的上传函数
  115. if ($_FILES) {
  116. require_once(DEDEINC.'/uploadsafe.inc.php');
  117. }
  118. //数据库配置文件
  119. require_once(DEDEDATA.'/common.inc.php');
  120. if (!isset($cfg_dbtype)) {
  121. $cfg_dbtype = 'mysql';
  122. }
  123. //载入系统验证安全配置
  124. if (file_exists(DEDEDATA.'/safe/inc_safe_config.php')) {
  125. require_once(DEDEDATA.'/safe/inc_safe_config.php');
  126. if (!empty($safe_faqs)) $safefaqs = unserialize($safe_faqs);
  127. }
  128. //Session跨域设置
  129. if (!empty($cfg_domain_cookie)) {
  130. @session_set_cookie_params(0, '/', $cfg_domain_cookie);
  131. }
  132. //php5.1版本以上时区设置
  133. //由于这个函数对于是php5.1以下版本并无意义,因此实际上的时间调用,应该用MyDate函数调用
  134. if (PHP_VERSION > '5.1') {
  135. $time51 = $cfg_cli_time * -1;
  136. @date_default_timezone_set('Etc/GMT'.$time51);
  137. }
  138. $cfg_isUrlOpen = @ini_get("allow_url_fopen");
  139. //用户访问的网站host
  140. if (PHP_SAPI === 'cli') {
  141. $cfg_clihost = 'https://www.dedebiz.com';
  142. } else {
  143. $cfg_clihost = 'http://'.$_SERVER['HTTP_HOST'];
  144. }
  145. //站点根目录
  146. $cfg_basedir = preg_replace('#'.$cfg_cmspath.'\/system$#i', '', DEDEINC);
  147. if ($cfg_multi_site == 'Y') {
  148. $cfg_mainsite = $cfg_basehost;
  149. } else {
  150. $cfg_mainsite = '';
  151. }
  152. //模板的存放目录
  153. $cfg_templets_dir = $cfg_cmspath.'/theme';
  154. $cfg_templeturl = $cfg_mainsite.$cfg_templets_dir;
  155. $cfg_templets_skin = empty($cfg_df_style) ? $cfg_mainsite.$cfg_templets_dir."/templets" : $cfg_mainsite.$cfg_templets_dir."/$cfg_df_style";
  156. //cms安装目录的网址
  157. $cfg_cmsurl = $cfg_mainsite.$cfg_cmspath;
  158. //插件目录,这个目录是用于存放计数器、投票、评论等程序的必要动态程序
  159. $cfg_plus_dir = $cfg_cmspath.'/apps';
  160. $cfg_phpurl = $cfg_mainsite.$cfg_plus_dir;
  161. $cfg_static_dir = $cfg_cmspath.'/static';
  162. $cfg_staticurl = $cfg_mainsite.$cfg_static_dir;
  163. $cfg_mobileurl = $cfg_mainsite.$cfg_mobile_dir;
  164. $cfg_data_dir = $cfg_cmspath.'/data';
  165. $cfg_dataurl = $cfg_mainsite.$cfg_data_dir;
  166. //会员目录
  167. $cfg_member_dir = $cfg_cmspath.'/user';
  168. $cfg_memberurl = $cfg_mainsite.$cfg_member_dir;
  169. //专题列表的存放路径
  170. $cfg_special = $cfg_cmspath.'/a/special';
  171. $cfg_specialurl = $cfg_mainsite.$cfg_special;
  172. //附件目录
  173. $cfg_medias_dir = $cfg_cmspath.$cfg_medias_dir;
  174. $cfg_mediasurl = $cfg_mainsite.$cfg_medias_dir;
  175. //上传的普通图片的路径,建议按默认
  176. $cfg_image_dir = $cfg_medias_dir.'/allimg';
  177. //用户投稿图片存放目录
  178. $cfg_user_dir = $cfg_medias_dir.'/userup';
  179. //上传的软件目录
  180. $cfg_soft_dir = $cfg_medias_dir.'/soft';
  181. //上传的多媒体文件目录
  182. $cfg_other_medias = $cfg_medias_dir.'/media';
  183. //软件摘要信息,****请不要删除本项**** 否则系统无法正确接收系统漏洞或升级信息
  184. $cfg_version = 'V6';
  185. $cfg_version_detail = '6.1.9beta'; //详细版本号
  186. $cfg_soft_lang = 'utf-8';
  187. $cfg_soft_public = 'base';
  188. $cfg_softname = '织梦内容管理系统';
  189. $cfg_soft_enname = 'DedeCMSV6';
  190. $cfg_soft_devteam = 'DedeBIZ';
  191. //文档的默认命名规则
  192. $art_shortname = $cfg_df_ext = '.html';
  193. $cfg_df_namerule = '{typedir}/{aid}'.$cfg_df_ext;
  194. //新建目录的权限,如果您使用别的属性,本程不保证程序能顺利在Linux或Unix系统运行
  195. if (isset($cfg_ftp_mkdir) && $cfg_ftp_mkdir == 'Y') {
  196. $cfg_dir_purview = '0755';
  197. } else {
  198. $cfg_dir_purview = 0755;
  199. }
  200. //会员是否使用精简模式
  201. $cfg_mb_lit = 'Y';
  202. //特殊全局变量
  203. $_sys_globals['curfile'] = '';
  204. $_sys_globals['typeid'] = 0;
  205. $_sys_globals['typename'] = '';
  206. $_sys_globals['aid'] = 0;
  207. if (empty($cfg_addon_savetype)) {
  208. $cfg_addon_savetype = 'Ymd';
  209. }
  210. if ($cfg_sendmail_bysmtp == 'Y' && !empty($cfg_smtp_usermail)) {
  211. $cfg_adminemail = $cfg_smtp_usermail;
  212. }
  213. //DedeBIZ商业化组件
  214. require_once(DEDEINC.'/libraries/dedebiz.class.php');
  215. //对全局分页传递参数进行过滤
  216. if (isset($GLOBALS['PageNo'])) {
  217. $GLOBALS['PageNo'] = intval($GLOBALS['PageNo']);
  218. }
  219. if (isset($GLOBALS['TotalResult'])) {
  220. $GLOBALS['TotalResult'] = intval($GLOBALS['TotalResult']);
  221. }
  222. if (!isset($cfg_NotPrintHead)) {
  223. if (PHP_SAPI != 'cli') {
  224. header("Content-Type: text/html; charset={$cfg_soft_lang}");
  225. }
  226. }
  227. //自动加载类库处理
  228. if (version_compare(PHP_VERSION, '7.2.0', '>=')) {
  229. require_once(DEDEINC.'/autoload7.inc.php');
  230. } else {
  231. require_once(DEDEINC.'/autoload.inc.php');
  232. }
  233. $cfg_biz_helpUrl = DEDEBIZURL."/help";
  234. $cfg_biz_gitUrl = DEDEBIZURL."/git";
  235. $cfg_biz_dedebizUrl = DEDEBIZURL;
  236. //引入数据库类
  237. if (!defined('MYSQL_BOTH')) {
  238. define('MYSQL_BOTH', MYSQLI_BOTH);
  239. }
  240. if (!defined('MYSQL_ASSOC')) {
  241. define('MYSQL_ASSOC', MYSQLI_ASSOC);
  242. }
  243. if (!defined('MYSQL_NUM')) {
  244. define('MYSQL_NUM', MYSQLI_NUM);
  245. }
  246. //全局常用函数
  247. require_once(DEDEINC.'/common.func.php');
  248. if ($GLOBALS['cfg_dbtype'] == 'mysql' || $GLOBALS['cfg_dbtype'] == 'mysqli') {
  249. require_once(DEDEINC.'/database/dedesqli.class.php');
  250. } else {
  251. require_once(DEDEINC.'/database/dedesqlite.class.php');
  252. }
  253. //载入小助手配置,并对其进行默认初始化
  254. $cfg_helper_autoload = array(
  255. 'charset', /* 编码小助手 */
  256. 'channelunit',/* 模型单元小助手 */
  257. 'string', /* 字符串小助手 */
  258. 'time', /* 日期小助手 */
  259. 'file', /* 文件小助手 */
  260. 'util', /* 单元小助手 */
  261. 'validate', /* 数据验证小助手 */
  262. 'filter', /* 过滤器小助手 */
  263. 'cookie', /* cookies小助手 */
  264. 'debug', /* 调试小助手 */
  265. 'archive', /* 文档小助手 */
  266. 'upload', /* 上传小助手 */
  267. 'extend', /* 扩展小助手 */
  268. );
  269. //初始化小助手
  270. helper($cfg_helper_autoload);