license.php 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: linyunming
  5. * Date: 2016/5/16
  6. * Time: 18:05
  7. */
  8. /*
  9. $saas_public_dir = APP_ROOT_PATH."install/Runtime".$GLOBALS['saas_public']."/";
  10. if(!file_exists($saas_public_dir))@mkdir($saas_public_dir,0777);
  11. $saas_public_dir = APP_ROOT_PATH."public".$GLOBALS['saas_public']."/";
  12. if(!file_exists($saas_public_dir))@mkdir($saas_public_dir,0777);
  13. $saas_public_dir = APP_ROOT_PATH."public".$GLOBALS['saas_public']."/attachment/";
  14. if(!file_exists($saas_public_dir))@mkdir($saas_public_dir,0777);
  15. $saas_public_dir = APP_ROOT_PATH."public".$GLOBALS['saas_public']."/db_backup/";
  16. if(!file_exists($saas_public_dir))@mkdir($saas_public_dir,0777);
  17. $saas_public_dir = APP_ROOT_PATH."public".$GLOBALS['saas_public']."/runtime/";
  18. if(!file_exists($saas_public_dir))@mkdir($saas_public_dir,0777);
  19. $saas_public_dir = APP_ROOT_PATH."public".$GLOBALS['saas_public']."/runtime/admin/";
  20. if(!file_exists($saas_public_dir))@mkdir($saas_public_dir,0777);
  21. $saas_public_dir = APP_ROOT_PATH."public".$GLOBALS['saas_public']."/session/";
  22. if(!file_exists($saas_public_dir))@mkdir($saas_public_dir,0777);
  23. $saas_public_dir = APP_ROOT_PATH."public".$GLOBALS['saas_public']."/uc_data/";
  24. if(!file_exists($saas_public_dir))@mkdir($saas_public_dir,0777);
  25. $saas_public_dir = APP_ROOT_PATH."public".$GLOBALS['saas_public']."/timezone_config.php";
  26. if(!file_exists($saas_public_dir))
  27. {
  28. @file_put_contents($saas_public_dir, @file_get_contents(APP_ROOT_PATH."public".$GLOBALS['saas_public']."/timezone_config.php"));
  29. }
  30. $saas_public_dir = APP_ROOT_PATH."public".$GLOBALS['saas_public']."/sys_config.php";
  31. if(!file_exists($saas_public_dir))
  32. {
  33. @file_put_contents($saas_public_dir, @file_get_contents(APP_ROOT_PATH."public".$GLOBALS['saas_public']."/sys_config.php"));
  34. }
  35. $saas_public_dir = APP_ROOT_PATH."public".$GLOBALS['saas_public']."/version.php";
  36. if(!file_exists($saas_public_dir))
  37. {
  38. @file_put_contents($saas_public_dir, @file_get_contents(APP_ROOT_PATH.'system/version.php'));
  39. }
  40. */
  41. if (PHP_VERSION >= '5.0.0')
  42. {
  43. $begin_run_time = @microtime(true);
  44. }
  45. else
  46. {
  47. $begin_run_time = @microtime();
  48. }
  49. @set_magic_quotes_runtime (0);
  50. define('MAGIC_QUOTES_GPC',get_magic_quotes_gpc()?True:False);
  51. if(!defined('IS_CGI'))
  52. define('IS_CGI',substr(PHP_SAPI, 0,3)=='cgi' ? 1 : 0 );
  53. if(!defined('_PHP_FILE_')) {
  54. if(IS_CGI) {
  55. //CGI/FASTCGI模式下
  56. $_temp = explode('.php',$_SERVER["PHP_SELF"]);
  57. define('_PHP_FILE_', rtrim(str_replace($_SERVER["HTTP_HOST"],'',$_temp[0].'.php'),'/'));
  58. }else {
  59. define('_PHP_FILE_', rtrim($_SERVER["SCRIPT_NAME"],'/'));
  60. }
  61. }
  62. if(!defined('APP_ROOT')) {
  63. // 网站URL根目录
  64. $_root = dirname(_PHP_FILE_);
  65. $_root = (($_root=='/' || $_root=='\\')?'':$_root);
  66. $_root = str_replace("/system","",$_root);
  67. $_root = str_replace("/wap","",$_root);
  68. $_root = str_replace("/mapi","",$_root);
  69. define('APP_ROOT', $_root );
  70. }
  71. //引入时区配置及定义时间函数
  72. if(function_exists('date_default_timezone_set')){
  73. if(app_conf('DEFAULT_TIMEZONE')){
  74. date_default_timezone_set(app_conf('DEFAULT_TIMEZONE'));
  75. }else{
  76. date_default_timezone_set('PRC');
  77. }
  78. }
  79. //引入数据库的系统配置及定义配置函数
  80. require APP_ROOT_PATH.'system/common.php';
  81. //end 引入时区配置及定义时间函数
  82. define("NOW_TIME",get_gmtime()); //当前UTC时间戳
  83. define("CLIENT_IP",get_client_ip()); //当前客户端IP
  84. define("SITE_DOMAIN",get_domain()); //站点域名
  85. define("SITE_DOMAIN_DOWNLOAD",get_domain()); //下载站点域名
  86. define("TIME_ZONE",app_conf('DEFAULT_TIMEZONE')); //时区
  87. if(file_exists(APP_ROOT_PATH."public/install.lock")){
  88. update_sys_config();
  89. }
  90. $sys_config = require APP_ROOT_PATH.'system/config.php';
  91. //end 分布式
  92. function app_conf($name)
  93. {
  94. if(isset($GLOBALS['sys_config'][$name])){
  95. return stripslashes($GLOBALS['sys_config'][$name]);
  96. }else{
  97. return false;
  98. }
  99. }
  100. //定义$_SERVER['REQUEST_URI']兼容性
  101. if (!isset($_SERVER['REQUEST_URI']))
  102. {
  103. if (isset($_SERVER['argv']))
  104. {
  105. $uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['argv'][0];
  106. }
  107. else
  108. {
  109. $uri = $_SERVER['PHP_SELF'] .'?'. $_SERVER['QUERY_STRING'];
  110. }
  111. $_SERVER['REQUEST_URI'] = $uri;
  112. }
  113. filter_request($_GET);
  114. filter_request($_POST);
  115. if(IS_DEBUG)
  116. error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
  117. else
  118. error_reporting(0);
  119. //end 引入数据库的系统配置及定义配置函数
  120. require APP_ROOT_PATH.'system/db/db.php';
  121. require APP_ROOT_PATH.'system/utils/es_cookie.php';
  122. require APP_ROOT_PATH.'system/utils/es_session.php';
  123. //es_session::start();
  124. if(true)
  125. {
  126. //重写模式
  127. $current_url = APP_ROOT;
  128. if(isset($_REQUEST['rewrite_param']))
  129. $rewrite_param = $_REQUEST['rewrite_param'];
  130. else
  131. $rewrite_param = "";
  132. $rewrite_param = str_replace(array( "\"","'" ), array("",""), $rewrite_param);
  133. $rewrite_param = explode("/",$rewrite_param);
  134. $rewrite_param_array = array();
  135. foreach($rewrite_param as $k=>$param_item)
  136. {
  137. if($param_item!='')
  138. $rewrite_param_array[] = $param_item;
  139. }
  140. foreach ($rewrite_param_array as $k=>$v)
  141. {
  142. if(substr($v,0,1)=='-')
  143. {
  144. //扩展参数
  145. $v = substr($v,1);
  146. $ext_param = explode("-",$v);
  147. foreach($ext_param as $kk=>$vv)
  148. {
  149. if($kk%2==0)
  150. {
  151. if(preg_match("/(\w+)\[(\w+)\]/",$vv,$matches))
  152. {
  153. $_GET[$matches[1]][$matches[2]] = $ext_param[$kk+1];
  154. }
  155. else
  156. $_GET[$ext_param[$kk]] = $ext_param[$kk+1];
  157. if($ext_param[$kk]!="p")
  158. {
  159. $current_url.=$ext_param[$kk];
  160. $current_url.="-".$ext_param[$kk+1]."-";
  161. }
  162. }
  163. }
  164. }
  165. elseif($k==0)
  166. {
  167. //解析ctl与act
  168. $ctl_act = explode("-",$v);
  169. if($ctl_act[0]!='id')
  170. {
  171. $_GET[CTL] = !empty($ctl_act[0])?$ctl_act[0]:"";
  172. $_GET[ACT] = !empty($ctl_act[1])?$ctl_act[1]:"";
  173. $current_url.="/".$ctl_act[0];
  174. if(!empty($ctl_act[1]))
  175. $current_url.="-".$ctl_act[1]."/";
  176. else
  177. $current_url.="/";
  178. }
  179. else
  180. {
  181. //扩展参数
  182. $ext_param = explode("-",$v);
  183. foreach($ext_param as $kk=>$vv)
  184. {
  185. if($kk%2==0)
  186. {
  187. if(preg_match("/(\w+)\[(\w+)\]/",$vv,$matches))
  188. {
  189. $_GET[$matches[1]][$matches[2]] = $ext_param[$kk+1];
  190. }
  191. else
  192. $_GET[$ext_param[$kk]] = $ext_param[$kk+1];
  193. if($ext_param[$kk]!="p")
  194. {
  195. if($kk==0)$current_url.="/";
  196. $current_url.=$ext_param[$kk];
  197. $current_url.="-".$ext_param[$kk+1]."-";
  198. }
  199. }
  200. }
  201. }
  202. }elseif($k==1)
  203. {
  204. //扩展参数
  205. $ext_param = explode("-",$v);
  206. foreach($ext_param as $kk=>$vv)
  207. {
  208. if($kk%2==0)
  209. {
  210. if(preg_match("/(\w+)\[(\w+)\]/",$vv,$matches))
  211. {
  212. $_GET[$matches[1]][$matches[2]] = $ext_param[$kk+1];
  213. }
  214. else
  215. $_GET[$ext_param[$kk]] = $ext_param[$kk+1];
  216. if($ext_param[$kk]!="p")
  217. {
  218. $current_url.=$ext_param[$kk];
  219. $current_url.="-".$ext_param[$kk+1]."-";
  220. }
  221. }
  222. }
  223. }
  224. }
  225. $current_url = substr($current_url,-1)=="-"?substr($current_url,0,-1):$current_url;
  226. }
  227. unset($_REQUEST['rewrite_param']);
  228. unset($_GET['rewrite_param']);
  229. //定义缓存
  230. require APP_ROOT_PATH.'system/cache/Cache.php';
  231. $cache = CacheService::getInstance();
  232. //$cache->celar_con();
  233. require_once APP_ROOT_PATH."system/cache/CacheFileService.php";
  234. $fcache = new CacheFileService(); //专用于保存静态数据的缓存实例
  235. $fcache->set_dir(APP_ROOT_PATH."public/runtime/data/");
  236. //end 定义缓存
  237. //定义DB
  238. define('DB_PREFIX', app_conf('DB_PREFIX'));
  239. if(!file_exists(APP_ROOT_PATH.'public/runtime/app/db_caches/'))
  240. mkdir(APP_ROOT_PATH.'public/runtime/app/db_caches/',0777);
  241. $pconnect = false;
  242. $db = new mysql_db(app_conf('DB_HOST').":".app_conf('DB_PORT'), app_conf('DB_USER'),app_conf('DB_PWD'),app_conf('DB_NAME'),'utf8',$pconnect);
  243. //end 定义DB
  244. //定义模板引擎
  245. require APP_ROOT_PATH.'system/template/template.php';
  246. if(!file_exists(APP_ROOT_PATH.'public/runtime/app/tpl_caches/'))
  247. mkdir(APP_ROOT_PATH.'public/runtime/app/tpl_caches/',0777);
  248. if(!file_exists(APP_ROOT_PATH.'public/runtime/app/tpl_compiled/'))
  249. mkdir(APP_ROOT_PATH.'public/runtime/app/tpl_compiled/',0777);
  250. $tmpl = new AppTemplate;
  251. //end 定义模板引擎
  252. $_REQUEST = array_merge($_GET,$_POST);
  253. filter_request($_REQUEST);
  254. if(file_exists(APP_ROOT_PATH.'system/wechat/platform_wechat.class.php')){
  255. require APP_ROOT_PATH.'system/wechat/platform_wechat.class.php';
  256. }
  257. require APP_ROOT_PATH.'system/utils/message_send.php';
  258. $msg = new message_send();
  259. //关于安装的检测
  260. if(!file_exists(APP_ROOT_PATH."public/install.lock"))
  261. {
  262. app_redirect(APP_ROOT."/install/index.php");
  263. }
  264. if(IS_DEBUG){
  265. ini_set("display_errors", 1);
  266. error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING ^ E_DEPRECATED);
  267. $GLOBALS['msg']->set_debug(true);
  268. }
  269. else
  270. error_reporting(0);
  271. //输出后台URL文件名称
  272. define('URL_NAME',app_conf("URL_NAME"));
  273. $GLOBALS['tmpl']->assign("URL_NAME",URL_NAME);
  274. define('DEFAULT_MODULE_NAME','index');