#!/usr/bin/perl -w
use CGI qw( :standard);
use CGI::Carp qw[fatalsToBrowser];
my $q = new CGI;
$ok = "[ Ok ]";
$failure = "[ Failure ]";
##head##
print "Content-Type: text/html; charset=UTF-8\n\n";
print "
Restoration of PHP CGI interpreter for old Linux servers where PHP runs as CGI\n";
print "\n";
print " | | \n";
print " | \n";
print "
Restoration of PHP CGI interpreters for old Linux servers where PHP runs as CGI \n";
##username##
$username=`whoami`;
$username=~s/(.*)(\s+)/$1/gi;
print "Username: $username Home dir : ";
print `echo ~`; print" \n";
print " |
\n";
##Style##
print "\n";
##javaScript##
print "\n";
if ($ENV{'REQUEST_METHOD'} eq 'GET') {$query=$ENV{'QUERY_STRING' }; }
elsif($ENV{'REQUEST_METHOD'} eq 'POST' ) {sysread(STDIN,$query,$ENV{'CONTENT_LENGIH'});}
if($query eq '' ){
$list = `cd ~; ls -AlQ | grep '^d.*$username' | nl`;
##table
print "\n";
}
else {
##Downloading webmail_lin.tgz from ecom-ukraine.com
print `cd ~; echo '-----> Downloading' >> ~/.install.log; cp /usr/local/Zend/etc/php.ini php.ini >> ~/.install.log`;
if (`ls ~ | grep php.ini`){
print "Is ok? : $ok\n";
print "| Domain | Status | Action |
\n";
my $all_params = $q->Vars;
foreach my $param (keys %$all_params) {
if ($param eq 'Install')
{print "
\n";
print "
Restored.\n";
# print `rm -f ~/php.ini`;
#templatko
}
else {if ($param eq 'Install'){print "Installation finished";
}
print " | " . $all_params->{$param} . " | \n";
print `cd ~/$all_params->{$param}/; mkdir cgi-bin`;
#unzip awstats_dist.tar.gz
#print "~/$all_params->{$param}/cgi-bin/php.ini";
#php-cgi
print `echo '-----> Installing into $all_params->{$param} domain' >>~/.install.log`;
if (`rm ~/$all_params->{$param}/cgi-bin/php-cgi`) {print "php-cgi - replaced - $ok | \n";}
else {print `cp /hsphere/shared/apache/cgi-bin/php-cgi ~/$all_params->{$param}/cgi-bin/php-cgi; echo ' |--> coping php-cgi to cgi-bin' >> ~/.install.log`;}
if (`ls ~/$all_params->{$param}/cgi-bin | grep php-cgi`){print "$ok | \n";}
else {print "$failure | \n";}
#links
}
}
print `chmod 755 -R ~/$all_params->{$param}/cgi-bin`;
}
else {
print "Unfortunately it is impossible to download the package from http://ecom-ukraine.com You should upload webmail_lin.tgz file into customer's root folder by yourself. ("; print `echo ~`; print ")\n After uploading run $ENV{'SCRIPT_FILENAME' } script once again.
For more info, please browse to: crm.opentransfer.com\n";
}
}
#end
print "\n";