head	1.5;
access;
symbols;
locks
	root:1.5; strict;
comment	@# @;


1.5
date	2026.10.21.16.14.34;	author root;	state Exp;
branches;
next	1.4;

1.4
date	2026.10.20.12.58.56;	author root;	state Exp;
branches;
next	1.3;

1.3
date	2026.10.16.12.19.05;	author root;	state Exp;
branches;
next	1.2;

1.2
date	2026.09.29.10.38.03;	author root;	state Exp;
branches;
next	1.1;

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


desc
@as i found it.
-bert
@


1.5
log
@as i found it. about to make a big logic change that could result in failure/errors.
-bert
@
text
@#!/usr/bin/perl

use POSIX qw(strftime);
use CGI qw(:standard :html3 :all *table *Tr *td unescape);
use CGI::Cookie;

my $base  = '/var/www/www.rcflightpath.com';
my $relp  = param('file'); $relp =~ s/\/?articles\///; $relp = $ENV{'REQUEST_URI'} if (!$relp);
my $mode  = param('mode');
my $style = '/new/style2.css';
my $doctype;
my $words;

$relp     =~ s/^\///;
$file     = "$base/$relp";

@@relp = split/\//,$relp;
my $title = pop(@@relp);
   $title = pop(@@relp) if ($title eq 'index.htmml');

$title =~ s/\.(html|cgi)$//;
$title =~ s/(\_|\-)/ /g;
$title = 'Error - Could not get a title' if (! $title);

