Showing phpinfo output on a WordPress page without FTP access to the server
If you’ve run into the same problem I did, welcome. Someone reached out saying everything's gone. No server access, logins and passwords all changed. Need to get the site away from the bad guys. Won’t go into the details — just use any backup plugin.
I needed some server info, the kind normally dumped by the phpinfo function. Good old friend, except without server access you can’t create a php file and drop it there.
Luckily the WordPress admin lets you edit theme files. I'll write a function that returns the phpinfo output and call it from any page on the site, I thought. You don’t even need to save the changes to get the info — everything shows up in the preview screen.
So, log into WordPress. Go to the Appearance -> Editor menu

Next, in the right-hand column called Templates, find the functions.php file:

Select it, the code shows up in the editor field. Scroll to the very end and drop in these lines:
function serverinfo() {
return phpinfo();
}
add_shortcode('serverinfo', 'serverinfo');
Hit Update File.
Next, go to your existing pages, pick any of them (better not the home page) and add this anywhere (preferably right at the start or end):
[serverinfo][/serverinfo]
In the top-right corner of the page, hit Preview.
As a result of this hands-on hackery, a page opens up with the phpinfo() output, styled by whatever theme is active.

