/lib/source.class.php
PHP | 52 lines | 50 code | 2 blank | 0 comment | 1 complexity | 42d1039e304d0fef94f76d55e7570002 MD5 | raw file
Possible License(s): LGPL-3.0
- <?php
- if(DEBUG){
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- }else {
- error_reporting(0);
- ini_set('display_errors', 1);
- }
- define('DIR', strtr(dirname(dirname(__FILE__)), array('\\'=>'/')).'/');
- define('DIR_APP', DIR.'app/');
- define('DIR_CLASS', DIR.'class/');
- define('DIR_CONF', DIR.'conf/');
- define('DIR_FUN', DIR.'fun/');
- define('DIR_LIB', DIR.'lib/');
- define('DIR_TPL', DIR.'tpl/');
- require DIR_LIB.'Libs.class.php';
- require DIR_CLASS.'Request.class.php';
- require DIR_FUN.'Source.fun.php';
- $key = 'jfaawiaw;sadhawkjaw123SAWDasd';
- $c = empty(Request::get('c')) ? 'index' : Request::get('c');
- $c_arr = explode('_', strtr($c, array('../' => '', './' => '', '/' => '', '\\' => '')));
- $f = empty(Request::get('f')) ? 'index/' : Request::get('f');
- $f = explode('.', strtr($f, array('../' => '', './' => '', '/' => '', '\\' => '')));
- $file = '';
- foreach((array)$f as $v){
- if(!empty($v)){
- $file .= $v.'/';
- }
- }
- $classname = '';
- foreach($c_arr as $v){
- $classname .= htmlspecialchars(ucwords(strtolower($v)), ENT_QUOTES, 'UTF-8').'_';
- }
- $classname = substr($classname, 0, -1);
- if(!file_exists(DIR_APP.$file.$classname.'.app.php')){
- if(DEBUG){
- exit('文件:'.DIR_APP.$file.$classname.'.app.php 不存在');
- }else {
- header('HTTP/1.1 404 Not Found');
- header("status: 404 Not Found");
- }
- }else {
- autoload($classname);
- }