From: Mikael Nordfeldth Date: Thu, 3 Sep 2015 15:52:04 +0000 (+0200) Subject: Include PHP libraries from system if not packaged and they are installed. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=84a65c718939be3c69b99a1100ef05ebee9be93b;p=quix0rs-gnu-social.git Include PHP libraries from system if not packaged and they are installed. Thanks to: "Bhuvan Krishna" "Sunil Mohan" --- diff --git a/lib/framework.php b/lib/framework.php index 1834c3e786..d749d23bdf 100644 --- a/lib/framework.php +++ b/lib/framework.php @@ -137,9 +137,18 @@ spl_autoload_register('GNUsocial_class_autoload'); * and is available here: http://www.php-fig.org/psr/psr-0/ */ spl_autoload_register(function($class){ - $file = INSTALLDIR.'/extlib/'.preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php'; + $class_path = preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php'; + $file = INSTALLDIR.'/extlib/'.$class_path; if (file_exists($file)) { require_once $file; + return; + } + + # Try if the system has this external library + $file = '/usr/share/php/'.$class_path; + if (file_exists($file)) { + require_once $file; + return; } });