PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/core/init.php

https://bitbucket.org/simancms/simancms
PHP | 140 lines | 121 code | 11 blank | 8 comment | 37 complexity | 3b7d4d61534ad217b57d2c71ce49690d MD5 | raw file
  1. <?php
  2. //------------------------------------------------------------------------------
  3. //| Content Management System SiMan CMS |
  4. //| http://www.simancms.org |
  5. //------------------------------------------------------------------------------
  6. //==============================================================================
  7. //#ver 1.6.19
  8. //#revision 2020-04-09
  9. //==============================================================================
  10. if (is_array($siman_useragent_blacklist))
  11. for ($i = 0; $i < sm_count($siman_useragent_blacklist); $i++)
  12. {
  13. if (sm_strpos(strtolower($_SERVER['HTTP_USER_AGENT']), strtolower($siman_useragent_blacklist[$i])) !== false)
  14. {
  15. @header("HTTP/1.0 403 Forbidden");
  16. exit('Acceess denied');
  17. }
  18. }
  19. if ($siman_block_empty_useragent && sm_strlen($_SERVER['HTTP_USER_AGENT'])==0 && $special['cli']!==true)
  20. {
  21. @header("HTTP/1.0 403 Forbidden");
  22. exit('Acceess denied');
  23. }
  24. if (!empty($siman_cache) && file_exists('files/temp/cache_'.md5($_SERVER['REQUEST_URI'])))
  25. {
  26. if (filectime('files/temp/cache_'.md5($_SERVER['REQUEST_URI']))+$siman_cache<time())
  27. unlink('files/temp/cache_'.md5($_SERVER['REQUEST_URI']));
  28. else
  29. {
  30. $fh = fopen('files/temp/cache_'.md5($_SERVER['REQUEST_URI']), 'rb');
  31. fpassthru($fh);
  32. exit;
  33. }
  34. }
  35. if (empty($sm['disable_session']))
  36. {
  37. session_start();
  38. }
  39. $_getvars = $_GET;
  40. $_postvars = $_POST;
  41. $_cookievars = $_COOKIE;
  42. $_servervars = $_SERVER;
  43. $_uplfilevars = $_FILES;
  44. if (array_key_exists('m', $_getvars))
  45. sm_set_array_value($_getvars, 'm', (string)sm_getvars('m'));
  46. if (array_key_exists('d', $_getvars))
  47. sm_set_array_value($_getvars, 'd', (string)sm_getvars('d'));
  48. if (empty($sm['disable_session']))
  49. {
  50. if (!empty($_SESSION) && is_array($_SESSION))
  51. foreach ($_SESSION as $key=>$val)
  52. {
  53. if (strcmp(substr($key, 0, sm_strlen($session_prefix)), $session_prefix) == 0)
  54. {
  55. $key = substr($key, sm_strlen($session_prefix));
  56. $_sessionvars[$key] = $val;
  57. }
  58. }
  59. }
  60. $special['main_tpl'] = 'index';
  61. $special['page_url'] = 'index.php';
  62. if (!empty($_servervars['QUERY_STRING']))
  63. $special['page_url'] .= '?'.$_servervars['QUERY_STRING'];
  64. $singleWindow = 0;
  65. $special['printmode'] = 'off';
  66. if (!empty(sm_getvars('printmode')))
  67. {
  68. if (sm_getvars('printmode') == 'on' || sm_getvars('printmode') == 1)
  69. {
  70. $special['printmode'] = 'on';
  71. $special['main_tpl'] = 'indexprint';
  72. }
  73. }
  74. if (!empty(sm_getvars('ajax')))
  75. {
  76. if (sm_getvars('ajax') == 1 || sm_getvars('ajax') == 'on')
  77. {
  78. $special['ajax'] = 1;
  79. $special['main_tpl'] = 'simpleout';
  80. $singleWindow = 1;
  81. }
  82. }
  83. if (!empty(sm_getvars('theonepage')))
  84. {
  85. if (sm_getvars('theonepage')==1 || sm_getvars('theonepage')=='on')
  86. {
  87. $special['main_tpl']='theonepage';
  88. $special['no_blocks']=true;
  89. $special['no_borders_main_block']=true;
  90. }
  91. }
  92. if (!empty(sm_getvars('chngdsrc')))
  93. {
  94. if (is_numeric(sm_getvars('chngdsrc')))
  95. {
  96. if (!empty($_settings['allowed_db_prefixes'][sm_getvars('chngdsrc')]))
  97. $_sessionvars['overwritedbprefix'] = $_settings['allowed_db_prefixes'][sm_getvars('chngdsrc')];
  98. }
  99. }
  100. if (!empty($_sessionvars['overwritedbprefix']))
  101. {
  102. if ($tableusersprefix == $tableprefix)
  103. $tableusersprefix = $_sessionvars['overwritedbprefix'];
  104. $tableprefix = $_sessionvars['overwritedbprefix'];
  105. }
  106. $sm['g'] =& $_getvars;
  107. $sm['p'] =& $_postvars;
  108. $sm['server'] =& $_servervars;
  109. $sm['cookies'] =& $_cookievars;
  110. $sm['files'] =& $_uplfilevars;
  111. $sm['session'] =& $_sessionvars;
  112. $sm['s'] =& $special;
  113. $sm['t'] =& $tableprefix;
  114. $sm['tu'] =& $tableusersprefix;
  115. $sm['output_replacers']=[];
  116. $sm['cacheit']=false;
  117. $sm['other']['includedlanguages']=[];
  118. $sm['s']['page_system_id'] = 'smp'.microtime(true).$sm['s']['rand'];
  119. $sm['s']['customcss']=[];
  120. $sm['s']['cssfiles']=[];
  121. $sm['s']['customjs']=[];
  122. $sm['s']['path']=[];
  123. $sm['s']['pagetitle']='';
  124. $sm['s']['document']['headdef']='';
  125. $sm['s']['document']['headend']='';
  126. $sm['s']['document']['bodyend']='';
  127. $sm['s']['document']['body_onload']='';
  128. $sm['s']['document']['bodymodifier']='';
  129. $sm['s']['textout']='';