if ($mode eq 'open') {
  open (CHECK,$relp);
  while (<CHECK>) {
    @@line = split/\s+/;
    $words += scalar(@@line);
    $doctype = 1 if ($_ =~ /DOCTYPE/);
#   $youtube = 1 if ($_ =~ /youtube/i);
  }
  $adjusted = $words * .01;
  $adjusted = $words - $adjusted;
  $words = sprintf ("%2.0d",$adjusted);
  close CHECK;
  if ($doctype) {
    open (AS_IS,$relp);
    while (<AS_IS>) {
      print;
    }
    close;
  } else {
    &print_header($title);
    print "<body>\n";
    &print_topnav;
    &print_hero($title);
    print "  <section class=\"article-body\">\n";
    print "    <div class=\"wrap\">\n";
    print "      <div class=\"article-grid\">\n" if (!$youtube);
    print "        <article class=\"article-content\">\n";
    if (-e $relp) {
      open (REQ,$relp);
      while (<REQ>) {
        chomp;
        if (($_ =~ /\<table/)&&($_ !~ /spec-table/)) {
          print "          <table class=\"spec-table\">\n";
        } else {
          if ($_ =~ /sec-head.*\<h2|h3/) {
            my $ptoc = $_;
            $ptoc =~ s/<h2>//;
            $ptoc =~ s/<\/h2>//;
            $ptoc =~ s/<h3>//;
            $ptoc =~ s/<\/h3>//;
            $ptoc =~ s/<\/div>//;
            $ptoc =~ s/<div.*>//;
            $ptoc =~ s/^\s+//;
            push (@@toc,$ptoc);
            $id++;
            my $new = $_;
            $new =~ s/<h2/<h2 id=$id/;
            $new =~ s/<h3/<h3 id=$id/;
            $new =~ s/^\s+//;
            print "          $new\n";
          } elsif ($_ =~ /\<h2|h3/) {
            my $ptoc = $_;
            $ptoc =~ s/<h3>//;
            $ptoc =~ s/<\/h3>//;
            $ptoc =~ s/<h2>//;
            $ptoc =~ s/<\/h2>//;
            $ptoc =~ s/<\/div>//;
            $ptoc =~ s/<div.*>//;
            $ptoc =~ s/^\s+//;
            push (@@toc,$ptoc);
            $id++;
            my $new = $_;
            $new =~ s/^\s+//;
            $new =~ s/<h2/<h2 id=$id/;
            print "          <div class='sec-head'>$new</div>\n";
          } else {
            print '          '.$_."\n";
          }
        }
      }
      close REQ;
    } else {
      $file_path = param('file');
      $file_path = $ENV{'REQUEST_URI'} if ($file !~ /\.html/);
      (undef,$file_path) = split/\&/,$file_path;
      $file_path =~ s/^file=//;
      my @@path = split/\//,$file_path;
      my $file_name = pop(@@path);
      chomp (my $search_results = `/usr/bin/locate $file_name`);
      $search_results =~ s/\/var\/www\//https:\/\//;
      my $path = join('/',@@path);
      print h1("The file you requested does not exist:");
      print br;
      print li("File Path: $file_path");
      print li("File: $file");
      print li("Filename: $file_name");
      print li("Possible: $search_results");
    }
    print "        </article>\n\n";
    foreach $ptoc(@@toc) {
      $id2++;
      $toc .= "              <li><a href=\"\#$id2\">$ptoc</a></li>\n";
    }
    &print_sidebar;
    print "      </div>  <!-- END ARTICLE-GRID -->\n" if (!$youtube);
    print "    </div>    <!-- END WRAP -->\n";
    print "  </section>  <!-- END ARTICLE-BODY SECTION -->\n\n";
    &print_footer;
    &print_script;
    print "</body>\n";
    print "</html>\n";

  }
} elsif ($mode eq 'redirect') {
  my $timeout = 2;
  my $redir_url = $file;
  print header(-charset => 'UTF-8');
  print start_html(
          -head=>meta({-http_equiv=>'refresh',-content=>"$timeout;url=$redir_url"})
        );
} else {
  &my_log;
  my $uri = $ENV{REQUEST_URI};
  my $rel_path = $uri; $rel_path =~ s/^\/articles\///;
  my @@path = split/\//,$uri;
  my $dirname = pop(@@path);
  my $dir_url = join('/',@@path);
  my $pwd = `pwd`;
  my $timeout = 2;
  my $redir_url = '/articles';
  my $title = "Directory of: <em>$dirname</em>";
  $stat1 = 'bert';
  $rel_path =~ s/^\///;
  $rel_path =~ s/\/\//\//;
  my @@path = split/\//,$rel_path;
  my $file_name = pop(@@path);
  if ((-e $rel_path)||($file_name eq '')) {
    &print_header($title);
    print "<body>\n";
    &print_topnav;
    &print_hero($title);
    print "  <section class='article-body'>\n";
    print "    <div class='wrap'>\n";
    print "      <div class='sec-head'><span class='sec-num'>Sitemap for</span><h2>$ENV{REQUEST_URI}</h2></div>\n";
    print "      <div class='article-grid-list'>\n";
    chdir "$rel_path" || print h1("Unable to access $rel_path") if (-d $rel_path);
  } else {
    $nfile = param('file');
    chomp (my @@possible = `locate -i '/articles/' | grep -i \"$file_name\"`);
    foreach (@@possible) {
      $poss = $_;
      last;
    }
    $poss =~ s/\/var\/www\/www\.rcflightpath\.com\///;
    print "Status: 301 Moved Permanently\r\n";
    print "Location: https://www.rcflightpath.com/$poss\r\n\r\n";
    exit;
  }
  my @@ls = <*>;
  foreach $node(@@ls) {
    next if (($node eq 'images')||($node eq 'RCS')||($node eq 'admin')||($node eq 'backups'));
    next if ($node =~ /\.(json|cgi|xml|pl|webp|php|js)$/);
    print "        <article class=\"article-content\">\n";
    if (-d $node) {
      print a({-href=>"/articles/$rel_path/$node"},img({-width=>40,-src=>'/images/ico_folder.png'})),br;
    } else {
      print a({-href=>"/articles/$rel_path/$node"},img({-width=>40,-src=>'/images/ico_file.png'})),br;
    }
    $link_name = $node;
    $link_name =~ s/\_/ /g;
    $link_name =~ s/(\.html)$//;
    print a({-href=>"/articles/$rel_path/$node"},$link_name);
    print "        </article>\n";
  }
  print "      </div>\n";
  print "    </div>\n";
  print "  </section>\n\n";
  &print_footer;
}

