diff -Nur --no-dereference smeserver-webhosting-0.0.9.old/createlinks smeserver-webhosting-0.0.9/createlinks --- smeserver-webhosting-0.0.9.old/createlinks 2014-06-18 12:27:47.000000000 -0400 +++ smeserver-webhosting-0.0.9/createlinks 2021-03-12 15:14:23.419000000 -0500 @@ -5,10 +5,15 @@ panel_link("webhosting", "manager"); for my $event (qw( - webhosting-modify + webhosting-modify smeserver-webhosting-update )) { - templates2events("/etc/httpd/conf/httpd.conf", $event); - safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); + #we can avoid those 2 as we are tricking ourself as ibay-modify and it will do those and php + #templates2events("/etc/httpd/conf/httpd.conf", $event); + #safe_symlink("sigusr1", "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); + event_link("webhosting-php-expand", $event, "05"); + event_link("webhosting-php-adjust", $event, "90"); } +$event="smeserver-webhosting-update"; +event_link("navigation-conf", $event, "70"); diff -Nur --no-dereference smeserver-webhosting-0.0.9.old/root/etc/e-smith/events/actions/webhosting-php-adjust smeserver-webhosting-0.0.9/root/etc/e-smith/events/actions/webhosting-php-adjust --- smeserver-webhosting-0.0.9.old/root/etc/e-smith/events/actions/webhosting-php-adjust 1969-12-31 19:00:00.000000000 -0500 +++ smeserver-webhosting-0.0.9/root/etc/e-smith/events/actions/webhosting-php-adjust 2021-03-13 01:30:28.439000000 -0500 @@ -0,0 +1,10 @@ +#!/usr/bin/perl -w +package esmith; + +use strict; +use Errno; + +# here we trick ourself into ibay-modify in order to have all php versions offered by smeserver-php +# not ideal as we would like to only have php and we also do samba .... but we are working on ibays. +my $event ="ibay-modify"; +system('/etc/e-smith/events/actions/adjust-services',$event); diff -Nur --no-dereference smeserver-webhosting-0.0.9.old/root/etc/e-smith/events/actions/webhosting-php-expand smeserver-webhosting-0.0.9/root/etc/e-smith/events/actions/webhosting-php-expand --- smeserver-webhosting-0.0.9.old/root/etc/e-smith/events/actions/webhosting-php-expand 1969-12-31 19:00:00.000000000 -0500 +++ smeserver-webhosting-0.0.9/root/etc/e-smith/events/actions/webhosting-php-expand 2021-03-13 01:30:28.669000000 -0500 @@ -0,0 +1,10 @@ +#!/usr/bin/perl -w +package esmith; + +use strict; +use Errno; + +# here we trick ourself into ibay-modify in order to have all php versions offered by smeserver-php +# not ideal as we would like to only have php and we also do samba .... but we are working on ibays. +my $event ="ibay-modify"; +system('/etc/e-smith/events/actions/generic_template_expand',$event); diff -Nur --no-dereference smeserver-webhosting-0.0.9.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/webhosting smeserver-webhosting-0.0.9/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/webhosting --- smeserver-webhosting-0.0.9.old/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/webhosting 2021-03-12 01:47:03.229000000 -0500 +++ smeserver-webhosting-0.0.9/root/etc/e-smith/locale/en-us/etc/e-smith/web/functions/webhosting 2021-03-13 01:30:29.392000000 -0500 @@ -425,7 +425,7 @@ DESC_PHPBASEDIR - You must specify the full path to the I-bay or remove the content to get back to default values : /home/e-smith/files/ibays/ibay_name/:/new/path:/other/path + You must specify the full path to the I-bay or remove the content to get back to default value @@ -440,5 +440,48 @@ Allow WebDav + + PHPVERSION + + Select the php-fpm version you want to use with this I-bay + + + + FILEUPLOAD + + Whether or not to allow HTTP file uploads (file_upload) + + + + MAXINPUTTIME + + Maximum time in seconds a script is allowed to parse input data (max_input_time) + + + + ALLOWPHTML + + Allow parsing php code inside html, phtml, htm and xml files. + + + + MAILFORCESENDER + + Force an email sender address for the script in this I-bay. + + + + DISABLEDFUNCTIONS + + List of php disabled functions (disable_functions) + + + + DESC_DISABLEDFUNCTIONS + + Leave empty or with a random string to disable. Copy and paste the following default list to reset to default + + + diff -Nur --no-dereference smeserver-webhosting-0.0.9.old/root/etc/e-smith/web/functions/webhosting smeserver-webhosting-0.0.9/root/etc/e-smith/web/functions/webhosting --- smeserver-webhosting-0.0.9.old/root/etc/e-smith/web/functions/webhosting 2014-06-18 12:27:47.000000000 -0400 +++ smeserver-webhosting-0.0.9/root/etc/e-smith/web/functions/webhosting 2021-03-13 01:30:29.150000000 -0500 @@ -105,13 +105,13 @@ ADD_TITLE - + - + - + @@ -122,60 +122,72 @@ DESC_DAV_SETTINGS - + - DESC_PHP_SETTINGS - + + + + + + options="print_options('MemoryLimit')"> - + + + + options="print_options('UploadMaxFilesize')"> + options="print_options('PostMaxSize')"> + options="print_options('MaxExecutionTime')"> + + + + + + + + + + + + + + + + - - DESC_PHPBASEDIR - + diff -Nur --no-dereference smeserver-webhosting-0.0.9.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/webhosting.pm smeserver-webhosting-0.0.9/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/webhosting.pm --- smeserver-webhosting-0.0.9.old/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/webhosting.pm 2014-06-18 12:27:47.000000000 -0400 +++ smeserver-webhosting-0.0.9/root/usr/share/perl5/vendor_perl/esmith/FormMagick/Panel/webhosting.pm 2021-03-13 01:30:28.919000000 -0500 @@ -17,6 +17,7 @@ use File::Basename; use Exporter; use Carp; +use esmith::php; our @ISA = qw(esmith::FormMagick Exporter); @@ -36,6 +37,67 @@ 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', 'unlimited' => 'UNLIMITED'); +our %optionsproperties =( + MemoryLimit => {'64M' => 'M0064MB', '128M' => 'M0128MB', + '256M' => 'M0256MB', '512M' => 'M0512MB', '768M' => 'M0768MB','1024M' => 'M1024MB'}, + 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 @@ -205,27 +267,39 @@ if ($rec) { $q->param(-name=>'description',-value=> - $rec->prop('Name')); + $rec->prop('Name')); # yes we keep this one simple $q->param(-name=>'indexes',-value=> - ($rec->prop('Indexes'))); + (get_current_value($self,'Indexes'))); $q->param(-name=>'followSymLinks',-value=> - ($rec->prop('FollowSymLinks'))); + (get_current_value($self,'FollowSymLinks'))); $q->param(-name=>'allowOverride',-value=> - ($rec->prop('AllowOverride'))); + (get_current_value($self,'AllowOverride'))); $q->param(-name=>'allowUrlfOpen',-value=> - ($rec->prop('AllowUrlfOpen'))); + (get_current_value($self,'AllowUrlfOpen'))); $q->param(-name=>'memorylimit',-value=> - ($rec->prop('MemoryLimit'))); + (get_current_value($self,'MemoryLimit'))); $q->param(-name=>'uploadmaxfilesize',-value=> - ($rec->prop('UpMaxFileSize'))); + (get_current_value($self,'UploadMaxFilesize'))); $q->param(-name=>'postmaxsize',-value=> - ($rec->prop('PostMaxSize'))); + (get_current_value($self,'PostMaxSize'))); $q->param(-name=>'maxexecutiontime',-value=> - ($rec->prop('MaxExecTime'))); + (get_current_value($self,'MaxExecTime'))); + $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'))); + ($rec->prop('PHPBaseDir'))); # yes we keep this one simple $q->param(-name=>'modDav',-value=> - ($rec->prop('ModDav'))); + (get_current_value($self,'ModDav'))); + # we set phpversion using function called by cgi file } } else { print qq( @@ -272,21 +346,6 @@ return undef; } -=head2 group_list() - -Returns a hash of groups for the Create/Modify screen's group field's -drop down list. - -=for testing -can_ok('main', 'group_list'); -my $g = group_list(); -is(ref($g), 'HASH', "group_list returns a hashref"); -is($g->{simpsons}, "Simpsons Family (simpsons)", - "Found names and descriptions"); - -=cut - - =head1 THE ROUTINES THAT ACTUALLY DO THE WORK =for testing @@ -326,18 +385,52 @@ my $name = $self->cgi->param('name'); if (my $acct = $accountdb->get($name)) { if ($acct->prop('type') eq 'ibay') { - $acct->merge_props( - Indexes => $self->cgi->param('indexes'), - FollowSymLinks => $self->cgi->param('followSymLinks'), - AllowOverride => $self->cgi->param('allowOverride'), - AllowUrlfOpen => $self->cgi->param('allowUrlfOpen'), - MemoryLimit => $self->cgi->param('memorylimit'), - UpMaxFileSize => $self->cgi->param('uploadmaxfilesize'), - PostMaxSize => $self->cgi->param('postmaxsize'), - MaxExecTime => $self->cgi->param('maxexecutiontime'), - PHPBaseDir => $self->cgi->param('phpbasedir'), - ModDav => $self->cgi->param('modDav'), - ); + + my %doing=( Indexes => 'indexes', + FollowSymLinks => 'followSymLinks', + AllowOverride => 'allowOverride', + ModDav => 'modDav', + PHPVersion => 'PHPVersion', + AllowUrlfOpen => 'allowUrlfOpen', + MemoryLimit => 'memorylimit', + FileUpload => 'fileupload', + UploadMaxFilesize => 'uploadmaxfilesize', + PostMaxSize => 'postmaxsize', + MaxExecTime => '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; @@ -368,7 +461,9 @@ 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); @@ -382,6 +477,86 @@ 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;