BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

autoload.php 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * Autoload
  5. *
  6. * Load classes automatically when they're needed.
  7. * The Gazelle convention is classes/lowercase_name.class.php.
  8. *
  9. * @param string $ClassName class name
  10. * @see https://www.php.net/manual/en/language.oop5.autoload.php
  11. */
  12. spl_autoload_register(function ($ClassName) {
  13. $ENV = ENV::go();
  14. $classname = strtolower($ClassName);
  15. $FilePath = "$ENV->SERVER_ROOT/classes/$classname.class.php";
  16. if (!file_exists($FilePath)) {
  17. // todo: Rename the following classes to conform with the code guidelines
  18. switch ($ClassName) {
  19. case 'MASS_USER_BOOKMARKS_EDITOR':
  20. $FileName = 'mass_user_bookmarks_editor.class';
  21. break;
  22. case 'MASS_USER_TORRENTS_EDITOR':
  23. $FileName = 'mass_user_torrents_editor.class';
  24. break;
  25. case 'MASS_USER_TORRENTS_TABLE_VIEW':
  26. $FileName = 'mass_user_torrents_table_view.class';
  27. break;
  28. case 'TEXTAREA_PREVIEW':
  29. $FileName = 'textarea_preview.class';
  30. break;
  31. case 'TORRENT':
  32. case 'BENCODE_DICT':
  33. case 'BENCODE_LIST':
  34. $FileName = 'torrent.class';
  35. break;
  36. case 'RecursiveArrayObject':
  37. $FileName = 'env.class';
  38. break;
  39. default:
  40. error("Couldn't import class $ClassName");
  41. }
  42. $FilePath = "$ENV->SERVER_ROOT/classes/$FileName.php";
  43. }
  44. require_once $FilePath;
  45. });