From a48d8533bf6a353972248720cf19ffb5ba55041f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 15 Mar 2013 19:54:08 +0400 Subject: [PATCH] Revert "db: use builtin classloader, lowercase class files" This reverts commit 57b8469e674ef082c30b7d1de40d5d53d50b251b. --- classes/{db/abstract.php => Db/Abstract.php} | 0 classes/{db/interface.php => Db/Interface.php} | 0 classes/{db/mysql.php => Db/Mysql.php} | 0 classes/{db/pgsql.php => Db/Pgsql.php} | 0 include/classloader.php | 15 --------------- include/db.php | 10 +++++++--- include/functions.php | 16 ++++++++++++++-- 7 files changed, 21 insertions(+), 20 deletions(-) rename classes/{db/abstract.php => Db/Abstract.php} (100%) rename classes/{db/interface.php => Db/Interface.php} (100%) rename classes/{db/mysql.php => Db/Mysql.php} (100%) rename classes/{db/pgsql.php => Db/Pgsql.php} (100%) delete mode 100644 include/classloader.php diff --git a/classes/db/abstract.php b/classes/Db/Abstract.php similarity index 100% rename from classes/db/abstract.php rename to classes/Db/Abstract.php diff --git a/classes/db/interface.php b/classes/Db/Interface.php similarity index 100% rename from classes/db/interface.php rename to classes/Db/Interface.php diff --git a/classes/db/mysql.php b/classes/Db/Mysql.php similarity index 100% rename from classes/db/mysql.php rename to classes/Db/Mysql.php diff --git a/classes/db/pgsql.php b/classes/Db/Pgsql.php similarity index 100% rename from classes/db/pgsql.php rename to classes/Db/Pgsql.php diff --git a/include/classloader.php b/include/classloader.php deleted file mode 100644 index 4b8b3738..00000000 --- a/include/classloader.php +++ /dev/null @@ -1,15 +0,0 @@ - diff --git a/include/db.php b/include/db.php index 020fd08a..28718fb0 100644 --- a/include/db.php +++ b/include/db.php @@ -1,9 +1,13 @@ quote($str); } -?> +?> \ No newline at end of file diff --git a/include/functions.php b/include/functions.php index caea2576..4dc286eb 100644 --- a/include/functions.php +++ b/include/functions.php @@ -5,7 +5,19 @@ $fetch_last_error = false; $pluginhost = false; - require_once "classloader.php"; + function __autoload($class) { + $class_file1 = str_replace("_", "/", basename($class)); // PSR-0 + $class_file2 = str_replace("_", "/", strtolower(basename($class))); + + $file1 = dirname(__FILE__)."/../classes/$class_file1.php"; + $file2 = dirname(__FILE__)."/../classes/$class_file2.php"; + + if (file_exists($file1)) { + require $file1; + } elseif (file_exists($file2)) { + require $file2; + } + } mb_internal_encoding("UTF-8"); date_default_timezone_set('UTC'); @@ -3891,4 +3903,4 @@ return in_array($interface, class_implements($class)); } -?> +?> \ No newline at end of file -- 2.39.5