Files
smeserver-phpsysinfo/root/usr/share/smanager/lib/SrvMngr/Controller/Phpsysinfo.pm

51 lines
1.9 KiB
Perl
Raw Normal View History

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;