isFile()) { $contents = php_strip_whitespace($file->getRealPath()); $fileName = $file->getFileName(); $pharFile = 'adminer-plugins/' . $fileName; if ( /** * Skip affected plugin * https://nvd.nist.gov/vuln/detail/CVE-2023-45197 */ $fileName !== 'file-upload.php' /** * Adminer editor's plugins are only relevant * in Adminer editor. */ && !str_starts_with($fileName, 'editor') && preg_match('/class\s(A[a-zA-Z0-9]+)\s(extends\sAdminer|\{)/', $contents, $m) ) { $plugins[$pharFile] = $contents; $classMap[$m[1]] = $file->getFileName(); } } } ksort($classMap); $phar->setStub( sprintf( $stub, json_encode($classMap, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) ) ); $autoLoader = <<addFromString( 'autoload.php', $autoLoader ); foreach($plugins as $file => $contents) { $phar->addFromString( $file, $contents ); } $phar->compressFiles(Phar::GZ); $phar->addFromString( 'adminer.php', php_strip_whitespace(__DIR__ . '/adminer.php'), ); rename($tmpFile, __DIR__ . '/index.php');