<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">use strict;


my $ryba=&lt;&lt;'END_OF_RYBA';
use strict;
use DBI;
use CGI;
use HTML::Template::Pro;
use Log::Log4perl;
use Crypt::CBC;
use Storable qw/freeze thaw/;
use Data::Dumper;

our($dbh, $q, $log, $curruser);
our(%rootlvl, %userlvl);

our($logconfigstr)=&lt;&lt;'EOL';
        log4perl.rootLogger = DEBUG,LOGFILE
    
        log4perl.appender.LOGFILE = Log::Log4perl::Appender::File
        log4perl.appender.LOGFILE.filename = c:/work/perl/error.log
        log4perl.appender.LOGFILE.mode = append
   
        log4perl.appender.LOGFILE.layout = PatternLayout
        log4perl.appender.LOGFILE.layout.ConversionPattern = [%r] %F %L %c - %m%n
EOL

eval{
  main();
};

sub dnice{
 print "Content-type: text/html\n\n";
 my($msg) = @_;
 $log-&gt;fatal($msg);
 print $msg;
 die;
}

sub main{
  Log::Log4perl-&gt;init_once(\$logconfigstr);
  $log = Log::Log4perl-&gt;get_logger('');
  $dbh ||= DBI-&gt;connect('dbi:mysql:help','','',{RaiseError =&gt; 1});
  $q = new CGI;
  checkuser();

  my $action;
  $action = $q-&gt;param('action') || $q-&gt;param('action','toc');
  dnice('No such action') if $action !~ /^(\w+)$/;
  $action = 'ext_' . $1;
  my($hdrs, $result, $noncacheable);

  dnice 'No access' if !accessallowed($action, $curruser);

  $log-&gt;debug(sub { Dumper $curruser });
  $log-&gt;debug("Entering $action");
  $log = Log::Log4perl-&gt;get_logger($action);
  eval{
    ($hdrs, $result, $noncacheable) = __PACKAGE__-&gt;$action;
  };
  dnice($@) if $@;
  $log = Log::Log4perl-&gt;get_logger('');
  $log-&gt;debug("Leaving $action");
  print $q-&gt;header( -type =&gt; 'text/html',
                    -charset =&gt; 'cp1251',
		    @$hdrs);
  !$result &amp;&amp; return;
  !ref $result &amp;&amp; print($result) &amp;&amp; return;
  
  my $tmpl = HTML::Template::Pro-&gt;new( filename          =&gt; $q-&gt;param('action') . '.tmpl',
				       path              =&gt; 'c:/work/perl/tmpl',
				       associate         =&gt; $q,
				       loop_context_vars =&gt; 1,
				       global_vars       =&gt; 1
				       );
  $tmpl-&gt;param(@$result);
  print $tmpl-&gt;output();
}

####################################################################################
#################################### ACTIONS #######################################
####################################################################################

END_OF_RYBA

mkdir 'tmpl' or die "Cannot create tmpl:$!";
for my $action (@ARGV){
  $ryba .=&lt;&lt;"END_OF_ACTION"; 
####################################################################################
sub ext_${action}{
    return [],
           [];
}

END_OF_ACTION

open FILE, "&gt;tmpl/$action.tmpl" or die "Cannot open file tmpl/$action.tmpl : $!";
close FILE;
}
open FILE, "&gt;main.pl" or die "Cannot open main.pl : $!";
print FILE $ryba;
close FILE;</pre></body></html>