sub print_header {
  my $title = shift;
  if ($title eq 'not_found') {
    print "Status: 404 Not Found\r\n";
    print "Content-type: text/html\r\n\r\n";
  }
  print <<HEADER;
<!DOCTYPE html>
<!-- new.cgi -->
<head>
  <link rel='icon' type='image/x-icon' href='/favicon2.ico'>
  <meta charset='UTF-8'>
  <meta name='viewport' content='width=device-width, initial-scale=1.0'>
  <title>$title</title>
  
  <!-- Load Google Fonts FIRST -->
  <link rel='preconnect' href='https://fonts.googleapis.com'>
  <link href="https://fonts.googleapis.com/css2?family=Big+Shoulders:wght\@@500;600;700;800&family=IBM+Plex+Mono:wght\@@400;500;600&family=Inter:wght\@@400;500;600&display=swap" rel="stylesheet">
  <link href='https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght\@@0,400;0,600;0,700;1,400&family=DM+Sans:wght\@@300;400;500;600&family=DM+Mono:wght\@@400;500&display=swap' rel='stylesheet'>

  <!-- THEN load your stylesheet so it can use those fonts -->
  <link href='/new/style2.css' rel='stylesheet'>
  
  <!-- Analytics -->
  <script async src='https://www.googletagmanager.com/gtag/js?id=G-3D6XXHE4VQ'></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'G-3D6XXHE4VQ');
  </script>
</head>
HEADER
}

sub print_hero {
  my $title   = shift;
  @@path       = split/\//,$relp;
  $file_name  = pop(@@path);
  $rel_path   = join ('/',@@path);
  if (-e "$rel_path/images/hero_img.jpg") {
    $hero_img = "/articles/$rel_path/images/hero_img.jpg";
  } elsif (-e "$rel_path/images/hero_img.png") {
    $hero_img = "/articles/$rel_path/images/hero_img.png";
  } elsif (-e "../$ENV{'REQUEST_URI'}images/hero_img.png") {
    $hero_img = "$ENV{'REQUEST_URI'}images/hero_img.png";
  } elsif (-e "../$ENV{'REQUEST_URI'}images/hero_img.jpg") {
    $hero_img = "$ENV{'REQUEST_URI'}images/hero_img.jpg";
  } else {
    $hero_img = '/images/articles_manuals.png';
  }

  #&print_debug("rel_path=$rel_path,request_uri=$ENV{'REQUEST_URI'},file_name=$file_name,relp=$relp,hero_img=$hero_img");

  opendir (LS,"$rel_path");
  @@ls = readdir(LS);
  $scalar_ls = scalar(@@ls);

  if ($scalar_ls > 3) {
    @@colors = qw /btn-primary btn-outline btn-tertiary btn-fourth btn-rotorflight/;
    $scalar_colors = scalar(@@colors);
    $max_listings = 5;
    if ($scalar_ls < $max_listings) {
      $choice = $scalar_ls;
    } else {
      $choice = $max_listings;
    }
    $buttons = "Related Articles (hit \"refresh\" for more):<br><div class=\"page-hero-btns\">";
    my @@results = &get_keywords($file_name);
    foreach $ls(@@results) {
      next if ($ls =~ /$file_name/);
      @@rpath = split/\//,$ls;
      $name = pop(@@rpath);
      $name =~ s/\.html$//;
      $name =~ s/(\_|\-)/ /g;
      $name =~ s/difference/diff/i;
      $name =~ s/between/b\/n/i;
      $name =~ s/\ and\ / \&amp\; /;
      $rpath = $path;
      $rpath =~ s/$base//;
      $pick = int(rand($scalar_colors));
      $buttons .= "  <a href=\"/articles/$ls\" class=\"$colors[$pick]\">$name</a>";
      $max++; last if ($max > 4);
    }
    $buttons .= "</div>";
  }
  @@path = split/\//,$ENV{REQUEST_URI};
  foreach (@@path) {
    next if (! $_);
    $nice_name = $_;
    $nice_name =~ s/\_/ /g;
    $nice_name =~ s/\.html//g;
    $nice_name =~ s/\%20/ /g;
    $breadcrumb .= "// <a href=\"https://www.rcflightpath.com$prev/$_\"><font color=\"#C5973A\">$nice_name</font></a>";
    $prev = "$prev/$_";
    $path = $_;
  }
  $path = $breadcrumb;

  if (-e $relp) {
    $file_bytes = (stat($relp))[7];
    $kb = 1024;
    $mb = 1024 * 1024;
    $stat1 = $file_name;
    $stat3 = "~ $words words";
    my $mod_time = (stat($relp))[9];
    my ($sec, $min, $hour, $mday, $mon, $year) = localtime($mod_time);
    @@months = qw /null Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
    $mon++;  # Adjust month (0-based index)
    $year += 1900; chomp $year; # Adjust year (start from 1900)
    $ampm = 'a.m.';
    $ampm = 'p.m.' if ($hour > 11);
    $hour = '0'.$hour if ($hour < 10);
    $min  = '0'.$min if ($min < 10);
    $stat2 = "<strong>Updated:</strong> $months[$mon] $mday, $year";
  } else {
    $stat1 = "<strong>relp = $relp</strong>";
    $stat2 = "<strong>rel_path = $rel_path</strong>";
    $stat3 = "<strong>http_uri = $ENV{'REQUEST_URI'}</strong>";
  }

  print <<HERO;
  <section id="article-hero">
    <div class="wrap">
      <img class="hero-img" src="$hero_img">
      <div class="article-hero-inner">

        <strong>
          <div class="page-hero-tag">
            $breadcrumb
          </div>
        </strong>

        <div class="sec-head"><h1>$title</h1></div>
  
        <div class="article-meta">
          <span>📄 $stat1</span>
          <span>📅 $stat2</span>
          <span>🏷️ $stat3</span>
        </div>
  
        <p class="hero-sub">$description</p>
  
        $buttons

        <br>
        <a href="/library.cgi"><span style="color: var(--accent); font-family: 'Share Tech Mono', monospace;"><strong>&lt;&lt; Back to Library</strong></span></a>

      </div>
    </div>
  </section>

HERO
}

