Brak opisu

Autoloader.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. class Autoloader{
  3. /**
  4. * 类库自动加载,写死路径,确保不加载其他文件。
  5. * @param string $class 对象类名
  6. * @return void
  7. */
  8. public static function autoload($class) {
  9. $name = $class;
  10. if(false !== strpos($name,'\\')){
  11. $name = strstr($class, '\\', true);
  12. }
  13. $filename = TOP_AUTOLOADER_PATH."/top/".$name.".php";
  14. if(is_file($filename)) {
  15. include $filename;
  16. return;
  17. }
  18. $filename = TOP_AUTOLOADER_PATH."/top/request/".$name.".php";
  19. if(is_file($filename)) {
  20. include $filename;
  21. return;
  22. }
  23. $filename = TOP_AUTOLOADER_PATH."/top/domain/".$name.".php";
  24. if(is_file($filename)) {
  25. include $filename;
  26. return;
  27. }
  28. $filename = TOP_AUTOLOADER_PATH."/aliyun/".$name.".php";
  29. if(is_file($filename)) {
  30. include $filename;
  31. return;
  32. }
  33. $filename = TOP_AUTOLOADER_PATH."/aliyun/request/".$name.".php";
  34. if(is_file($filename)) {
  35. include $filename;
  36. return;
  37. }
  38. $filename = TOP_AUTOLOADER_PATH."/aliyun/domain/".$name.".php";
  39. if(is_file($filename)) {
  40. include $filename;
  41. return;
  42. }
  43. $filename = TOP_AUTOLOADER_PATH."/dingtalk/".$name.".php";
  44. if(is_file($filename)) {
  45. include $filename;
  46. return;
  47. }
  48. $filename = TOP_AUTOLOADER_PATH."/dingtalk/request/".$name.".php";
  49. if(is_file($filename)) {
  50. include $filename;
  51. return;
  52. }
  53. $filename = TOP_AUTOLOADER_PATH."/dingtalk/domain/".$name.".php";
  54. if(is_file($filename)) {
  55. include $filename;
  56. return;
  57. }
  58. $filename = TOP_AUTOLOADER_PATH."/QimenCloud/".$name.".php";
  59. if(is_file($filename)) {
  60. include $filename;
  61. return;
  62. }
  63. }
  64. }
  65. spl_autoload_register('Autoloader::autoload');
  66. ?>