Files
smeserver-phpsysinfo/root/usr/share/smanager/lib/SrvMngr/Controller/Phpsysinfo.pm
Jean-Philippe Pialasse fcb9a8fbf7 * Thu Sep 25 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-2.sme
- CSP relaxed policy
- revert authentication
- httpd syntax fix
- smanager improvement
2025-09-25 12:38:42 -04:00

51 lines
1.9 KiB
Perl

package SrvMngr::Controller::Phpsysinfo;
#----------------------------------------------------------------------
# heading : Legacy
# description : System Information
# navigation : 4000 600
#----------------------------------------------------------------------
#----------------------------------------------------------------------
# name : phpsysinfo, method : get, url : /phpsysinfo, ctlact : Phpsysinfo#main
#
# routes : end
#----------------------------------------------------------------------
use strict;
use warnings;
use Mojo::Base 'Mojolicious::Controller';
use Locale::gettext;
use SrvMngr::I18N;
use SrvMngr qw(theme_list init_session);
use Mojo::UserAgent;
my $ua = Mojo::UserAgent->new;
$ua->insecure(1);
sub main {
my $c = shift;
my $title = $c->l('psi_phpsysinfo_panel');
my $host = $c->req->url->to_abs->host;
my $php_url = "https://".$host."/phpsysinfo/index.php?disp=static";
my $php_url2 = "https://".$host."/phpsysinfo/index.php?disp=bootstrap";
$ua->get($php_url => sub {
my ($ua, $tx) = @_;
if ($tx->res->is_success) {
my $php_content = $tx->res->body;
my ($phpsysinfo_html) = $php_content =~ m{<body[^>]*>(.*?)</body>}si;
$phpsysinfo_html =~ s/^( SME Server|<BR>Copyright \(c\)).*\n//gmi;
$c->stash(title => $title, phpsysinfo => $phpsysinfo_html, php_url => $php_url, php_url2 => $php_url2);
$c->render(template => 'phpsysinfo');
} else {
my $code = $tx->res->code // 'No code';
my $redirect = $code eq '302' ? $tx->res->headers->location : '';
$c->render(text => "Failed to fetch PHP content: $code $redirect", status => 500);
}
});
# Do not render here; rendering happens in the callback
}
#sub main {
# my $c = shift;
# $c->proxy_to('https://sme11.thereadclan.me.uk/phpsysinfo/index.php?disp=static');
#}
1;