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 $php_url = 'https://sme11.thereadclan.me.uk/phpsysinfo/index.php?disp=static'; #my $first_line = q{}; #my $second_line = q{}; $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{]*>(.*?)}si; $phpsysinfo_html =~ s/^( SME Server|
Copyright \(c\)).*\n//gmi; # Insert $first_line before $second_line - supressing CSP #$phpsysinfo_html =~ s/(\Q$second_line\E)/$first_line\n$1/; $c->stash(title => $title, phpsysinfo => $phpsysinfo_html, php_url => $php_url); $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;