sub print_topnav {
  print <<TOPNAV;
  <nav id="topnav">
    <a href="/resources.html"><img width=100 src="/images/logo6.png"></a>
    <span>
      <div class="nav-links"><a href="https://www.youtube.com/\@@RCFlightPath">FOLLOW US AT:</a>
      <a href="https://www.youtube.com/\@@RCFlightPath"><img width=25 src="/images/ico_sm_yt.png"></a>
      <a href="https://www.instagram.com/rc_flightpath/"><img width=25 src="/images/ico_sm_ig.png"></a>
      </div>
    </span>
    <div class="nav-links">
      <a href="/">Home</a>
      <a href="/resources.html">Resources</a>
      <a href="/library.cgi">Library</a>
      <a href="/resources.html#airfields">Airfields</a>
      <a href="/resources.html#links">Links</a>
      <a class="cta" href="/#contact">Contact Us</a>
    </div>
  </nav>

TOPNAV
}

sub get_keywords {
  my $keywords;
  @@words = split/\_/,$file_name;
  foreach (@@words) {
    $a = lc($_);
    $a =~ s/\.html//g;
    next if (($a eq 'on')||($a eq 'in')||($a eq 'with')||($a eq 'and')||($a eq 'index')||($a eq 'c'));
    next if (($a eq 'a')||($a eq 'make')||($a eq 'How')||($a eq 'rc')||($a eq 'to')||($a eq 'of'));
    next if (($a eq 'the')||($a eq 'make')||($a eq 'how')||($a eq 'for')||($a eq 'to')||($a eq 'of'));
    next if ($a =~ /\d/);
    $keywords .= "$a|";
  }
  $keywords =~ s/\|$//;
  chdir ("$base/articles");
  chomp (@@results = `/usr/bin/find . | egrep -i \"$keywords\" | egrep -iv \"\.csv|\.png|\.jpg|\.db|\.mp4|\.tbz|RCS|index\.html|mkr|tmp|images|dump|backup|admin|new|\.old|\.disabled|\.current\"`);
  return (@@results);
}

