Phpinfo plugin for anyone who is interested
-
First off I am very new to wprdpress and I am not a php coder. I wanted a way to view my phpinfo from the admin area so I threw this together. Simple, but not very elegant, but it works. I am sure there are better ways to do it, and I invite any feedback you may have.
Why did I do a plugin as obosed to just having a phpinfo.php file out there, well because there are some security issues with doing so.
Anyway here it is.
<?php
/*
Plugin Name: PHPInfo
Plugin URI:
Description: Displays PHPInfo via the admin area.
Version: v1.0
Author: SCuM
Author URI:
*//*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/function phpinfoFromAdmin() {
add_options_page('PHPInfo', 'PHPInfo', 9, basename(__FILE__), 'showPHPInfo');
}add_action('admin_menu', 'phpinfoFromAdmin');
function showPHPInfo()
{
// Get PHPINFO and parse info out
ob_start();
phpinfo();
$phpinfo .= ob_get_contents();
$phpinfo = preg_replace("#^.*<body>#is", "", $phpinfo);
$phpinfo = preg_replace("#</body>.*$#is", "", $phpinfo);
ob_end_clean();// Define PHPINFO Style
$phpinfo_style = "
<style type=\"text/css\">
.wrap pre {margin: 0px; font-family: monospace;}
.wrap table {border-collapse: collapse;}
.wrap .center {text-align: center;}
.wrap .center table { margin-left: auto; margin-right: auto; text-align: left;}
.wrap .center th { text-align: center !important; }
.wrap td, .wrap th { border: 1px solid #000000; vertical-align: baseline;}
.wrap .p {text-align: left;}
.wrap .e {background-color: #ccccff; font-weight: bold; color: #000000;}
.wrap .h {background-color: #9999cc; font-weight: bold; color: #000000;}
.wrap .v {background-color: #cccccc; color: #000000;}
.wrap i {color: #666666; background-color: #cccccc;}
.wrap img {float: right; border: 0px;}
.wrap hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;}
</style>";// Echo it to the screen
echo $phpinfo_style . "<div class=\"wrap\">" . $phpinfo . "</div>";
}
?>
- The topic ‘Phpinfo plugin for anyone who is interested’ is closed to new replies.