Server IP : 85.214.239.14 / Your IP : 18.227.134.45 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /var/www/wordpress/wp-content/plugins/enable-media-replace/build/shortpixel/ |
Upload File : |
<?php namespace EnableMediaReplace\Build; class PackageLoader { public $dir; public $composerFile = false; public function __construct() { } public function setComposerFile($filePath) { $this->composerFile = json_decode(file_get_contents($filePath),1); } public function getComposerFile($filePath = false ) { if (! $this->composerFile) $this->composerFile = json_decode(file_get_contents($this->dir."/composer.json"), 1); return $this->composerFile; } public function load($dir) { $this->dir = $dir; $composer = $this->getComposerFile(); if(isset($composer["autoload"]["psr-4"])){ $this->loadPSR4($composer['autoload']['psr-4']); } if(isset($composer["autoload"]["psr-0"])){ $this->loadPSR0($composer['autoload']['psr-0']); } if(isset($composer["autoload"]["files"])){ $this->loadFiles($composer["autoload"]["files"]); } } public function loadFiles($files){ foreach($files as $file){ $fullpath = $this->dir."/".$file; if(file_exists($fullpath)){ include_once($fullpath); } } } public function loadPSR4($namespaces) { $this->loadPSR($namespaces, true); } public function loadPSR0($namespaces) { $this->loadPSR($namespaces, false); } public function loadPSR($namespaces, $psr4) { $dir = $this->dir; // Foreach namespace specified in the composer, load the given classes foreach ($namespaces as $namespace => $classpaths) { if (!is_array($classpaths)) { $classpaths = array($classpaths); } spl_autoload_register(function ($classname) use ($namespace, $classpaths, $dir, $psr4) { // Check if the namespace matches the class we are looking for if (preg_match("#^".preg_quote($namespace)."#", $classname)) { // Remove the namespace from the file path since it's psr4 if ($psr4) { $classname = str_replace($namespace, "", $classname); } // $filename = preg_replace("#\\\\#", "", $classname).".php"; // This is fix for nested classes which were losing a / $filename = ltrim($classname .'.php', '\\'); $filename = str_replace('\\','/', $filename); foreach ($classpaths as $classpath) { $fullpath = trailingslashit($dir) . trailingslashit($classpath) .$filename; if (file_exists($fullpath)) { include_once $fullpath; } } } }); } } }