initial commit of file from CVS for smeserver-webhosting on Sat Sep 7 16:45:03 AEST 2024
This commit is contained in:
@@ -0,0 +1,562 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#
|
||||
# $Id: ibays.pm,v 1.8 2005/09/06 05:49:52 apc Exp $
|
||||
#
|
||||
|
||||
package esmith::FormMagick::Panel::webhosting;
|
||||
|
||||
use strict;
|
||||
|
||||
use esmith::FormMagick;
|
||||
use esmith::AccountsDB;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::DomainsDB;
|
||||
use esmith::cgi;
|
||||
use esmith::util;
|
||||
use File::Basename;
|
||||
use Exporter;
|
||||
use Carp;
|
||||
use esmith::php;
|
||||
|
||||
our @ISA = qw(esmith::FormMagick Exporter);
|
||||
|
||||
our @EXPORT = qw(
|
||||
print_ibay_table
|
||||
print_ibay_name_field
|
||||
print_vhost_message
|
||||
max_ibay_name_length
|
||||
handle_ibays
|
||||
print_save_or_add_button
|
||||
wherenext
|
||||
validate_up_post
|
||||
);
|
||||
|
||||
our $VERSION = sprintf '%d.%03d', q$Revision: 1.9 $ =~ /: (\d+).(\d+)/;
|
||||
|
||||
our $accountdb = esmith::AccountsDB->open();
|
||||
our $configdb = esmith::ConfigDB->open();
|
||||
|
||||
#TODO those 3 variables should be exported from esmith::php
|
||||
our $defaultdisabledfunc='system,show_source,' .
|
||||
'symlink,exec,dl,shell_exec,' .
|
||||
'passthru,phpinfo,' .
|
||||
'escapeshellarg,escapeshellcmd';
|
||||
our $BASEPHP = 54;
|
||||
our %defaultproperties = (
|
||||
MemoryLimit => '128M',
|
||||
MaxExecutionTime => '30',
|
||||
MaxInputTime => '60',
|
||||
AllowUrlFopen => 'disabled',
|
||||
PostMaxSize => '20M',
|
||||
UploadMaxFilesize => '10M',
|
||||
FileUpload => 'enabled',
|
||||
PHPBaseDir => '/home/e-smith/files/ibays/$key:/var/lib/php/$key',
|
||||
DisabledFunctions => $defaultdisabledfunc,
|
||||
MailForceSender => "admin@".$configdb->get_value('DomainName'),
|
||||
AllowPHTML => 'disabled',
|
||||
|
||||
ModDav => "disabled",
|
||||
AllowOverride => "None",
|
||||
FollowSymLinks => "disabled",
|
||||
Indexes => "enabled",
|
||||
);
|
||||
|
||||
|
||||
# those are ok to be defined here and not in core.
|
||||
our %sizehash = ('20M' => 'S0020MB', '30M' => 'S0030MB', '40M' => 'S0040MB', '50M' => 'S0050MB',
|
||||
'75M' => 'S0075MB', '100M' => 'S0100MB', '125M' => 'S0125MB', '150M' => 'S0150MB', '175M' => 'S0175MB',
|
||||
'200M' => 'S0200MB', '300M' => 'S0300MB','400M' => 'S0400MB', '500M' => 'S0500MB', '600M' => 'S0600MB',
|
||||
'700M' => 'S0700MB', '800M' => 'S0800MB', '900M' => 'S0900MB', '1000M' => 'S1000MB', '1250M' => 'S1250MB',
|
||||
'1500M' => 'S1500MB', '1750M' => 'S1750MB', '1999M' => 'S2000MB');
|
||||
our %binary = ('disabled' => 'DISABLED', 'enabled' => 'ENABLED');
|
||||
our %timehash = ( '60' => 'T001m', '120' => 'T002m', '180' => 'T003m', '240' => 'T004m', '300' => 'T005m',
|
||||
'360' => 'T006m', '420' => 'T007m', '480' => 'T008m', '540' => 'T009m', '600' => 'T010m', '900' => 'T015m',
|
||||
'1800' => 'T030m', '2700' => 'T045m', '3600' => 'T060m', '7200' => 'T120m', '0' => 'UNLIMITED');
|
||||
our %optionsproperties =(
|
||||
MemoryLimit => {'64M' => 'M0064MB', '128M' => 'M0128MB',
|
||||
'256M' => 'M0256MB', '512M' => 'M0512MB', '768M' => 'M0768MB','1024M' => 'M1024MB' ,'2048M' => 'M2048MB','3072M' => 'M3072MB','4096M' => 'M4096MB','61444M' => 'M6144MB','8192M' => 'M8192MB'},
|
||||
MaxExecutionTime => {%timehash},
|
||||
MaxInputTime => {%timehash},
|
||||
AllowUrlFopen => {%binary},
|
||||
PostMaxSize => {%sizehash},
|
||||
UploadMaxFilesize => {%sizehash},
|
||||
FileUpload => {%binary},
|
||||
DisabledFunctions => $defaultdisabledfunc,
|
||||
AllowPHTML => {%binary},
|
||||
|
||||
ModDav => {%binary},
|
||||
AllowOverride => { None =>'None' ,
|
||||
All => 'All',
|
||||
AuthConfig => 'AuthConfig',
|
||||
FileInfo => 'FileInfo',
|
||||
Indexes => 'Indexes',
|
||||
Limit => 'Limit',
|
||||
'FileInfo Indexes' => 'FileInfo Indexes',
|
||||
},
|
||||
FollowSymLinks => {%binary},
|
||||
Indexes => {%binary},
|
||||
);
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
esmith::FormMagick::Panels::ibays - useful panel functions
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use esmith::FormMagick::Panels::ibays;
|
||||
|
||||
my $panel = esmith::FormMagick::Panel::ibays->new();
|
||||
$panel->display();
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
=head2 new();
|
||||
|
||||
Exactly as for esmith::FormMagick
|
||||
|
||||
=begin testing
|
||||
|
||||
$ENV{ESMITH_ACCOUNT_DB} = "10e-smith-base/accounts.conf";
|
||||
$ENV{ESMITH_CONFIG_DB} = "10e-smith-base/configuration.conf";
|
||||
$ENV{ESMITH_DOMAINS_DB} = "10e-smith-base/domains.conf";
|
||||
|
||||
use_ok('esmith::FormMagick::Panel::ibays');
|
||||
use vars qw($panel);
|
||||
ok($panel = esmith::FormMagick::Panel::ibays->new(),
|
||||
"Create panel object");
|
||||
isa_ok($panel, 'esmith::FormMagick::Panel::ibays');
|
||||
|
||||
{ package esmith::FormMagick::Panel::ibays;
|
||||
our $accountdb;
|
||||
::isa_ok($accountdb, 'esmith::AccountsDB');
|
||||
}
|
||||
|
||||
=end testing
|
||||
|
||||
=cut
|
||||
|
||||
sub new
|
||||
{
|
||||
my $proto = shift;
|
||||
my $class = ref($proto) || $proto;
|
||||
my $self = esmith::FormMagick::new($class);
|
||||
$self->{calling_package} = (caller)[0];
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
=head1 HTML GENERATION ROUTINES
|
||||
|
||||
Routines for generating chunks of HTML needed by the panel.
|
||||
|
||||
=head1 ROUTINES FOR FILLING IN FIELDS
|
||||
|
||||
=head2 print_ibay_table
|
||||
|
||||
Prints out the ibay table on the front page.
|
||||
|
||||
=for testing
|
||||
my $self = esmith::FormMagick::Panel::ibays->new();
|
||||
$self->{cgi} = CGI->new("");
|
||||
can_ok('main', 'print_ibay_table');
|
||||
$self->print_ibay_table();
|
||||
like($_STDOUT_, qr/NAME/, "Found NAME header in table output");
|
||||
#like($_STDOUT_, qr/testibay/, "Found test ibay in user table output");
|
||||
#like($_STDOUT_, qr/ff0000/, "Found red 'reset password' output");
|
||||
|
||||
=cut
|
||||
|
||||
sub print_ibay_table {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $name = $self->localise('NAME');
|
||||
my $description = $self->localise('DESCRIPTION');
|
||||
my $modify = $self->localise('MODIFY');
|
||||
my $action_h = $self->localise('ACTION');
|
||||
|
||||
my @ibays = $accountdb->ibays();
|
||||
|
||||
unless ( scalar @ibays )
|
||||
{
|
||||
print $q->Tr($q->td($self->localise('NO_IBAYS')));
|
||||
return "";
|
||||
}
|
||||
|
||||
print $q->start_table({-CLASS => "sme-border"}),"\n";
|
||||
print $q->Tr (
|
||||
esmith::cgi::genSmallCell($q, $name,"header"),
|
||||
esmith::cgi::genSmallCell($q, $description,"header"),
|
||||
esmith::cgi::genSmallCell($q, $action_h,"header", 3)),"\n";
|
||||
my $scriptname = basename($0);
|
||||
|
||||
foreach my $i (@ibays)
|
||||
{
|
||||
my $ibayname = $i->key();
|
||||
my $ibaydesc = $i->prop('Name');
|
||||
|
||||
my $modifiable = $i->prop('Modifiable') || 'yes';
|
||||
|
||||
|
||||
my $params = $self->build_ibay_cgi_params($ibayname, $i->props());
|
||||
|
||||
|
||||
my $href = "$scriptname?$params&action=modify&wherenext=";
|
||||
|
||||
my $actionModify = ' ';
|
||||
if ($modifiable eq 'yes')
|
||||
{
|
||||
$actionModify .= $q->a({href => "${href}CreateModify"},$modify)
|
||||
. ' ';
|
||||
}
|
||||
|
||||
|
||||
print $q->Tr (
|
||||
esmith::cgi::genSmallCell($q, $ibayname,"normal"),
|
||||
esmith::cgi::genSmallCell($q, $ibaydesc,"normal"),
|
||||
esmith::cgi::genSmallCell($q, $actionModify,"normal"));
|
||||
}
|
||||
|
||||
print $q->end_table,"\n";
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
sub build_ibay_cgi_params {
|
||||
my ($self, $ibayname, %oldprops) = @_;
|
||||
|
||||
#$oldprops{'description'} = $oldprops{Name};
|
||||
#delete $oldprops{Name};
|
||||
|
||||
my %props = (
|
||||
page => 0,
|
||||
page_stack => "",
|
||||
#".id" => $self->{cgi}->param('.id') || "",
|
||||
name => $ibayname,
|
||||
#%oldprops
|
||||
);
|
||||
|
||||
return $self->props_to_query_string(\%props);
|
||||
}
|
||||
|
||||
*wherenext = \&CGI::FormMagick::wherenext;
|
||||
sub print_ibay_name_field {
|
||||
my $self = shift;
|
||||
my $in = $self->{cgi}->param('name') || '';
|
||||
my $action = $self->{cgi}->param('action') || '';
|
||||
my $maxLength = $configdb->get('maxIbayNameLength')->value;
|
||||
print qq(<tr><td colspan="2">) . $self->localise('NAME_FIELD_DESC',
|
||||
{maxLength => $maxLength}) . qq(</td></tr>);
|
||||
print qq(<tr><td class="sme-noborders-label">) .
|
||||
$self->localise('NAME_LABEL') . qq(</td>\n);
|
||||
if ($action eq 'modify' and $in) {
|
||||
print qq(
|
||||
<td class="sme-noborders-content">$in
|
||||
<input type="hidden" name="name" value="$in">
|
||||
<input type="hidden" name="action" value="modify">
|
||||
</td>
|
||||
);
|
||||
|
||||
# Read the values for each field from the accounts db and store
|
||||
# them in the cgi object so our form will have the correct
|
||||
# info displayed.
|
||||
my $q = $self->{cgi};
|
||||
my $rec = $accountdb->get($in);
|
||||
if ($rec)
|
||||
{
|
||||
$q->param(-name=>'description',-value=>
|
||||
$rec->prop('Name')); # yes we keep this one simple
|
||||
$q->param(-name=>'indexes',-value=>
|
||||
(get_current_value($self,'Indexes')));
|
||||
$q->param(-name=>'followSymLinks',-value=>
|
||||
(get_current_value($self,'FollowSymLinks')));
|
||||
$q->param(-name=>'allowOverride',-value=>
|
||||
(get_current_value($self,'AllowOverride')));
|
||||
$q->param(-name=>'allowUrlFopen',-value=>
|
||||
(get_current_value($self,'AllowUrlFopen')));
|
||||
$q->param(-name=>'memorylimit',-value=>
|
||||
(get_current_value($self,'MemoryLimit')));
|
||||
$q->param(-name=>'uploadmaxfilesize',-value=>
|
||||
(get_current_value($self,'UploadMaxFilesize')));
|
||||
$q->param(-name=>'postmaxsize',-value=>
|
||||
(get_current_value($self,'PostMaxSize')));
|
||||
$q->param(-name=>'maxexecutiontime',-value=>
|
||||
(get_current_value($self,'MaxExecutionTime')));
|
||||
$q->param(-name=>'maxinputtime',-value=>
|
||||
(get_current_value($self,'MaxInputTime')));
|
||||
$q->param(-name=>'fileupload',-value=>
|
||||
(get_current_value($self,'FileUpload')));
|
||||
$q->param(-name=>'allowphtml',-value=>
|
||||
(get_current_value($self,'AllowPHTML')));
|
||||
$q->param(-name=>'mailforcesender',-value=>
|
||||
($rec->prop('MailForceSender'))); # yes we keep this one simple
|
||||
my $df = ($rec->prop('DisabledFunctions'))? $rec->prop('DisabledFunctions') : $defaultdisabledfunc;
|
||||
$q->param(-name=>'disabledfunctions',-value=>
|
||||
($df)); # yes we want todo this one this way.
|
||||
$q->param(-name=>'phpbasedir',-value=>
|
||||
($rec->prop('PHPBaseDir'))); # yes we keep this one simple
|
||||
$q->param(-name=>'modDav',-value=>
|
||||
(get_current_value($self,'ModDav')));
|
||||
# we set phpversion using function called by cgi file
|
||||
}
|
||||
} else {
|
||||
print qq(
|
||||
<td><input type="text" name="name" value="$in">
|
||||
<input type="hidden" name="action" value="create">
|
||||
</td>
|
||||
);
|
||||
}
|
||||
|
||||
print qq(</tr>\n);
|
||||
return undef;
|
||||
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=head2 print_vhost_message()
|
||||
|
||||
Prints a warning message that vhosts whose content is this ibay will be
|
||||
modified to point to primary site.
|
||||
|
||||
=for testing
|
||||
$panel->{cgi} = CGI->new();
|
||||
$panel->{cgi}->param(-name=>'name', -value=>'bar');
|
||||
is($panel->print_vhost_message(), undef, 'print_vhost_message');
|
||||
|
||||
=cut
|
||||
|
||||
sub print_vhost_message {
|
||||
my $self = shift;
|
||||
my $q = $self->{cgi};
|
||||
my $name = $q->param('name');
|
||||
|
||||
my $domaindb = esmith::DomainsDB->open();
|
||||
my @domains = $domaindb->get_all_by_prop(Content => $name);
|
||||
my $vhostListItems = join "\n",
|
||||
(map ($q->li($_->key." ".$_->prop('Description')),
|
||||
@domains));
|
||||
if ($vhostListItems)
|
||||
{
|
||||
print $self->localise('VHOST_MESSAGE', {vhostList => $vhostListItems});
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
=head1 THE ROUTINES THAT ACTUALLY DO THE WORK
|
||||
|
||||
=for testing
|
||||
can_ok('main', 'handle_ibays');
|
||||
|
||||
=cut
|
||||
|
||||
sub handle_ibays {
|
||||
my ($self) = @_;
|
||||
|
||||
|
||||
if ($self->cgi->param("action") eq "create") {
|
||||
$self->create_ibay();
|
||||
} else {
|
||||
$self->modify_ibay();
|
||||
}
|
||||
}
|
||||
|
||||
=head2 print_save_or_add_button()
|
||||
=cut
|
||||
|
||||
sub print_save_or_add_button {
|
||||
my ($self) = @_;
|
||||
|
||||
my $action = $self->cgi->param("action") || '';
|
||||
if ($action eq "modify") {
|
||||
$self->print_button("SAVE");
|
||||
} else {
|
||||
$self->print_button("ADD");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub modify_ibay {
|
||||
my ($self) = @_;
|
||||
my $name = $self->cgi->param('name');
|
||||
if (my $acct = $accountdb->get($name)) {
|
||||
if ($acct->prop('type') eq 'ibay') {
|
||||
|
||||
my %doing=( Indexes => 'indexes',
|
||||
FollowSymLinks => 'followSymLinks',
|
||||
AllowOverride => 'allowOverride',
|
||||
ModDav => 'modDav',
|
||||
PHPVersion => 'PHPVersion',
|
||||
AllowUrlFopen => 'allowUrlFopen',
|
||||
MemoryLimit => 'memorylimit',
|
||||
FileUpload => 'fileupload',
|
||||
UploadMaxFilesize => 'uploadmaxfilesize',
|
||||
PostMaxSize => 'postmaxsize',
|
||||
MaxExecutionTime => 'maxexecutiontime',
|
||||
MaxInputTime => 'maxinputtime',
|
||||
AllowPHTML => 'allowphtml',
|
||||
MailForceSender => 'mailforcesender',
|
||||
DisabledFunctions => 'disabledfunctions',
|
||||
PHPBaseDir => 'phpbasedir',
|
||||
);
|
||||
foreach my $prop (keys %doing) {
|
||||
my $value = $self->cgi->param($doing{$prop});
|
||||
$value = "" if ( $value eq "$BASEPHP" && $prop eq 'PHPVersion');
|
||||
my $default = $defaultproperties{$prop} || "";
|
||||
# exceptions to handle
|
||||
# DisabledFunctions if equal def delprop
|
||||
if ($prop eq 'DisabledFunctions' && $value eq $default) {
|
||||
$acct->delete_prop($prop) ;
|
||||
next;
|
||||
}
|
||||
# MailForceSender if empty delprop
|
||||
if ($prop eq 'MailForceSender' && $value eq "" ) {
|
||||
$acct->delete_prop($prop) ;
|
||||
next
|
||||
}
|
||||
# PHPBaseDir if empty delprop
|
||||
if ($prop eq 'PHPBaseDir' && $value eq "" ) {
|
||||
$acct->delete_prop($prop) ;
|
||||
next
|
||||
}
|
||||
# others if == default delprop
|
||||
if ($value eq "default") {
|
||||
$acct->delete_prop($prop) ;
|
||||
next;
|
||||
}
|
||||
$acct->merge_props($prop => $value);
|
||||
#TODO store them in a hash and call merge_props once
|
||||
}
|
||||
|
||||
# Untaint $name before use in system()
|
||||
$name =~ /(.+)/; $name = $1;
|
||||
if (system ("/sbin/e-smith/signal-event", "webhosting-modify",
|
||||
$name) == 0)
|
||||
{
|
||||
$self->success("SUCCESSFULLY_MODIFIED_IBAY");
|
||||
} else {
|
||||
$self->error("ERROR_WHILE_MODIFYING_IBAY");
|
||||
}
|
||||
} else {
|
||||
$self->error('CANT_FIND_IBAY');
|
||||
}
|
||||
} else {
|
||||
$self->error('CANT_FIND_IBAY');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
=head2 validate_up_post
|
||||
|
||||
verify that the upload_max_filesize value is not greater than the post_max_size value. If yes then display an error message.
|
||||
|
||||
=cut
|
||||
sub validate_up_post{
|
||||
my $self = shift;
|
||||
my $upmaxfilesize = $self->cgi->param('uploadmaxfilesize');
|
||||
my $postmaxsizeform = $self->cgi->param('postmaxsize');
|
||||
##set value to "0M" if disabled in order to compare uploadmaxfilesize and postmaxsize
|
||||
$upmaxfilesize = "0M" if $upmaxfilesize eq 'disabled';
|
||||
$upmaxfilesize = $defaultproperties{'UploadMaxFilesize'} if $upmaxfilesize eq 'default';
|
||||
$postmaxsizeform = "0M" if $postmaxsizeform eq 'disabled';
|
||||
$postmaxsizeform =$defaultproperties{'PostMaxSize'} if $postmaxsizeform eq 'default';
|
||||
##remove the 'M' unit
|
||||
my $upmaxfilesizechop = chop($upmaxfilesize);
|
||||
my $postmaxsizeformchop = chop($postmaxsizeform);
|
||||
##test the condition
|
||||
if ( $upmaxfilesize > $postmaxsizeform )
|
||||
{
|
||||
return $self->localise('UPLOADMAXFILESIZE_IS_GREATER_THAN_POSTMAXSIZE');
|
||||
}
|
||||
else
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
=head2 get_current_php_value
|
||||
|
||||
=cut
|
||||
sub get_current_php_value{
|
||||
my ($self) = @_;
|
||||
my $name = $self->cgi->param('name');
|
||||
my $ibay= $accountdb->get($name);
|
||||
return "default" unless defined $ibay->prop('PHPVersion');
|
||||
return VersionToUse($accountdb->get($name));
|
||||
}
|
||||
|
||||
|
||||
=head2 get_current_php_value
|
||||
|
||||
=cut
|
||||
sub get_php_options{
|
||||
my ($self) = @_;
|
||||
my $translate = $self->localise('DEFAULT');
|
||||
my %options= listPHPVersionHash();
|
||||
$options{"default"}="$translate: ".PHPdefault();
|
||||
return \%options;
|
||||
}
|
||||
|
||||
=head2 get_current_value ($self, $property)
|
||||
|
||||
|
||||
=cut
|
||||
sub get_current_value{
|
||||
my ($self, $property) = @_;
|
||||
my $name = $self->cgi->param('name');
|
||||
my $ibay = $accountdb->get($name);
|
||||
my $key = $ibay->key;
|
||||
my $default = $defaultproperties{$property} || "";
|
||||
$default =~ s/\$key/$key/g if $property eq "PHPBaseDir";
|
||||
my $value = ($ibay->prop($property))? $ibay->prop($property) : "default" ;
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
sub print_options{
|
||||
my ($self, $property) = @_;
|
||||
my $translate = $self->localise('DEFAULT');
|
||||
my $name = $self->cgi->param('name');
|
||||
my $ibay = $accountdb->get($name);
|
||||
my $key = $ibay->key;
|
||||
my $default = $defaultproperties{$property} || "";
|
||||
$default =~ s/\$key/$key/g if $property eq "PHPBaseDir";
|
||||
my %opts=%{$optionsproperties{$property}};
|
||||
$default=$self->localise(uc($default)) unless ($property eq 'AllowOverride');
|
||||
$opts{"default"} = "$translate: ".$default;
|
||||
return \%opts
|
||||
|
||||
}
|
||||
|
||||
sub print_disabledfunctions{
|
||||
my ($self) = @_;
|
||||
my $translate = $self->localise('DESC_DISABLEDFUNCTIONS');
|
||||
my $name = $self->cgi->param('name');
|
||||
my $ibay= $accountdb->get($name);
|
||||
return "$translate : ". $defaultdisabledfunc ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
sub print_phpbasedir{
|
||||
my ($self) = @_;
|
||||
my $translate = $self->localise('DESC_PHPBASEDIR');
|
||||
my $name = $self->cgi->param('name');
|
||||
my $ibay= $accountdb->get($name);
|
||||
my $key = $ibay->key;
|
||||
my $default = $defaultproperties{'PHPBaseDir'} ||'';
|
||||
$default =~ s/\$key/$key/g;
|
||||
my $basedir = ($ibay->prop('PHPBaseDir')) ? $ibay->prop('PHPBaseDir') : $defaultproperties{'PHPBaseDir'};
|
||||
return "$translate : ". $default ;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
407
root/usr/share/smanager/lib/SrvMngr/Controller/Webhosting.pm
Normal file
407
root/usr/share/smanager/lib/SrvMngr/Controller/Webhosting.pm
Normal file
@@ -0,0 +1,407 @@
|
||||
package SrvMngr::Controller::Webhosting;
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# heading : Network
|
||||
# description : Webhosting
|
||||
# navigation : 6000 150
|
||||
#
|
||||
# name : webhosting, method : get, url : /webhosting, ctlact : webhosting#main
|
||||
# name : webhostingu, method : post, url : /webhosting, ctlact : webhosting#do_action
|
||||
# name : webhostingr, method : get, url : /webhosting2, ctlact : webhosting#do_display
|
||||
#
|
||||
# routes : end
|
||||
#----------------------------------------------------------------------
|
||||
use strict;
|
||||
use warnings;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
|
||||
use Locale::gettext;
|
||||
use SrvMngr::I18N;
|
||||
use SrvMngr qw( theme_list init_session is_normal_password );
|
||||
|
||||
use esmith::AccountsDB;
|
||||
use esmith::ConfigDB;
|
||||
use esmith::DomainsDB;
|
||||
use esmith::php;
|
||||
|
||||
our $adb = esmith::AccountsDB->open() || die "Couldn't open accounts db";
|
||||
our $cdb = esmith::ConfigDB->open() || die "Couldn't open config db";
|
||||
|
||||
#TODO those 3 variables should be exported from esmith::php
|
||||
our $defaultdisabledfunc='system,show_source,' .
|
||||
'symlink,exec,dl,shell_exec,' .
|
||||
'passthru,phpinfo,' .
|
||||
'escapeshellarg,escapeshellcmd';
|
||||
|
||||
our $BASEPHP = 54;
|
||||
|
||||
our %defaultproperties = (
|
||||
MemoryLimit => '128M',
|
||||
MaxExecutionTime => '30',
|
||||
MaxInputTime => '60',
|
||||
AllowUrlFopen => 'disabled',
|
||||
PostMaxSize => '20M',
|
||||
UploadMaxFilesize => '10M',
|
||||
FileUpload => 'enabled',
|
||||
PHPBaseDir => '/home/e-smith/files/ibays/$key:/var/lib/php/$key',
|
||||
DisabledFunctions => $defaultdisabledfunc,
|
||||
MailForceSender => "admin@".$cdb->get_value('DomainName'),
|
||||
AllowPHTML => 'disabled',
|
||||
|
||||
ModDav => "disabled",
|
||||
AllowOverride => "None",
|
||||
FollowSymLinks => "disabled",
|
||||
Indexes => "enabled",
|
||||
);
|
||||
|
||||
# those are ok to be defined here and not in core.
|
||||
our %sizehash = ('20M' => 'S0020MB', '30M' => 'S0030MB', '40M' => 'S0040MB', '50M' => 'S0050MB',
|
||||
'75M' => 'S0075MB', '100M' => 'S0100MB', '125M' => 'S0125MB', '150M' => 'S0150MB', '175M' => 'S0175MB',
|
||||
'200M' => 'S0200MB', '300M' => 'S0300MB','400M' => 'S0400MB', '500M' => 'S0500MB', '600M' => 'S0600MB',
|
||||
'700M' => 'S0700MB', '800M' => 'S0800MB', '900M' => 'S0900MB', '1000M' => 'S1000MB', '1250M' => 'S1250MB',
|
||||
'1500M' => 'S1500MB', '1750M' => 'S1750MB', '1999M' => 'S2000MB');
|
||||
|
||||
our %binary = ('disabled' => 'DISABLED', 'enabled' => 'ENABLED');
|
||||
|
||||
our %timehash = ( '60' => 'T001m', '120' => 'T002m', '180' => 'T003m', '240' => 'T004m', '300' => 'T005m',
|
||||
'360' => 'T006m', '420' => 'T007m', '480' => 'T008m', '540' => 'T009m', '600' => 'T010m', '900' => 'T015m',
|
||||
'1800' => 'T030m', '2700' => 'T045m', '3600' => 'T060m', '7200' => 'T120m', '0' => 'UNLIMITED');
|
||||
|
||||
our %optionsproperties =(
|
||||
MemoryLimit => {'64M' => 'M0064MB', '128M' => 'M0128MB',
|
||||
'256M' => 'M0256MB', '512M' => 'M0512MB', '768M' => 'M0768MB','1024M' => 'M1024MB' ,'2048M' => 'M2048MB','3072M' => 'M3072MB','4096M' => 'M4096MB','61444M' => 'M6144MB','8192M' => 'M8192MB'},
|
||||
MaxExecutionTime => {%timehash},
|
||||
MaxInputTime => {%timehash},
|
||||
AllowUrlFopen => {%binary},
|
||||
PostMaxSize => {%sizehash},
|
||||
UploadMaxFilesize => {%sizehash},
|
||||
FileUpload => {%binary},
|
||||
DisabledFunctions => $defaultdisabledfunc,
|
||||
AllowPHTML => {%binary},
|
||||
ModDav => {%binary},
|
||||
AllowOverride => { None =>'None' ,
|
||||
All => 'All',
|
||||
AuthConfig => 'AuthConfig',
|
||||
FileInfo => 'FileInfo',
|
||||
Indexes => 'Indexes',
|
||||
Limit => 'Limit',
|
||||
'FileInfo Indexes' => 'FileInfo Indexes',
|
||||
},
|
||||
FollowSymLinks => {%binary},
|
||||
Indexes => {%binary},
|
||||
);
|
||||
|
||||
sub main {
|
||||
|
||||
my $c = shift;
|
||||
$c->app->log->info($c->log_req);
|
||||
|
||||
my %wh_datas = ();
|
||||
my $title = $c->l('wh_FORM_TITLE');
|
||||
|
||||
$wh_datas{'trt'} = 'LIST';
|
||||
|
||||
my @ibays = $adb->ibays();
|
||||
|
||||
$c->stash( title => $title, wh_datas => \%wh_datas, ibays => \@ibays );
|
||||
$c->render(template => 'webhosting');
|
||||
|
||||
};
|
||||
|
||||
|
||||
sub do_display {
|
||||
|
||||
my $c = shift;
|
||||
$c->app->log->info($c->log_req);
|
||||
|
||||
my $rt = $c->current_route;
|
||||
my $trt = ($c->param('trt') || '');
|
||||
my $ibay = $c->param('ibay') || '';
|
||||
|
||||
my %wh_datas = ();
|
||||
my $title = $c->l('wh_FORM_TITLE');
|
||||
my $modul = '';
|
||||
|
||||
$wh_datas{'trt'} = $trt;
|
||||
|
||||
if ( $trt eq 'UPD' ) {
|
||||
|
||||
my $rec = $adb->get($ibay);
|
||||
if ($rec and $rec->prop('type') eq 'ibay') {
|
||||
$wh_datas{ibay} = $ibay;
|
||||
$wh_datas{description} = $rec->prop('Name');
|
||||
$wh_datas{indexes} = get_current_value($c, $ibay, 'Indexes');
|
||||
$wh_datas{followsymLinks} = get_current_value($c, $ibay, 'FollowSymLinks');
|
||||
$wh_datas{allowoverride} = get_current_value($c, $ibay, 'AllowOverride');
|
||||
$wh_datas{allowurlfopen} = get_current_value($c, $ibay, 'AllowUrlFopen');
|
||||
$wh_datas{memorylimit} = get_current_value($c, $ibay, 'MemoryLimit');
|
||||
$wh_datas{uploadmaxfilesize} = get_current_value($c, $ibay, 'UploadMaxFilesize');
|
||||
$wh_datas{postmaxsize} = get_current_value($c, $ibay, 'PostMaxSize');
|
||||
$wh_datas{maxexecutiontime} = get_current_value($c, $ibay, 'MaxExecutionTime');
|
||||
$wh_datas{maxinputtime} = get_current_value($c, $ibay, 'MaxInputTime');
|
||||
$wh_datas{fileupload} = get_current_value($c, $ibay, 'FileUpload');
|
||||
$wh_datas{allowphtml} = get_current_value($c, $ibay, 'AllowPHTML');
|
||||
$wh_datas{mailforcesender} = $rec->prop('MailForceSender');
|
||||
my $df = ($rec->prop('DisabledFunctions'))? $rec->prop('DisabledFunctions') : $defaultdisabledfunc;
|
||||
$wh_datas{disabledfunctions} = $df; # yes we want todo this one this way.
|
||||
$wh_datas{phpbasedir} = $rec->prop('PHPBaseDir'); # yes we keep this one simple
|
||||
$wh_datas{moddav} = get_current_value($c, $ibay, 'ModDav');
|
||||
$wh_datas{phpversion} = get_current_php_value($c, $ibay, 'PHPVersion');
|
||||
# we set phpversion using function called by cgi file
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( $trt eq 'LIST' ) {
|
||||
my @ibays = $adb->ibays();
|
||||
$c->stash( ibays => \@ibays );
|
||||
}
|
||||
|
||||
$c->stash( title => $title, modul => $modul, wh_datas => \%wh_datas );
|
||||
$c->render( template => 'webhosting' );
|
||||
|
||||
};
|
||||
|
||||
|
||||
sub do_action {
|
||||
|
||||
my $c = shift;
|
||||
$c->app->log->info($c->log_req);
|
||||
|
||||
my $rt = $c->current_route;
|
||||
my $trt = ($c->param('trt') || '');
|
||||
|
||||
my %wh_datas = ();
|
||||
my $title = $c->l('wh_FORM_TITLE');
|
||||
|
||||
$wh_datas{'trt'} = $trt;
|
||||
|
||||
my $result = '';
|
||||
my $res;
|
||||
|
||||
|
||||
if ( $trt eq 'UPD' ) {
|
||||
|
||||
my $name = ($c->param('ibay') || '');
|
||||
|
||||
# controls
|
||||
$res = validate_up_post( $c );
|
||||
$result .= $res unless $res eq 'OK';
|
||||
|
||||
if ( ! $result ) {
|
||||
$res = modify_ibay( $c, $name );
|
||||
$result .= $res unless $res eq 'OK';
|
||||
if ( ! $result ) {
|
||||
$result = $c->l('wh_SUCCESSFULLY_MODIFIED_IBAY') . ' ' . $name;
|
||||
$wh_datas{trt} = 'LST';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# common parts
|
||||
|
||||
if ($res ne 'OK') {
|
||||
$c->stash( error => $result );
|
||||
$c->stash( title => $title, wh_datas => \%wh_datas );
|
||||
return $c->render('webhosting');
|
||||
}
|
||||
|
||||
my $message = "'Ibays' updates ($trt) DONE";
|
||||
$c->app->log->info($message);
|
||||
$c->flash( success => $result );
|
||||
|
||||
$c->redirect_to('/webhosting');
|
||||
};
|
||||
|
||||
|
||||
sub modify_ibay {
|
||||
|
||||
my ($c, $name) = @_;
|
||||
|
||||
my $msg;
|
||||
my $acct = $adb->get($name);
|
||||
if ( ! $acct or $acct->prop('type') ne 'ibay') {
|
||||
return $c->l('wh_CANT_FIND_IBAY') if $msg ne 'OK';
|
||||
}
|
||||
|
||||
# real & current ibay
|
||||
my %doing=( Indexes => 'indexes',
|
||||
FollowSymLinks => 'followSymLinks',
|
||||
AllowOverride => 'allowOverride',
|
||||
ModDav => 'modDav',
|
||||
PHPVersion => 'phpVersion',
|
||||
AllowUrlFopen => 'allowUrlFopen',
|
||||
MemoryLimit => 'memorylimit',
|
||||
FileUpload => 'fileupload',
|
||||
UploadMaxFilesize => 'uploadmaxfilesize',
|
||||
PostMaxSize => 'postmaxsize',
|
||||
MaxExecutionTime => 'maxexecutiontime',
|
||||
MaxInputTime => 'maxinputtime',
|
||||
AllowPHTML => 'allowphtml',
|
||||
MailForceSender => 'mailforcesender',
|
||||
DisabledFunctions => 'disabledfunctions',
|
||||
PHPBaseDir => 'phpbasedir',
|
||||
);
|
||||
foreach my $prop (keys %doing) {
|
||||
my $value = $c->param($doing{$prop});
|
||||
$value = "" if ( $value eq "$BASEPHP" && $prop eq 'PHPVersion');
|
||||
my $default = $defaultproperties{$prop} || "";
|
||||
# exceptions to handle
|
||||
# DisabledFunctions if equal def delprop
|
||||
if ($prop eq 'DisabledFunctions' && $value eq $default) {
|
||||
$acct->delete_prop($prop) ;
|
||||
next;
|
||||
}
|
||||
# MailForceSender if empty delprop
|
||||
if ($prop eq 'MailForceSender' && $value eq "" ) {
|
||||
$acct->delete_prop($prop) ;
|
||||
next
|
||||
}
|
||||
# PHPBaseDir if empty delprop
|
||||
if ($prop eq 'PHPBaseDir' && $value eq "" ) {
|
||||
$acct->delete_prop($prop) ;
|
||||
next
|
||||
}
|
||||
# others if == default delprop
|
||||
if ($value eq "default") {
|
||||
$acct->delete_prop($prop) ;
|
||||
next;
|
||||
}
|
||||
$acct->merge_props($prop => $value);
|
||||
#TODO store them in a hash and call merge_props once
|
||||
}
|
||||
|
||||
# Untaint $name before use in system()
|
||||
$name =~ /(.+)/; $name = $1;
|
||||
if (system ("/sbin/e-smith/signal-event", "webhosting-modify",
|
||||
$name) == 0)
|
||||
{
|
||||
$msg = 'OK';
|
||||
} else {
|
||||
$msg = $c->l('wh_ERROR_WHILE_MODIFYING_IBAY');
|
||||
}
|
||||
|
||||
return $msg;
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub get_current_value{
|
||||
my ($c, $name, $property) = @_;
|
||||
my $ibay = $adb->get($name);
|
||||
my $key = $ibay->key;
|
||||
my $default = $defaultproperties{$property} || "";
|
||||
$default =~ s/\$key/$key/g if $property eq "PHPBaseDir";
|
||||
my $value = ($ibay->prop($property))? $ibay->prop($property) : "default" ;
|
||||
return $value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
=head2 validate_up_post
|
||||
|
||||
verify that the upload_max_filesize value is not greater than the post_max_size value. If yes then display an error message.
|
||||
|
||||
=cut
|
||||
|
||||
sub validate_up_post{
|
||||
|
||||
my $c = shift;
|
||||
my $upmaxfilesize = $c->param('uploadmaxfilesize');
|
||||
my $postmaxsizeform = $c->param('postmaxsize');
|
||||
##set value to "0M" if disabled in order to compare uploadmaxfilesize and postmaxsize
|
||||
$upmaxfilesize = "0M" if $upmaxfilesize eq 'disabled';
|
||||
$upmaxfilesize = $defaultproperties{'UploadMaxFilesize'} if $upmaxfilesize eq 'default';
|
||||
$postmaxsizeform = "0M" if $postmaxsizeform eq 'disabled';
|
||||
$postmaxsizeform =$defaultproperties{'PostMaxSize'} if $postmaxsizeform eq 'default';
|
||||
##remove the 'M' unit
|
||||
my $upmaxfilesizechop = chop($upmaxfilesize);
|
||||
my $postmaxsizeformchop = chop($postmaxsizeform);
|
||||
##test the condition
|
||||
if ( $upmaxfilesize > $postmaxsizeform ) {
|
||||
return $c->l('wh_UPLOADMAXFILESIZE_IS_GREATER_THAN_POSTMAXSIZE');
|
||||
} else {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub get_current_php_value {
|
||||
|
||||
my ($c, $name) = @_;
|
||||
my $ibay= $adb->get($name);
|
||||
return "default" unless defined $ibay->prop('PHPVersion');
|
||||
return VersionToUse($adb->get($name));
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub get_php_options {
|
||||
|
||||
my ($c) = @_;
|
||||
my $translate = $c->l('wh_DEFAULT');
|
||||
my %opts= listPHPVersionHash();
|
||||
# transform options list
|
||||
my @opts = [ "$translate: ".PHPdefault(), 'default' ];
|
||||
foreach my $key ( sort keys %opts ) {
|
||||
push @opts, [ $opts{$key}, $key ];
|
||||
}
|
||||
# push @opts, [ "$translate: ".PHPdefault(), 'default' ];
|
||||
|
||||
return \@opts;
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub print_options {
|
||||
|
||||
my ($c, $property) = @_;
|
||||
|
||||
my $translate = $c->l('wh_DEFAULT');
|
||||
my $name = $c->param('ibay');
|
||||
my $ibay = $adb->get($name);
|
||||
my $key = $ibay->key;
|
||||
my $default = $defaultproperties{$property} || "";
|
||||
$default =~ s/\$key/$key/g if $property eq "PHPBaseDir";
|
||||
$default=$c->l(uc("$default")) unless ($property eq 'AllowOverride');
|
||||
|
||||
# transform options list
|
||||
my @opts;
|
||||
foreach my $key ( sort keys %{$optionsproperties{$property}} ) {
|
||||
push @opts, [ $c->l($optionsproperties{$property}{$key}), $key ];
|
||||
}
|
||||
push @opts, ["$translate: ".$default => 'default'];
|
||||
|
||||
return \@opts
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub print_disabledfunctions {
|
||||
|
||||
my ($c) = @_;
|
||||
my $translate = $c->l('wh_DESC_DISABLEDFUNCTIONS');
|
||||
my $name = $c->param('ibay');
|
||||
my $ibay= $adb->get($name); # ??
|
||||
return "$translate : ". $defaultdisabledfunc ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub print_phpbasedir {
|
||||
|
||||
my ($c) = @_;
|
||||
my $translate = $c->l('wh_DESC_PHPBASEDIR');
|
||||
my $name = $c->param('ibay');
|
||||
my $ibay= $adb->get($name);
|
||||
my $key = $ibay->key;
|
||||
my $default = $defaultproperties{'PHPBaseDir'} ||'';
|
||||
$default =~ s/\$key/$key/g;
|
||||
my $basedir = ($ibay->prop('PHPBaseDir')) ? $ibay->prop('PHPBaseDir') : $defaultproperties{'PHPBaseDir'};
|
||||
return "$translate : ". $default ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
1
|
@@ -0,0 +1,85 @@
|
||||
'wh_FORM_TITLE' => 'Web Hosting Contrib',
|
||||
'wh_webhosting' => 'I-bays - Web Hosting',
|
||||
'wh_FIRSTPAGE_DESC' => 'Manage Apache and PHP settings',
|
||||
'wh_ADD_TITLE' => 'Modify Apache and PHP Settings.',
|
||||
'wh_NAME_FIELD_DESC' => 'These parameters will be effective only if the access from the web is allowed for the concerned I-bay in the informations bays panel.',
|
||||
'wh_NAME_LABEL' => 'Information bay name',
|
||||
'wh_NO_IBAYS' => 'There are no I-bays currently configured.',
|
||||
'wh_CANT_FIND_IBAY' => 'Can\'t find account for {$name} (does it exist?)',
|
||||
'wh_ERROR_WHILE_MODIFYING_IBAY' => 'An error occurred while modifying the I-bay.',
|
||||
'wh_SUCCESSFULLY_MODIFIED_IBAY' => 'Successfully modified I-bay.',
|
||||
'wh_VIRTUAL_HOST_MESSAGE' => 'The following virtual domains were using this information bay as their content and will be changed to the primary web site (you can change them to something else afterward).',
|
||||
'wh_VHOST_MESSAGE' => '<P>The following virtual domains were using this information bay as their content and will be changed to the primary web site (you can change them to something else afterward):</P><ul>{$vhostList}</ul>',
|
||||
'wh_Information bays' => 'Information bays',
|
||||
'wh_DESC_HTTP_SETTINGS' => 'The following settings control the access of this I-bay using the HTTP/HTTPS protocol.',
|
||||
'wh_DESC_PHP_SETTINGS' => 'The following settings control the PHP values of this I-bay.',
|
||||
'wh_INDEXES' => 'Allow directory listing (+Indexes)',
|
||||
'wh_FOLLOWSYMLINKS' => 'Follow symbolic links (FollowSymLinks)',
|
||||
'wh_ALLOWOVERRIDE' => 'Allow .htaccess policy (AllowOverride)',
|
||||
'wh_ALLOWURLFOPEN' => 'Allow access to remote files (Allow_url_fopen)',
|
||||
'wh_DEFAULT' => 'Default value',
|
||||
'M0064MB' => '64MB',
|
||||
'M0128MB' => '128MB',
|
||||
'M0256MB' => '256MB',
|
||||
'M0512MB' => '512MB',
|
||||
'M0768MB' => '768MB',
|
||||
'M1024MB' => '1024MB',
|
||||
'M2048MB' => '2048MB',
|
||||
'M3072MB' => '3072MB',
|
||||
'M4096MB' => '4096MB',
|
||||
'M6144MB' => '6144MB',
|
||||
'M8192MB' => '8192MB',
|
||||
'T001m' => '1 minute',
|
||||
'T002m' => '2 minutes',
|
||||
'T003m' => '3 minutes',
|
||||
'T004m' => '4 minutes',
|
||||
'T005m' => '5 minutes',
|
||||
'T006m' => '6 minutes',
|
||||
'T007m' => '7 minutes',
|
||||
'T008m' => '8 minutes',
|
||||
'T009m' => '9 minutes',
|
||||
'T010m' => '10 minutes',
|
||||
'T015m' => '15 minutes ',
|
||||
'T030m' => '30 minutes',
|
||||
'T045m' => '45 minutes',
|
||||
'T060m' => 'One hour',
|
||||
'T120m' => 'Two hours',
|
||||
'wh_UNLIMITED' => 'Unlimited',
|
||||
'S0020MB' => '20MB',
|
||||
'S0030MB' => '30MB',
|
||||
'S0040MB' => '40MB',
|
||||
'S0050MB' => '50MB',
|
||||
'S0075MB' => '75MB',
|
||||
'S0100MB' => '100MB',
|
||||
'S0125MB' => '125MB',
|
||||
'S0150MB' => '150MB',
|
||||
'S0175MB' => '175MB',
|
||||
'S0200MB' => '200MB',
|
||||
'S0300MB' => '300MB',
|
||||
'S0400MB' => '400MB',
|
||||
'S0500MB' => '500MB',
|
||||
'S0600MB' => '600MB',
|
||||
'S0700MB' => '700MB',
|
||||
'S0800MB' => '800MB',
|
||||
'S0900MB' => '900MB',
|
||||
'S1000MB' => '1000MB',
|
||||
'S1250MB' => '1250MB',
|
||||
'S1500MB' => '1500MB ',
|
||||
'S1750MB' => '1750MB',
|
||||
'S2000MB' => '2000MB',
|
||||
'wh_MEMORYLIMIT' => 'Php memory limit (memory_limit)',
|
||||
'wh_UPLOADMAXFILESIZE' => 'Maximum upload size (upload_max_filesize)',
|
||||
'wh_POSTMAXSIZE' => 'Maximum post size (post_max_size)',
|
||||
'wh_MAXEXECUTIONTIME' => 'Maximum execution time (max_execution_time)',
|
||||
'wh_UPLOADMAXFILESIZE_IS_GREATER_THAN_POSTMAXSIZE' => ' The maximum upload file size is greater than the maximum post size form ',
|
||||
'wh_PHPBASEDIR' => 'Enter Path(s) for PHP Scripts (PHPBasedir) ',
|
||||
'wh_DESC_PHPBASEDIR' => 'You must specify the full path to the I-bay or remove the content to get back to default value ',
|
||||
'wh_DESC_DAV_SETTINGS' => 'The following settings control the WebDav files transfer protocol of this I-bay.',
|
||||
'wh_ENABLE_MOD_DAV' => 'Allow WebDav',
|
||||
'wh_PHPVERSION' => 'Select the php-fpm version you want to use with this I-bay',
|
||||
'wh_FILEUPLOAD' => 'Whether or not to allow HTTP file uploads (file_upload)',
|
||||
'wh_MAXINPUTTIME' => 'Maximum time in seconds a script is allowed to parse input data (max_input_time)',
|
||||
'wh_ALLOWPHTML' => 'Allow parsing php code inside html, phtml, htm and xml files.',
|
||||
'wh_MAILFORCESENDER' => 'Force an email sender address for the script in this I-bay.',
|
||||
'wh_DISABLEDFUNCTIONS' => 'List of php disabled functions (disable_functions)',
|
||||
'wh_DESC_DISABLEDFUNCTIONS' => 'Leave empty or with a random string to disable. Copy and paste the following default list to reset to default',
|
@@ -0,0 +1,46 @@
|
||||
<div id='wh_list'>
|
||||
|
||||
<p>
|
||||
%=l 'wh_FIRSTPAGE_DESC'
|
||||
<br><br>
|
||||
</p>
|
||||
|
||||
% my $numIbays = @$ibays;
|
||||
% if ($numIbays == 0){
|
||||
%=l 'wh_NO_IBAYS'
|
||||
% } else {
|
||||
<table class="sme-border TableSort"><thead>
|
||||
<tr>
|
||||
<th class='sme-border'>
|
||||
%=l 'NAME'
|
||||
</th>
|
||||
<th class='sme-border'>
|
||||
%=l 'DESCRIPTION'
|
||||
</th>
|
||||
<th class='sme-border'>
|
||||
%=l 'ACTION'
|
||||
</th>
|
||||
</tr>
|
||||
</thead><tbody>
|
||||
% foreach my $ibay (@$ibays)
|
||||
% {
|
||||
% my $modifiable = $ibay->prop('Modifiable') || 'yes';
|
||||
<tr>
|
||||
%= t td => (class => 'sme-border') => $ibay->key
|
||||
%= t td => (class => 'sme-border') => $ibay->prop('Name')
|
||||
% my $actionModify = ' ';
|
||||
% if ($modifiable eq 'yes') {
|
||||
% $actionModify = "<a href='webhosting2?CsrfDef=TOKEN&trt=UPD&ibay=" . $ibay->key . "'>" . l('MODIFY') . "</a>";
|
||||
% }
|
||||
<td class='sme-border'><%= $c->render_to_string(inline => $actionModify) %></td>
|
||||
|
||||
</tr>
|
||||
% }
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%} %>
|
||||
|
||||
%= hidden_field 'trt' => $wh_datas->{trt}
|
||||
|
||||
</div>
|
@@ -0,0 +1,149 @@
|
||||
<div id='wh_upd'>
|
||||
|
||||
%= form_for '/webhosting' => (method => 'POST') => begin
|
||||
<p>
|
||||
<h2>
|
||||
%=l 'wh_ADD_TITLE'
|
||||
</h2>
|
||||
<br>
|
||||
%=l 'wh_NAME_FIELD_DESC'
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span class=label>
|
||||
%=l 'wh_NAME_LABEL', class => 'label'
|
||||
</span><span class=data>
|
||||
%= $wh_datas->{ibay}, class => 'data'
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_INDEXES'
|
||||
</span><span class=data>
|
||||
% param 'indexes' => $wh_datas->{indexes} unless param 'indexes';
|
||||
%= select_field 'indexes' => $c->print_options('Indexes'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_FOLLOWSYMLINKS'
|
||||
</span><span class=data>
|
||||
% param 'followSymLinks' => $wh_datas->{followsymLinks} unless param 'followSymLinks';
|
||||
%= select_field 'followSymLinks' => $c->print_options('FollowSymLinks'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_ALLOWOVERRIDE'
|
||||
</span><span class=data>
|
||||
% param 'allowOverride' => $wh_datas->{allowoverride} unless param 'allowOverride';
|
||||
%= select_field 'allowOverride' => $c->print_options('AllowOverride'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><%=l 'wh_DESC_DAV_SETTINGS', class => 'label'%></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_ENABLE_MOD_DAV'
|
||||
</span><span class=data>
|
||||
% param 'modDav' => $wh_datas->{moddav} unless param 'modDav';
|
||||
%= select_field 'modDav' => $c->print_options('ModDav'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><%=l 'wh_DESC_PHP_SETTINGS', class => 'label'%></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_PHPVERSION'
|
||||
</span><span class=data>
|
||||
% param 'phpVersion' => $wh_datas->{phpversion} unless param 'phpVersion';
|
||||
%= select_field 'phpVersion' => $c->get_php_options(), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_ALLOWURLFOPEN'
|
||||
</span><span class=data>
|
||||
% param 'allowUrlFopen' => $wh_datas->{allowurlfopen} unless param 'allowUrlFopen';
|
||||
%= select_field 'allowUrlFopen' => $c->print_options('AllowUrlFopen'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_MEMORYLIMIT'
|
||||
</span><span class=data>
|
||||
% param 'memorylimit' => $wh_datas->{memorylimit} unless param 'memorylimit';
|
||||
%= select_field 'memorylimit' => $c->print_options('MemoryLimit'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_FILEUPLOAD'
|
||||
</span><span class=data>
|
||||
% param 'fileupload' => $wh_datas->{fileupload} unless param 'fileupload';
|
||||
%= select_field 'fileupload' => $c->print_options('FileUpload'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_UPLOADMAXFILESIZE'
|
||||
</span><span class=data>
|
||||
% param 'uploadmaxfilesize' => $wh_datas->{uploadmaxfilesize} unless param 'uploadmaxfilesize';
|
||||
%= select_field 'uploadmaxfilesize' => $c->print_options('UploadMaxFilesize'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_POSTMAXSIZE'
|
||||
</span><span class=data>
|
||||
% param 'postmaxsize' => $wh_datas->{postmaxsize} unless param 'postmaxsize';
|
||||
%= select_field 'postmaxsize' => $c->print_options('PostMaxSize'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_MAXEXECUTIONTIME'
|
||||
</span><span class=data>
|
||||
% param 'maxexecutiontime' => $wh_datas->{maxexecutiontime} unless param 'maxexecutiontime';
|
||||
%= select_field 'maxexecutiontime' => $c->print_options('MaxExecutionTime'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_MAXINPUTTIME'
|
||||
</span><span class=data>
|
||||
% param 'maxinputtime' => $wh_datas->{maxinputtime} unless param 'maxinputtime';
|
||||
%= select_field 'maxinputtime' => $c->print_options('MaxInputTime'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_ALLOWPHTML'
|
||||
</span><span class=data>
|
||||
% param 'allowphtml' => $wh_datas->{allowphtml} unless param 'allowphtml';
|
||||
%= select_field 'allowphtml' => $c->print_options('AllowPHTML'), class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_MAILFORCESENDER'
|
||||
</span><span class=data>
|
||||
% param 'mailforcesender' => $wh_datas->{mailforcesender} unless param 'mailforcesender';
|
||||
%=text_field 'mailforcesender' => size => '60', class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_DISABLEDFUNCTIONS'
|
||||
</span><span class=data>
|
||||
% param 'disabledfunctions' => $wh_datas->{disabledfunctions} unless param 'disabledfunctions';
|
||||
%=text_field 'disabledfunctions' => size => '60', class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><%= $c->print_disabledfunctions() %></p>
|
||||
|
||||
<p><span class=label>
|
||||
%=l 'wh_PHPBASEDIR'
|
||||
</span><span class=data>
|
||||
% param 'phpbasedir' => $wh_datas->{phpbasedir} unless param 'phpbasedir';
|
||||
%=text_field 'phpbasedir' => size => '60', class => 'input'
|
||||
<br></span></p>
|
||||
|
||||
<p><%= $c->print_phpbasedir() %></p>
|
||||
|
||||
<div class='center'>
|
||||
%= submit_button l('SAVE'), class => 'action'
|
||||
</div>
|
||||
|
||||
%= hidden_field 'trt' => $wh_datas->{trt}
|
||||
%= hidden_field 'ibay' => $wh_datas->{ibay}
|
||||
|
||||
% end
|
||||
|
||||
</div>
|
@@ -0,0 +1,33 @@
|
||||
% layout 'default', title => "Sme server 2 - webhosting";
|
||||
|
||||
% content_for 'module' => begin
|
||||
<div id="module" class="module panel-webhosting">
|
||||
|
||||
% if ($config->{debug} == 1) {
|
||||
<p>
|
||||
%= dumper $c->current_route
|
||||
%= dumper $wh_datas
|
||||
</p>
|
||||
% }
|
||||
|
||||
% if ( stash 'error' ) {
|
||||
<br><div class=sme-error>
|
||||
%= $c->render_to_string(inline => stash 'error')
|
||||
</div>
|
||||
%}
|
||||
|
||||
<h1><%= $title%></h1>
|
||||
|
||||
% if ( stash 'modul' ) {
|
||||
%= $c->render_to_string(inline => stash 'modul' );
|
||||
% }
|
||||
|
||||
% if ($wh_datas->{trt} eq 'UPD') {
|
||||
%= include 'partials/_wh_upd'
|
||||
%} else {
|
||||
%= include 'partials/_wh_list'
|
||||
%}
|
||||
|
||||
</div>
|
||||
%end
|
||||
|
Reference in New Issue
Block a user