sub print_sidebar {
  my $related;
  my @@results = &get_keywords($file_name);
  foreach (@@results) {
    next if ($_ eq $file_name);
    next if (($_ eq '.')||($_ eq '..')||($_ eq "")||($_ eq " "));
    next if ($_ =~ /^<span/);
    @@rel_path = split/\//;
    $file_name = pop(@@rel_path);
    $file_name =~ s/\.(jpg|png|html|cgi|gif|tif|pdf)$//;
    $file_name =~ s/\_/ /g;
    $related .= "              <li><a href=\"/articles/$_\">$file_name</a></li>\n";
  }
  print <<SIDEBAR;
        <aside class="article-sidebar">
          <div class="sidebar-card">
            <h4>Article Details</h4>
            <div class="sidebar-meta-item">$stat1</div>
            <div class="sidebar-meta-item">$stat2</div>
            <div class="sidebar-meta-item">$stat3</div>
            <div class="sidebar-meta-item">$stat4</div>
          </div>
          <div class="sidebar-card">
            <h4>File Sections (Easy Access):</h4>
            <ul class="toc-list">
$toc            </ul>
          </div>
          <div class="sidebar-card">
            <h4>Related Articles & Topics:</h4>
            <ul class="toc-list">
$related            </ul>
          </div>
        </aside>

SIDEBAR
}

sub print_footer {
  print <<FOOTER;
  <footer>
    <center>
    <table width=55% border=0>
      <tr>
        <td>
          <center>
            <strong>RC FlightPath</strong><br>
            Sunland, CA 91040 &nbsp;·&nbsp; Apollo XI Airfield, Van Nuys, CA<br>
            <a href="mailto:piroflip@@gmail.com">rcflightpath@@gmail.com</a> &nbsp;·&nbsp; (818) 600-1381<br>
            FAA Part 107 Certified &nbsp;·&nbsp; TRUST Certified &nbsp;·&nbsp; AMA Insured<br>
            © 2026 RC FlightPath. Flight Training · Custom Builds · Autonomous Drone Solutions. All rights reserved.
          </center>
        </td>
        <td>
          Proud supporters of
        </td>
        <td>
          <a href="https://www.facebook.com/hashtag/keeprchelisalive"><img height=100 src="/images/keep_rc_helis_alive.gif"></a>
        </td>
        <td>
          <a href="http://www.ircha.org"><img height=50 src="/images/ircha_logo.png"></a>
        </td>
      </tr>
    </table>
    </center>
  </footer>

FOOTER
}

sub print_script {
  print <<SCRIPT;
  <script>
    // This is a place for a script
  </script>

SCRIPT
}

sub my_log {
  # Path to your custom visitor log
  my $vislog = '/var/www/www.rcflightpath.com/tmp/404.log';

  # Capture useful environment variables
  my $ip       = $ENV{REMOTE_ADDR}        || '-';
  my $method   = $ENV{REQUEST_METHOD}     || '-';
  my $uri      = $ENV{REQUEST_URI}        || '-';
  my $referer  = $ENV{HTTP_REFERER}       || '-';
  my $agent    = $ENV{HTTP_USER_AGENT}    || '-';
  my $query    = $ENV{QUERY_STRING}       || '-';

  # Timestamp
  my $ts = scalar localtime();

  # Build one clean log line
  my $logline = "$ts | IP=$ip | METHOD=$method | URI=$uri | REFERER=$referer | UA=$agent | QUERY=$query\n";

  # Append to log
  if (open my $fh, ">>", $vislog) {
      print $fh $logline;
      close $fh;
  }
}

sub print_debug {
  my $pwd = `pwd`;
  my $params = shift;
  my @@array = split/\,/,$params;
  print "  <section class=\"article-body\">\n";
  print "    <div class=\"wrap\">\n";
  print "      <div class=\"article-grid-full\">\n";
  print "        <article class=\"article-content\">\n";
  print '          <li>pwd=',$pwd."</li>\n";
  foreach (@@array) {
    print '          ',li("array: $_");
  }
  print "        </article>\n";
  print "      </div>\n";
  print "    </div><!-- END WRAP -->\n";
  print "  </section>\n";
}
@


1.4
log
@as i found it.
-bert
@
text
@d17 8
d44 1
a44 1
    &print_header($style);
d97 5
a101 1
      my @@path = split/\//,$relp;
