summaryrefslogtreecommitdiffstats
path: root/lib/class/core.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/class/core.class.php')
-rw-r--r--lib/class/core.class.php56
1 files changed, 40 insertions, 16 deletions
diff --git a/lib/class/core.class.php b/lib/class/core.class.php
index 55e594d5..5619225c 100644
--- a/lib/class/core.class.php
+++ b/lib/class/core.class.php
@@ -41,27 +41,27 @@ class Core {
/**
* autoload
- * This function automatically loads any missing classes as they are
- * needed so that we don't use a million include statements which load
- * more than we need.
+ * This function automatically loads any missing classes as they are
+ * needed so that we don't use a million include statements which load
+ * more than we need.
*/
public static function autoload($class) {
- // Lowercase the class
- $class = strtolower($class);
+ // Lowercase the class
+ $class = strtolower($class);
- $file = Config::get('prefix') . "/lib/class/$class.class.php";
+ $file = Config::get('prefix') . "/lib/class/$class.class.php";
- // See if it exists
- if (is_readable($file)) {
- require $file;
- if (is_callable($class . '::_auto_init')) {
- $class::_auto_init();
- }
- }
- // Else log this as a fatal error
- else {
- debug_event('autoload', "'$class' not found!", 1);
+ // See if it exists
+ if (Core::is_readable($file)) {
+ require $file;
+ if (is_callable($class . '::_auto_init')) {
+ $class::_auto_init();
}
+ }
+ // Else log this as a fatal error
+ else {
+ debug_event('autoload', "'$class' not found!", 1);
+ }
} // autoload
/**
@@ -164,5 +164,29 @@ class Core {
} // image_dimensions
+ /*
+ * is_readable
+ *
+ * Replacement function because PHP's is_readable is buggy:
+ * https://bugs.php.net/bug.php?id=49620
+ */
+ public static function is_readable($path) {
+ if (is_dir($path)) {
+ $handle = opendir($path);
+ if ($handle === false) {
+ return false;
+ }
+ closedir($handle);
+ return true;
+ }
+
+ $handle = fopen($path, 'rb');
+ if ($handle === false) {
+ return false;
+ }
+ fclose($handle);
+ return true;
+ }
+
} // Core
?>