note 130025 added to function.phpinfo
| From: | me@adventurejosh.com | Date: | Fri, 14 Feb 2025 11:33:33 +0000 |
| Subject: | note 130025 added to function.phpinfo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221847@lists.php.net to get a copy of this message | ||
Bootstrap 5 styling...
<?php
// Start output buffering
ob_start();
// Output phpinfo
phpinfo();
// Capture and clean the output
$phpinfo = ob_get_clean();
// Remove phpinfo's default inline styles
$phpinfo = preg_replace('/<style[^>]*>.*?<\/style>/s', '',
$phpinfo);
// Add Bootstrap table classes and the "responsive-table" class directly to each
<table> tag
$phpinfo = preg_replace('/<table([^>]*)>/i', '<table$1 class="table
table-striped table-sm table-hover responsive-table">', $phpinfo);
// Convert any <td> with class "e" to <th>, remove the "e" from its
class list,
// and add an inline min-width of 100px along with the class "text-md-end".
$phpinfo = preg_replace_callback(
'/<td(?=[^>]*\bclass\s*=\s*["\'][^"\']*\be\b[^"\']*["\'])([^>]*)>(.*?)<\/td>/is',
function ($matches) {
$attrs = $matches[1];
$content = $matches[2];
// Process the class attribute: remove "e" and add "text-md-end"
if (preg_match('/\bclass\s*=\s*["\']([^"\']*)["\']/',
$attrs, $classMatch)) {
$classes = $classMatch[1];
// Split classes into an array, filter out "e"
$classesArray = preg_split('/\s+/', $classes);
$classesArray = array_filter($classesArray, function($class) {
return $class !== 'e';
});
// Add text-md-end if not already present
if (!in_array('text-md-end', $classesArray)) {
$classesArray[] = 'text-md-end';
}
$newClasses = implode(' ', $classesArray);
// Remove the old class attribute and add our new one
$attrs =
preg_replace('/\bclass\s*=\s*["\'][^"\']*["\']/',
'', $attrs);
$attrs .= ' class="' . $newClasses . '"';
} else {
$attrs .= ' class="text-md-end"';
}
// Process the style attribute: add min-width:100px;
if (preg_match('/\bstyle\s*=\s*["\']([^"\']*)["\']/',
$attrs, $styleMatch)) {
$styles = $styleMatch[1];
if (stripos($styles, 'min-width') === false) {
$styles = rtrim($styles, ';') . '; min-width:100px;';
}
$attrs =
preg_replace('/\bstyle\s*=\s*["\'][^"\']*["\']/',
'', $attrs);
$attrs .= ' style="' . trim($styles) . '"';
} else {
$attrs .= '
style="min-width:150px;max-width:100vw;overflow-x:scroll;text-wrap:nowrap;"';
}
return '<th' . $attrs . '>' . $content . '</th>';
},
$phpinfo
);
// Make header tags smaller by shifting their level by 3 (capped at h6)
// For example: <h1> becomes <h4>, <h2> becomes <h5>, <h3> becomes
<h6>
$phpinfo = preg_replace_callback(
'/<h([1-6])([^>]*)>(.*?)<\/h\1>/is',
function ($matches) {
$newLevel = min($matches[1] + 3, 6);
return '<h' . $newLevel . $matches[2] . '>' . $matches[3] .
'</h' . $newLevel . '>';
},
$phpinfo
);
?>
<?php
// Output the modified phpinfo content
echo $phpinfo;
?>
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 180.253.116.188)
----
Manual Page -- https://php.net/manual/en/function.phpinfo.php
Edit -- https://main.php.net/note/edit/130025
Del: integrated -- https://main.php.net/note/delete/130025/integrated
Del: useless -- https://main.php.net/note/delete/130025/useless
Del: bad code -- https://main.php.net/note/delete/130025/bad+code
Del: spam -- https://main.php.net/note/delete/130025/spam
Del: non-english -- https://main.php.net/note/delete/130025/non-english
Del: in docs -- https://main.php.net/note/delete/130025/in+docs
Del: other reasons-- https://main.php.net/note/delete/130025
Reject -- https://main.php.net/note/reject/130025
Search -- https://main.php.net/manage/user-notes.php