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.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. $FilePath = SERVER_ROOT . '/classes/' . strtolower($ClassName) . '.class.php';
  14. #$FilePath = $_SERVER['DOCUMENT_ROOT'] . '/classes/' . strtolower($ClassName) . '.class.php';
  15. if (!file_exists($FilePath)) {
  16. // todo: Rename the following classes to conform with the code guidelines
  17. switch ($ClassName) {
  18. case 'MASS_USER_BOOKMARKS_EDITOR':
  19. $FileName = 'mass_user_bookmarks_editor.class';
  20. break;
  21. case 'MASS_USER_TORRENTS_EDITOR':
  22. $FileName = 'mass_user_torrents_editor.class';
  23. break;
  24. case 'MASS_USER_TORRENTS_TABLE_VIEW':
  25. $FileName = 'mass_user_torrents_table_view.class';
  26. break;
  27. case 'TEXTAREA_PREVIEW':
  28. $FileName = 'textarea_preview.class';
  29. break;
  30. case 'TORRENT':
  31. case 'BENCODE_DICT':
  32. case 'BENCODE_LIST':
  33. $FileName = 'torrent.class';
  34. break;
  35. case 'RecursiveArrayObject':
  36. $FileName = 'env.class';
  37. break;
  38. case 'Parsedown':
  39. $FileName = 'vendor/Parsedown';
  40. break;
  41. case 'ParsedownExtra':
  42. $FileName = 'vendor/ParsedownExtra';
  43. break;
  44. case 'TwitterAPIExchange':
  45. $FileName = 'vendor/TwitterAPIExchange';
  46. break;
  47. default:
  48. error("Couldn't import class $ClassName");
  49. }
  50. $FilePath = SERVER_ROOT . "/classes/$FileName.php";
  51. #$FilePath = $_SERVER['DOCUMENT_ROOT'] . "/classes/$FileName.php";
  52. }
  53. require_once $FilePath;
  54. });