head	1.1;
access;
symbols;
locks; strict;
comment	@# @;


1.1
date	2025.10.24.05.34.28;	author root;	state Exp;
branches;
next	;


desc
@original.
-bert
@


1.1
log
@Initial revision
@
text
@#!/usr/bin/perl

use lib qw (/var/www/www.rcflightpath.com/lib);
use POSIX qw(strftime);
use CGI qw(:standard :html3 :all *table *Tr *td unescape);
use CGI::Cookie;
use Templates::Navbar;
use Templates::Header;
use Templates::Footer;

$topic      = param('topic');
$user_agent = user_agent();
$filepath   = '/var/www/www.rcflightpath.com/XXX.cgi';
$title      = 'Battery/Charger Notes & Data Respository';
$keywords   = 'KEYWORDS HERE';
$page_desc  = 'PAGE DESCRIPTION HERE';

charset('UTF-8');

$|=1;

if (-e 'style.css') {
  $style = 'style.css';
} elsif (-e '../style.css') {
  $style = '../style.css';
} else {
  $style = '/style.css';
}

Header::print_header($title,$style,$page_desc,$keywords);

print start_table({-border=>0,-margin=>0,-topmargin=>0,-cellpadding=>0,-cellspacing=>0,-width=>900}),"<!-- START MAIN TABLE -->\n ",
       start_Tr,"<!-- START HEADER -->\n  ",
        start_td({-colspan=>2}),"\n   ";
         Header::print_titlebar($title,$filepath,'FFFFFF');
print   end_td,"\n",
       end_Tr,"<!-- END HEADER -->\n",
       start_Tr,"<!-- START NAVBAR -->\n ",
        start_td({-valign=>'top',-rowspan=>3}),"\n\n    ";
         Navbar::default('home');
print   end_td,"<!-- END NAVBAR -->\n  ",
        start_td({-valign=>'top'}),div({-id=>'main'}),"<!-- START CONTENT -->\n  ";
         &print_content;
print   end_td,"\n ",
       end_Tr,"<!-- END CONTENT -->\n ",
       start_Tr,"<!-- START FOOTER -->\n  ",
        start_td({-align=>'center'}),"\n  ";
         Footer::print_footer;
print   end_td,"\n ",
       end_Tr,"<!-- END FOOTER -->\n",
      end_table,"<!-- END MAIN TABLE -->\n",
     end_html;

sub print_content {
  my $pwd = `/usr/bin/pwd`; chomp $pwd;
  my $cwd = '/var/www/www.rcflightpath.com';
  $pwd =~ s/$cwd//;
  print br,b("\"$pwd\" directory contents:"),p;
  &recurse(0,$pwd);
}

sub recurse {
  my $gen = shift; $gen++;
  my $path = shift;
  my @@ls = <*>;
  my $pwd = `/usr/bin/pwd`;
  my $length = scalar(@@ls);
  my $cnt;
  my $space = '&nbsp;';
  print '<ul>';
  #print "$pwd has $length elements:";
  foreach (@@ls) {
    $cnt++;
    next if ($_ eq 'index.cgi');
    if (-d) {
      print "&nbsp;" x $gen;
      #print "<li>dir($gen): $path/$_\n";
      print "<li>$path/$_:\n";
      chdir $_ || print "unable to access $obj\n";
      &recurse($gen,"$path/$_");
      chdir '..';
    } else {
      print "&nbsp;" x $gen;
      #print "<li>file($gen): ",a({-href=>"$path/$_"},"$path/$_");
      print '<li>',a({-href=>"$path/$_"},"$path/$_");
    }
    #print "$_ is the LAST ELEMENT\n",p if ($cnt == $length);
    print '</ul>' if ($cnt == $length);
  }
}
@
