PHPMailerAutoload.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * PHPMailer SPL autoloader.
  4. * PHP Version 5
  5. * @package PHPMailer
  6. * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
  7. * @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
  8. * @author Jim Jagielski (jimjag) <jimjag@gmail.com>
  9. * @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
  10. * @author Brent R. Matzelle (original founder)
  11. * @copyright 2012 - 2014 Marcus Bointon
  12. * @copyright 2010 - 2012 Jim Jagielski
  13. * @copyright 2004 - 2009 Andy Prevost
  14. * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
  15. * @note This program is distributed in the hope that it will be useful - WITHOUT
  16. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  17. * FITNESS FOR A PARTICULAR PURPOSE.
  18. */
  19. /**
  20. * PHPMailer SPL autoloader.
  21. * @param string $classname The name of the class to load
  22. */
  23. function PHPMailerAutoload($classname)
  24. {
  25. //Can't use __DIR__ as it's only in PHP 5.3+
  26. $filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
  27. if (is_readable($filename)) {
  28. require $filename;
  29. }
  30. }
  31. if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
  32. //SPL autoloading was introduced in PHP 5.1.2
  33. if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
  34. spl_autoload_register('PHPMailerAutoload', true, true);
  35. } else {
  36. spl_autoload_register('PHPMailerAutoload');
  37. }
  38. } else {
  39. /**
  40. * Fall back to traditional autoload for old PHP versions
  41. * @param string $classname The name of the class to load
  42. */
  43. function __autoload($classname)
  44. {
  45. PHPMailerAutoload($classname);
  46. }
  47. }