d103 2
d108 2
d111 1
a111 1
      print li("Path: $path");
d152 1
a152 1
    &print_header;
d162 1
a162 10
    &print_header('not_found');
    print "<body>\n";
    &print_topnav;
    $title = 'System Error';
    &print_hero($title);
    print "  <section class='article-body'>\n";
    print "    <div class='wrap'>\n";
    print "      <div class='sec-head'><span class='sec-num'>File not Found:</span><h2>$file_name</h2></div>\n";
    print "      <div class='article-grid-list'>\n";
    print "      <div class='card'>\n";
d164 3
a166 4
    print "      <div class='sec-head'><span class='sec-num'>Try these files:</span></div>\n";
    foreach my $poss(@@possible) {
      $poss =~ s/\/var\/www\/www\.rcflightpath\.com\///;
      print '      ',li(a({-href=>"/$poss"},$poss))."\n";
d168 3
a170 7
    print "      </div>\n";
    print "      </div>\n";
    print "    </div>\n";
    print "  </section>\n\n";
    &print_footer;
    print "</body>\n";
    print "</html>\n";
d196 2
a197 2
  my $status = shift;
  if ($status eq 'not_found') {
d203 1
a203 1
<! -- new.cgi -->
d208 1
a208 1
  <title>RC FlightPath</title>
d231 4
a234 3
  @@path = split/\//,$relp;
  $file_name = pop(@@path);
  $rel_path = join ('/',@@path);
a255 1

a261 1

a280 12

  $title = shift;
  if (! $title) {
    $title = $file_name;
    $title =~ s/\.(html|cgi)$//;
    $title =~ s/(\_|\-)/ /g;
  }
  if ($title eq 'index') {
    @@mypath = split/\//,$path;
    $title = pop(@@mypath);
  }

a298 7
#   if ($file_bytes > $mb) {
#     $stat3 = '<strong>File size:</strong> '.sprintf ("%2.2f",$file_bytes / $mb).' Mb';
#   } elsif ($file_bytes > $kb) {
#     $stat3 = '<strong>File size:</strong> '.sprintf ("%2.2f",$file_bytes / $kb).' Kb';
#   } else {
#     $stat3 = '<strong>File size:</strong> '.(stat($relp))[7].' bytes';
#   }
@


1.3
log
@as i found it.
-bert
@
text
@d3 1
d5 1
d7 9
a15 5
$basedir  = '/var/www/www.rcflightpath.com';
$template = $basedir.'/templates/rcfp_header.html';
$mode     = param('mode');
$file     = param('file');
$author   = 'Authors: Bert M./Gemini';
d18 92
a109 32
  $file =~ s/^\///; #<- FOR SECURITY
  $found = $file;
  $found = "$basedir/$file" if ((!-e $file)&&(-e "$basedir/$file"));;
  if (-e $found) {
    open (FILE,$found);
    while (<FILE>) {
      $standalone = 1 if ($_ =~ /DOCTYPE\s+html/);
      $backup .= $_;
      $title = $_ if ($_ =~ /\<title\>/);
      $title_bkp = $_ if ($_ =~ /\<h1\>/);
      $title_bkp2 = $_ if ($_ =~ /title/);
      $flag = 1 if ($_ =~ /\<body\>/);
      next unless $flag;
      $content .= $_;
    }
    close FILE;
    if ((!$content)&&(!$backup)) {
      $content = '<strong>Warning:</strong> "content" (and "backup") variables are empty'
    } elsif (($content)&&(!$title)) {
      $content = $backup;
    } elsif ((!$content)&&($backup)) {
      $content = $backup;
    }
    $title =~ s/\<title\>//;
    $title =~ s/\<\/title\>//;
    if (!$title) {
      $title = $title_bkp;
      $title =~ s/\<h1\>//;
      $title =~ s/\<\/h1\>//;
    }
    @@path = split/\//,$file;
    pop (@@path);
d111 81
d193 34
d228 15
a242 14
    $path = join(' // ',@@path);

    @@path = split/\//,$ENV{REQUEST_URI};
    foreach (@@path) {
      next if (! $_);
      s/\_/ /g;
      s/\.html//g;
      $nice_name = $_;
      $nice_name =~ s/\%20/ /g;
      $breadcrumb .= "// <a href=\"https://www.rcflightpath.com$prev/$_\"><font color=\"#C5973A\">$nice_name</font></a>";
      $prev = "$prev/$_";
      $path = $_;
    }
    $path = $breadcrumb;
d244 1
d246 14
d261 19
d281 10
d292 12
a303 6
    $title = $title_bkp2 if (($title_bkp2)&&(!$title));
    $title =~ s/title=//;
    $title =~ s/\.html//;
    $title =~ s/\_/ /;
    $description = '<p class="hero-sub">Some articles on this website are created using a combination of AI‑assisted writing, human editing, and factual research. While every effort is made to ensure accuracy, clarity, and reliability, the information provided may occasionally contain errors, omissions, or interpretations that differ from other sources.</p><p class="hero-sub">The content is intended for general informational purposes only and should not be treated as professional advice. Readers are encouraged to verify important details independently and use their own judgment when applying any information found here.</p>';
    $description = '<p class="hero-sub"><strong>Disclaimer:</strong> Articles may use AI assistance. Content is for general information only, not professional advice. Please verify important details independently.</p>';
d305 14
a318 1
    my $mod_time = (stat("$basedir/$file"))[9];
d327 37
a363 1
    $updated = "Last Updated: $months[$mon] $mday, $year";
d365 144
a508 42
  } else {
    $uri = $ENV{REQUEST_URI};
    @@filepath = split/\=/,$uri;
    $relpath = pop(@@filepath);
    $relpath =~ s/\%20/_/g;
    @@relpath = split/\//,$relpath;
    $filename = pop(@@relpath);
    chomp ($mypath = `locate $filename | grep articles`);
    $mypath =~ s/\/var\/www\/www\.rcflightpath\.com\///;
    if ($mypath) {
      $choice = $mypath;
      $choice = '/'.$choice if ($choice !~ /^\//);
      print "Status: 301 Moved Permanently\r\n";
      print "Location: https://www.rcflightpath.com/$choice\r\n";
      print "Content-Type: text/html; charset=UTF-8\r\n\r\n";
    } else {
      print "Status: 404 Not Found\r\n";
      print "Content-Type: text/html; charset=UTF-8\r\n\r\n";
      $choice = 'https://www.rcflightpath.com/library.cgi#latest';
    }
    #$redirect = "<meta http-equiv=\"refresh\" content=\"5; url=$choice\">\n";

    $path = 'Internal Systems Error';
    $title = 'Your file has been moved - <em>Redirecting you Now.</em>';
    $title = $filename;
    $content = "<strong>Internal Systems Details:</strong><br>No suCh file: $found";
    $description = 'A 404 error means the webpage a visitor is looking for cannot be found. It happens because the address was typed wrong, the page was moved, or the link is old';
    $logfile = '/var/www/www.rcflightpath.com/tmp/404.log';
    $referer = $ENV{HTTP_REFERER};
    my $mod_time = (stat("$basedir/$file"))[9];
    my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
    @@months = qw /null Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
    $mon++;  # Adjust month (0-based index)
    $year += 1900; chomp $year; # Adjust year (start from 1900)
    $ampm = 'a.m.';
    $ampm = 'p.m.' if ($hour > 11);
    $hour = '0'.$hour if ($hour < 10);
    $min  = '0'.$min if ($min < 10);
    open (LOG,">>$logfile");
    print LOG "$mday$months[$mon]$year-$hour:$min|$referer|$file\n";
    close LOG;
    $updated = 'Last Updated: N/A';
a509 5
} else {
  $content = "<strong>Internal Systems Details:</strong> Latest Article Mode";
  $path = 'Latest Article Listings';
  $cwd = `pwd`;
  $buttons = &get_latest("$cwd/index.cgi");
d512 11
a522 70
if ($standalone) {
  print $backup;
} else {
  $buttons  = &get_latest("$basedir/$file");
  $referer  = $ENV{HTTP_REFERER};
  $referer  = '/library.cgi' if (!$referer);
  @@cat_path = split/\//,$referer;
  pop(@@cat_path);
  $category = 'Category: '.pop(@@cat_path);
  $direct = ' ' if (! $redirect);
  open (TEMPL,$template) || print "No such template: $template";
  while (<TEMPL>) {
    s/CONTENT/$content/;
    s/TITLE/$title/;
    s/BREADCRUMB/$path/;
    s/DESCRIPTION/$description/;
    s/AUTHOR/$author/;
    s/UPDATED/$updated/;
    s/CATEGORY/$category/;
    s/BUTTONS/$buttons/;
    s/REFERER/$referer/;
    s/REDIRECT/$redirect/;
    $output .= $_;
  }
  close TEMPL;
  print $output;
}

sub get_latest {
  $file_path = shift;
  @@parts = split/\//,$file_path;
  @@pparts = @@parts;
  pop @@parts;
  pop @@pparts;
  $dir = pop @@pparts;
  $file_loc = join '/',@@parts;
  $dir =~ s/\_/\ /g;
  $out  = "<font color=\"orange\">Related Articles in \"$dir\":</font>";
  $out .= '<div class="page-hero-btns">'."\n";
  chomp (@@list = `locate -w $file_loc | grep \.html`);
  foreach $file(@@list) {
    next if ($file =~ /\/RCS|index\.html|index\.cgi|\.swp/);
    $mtime = (stat($file))[9];
    $file =~ s/\/var\/www\/www\.rcflightpath\.com//;
    $hash{$file} = $mtime;
  }
  foreach (sort keys %hash) {
    next if ($_ =~ /template|\/test\//);
    $count++;
#   print "$_ = $hash{$_}\n";
    $rel = $_;
    @@rel = split/\//,$rel;
    $file = pop(@@rel);
    $file =~ s/\.html//;
    $file =~ s/\_/ /g;
    $style = &get_style($file);
    $out .= "        <a href=\"$rel\" class=\"$style\">$file</a>"."\n";
    last if ($count == 5);
  }
  $out .= '      </div>'."\n";
  return $out;
}

sub get_style {
  if ($_[0] =~ /rotorflight|jaiwen/i) {
    return 'btn-rotorflight';
  } else {
    @@flavors = qw /btn-orange btn-green btn-yellow btn-outline/;
    $picked  = $flavors[ rand @@flavors ];
    return $picked;
d524 4
@


1.2
log
@as i found it.
-bert
@
text
@d44 3
d48 18
d85 20
a104 1
    $redirect = "<meta http-equiv=\"refresh\" content=\"5; url=https://www.rcflightpath.com/library.cgi#latest\">\n";
d107 3
a109 2
    $title = '404 <em>Error</em>';
    $content = "<strong>Internal Systems Details:</strong><br>No such file: $found";
a137 3
  $category = 'Category: ';
  @@cat_path = split/\/\//,$path;
  $category .= pop(@@cat_path);
d140 3
d175 1
a175 1
    next if ($file =~ /\/RCS|index\.html|index\.cgi/);
@


1.1
log
@Initial revision
@
text
@d51 12
d64 2
d84 1
a85 10
  my $mod_time = (stat("$basedir/$file"))[9];
  my ($sec, $min, $hour, $mday, $mon, $year) = localtime($mod_time);
  @@months = qw /null Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
  $mon++;  # Adjust month (0-based index)
  $year += 1900; chomp $year; # Adjust year (start from 1900)
  $ampm = 'a.m.';
  $ampm = 'p.m.' if ($hour > 11);
  $hour = '0'.$hour if ($hour < 10);
  $min  = '0'.$min if ($min < 10);
  $updated = "Last Updated: $months[$mon] $mday, $year";
d96 1
a96 1
  $buttons = &get_latest("$basedir/$file");
d100 3
a102 2
  $referer = $ENV{HTTP_REFERER};
  $referer = '/library.cgi' if (!$referer);
d114 1
d137 1
a137 1
    $hash{$mtime} = $file;
d139 2
a140 2
  foreach (sort { $b cmp $a } keys %hash) {
    next if ($hash{$_} =~ /template|\/test\//);
d143 1
a143 1
    $rel = $hash{$_};
d150 1
a150 1
    last if ($count == 4);
@
