+sub _cache_file_modification_times {
+ my ($self) = @_;
+
+ return unless $self->_interface_is_fcgi && $::lx_office_conf{debug}->{restart_fcgi_process_on_changes};
+
+ require File::Find;
+ require POSIX;
+
+ my $wanted = sub {
+ return unless $File::Find::name =~ m/\.(?:pm|f?pl|html|conf|conf\.default)$/;
+ $fcgi_file_cache{ $File::Find::name } = (stat $File::Find::name)[9];
+ };
+
+ my $cwd = POSIX::getcwd();
+ File::Find::find($wanted, map { "${cwd}/${_}" } qw(config bin SL templates/webpages));
+ map { my $name = "${cwd}/${_}"; $fcgi_file_cache{$name} = (stat $name)[9] } qw(admin.pl dispatcher.fpl);
+}
+
+sub _watch_for_changed_files {
+ my ($self) = @_;
+
+ return unless $self->_interface_is_fcgi && $::lx_office_conf{debug}->{restart_fcgi_process_on_changes};
+
+ my $ok = all { (stat($_))[9] == $fcgi_file_cache{$_} } keys %fcgi_file_cache;
+ return if $ok;
+ $::lxdebug->message(LXDebug::DEBUG1(), "Program modifications detected. Restarting.");
+ exit;
+}
+
+sub get_standard_filehandles {
+ my $self = shift;
+
+ return $self->{interface} =~ m/f(?:ast)cgi/i ? $self->{request}->GetHandles() : (\*STDIN, \*STDOUT, \*STDERR);
+}
+
+sub _init_environment {
+ my %key_map = ( lib => { name => 'PERL5LIB', append_path => 1 },
+ path => { name => 'PATH', append_path => 1 },
+ );
+ my $cfg = $::lx_office_conf{environment} || {};
+
+ while (my ($key, $value) = each %{ $cfg }) {
+ next unless $value;
+
+ my $info = $key_map{$key} || {};
+ $key = $info->{name} || $key;
+
+ if ($info->{append_path}) {
+ $value = ':' . $value unless $value =~ m/^:/ || !$ENV{$key};
+ $value = $ENV{$key} . $value;
+ }
+
+ $ENV{$key} = $value;
+ }
+}
+
+sub _check_for_old_config_files {
+ my @old_files = grep { -f "config/${_}" } qw(authentication.pl console.conf lx-erp.conf lx-erp-local.conf);
+ return unless @old_files;
+
+ $::form->{title} = $::locale->text('Old configuration files');
+ $::form->{stylesheet} = 'lx-office-erp.css';
+ $::form->header;
+ print $::form->parse_html_template('login/old_configuration_files', { FILES => \@old_files });
+
+ ::end_of_request();
+}
+