PageRenderTime 52ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/source.class.php

https://github.com/ywl890227/longphp
PHP | 52 lines | 50 code | 2 blank | 0 comment | 1 complexity | 42d1039e304d0fef94f76d55e7570002 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. if(DEBUG){
  3. error_reporting(E_ALL);
  4. ini_set('display_errors', 1);
  5. }else {
  6. error_reporting(0);
  7. ini_set('display_errors', 1);
  8. }
  9. define('DIR', strtr(dirname(dirname(__FILE__)), array('\\'=>'/')).'/');
  10. define('DIR_APP', DIR.'app/');
  11. define('DIR_CLASS', DIR.'class/');
  12. define('DIR_CONF', DIR.'conf/');
  13. define('DIR_FUN', DIR.'fun/');
  14. define('DIR_LIB', DIR.'lib/');
  15. define('DIR_TPL', DIR.'tpl/');
  16. require DIR_LIB.'Libs.class.php';
  17. require DIR_CLASS.'Request.class.php';
  18. require DIR_FUN.'Source.fun.php';
  19. $key = 'jfaawiaw;sadhawkjaw123SAWDasd';
  20. $c = empty(Request::get('c')) ? 'index' : Request::get('c');
  21. $c_arr = explode('_', strtr($c, array('../' => '', './' => '', '/' => '', '\\' => '')));
  22. $f = empty(Request::get('f')) ? 'index/' : Request::get('f');
  23. $f = explode('.', strtr($f, array('../' => '', './' => '', '/' => '', '\\' => '')));
  24. $file = '';
  25. foreach((array)$f as $v){
  26. if(!empty($v)){
  27. $file .= $v.'/';
  28. }
  29. }
  30. $classname = '';
  31. foreach($c_arr as $v){
  32. $classname .= htmlspecialchars(ucwords(strtolower($v)), ENT_QUOTES, 'UTF-8').'_';
  33. }
  34. $classname = substr($classname, 0, -1);
  35. if(!file_exists(DIR_APP.$file.$classname.'.app.php')){
  36. if(DEBUG){
  37. exit('文件:'.DIR_APP.$file.$classname.'.app.php 不存在');
  38. }else {
  39. header('HTTP/1.1 404 Not Found');
  40. header("status: 404 Not Found");
  41. }
  42. }else {
  43. autoload($classname);
  44. }