XRL  2.0.0
Simple XML-RPC Library (both client and server)
Autoload.php
1 <?php
2 /*
3  * This file is part of XRL, a simple XML-RPC Library for PHP.
4  *
5  * Copyright (c) 2012, XRL Team. All rights reserved.
6  * XRL is licensed under the 3-clause BSD License.
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace fpoirotte\XRL;
13 
20 class Autoload
21 {
43  public static function load($class)
44  {
45  if (strpos($class, ':') !== false) {
46  throw new \Exception('Possible remote execution attempt');
47  }
48 
49  $class = ltrim($class, '\\');
50  if (strncmp($class, 'fpoirotte\\XRL\\', 14)) {
51  return false;
52  }
53 
54  $class = substr($class, 14);
55  $class = str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $class);
56  if (!strncmp($class, 'tests\\', 6)) {
57  $path = dirname(__DIR__);
58  } else {
59  $path = __DIR__;
60  }
61  require($path . DIRECTORY_SEPARATOR . $class . '.php');
62  $res = (class_exists($class, false) || interface_exists($class, false));
63  return $res;
64  }
65 
72  public static function register()
73  {
74  static $registered = false;
75 
76  if (!$registered) {
77  spl_autoload_register(array(__CLASS__, "load"));
78  }
79  }
80 }
static load($class)
Definition: Autoload.php:43
An helper class that wraps XRL's autoloader.
Definition: Autoload.php:20