#!/usr/bin/perl
#
#
$htdocs="/usr/local/www/vhosts/nauka-i-zizn.ru/htdocs/";
unshift(@INC,"/usr/local/www/vhosts/nauka-i-zizn.ru/support");
require "cgi-lib.pl";
open(WEB,">/usr/local/www.vhosts/nauka-i-zizn.ru/"."0_AL.log");
print WEB "==20.02========\n";
$HEADER="header";
$NARGV = $#ARGV;
# print WEB "$NARGV\n";
$RR=$ARGV[0];
print WEB "$NARGV $RR $HEADER\n";
$shtml = "htm"; $list="dir";
if ( -e "$htdocs/$RR/LIST.shtml") {
$shtml ="shtml"; $list="LIST";
};
if ( ($NARGV == 1) && ($ARGV[1] == 9999) ){
$NARGV=0; # $HEADER="_self" ; #$HEADER="_top" ;
print WEB "$NARGV $RR $ARGV[1] $HEADER\n";
};
if($NARGV > 1) {
$YYNN=$ARGV[1];
$YYNN =~ /(\d)(\d)(\d\d)/;
$YY=$1.$2; $Y=$2; $YY00=$YY."00"; $YNN=$2.$3; $NN=$3;
$RRYNNPPP=$ARGV[2];
$RRYNNPPP =~ /(\d\d)(\d)(\d\d)/; $rr=$1; $ynn=$2.$3;
$JG="00";
if ($rr > $JG ) {
@RN =("01","16","24","40","50","57");
print WEB "==20.02======$rr $JG==\n";
foreach $i (0 .. ($#RN - 1) ) {
$JG=$RN[$i];
print WEB " $i $rr $JG $RN[$i]\n";
last if( ($rr >= $RN[$i]) && ($rr < $RN[$i+1]) );
};
print WEB "==20.02======$rr $JG==\n";
}; #$rr > "00"
$HTM = ($NARGV == 3)?$ARGV[3]:htm;
$WIDTH=($HTM eq 'htm'|| $HTM eq 'html'|| $HTM eq 'shtml')?'34%,66%':'14%,40%,46%';
$DIR ="D$RR.$shtml";
$DIR="D$YYNN.shtml" if($HTM eq 'HTM'|| $HTM eq 'htm');
#19/02 $RETURN="/cgi/nauka.pl?00+$YY00+00$Y"."00000+shtml";
#20/02 $RETURN="/cgi/nauka.pl?00+9999+00$Y"."00000+shtml";
$RETURN="/cgi/nauka.pl?00+9999+007"."000".$JG."+shtml";
# $RETURN="/0-DIR/RUBRIKI.HTM";
# $RETURN="/0-DIR/dir$YYNN.shtml" if($HTM eq 'HTM'|| $HTM eq 'htm');
$RETURN=
"/cgi/nauka.pl?00+$YY00+00$YNN"."000+shtml" if($HTM eq 'HTM'|| $HTM eq 'htm');
$RETURN="/rubriki.htm";
#19/02 $RETURN=
#"/00/$YY00/00$YNN"."000.shtml" if($HTM eq 'HTM'|| $HTM eq 'htm');
if ($RR eq "00") { $RETURN="/index.htm";};
};
print WEB "=== $NARGV $RR $YYNN $RRYNNPPP $DIR $RETURN ===\n";
#====================
if ($NARGV == 0) {
$JG="00";
if ($RR > $JG ) {
@RN =("01","16","24","40","50","57");
print WEB "==20.02======$RR $JG==\n";
foreach $i (0 .. ($#RN - 1) ) {
$JG=$RN[$i];
print WEB " $i $RR $JG $RN[$i]\n";
last if( ($RR >= $RN[$i]) && ($RR < $RN[$i+1]) );
};
print WEB "==20.02======$RR $JG==\n";
$RETURN="/cgi/nauka.pl?00+9999+007000".$JG."+shtml";
$RETURN="/rubriki.htm";
}; #$RR > "00"
# $RETURN="RUBRIKI.HTM";
if ($RR eq "00") { $RETURN="index.htm";};
# system("cp $htdocs/$RR/dir.$shtml $htdocs/$RR/DIR.shtml");
$DIR ="D$RR.shtml";
$YyNn=""; $RRYNNPPP="dir"; $FRAME=$RR."000000";
print WEB "$list.$shtml\n";
open(LIST,$htdocs."$RR/$list.$shtml");
$NL=0; $TITLE='';
while() { chop; ++$NL;
# 04 - Рассказы о минералах
if( ($NL==1) && ( $_ =~ /^(.+)<\/font>/ ) ) {
print WEB "$NL $1\n";
$TITLE=$1;
};
if(/^$htdocs"."$RR/$DIR");
print DIR <<"DIR_HTM";
$TITLE
DIR_HTM
close(DIR);
};# if($HTM ne 'shtml') || $if($TITLE) ...
#
close(WEB);
#
$HEADER = "contents"; #"_parent"; # "_self"; "_top";
$RR_DIR="/$RR/$DIR";
if($HTM eq 'shtml') {
$WIDTH='30%,70%';
$RR_DIR="/index-$ynn.shtml";
# system("cp $htdocs/index.shtml $htdocs/INDEX.shtml");
};
$FR_D="";
$FR_P='';
if($HTM eq 'HTML'|| $HTM eq 'HTM') {
#$FR_P=
# "";
};
$htm=($HTM eq 'shtml')?'shtml':'htm';
$FR_C=
"";
#
$FRAMES="$RR/$RRYNNPPP.htm";
open(FRAMES,">$htdocs"."$FRAMES");
#Content-type: text/html
#
print FRAMES <<"end_frame";
Science and Life
end_frame
close(FRAMES);
print "Location: /$FRAMES\n\n";
#$page_c = "/$RR/$YYNN/$RRYNNPPP.$htm";
#print "Location: $page_c\n\n";
exit;