0001#!/usr/bin/perl
0002require './jcode.pl';#REQUIRE JCODE LIBRARY
0003#use kcatch qw(source);#KCATCH
0004
0005
0006#FORESMUNDI GENERATOR SCRIPT DEFINE
0007$ScriptName = 'GENERATOR'; #SCRIPT NAME
0008$Version = 'ICHI'; #VERSION
0009$BuildNumber = '.20010305'; #BUILD NUMBER
0010$ScriptPath = './generator.cgi'; #SCRIPT PATH
0011$GenerateOriginPath = './generator.csv'; #GENERATE ORIGIN
0012$Manufacturer = 'FORESMUNDI'; #MANUFACTURER
0013$ManufacturerURL = 'http://www.archi-map.net/about_us_07.htm';
0014$Author = 'm921320@mediawars.ne.jp, kimura@radika.com';#I AM EXPECTING THAT YOU WILL DEVELOP THIS SCRIPT WITH US.
0015$SearchMethod = 'or'; #DEFAULT SEARCH METHOD
0016$LayoutStyle = 1; #DEFAULT LAYOUT STYLE
0017$DoYouSeeDebug = 0; #0 OR 1(SEE) MESSAGES
0018$DoYouSeeConnection = 1; #0 OR 1(SEE) HYPERLINKS
0019
0020
0021#DECODE REQUEST EXECUTE FIRST
0022 if ($ENV{'REQUEST_METHOD'} eq 'POST') {#ENVIRONMENT
0023 if ($ENV{'CONTENT_LENGTH'} > 51200) { &MakeErrorReport("Your sentence was too long."); }
0024 read(STDIN, $Buffer, $ENV{'CONTENT_LENGTH'});
0025 } else { $Buffer = $ENV{'QUERY_STRING'};
0026 }
0027 if ($Buffer) {#REGULATE
0028 $Buffer =~ s/<[^>]*(>|$)//g;#KILL HTML TAGS
0029 @Pairs = split(/&/, $Buffer);
0030 foreach $Pair (@Pairs) {
0031 ($FieldName,$Value) = split(/=/, $Pair);
0032 $Value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;#DECODE URL ENCODE
0033 &jcode::convert(\$Value, 'sjis');#DECODE JAPANESE CHARACTOR TO SJIS
0034 $FieldName =~ tr/A-Z/a-z/;#LOWER CASE
0035 $Form{$FieldName} = $Value;
0036 }
0037 }
0038
0039
0040#PREFERENCE
0041 if ($Form{'style'}) {$LayoutStyle = $Form{'style'};}
0042
0043
0044#FOR THE PAGE
0045 print "Content-type: text/html\n
0046<html>
0047<head>
0048<META HTTP-EQUIV=\"Content-type\" CONTENT=\"text/html; charset=Shift_JIS\">
0049<META NAME=\"GENERATOR\" content=\"FORESMUNDI GENERATOR $Version$BuildNumber\">\n\n
0050<STYLE type=\"text/css\">
0051<!--
0052a {font-size: 10pt; font-family: Verdana, Arial, Helvetica; text-decoration: underLine}
0053p {font-size: 10pt; font-family: Verdana, Arial, Helvetica}
0054li {font-size: 10pt; font-family: Verdana, Arial, Helvetica}
0055td {font-size: 10pt; font-family: Verdana, Arial, Helvetica}
0056pre {font-size: 10pt; font-family: Verdana, Arial, Helvetica}
0057a:hover {color:#FF0000;}
0058-->
0059</STYLE>\n\n\n";
0060
0061
0062#DEBUG DUMP
0063 if ($Form{'debug'} ne '') {
0064 $DoYouSeeDebug = $Form{'debug'};#SET DEBUG
0065 print "<p><i><font color=\"yellow\"><b><font size=\"5\">DebugMode $ScriptName</font></b><br>$Buffer/$Form{'word'} $GenerateOriginPath $ENV{'HTTP_COOKIE'}</b></font></i></p>\n";#DEBUG MESSAGES
0066 }
0067
0068
0069#LINE QUERY FORM LINE QUERY HOW LINE FOOTER
0070 #LINE QUERY FORM 1
0071 if ($Form{'queryform'}) {$QueryForm = $Form{'queryform'};}
0072 if ($Form{'word'}) {$Word = $Form{'word'};}
0073 $LineQueryForm = "<a name=\"queryform\"></a><form action=\"$ScriptPath\" method=\"GET\">
0074<div align=\"center\">
0075 <table border=\"0\" cellspacing=\"\">
0076 <tr>
0077 <td nowrap align=\"center\" valign=\"middle\"><input type=\"text\" name=\"word\" size=\"8\" value=\"$Word\" style=\"font-family: Verdana, Arial, Helvetica\"></td>
0078 <td nowrap align=\"center\" valign=\"middle\"><input type=\"image\" border=\"0\" src=\"./arrow.gif\" width=\"19\" height=\"16\" alt=\"search\" align=\"middle\"></td>
0079 </tr>
0080 </table>
0081</div>
0082</form>\n\n\n";
0083 #LINE QUERY FORM 2
0084 if($QueryForm eq '2') {$LineQueryForm = "<a name=\"queryform\"></a>
0085<form action=\"$ScriptPath\" method=\"GET\">
0086<div align = \"center\"><table border=\"0\" cellspacing=\"1\">
0087 <tr>
0088 <td nowrap><b>SearchField</b></td>
0089 <td nowrap><b>SearchKeyWords</b></td>
0090 <td nowrap><b>OR</b></td>
0091 <td nowrap><b>AND</b></td>
0092 <td nowrap><b></b></td>
0093 </tr>
0094 <td nowrap><select name=\"field\" style=\"font-family: Verdana, Arial, Helvetica\">
0095 <option value=\"*\">*</option>
0096 <option value=\"documentno\">01.DocumentNo</option>
0097 <option value=\"architecturehead\">02.ArchitectureHead</option>
0098 <option value=\"architecture\">03.Architecture</option>
0099 <option value=\"architecturejp\">04.ArchitectureJp</option>
0100 <option value=\"architecturejpkana\">05.ArchitectureJpKana</option>
0101 <option value=\"url\">06.URL</option>
0102 <option value=\"photograph\">07.Photograph</option>
0103 <option value=\"country\">08.Country</option>
0104 <option value=\"countryjp\">09.CountryJp</option>
0105 <option value=\"location\">10.Location</option>
0106 <option value=\"locationjp\">11.LocationJp</option>
0107 <option value=\"architecthead\">12.ArchitectHead</option>
0108 <option value=\"architect\">13.Architect</option>
0109 <option value=\"architectjp\">14.ArchitectJp</option>
0110 <option value=\"architecturetype\">15.ArchitectureType</option>
0111 <option value=\"architecturetypejp\">16.ArchitectureTypeJp</option>
0112 <option value=\"author\">17.Author</option>
0113 <option value=\"preparationdate\">18.PreparationDate</option>
0114 <option value=\"vague\">19.Vague</option></select></td>
0115 <td nowrap><input type=\"text\" name=\"word\" size=\"30\" value=\"$Word\" style=font-size: 14pt; font-family: Verdana, Arial, Helvetica\"></td>
0116 <td nowrap><input type=\"radio\" value=\"or\" checked name=\"searchmethod\"></td>
0117 <td nowrap><input type=\"radio\" value=\"and\" name=\"searchmethod\"></td>
0118 <td nowrap><input type=\"image\" border=\"0\" src=\"./arrow.gif\" width=\"19\" height=\"16\" alt=\"search\" align=\"middle\"></td>
0119 </tr>
0120</table></div>
0121</form>\n\n\n";}
0122 #LINE FOOTER
0123 $LineFooter = "<p align=\"center\"><a href=\"$ManufacturerURL\" target=\"_top\">$ScriptName</a> <a href=\"$ScriptPath?view=code\" target=\"_top\">CODE</a></p>\n\n\n</body></html>";
0124
0125
0126#PERIOD
0127 if ($Form{'period'}) {
0128 open(IN,"$GenerateOriginPath") || &MakeErrorReport("Open Error : $GenerateOriginPath");#GENERATE ORIGN
0129 @Lines = <IN>;
0130 close(IN);
0131 print "<title>ARCHITECTURALMAP</title>\n";
0132 print "</head>\n\n\n";
0133 print "<body bgcolor=\"#000000\" background=\"\" text=\"#FFFFFF\" link=\"#336699\" vlink=\"#B0C4DE\">\n\n\n";
0134 ($Sec,$Min,$Hour,$Mday,$Mon,$Year,$Wday,$yday,$isdst) = localtime(time - $Form{'period'}*24*60*60); $Mon++; $Year += 1900;#PERIOD SECOND
0135 $Period = sprintf("%04d%02d%02d",$Year,$Mon,$Mday);
0136 ($Sec,$Min,$Hour,$Mday,$Mon,$Year,$Wday,$yday,$isdst) = localtime(time); $Mon++; $Year += 1900;#TODAY SECOND
0137 $Today = sprintf("%04d%02d%02d",$Year,$Mon,$Mday);
0138 $Applicable = 0;#SET ZERO
0139 $LastRecordPreparationDate = 0;#SET FAULT AT FIRST
0140 foreach $LineNo (1 .. $#Lines) {#LOOP LAST RECORD DAY
0141 @Fields{'documentno','architecturehead','architecture','architecturejp','architecturejpkana','url','photograph','country','countryjp','location','locationjp','architecthead','architect','architectjp','architecturetype','architecturetypejp','author','preparationdate','vague'} = split(/,/, $Lines[$LineNo]);#SPLIT LINE
0142 if (!$LastRecordPreparationDate && $Fields{'preparationdate'} <= $Today) {
0143 $LastRecordPreparationDate = $Fields{'preparationdate'};
0144 $LastRecordDocumentNo = $Fields{'documentno'};
0145 last;
0146 }
0147 }
0148 $Year = substr($LastRecordPreparationDate,0,4);#CALENDAR
0149 $Mon = substr($LastRecordPreparationDate,4,2);
0150 $Mday = substr($LastRecordPreparationDate,6,2);
0151 @Month = ('Nothing','January','February','March','April','May','June','July','August','September','October','November','December');
0152 $MyString = 'オススメ';&jcode::convert(\$MyString, 'sjis','euc');
0153 print "<p align=\"center\"><b>NUMERO $LastRecordDocumentNo $Month[$Mon] $Mday $Year</b></p>\n";
0154 print "<p align=\"center\"><b><a href=\"$ScriptPath?vibration=1\" target=\"main\">$MyString</b></a></p>\n<hr noshade size=\"1\">\n\n\n";
0155 $Applicable = 0;#APPLICABLE ZERO
0156 foreach $LineNo (1 .. $#Lines) {#LOOP PREPARATIONDATE
0157 @Fields{'documentno','architecturehead','architecture','architecturejp','architecturejpkana','url','photograph','country','countryjp','location','locationjp','architecthead','architect','architectjp','architecturetype','architecturetypejp','author','preparationdate','vague'} = split(/,/, $Lines[$LineNo]);#SPLIT LINE
0158 #if ($Period <= $Fields{'preparationdate'} && $Fields{'preparationdate'} <= $Today || $Applicable < 4) {
0159 if($Fields{'preparationdate'} <= $Today){
0160 if($Period <= $Fields{'preparationdate'} || $Applicable < 4) {
0161 $Applicable++;
0162 if ($DoYouSeeDebug) {
0163 print "<p><font color=\"yellow\"><i>if ($Period <= $Fields{'preparationdate'} && $Fields{'preparationdate'} <= $Today) {} #$Applicable $_</i></font></p>\n";
0164 }
0165 &MakeLineContent($Lines[$LineNo], $LayoutStyle);
0166 print $LineContent;
0167 }
0168 if ($Period >= $Fields{'preparationdate'} && $Applicable > 4) {last;}#EXIT LOOP FOR THE QUICKNESS
0169 }
0170 }
0171 #print "<p align=\"center\">The reason why the documents of the architectures which you were looking for didn't exist here may be because it passed for more than one month after documents were contributed.</p><p align=\"center\">You'll be able to seek for the documents about the architectures which weren't here in the <b><a href=\"../a_map/map_index_00.htm\" target=\"_top\">index page.</a></b> there're $TotalRecordNumber documents at present.</p><p align=\"center\"><b><a href=\"../a_map/history.htm\" target=\"_top\">History</a></b> of the site.</p><p align=\"center\"><b><a href=\"../a_map/index.htm\" target=\"_top\">Homepage.</a></b></p>\n";
0172 print $LineFooter;
0173 exit;#EXIT PROCESS
0174 }
0175
0176
0177#VIBRATION
0178 if ($Form{'vibration'}) {#DISPLAY AT RANDOM
0179 open(IN,"$GenerateOriginPath") || &MakeErrorReport("Open Error : $GenerateOriginPath");
0180 @Lines = <IN>;
0181 close(IN);
0182 srand;#SET RANDOM SEED
0183 $Vibration = int(rand($#Lines));#VIBRATION LINE
0184 @Fields{'documentno','architecturehead','architecture','architecturejp','architecturejpkana','url','photograph','country','countryjp','location','locationjp','architecthead','architect','architectjp','architecturetype','architecturetypejp','author','preparationdate','vague'} = split(/,/, $Lines[$Vibration]);#SPLIT LINE
0185 #print "<title>$Fields{'architecture'} $Fields{'architecturejp'}</title>\n";
0186 print "<title>$ScriptName</title>\n";
0187 print "</head>\n\n\n";
0188 print "<body bgcolor=\"#000000\" background=\"\" text=\"#FFFFFF\" link=\"#336699\" vlink=\"#B0C4DE\">\n\n\n";
0189 if ($DoYouSeeDebug) {print "<p><font color=\"yellow\"><i>$#Lines $Vibration $Fields{'documentno'}</i></font></p>\n";}
0190 foreach (1 .. $Form{'vibration'}) {
0191 &MakeLineContent($Lines[$Vibration], $LayoutStyle);
0192 print $LineContent;
0193 $Vibration = int(rand($#Lines));#NEXT VIBRATION LINE
0194 }
0195 #print "<p align=\"center\">The Architecture which I recommend only to you secretly.</p>\n\n\n";
0196 print $LineFooter;
0197 exit;#EXIT PROCESS
0198 }
0199
0200
0201#SEARCH WORD
0202 if ($Form{'word'}) {
0203
0204 #Modify bigin 2008/10/25 Yoshihiro Nakazoe
0205 $SearchWordShow_str = $Form{'word'};
0206 &jcode::convert(\$SearchWordShow_str, 'sjis','euc');
0207 #Modify end
0208
0209 open(IN,"$GenerateOriginPath") || &MakeErrorReport("Open Error : $GenerateOriginPath");
0210 @Lines = <IN>;
0211 close(IN);
0212 print "<title>$ScriptName</title>\n";
0213 print "</head>\n\n\n";
0214 if ($LayoutStyle eq 1) {print "<body bgcolor=\"#000000\" background=\"\" text=\"#FFFFFF\" link=\"#336699\" vlink=\"#B0C4DE\">\n\n\n";}
0215 if ($LayoutStyle eq 2) {print "<body bgcolor=\"#FFFFFF\" background=\"\" text=\"#000000\" link=\"#336699\" vlink=\"#B0C4DE\">\n\n\n";}
0216 if ($LayoutStyle eq 3) {print "<body bgcolor=\"#FFFFFF\" background=\"\" text=\"#000000\" link=\"#336699\" vlink=\"#B0C4DE\">\n\n\n";}
0217 $Applicable = 0;#SET APPLICABLE COUNT ZERO
0218 $Word = $Form{'word'};#JAPANESE CODE
0219 &jcode::convert(\$Word, 'euc','sjis'); #01 CONVERT TO EUC 20010304
0220
0221
0222 &jcode::tr(\$Word, '0-9A-Za-z−','0-9A-Za-z-'); #02 AGAINST 2BYTE ALPHABET NUMERICAL
0223 &jcode::tr(\$Word, '+&|?〜・、。 ','+&|?~ '); #03 AGAINST 2BYTE SPECIAL
0224 &jcode::tr(\$Word, 'A-Z','a-z'); #04 LOWER CASE
0225 if (index($Word,'|') >= 0) {$SearchMethod = 'or';} #06 OR
0226 if (index($Word,'&') >= 0) {$SearchMethod = 'and';} #07 AND
0227 if ($Form{'searchmethod'}) {$SearchMethod = $Form{'searchmethod'};}#08 QUERYSTRING
0228
0229 #Modify bigin 2008/10/25 Yoshihiro Nakazoe
0230# $Word =~ s/(\++)|(\&+)|(\|)|(?)/ /g; #09 PLUS AND BAR TO SPACE
0231 #Modify end
0232
0233 $Word =~ s/^\s//g; #10 KILL FIRST PLUS
0234 &jcode::convert(\$Word, 'sjis','euc'); #11 CONVERT TO SJIS
0235 @Pairs = split(/\s+/, $Word); #12 SPLIT SEARCH WORDS
0236 foreach $LineNo (1 .. $#Lines) {
0237 $Flag=0;#SET FLAG ZERO
0238 foreach (@Pairs) {
0239 $_ =~ tr/A-Z/a-z/;#LOWER CASE PAIR
0240 $LinePlus = $Lines[$LineNo];
0241 if ($Form{'field'} && $Form{'field'} ne 'everything' && $Form{'field'} ne '*') {
0242 @Fields{'documentno','architecturehead','architecture','architecturejp','architecturejpkana','url','photograph','country','countryjp','location','locationjp','architecthead','architect','architectjp','architecturetype','architecturetypejp','author','preparationdate','vague'} = split(/,/, $Lines[$LineNo]);#SPLIT LINE
0243 $Form{'field'} =~ tr/A-Z/a-z/;#LOWER CASE
0244 $LinePlus = $Fields{$Form{'field'}};#ONLY FIELD
0245 }
0246 $LinePlus =~ s/\s+//g;#REMOVE SPACE
0247 $LinePlus =~ tr/A-Z/a-z/;#LOWER CASE EVERYTHING
0248 if (index($LinePlus,$_) >= 0) {#HAVE OR HAVE NOT
0249 $Flag=1;#FLAG STANDS UP
0250 if ($SearchMethod eq 'or') {$last;}#OR
0251 } else {
0252 if ($SearchMethod eq 'and') {$Flag=0; last;}#AND
0253 }
0254 }
0255 if ($Flag) {
0256 $Applicable++;
0257
0258 #Modify bigin 2008/10/25 Yoshihiro Nakazoe
0259 if ($DoYouSeeDebug) {print "<p><i><font color=\"yellow\">$Lines[$LineNo]</p><p>$LinePlus @Pairs $SearchMethod #$Applicable</font></i></p>\n";}
0260 #Modify end
0261
0262 &MakeLineContent($Lines[$LineNo], $LayoutStyle);
0263 print $LineContent;
0264 }
0265 }
0266 $SearchMethod =~ tr/a-z/A-Z/;
0267 &jcode::convert(\$Word, 'euc','sjis'); #11 CONVERT TO SJIS
0268
0269 #Modify bigin 2008/10/25 Yoshihiro Nakazoe
0270 $SQL = "SELECT * FROM AMAP WHERE * \~\* \'".$SearchWordShow_str."\' $SearchMethod";
0271 if ($Form{'field'}) {$SQL = "SELECT * FROM AMAP WHERE $Form{'field'} \~\* '".$SearchWordShow_str."' $SearchMethod";}
0272 #modify end
0273
0274 print "<p align=\"center\"><a name=\"applicable\"></a>$Applicable DOCUMENT(S) EXISTED. $SQL</p>\n";
0275
0276 if ($QueryForm || $Form{'word'}) {print $LineQueryForm;}#WHEN WORD
0277 if ($Applicable eq 0) {print "<p align=\"center\">You may be able to seek for the documents about the architectures from these.</p><p align=\"center\">index by <b><a href=\"$ScriptPath\?queryindex=1\" target=\"_top\">ARCHITECTURES</a></b><br>index by <b><a href=\"$ScriptPath\?queryindex=2\" target=\"_top\">ARCHITECT</a></b><br>index by <b><a href=\"$ScriptPath\?queryindex=3\" target=\"_top\">ARCHITECTURE TYPES</a></b></p>\n\n\n";}
0278 print $LineFooter;
0279 #WHEN NO APPLICABLE INVESTIGATE THE CAUSE OF ZERO
0280 if (0) {
0281 $QueryLogPath = './query.csv';#QUERYLOG PATH
0282 $QueryLogMaximum = 44;#QUERYLOG MAXIMUM
0283 $LockPath = './lock';#LOCK
0284 $Retry = 5;#TIMES
0285 while (!symlink(".", $LockPath)) {
0286 if (--$Retry <= 0) {
0287 &MakeErrorReport("Locked : $LockPath");
0288 if (-e $LockPath) {unlink($LockPath);}
0289 exit;EMERGENCY EXIT
0290 }
0291 sleep(1);
0292 }
0293 open(IN,"$QueryLogPath") || &MakeErrorReport("Open Error : $QueryLogPath");#QUERYLOG OPEN
0294 #open(IN,"./query2.csv") || &MakeErrorReport("Open Error : $QueryLogPath");#QUERYLOG OPEN
0295 @Lines = <IN>;
0296 close(IN);
0297 while($QueryLogMaximum <= @Lines) {pop(@Lines);}#POP OVER
0298 $RemoteHost = $ENV{'REMOTE_HOST'};#REMOTE HOST
0299 if (!$RemoteHost || $RemoteHost eq $ENV{'REMOTE_ADDR'}) {
0300 $RemoteHost = gethostbyaddr(pack("C4", split(/\./, $ENV{'REMOTE_ADDR'})), 2);
0301 if ($RemoteHost eq '') {$RemoteHost = $ENV{'REMOTE_ADDR'};}
0302 }
0303 $HttpUserAgent = $ENV{'HTTP_USER_AGENT'};
0304 if (!$HttpUserAgent) {$HttpUserAgent = 'SecretServiceAgent';}
0305 ($Sec,$Min,$Hour,$Mday,$Mon,$Year,$Wday,$yday,$isdst) = localtime(time); $Mon++; $Year += 1900;#TODAY SECOND
0306 $Now = sprintf("%04d%02d%02d %02d:%02d:%02d",$Year,$Mon,$Mday,$Hour,$Min,$Sec);
0307 unshift(@Lines, "$Now,$RemoteHost,$HttpUserAgent,$Reffer,$Form{'word'},$Form{'field'},$SearchMethod,$Applicable\r\n");#ONE RECORD
0308 open(OUT,">$QueryLogPath");
0309 print OUT @Lines;
0310 close(OUT);
0311 #chmod(0666,$QueryLogPlusPath);#CHMOD 666
0312 if (-e $LockPath) {unlink($LockPath);}
0313 }
0314 exit;#EXIT PROCESS
0315 }
0316
0317
0318#QUERY INDEX
0319 if ($Form{'queryindex'}) {
0320 if ($Form{'queryindex'} eq '1') {#QUERY INDEX 1 ARCHITECTURES
0321 $BoltPath = '../map_index_04.htm';#GLUE THIS FILE TO THE GENERATOR
0322 open(INBolt,"$BoltPath") || &MakeErrorReport("Open Error : $BoltPath");
0323 @INBoltLines = <INBolt>;
0324 close(INBolt);
0325 foreach (@INBoltLines) {#LOOP ALPHABETICALLY
0326 $_ =~ s/(<\!doctype.*)|(<html>)|(<\/html>)|(<head>)|(<\/head>)|(<meta.*)|(<\/body>)|(<base target.*)|(<BASE TARGET.*)|(<\!--webbot.*)//g;
0327 $_ =~ s/^\n//;
0328 print $_;
0329 }
0330 open(IN,"$GenerateOriginPath") || &MakeErrorReport("Open Error : $GenerateOriginPath");
0331 @Lines = <IN>;
0332 close(IN);
0333 print "\n\n\n<p align=\"center\"><b>\n";
0334 foreach (A .. Z) {print "<a href=\"#$_\">$_</a>\n";}#LOOP ALPHABETICALLY
0335 print "</b></p>\n\n\n<p>";
0336 foreach (A .. Z) {
0337 print "<p align=\"center\"><a name=\"$_\"></a><a href=\"$ScriptPath?field=architecturehead&word=$_&searchmethod=and\" target=\"main\"><b><font size=\"5\">$_</font></b></a></p>\n<p>\n";
0338 foreach $LineNo (1 .. $#Lines) {#SEEK ALPHABETICALLY
0339 @Fields{'documentno','architecturehead','architecture','architecturejp','architecturejpkana','url','photograph','country','countryjp','location','locationjp','architecthead','architect','architectjp','architecturetype','architecturetypejp','author','preparationdate','vague'} = split(/,/, $Lines[$LineNo]);#SPLIT LINE
0340 if (index($Fields{'architecturehead'},$_) >= 0) {#HAVE OR HAVE NOT AND PUSH LINEPLUS
0341 push(@LinesPlus,$Line);
0342 if ($Fields{'architecture'}) {$Architecture{"$Fields{'architecture'} $Fields{'architecturejp'} "} = '';}#MAKE AN ARCHITECT LIST
0343 }
0344 }
0345 @Architecture = keys %Architecture;
0346 @Architecture = sort @Architecture;#KEYS ARRANGE
0347 print "<blockquote><p>\n";
0348 foreach $Architecture (@Architecture) {print "$Architecture";}#KEYS LOOP
0349 print "</p></blockquote>\n\n\n";#CLOSE BLOCKQUOTE
0350 %Architecture = <>;#CLEAR
0351 @LinesPlus = <>;#CLEAR
0352 }
0353 print "<hr noshade size=\"1\">\n\n\n";
0354 print $LineFooter;
0355 exit;#EXIT PROCESS
0356 }
0357 if ($Form{'queryindex'} eq '2') {#QUERY INDEX ARCHITECT
0358 open(IN,"$GenerateOriginPath") || &MakeErrorReport("Open Error : $GenerateOriginPath");
0359 @Lines = <IN>;
0360 close(IN);
0361 $BoltPath = '../map_index_03.htm';#GLUE THIS FILE TO THE GENERATOR
0362 open(INBolt,"$BoltPath") || &MakeErrorReport("Open Error : $BoltPath");
0363 @INBoltLines = <INBolt>;
0364 close(INBolt);
0365 foreach (@INBoltLines) {#LOOP ALPHABETICALLY
0366 $_ =~ s/(<\!doctype.*)|(<html>)|(<\/html>)|(<head>)|(<\/head>)|(<\/body>)|(<base target.*)|(<BASE TARGET.*)|(<\!--webbot.*)//g;
0367 $_ =~ s/^\n//;
0368 print $_;
0369 }
0370 print "\n\n\n<p align=\"center\"><b>\n";
0371 foreach (A .. Z) {print "<a href=\"#$_\">$_</a>\n";}#ALPHABETICALLY
0372 print "</b></p>\n\n\n<p>";
0373 foreach (A .. Z) {
0374 print "<p align=\"center\"><a name=\"$_\"></a><b><font size=\"5\">$_</font></b><p>\n";
0375 foreach $LineNo (1 .. $#Lines) {#SEEK ALPHABETICALLY
0376 @Fields{'documentno','architecturehead','architecture','architecturejp','architecturejpkana','url','photograph','country','countryjp','location','locationjp','architecthead','architect','architectjp','architecturetype','architecturetypejp','author','preparationdate','vague'} = split(/,/, $Lines[$LineNo]);#SPLIT LINE
0377 if (index($Fields{'architecthead'},$_) >= 0) {#HAVE OR HAVE NOT AND PUSH LINEPLUS
0378 push(@LinesPlus,$Line);
0379 if ($Fields{'architect'}) {$Architect{$Fields{'architect'}} = "$Fields{'architect'} $Fields{'architectjp'}";}#MAKE AN ARCHITECT LIST
0380 }
0381 }
0382 @Architect = keys %Architect;
0383 @Architect = sort @Architect;#KEYS ARRANGE
0384 print "<ul>\n";
0385 foreach $Architect (@Architect) {#KEYS LOOP
0386 $ArchitectPlus = $Architect{"$Architect"};
0387 $ArchitectNoand = $Architect;
0388 $ArchitectNoand =~ s/\&/ /s;
0389 print " <li><b><a href=\"$ScriptPath?field=architect&word=$ArchitectNoand&searchmethod=and\" target=\"main\">$ArchitectPlus</a></b><br>";
0390 foreach $Line (@LinesPlus) {
0391 @Fields{'documentno','architecturehead','architecture','architecturejp','architecturejpkana','url','photograph','country','countryjp','location','locationjp','architecthead','architect','architectjp','architecturetype','architecturetypejp','author','preparationdate','vague'} = split(/,/, $Line);#SPLIT LINE
0392 #@Fields = split(/,/, $Line);#FIELDS
0393 if ($Fields{'architect'} eq $Architect) {
0394 print "$Fields{'architecture'} $Fields{'architecturejp'} ";
0395 }
0396 }
0397 print "</li>\n";#CLOSE LI
0398 }
0399 print "</ul>\n\n\n";
0400 %Architect = <>;#CLEAR
0401 @LinesPlus = <>;#CLEAR
0402 }
0403 print "<hr noshade size=\"1\">\n\n\n";
0404 print $LineFooter;
0405 exit;#EXIT PROCESS
0406 }
0407 if ($Form{'queryindex'} eq '3') {#QUERY INDEX ARCHITECTURE TYPES
0408 open(IN,"$GenerateOriginPath") || &MakeErrorReport("Open Error : $GenerateOriginPath");
0409 @Lines = <IN>;
0410 close(IN);
0411 $BoltPath = '../map_index_05.htm';#GLUE THIS FILE TO THE GENERATOR
0412 open(INBolt,"$BoltPath") || &MakeErrorReport("Open Error : $BoltPath");
0413 @INBoltLines = <INBolt>;
0414 close(INBolt);
0415 foreach (@INBoltLines) {#LOOP ALPHABETICALLY
0416 $_ =~ s/(<\!doctype.*)|(<html>)|(<\/html>)|(<head>)|(<\/head>)|(<\/body>)|(<base target.*)|(<BASE TARGET.*)|(<\!--webbot.*)//g;
0417 $_ =~ s/^\n//;
0418 print $_;
0419 }
0420 print "\n\n\n";
0421 #DEFINE TYPES
0422 $ArchitectureTypes = 'Houses,Apartment/Condominium,Commercial Building,Office,Hotel/Inn,Banquet Room/Wedding Hall,Government Office Building,Educational Facilities,Community Center/Cultural Center,Hall/Music Hall,Museum/Art Museum/Memorial Museum,Library,Gymnasium/Sports Facilities,Medical Facilities/Welfare Facilities,Sanitary Facilities/Bathhouse,Bank/Post Office/Telephone Office,Prison,Training Institution,Research Institution,Factory Building/Warehouse,Port/Airport,Station Building/Parking Structure,Power Station/Water Service,Bridge,Tower/Lighthouse,Church/Religious House,Temple/Mosque,Palace/Guesthouse/Castle/Mausoleum,Shinto Shrine,Buddhist Temple,Tea-Ceremony Room/Tea House,Yard/Garden/Park,Crematorium/Funeral hall/Cemetery,Complex,Urban Planning/Landscape/Ruin,Monument/Artwork,Event/Festival,Industrial Product';
0423 $ArchitectureTypesJp = '住宅,集合住宅,商業施設・店舗,事務所・オフィス,宿泊施設,宴会場・パーティルーム・結婚式場,官公庁舎,学校施設,コミュニティセンター・文化センター,ホール・劇場,美術館・博物館・記念館,図書館,体育館・スポーツ施設,病院・福祉施設,衛生施設・浴場,銀行・郵便局・電話局,監獄・刑務所,研修施設,研究施設,工場・倉庫,港・空港,駅舎・バスターミナル・駐車場,発電所・水道施設,橋梁,塔・灯台,教会・修道院,神殿・モスク,宮殿・迎賓館・城・霊廟,神社,仏教寺院,茶室,庭園・公園,火葬場・斎場・墓地,複合施設,都市計画・風景・まちなみ・廃墟,記念碑・アートワーク,行事・祭事,工業製品';
0424 &jcode::convert(\$ArchitectureTypesJp, 'sjis','euc');
0425 #&jcode'convert(*ArchitectureTypesJp,'sjis','euc');
0426 @ArchitectureTypes = split(/,/, $ArchitectureTypes);
0427 @ArchitectureTypesJp = split(/,/, $ArchitectureTypesJp);
0428 print "\n\n\n<p align=\"center\"><b>\n";
0429 foreach (0 .. $#ArchitectureTypes) {print "<a href=\"#$ArchitectureTypes[$_]\">$ArchitectureTypes[$_]</a>\n";}#TYPES
0430 print "</b></p>\n\n\n<p>";
0431 foreach (0 .. $#ArchitectureTypes) {#LOOP TYPES
0432 print "<p align=\"center\"><b><a name=\"$ArchitectureTypes[$_]\"></a><a href=\"$ScriptPath?field=architecturetype&word=$ArchitectureTypes[$_]&searchmethod=and\" target=\"main\"><font size=\"5\">$ArchitectureTypes[$_]</font><br>$ArchitectureTypesJp[$_]</a></b>\n";
0433 foreach $LineNo (1 .. $#Lines) {#SEEK TYPES
0434 @Fields{'documentno','architecturehead','architecture','architecturejp','architecturejpkana','url','photograph','country','countryjp','location','locationjp','architecthead','architect','architectjp','architecturetype','architecturetypejp','author','preparationdate','vague'} = split(/,/, $Lines[$LineNo]);#SPLIT LINE
0435 if (index($Fields{'architecturetype'},$ArchitectureTypes[$_]) >= 0) {#HAVE OR HAVE NOT AND PUSH LINEPLUS
0436 push(@LinesPlus,$Line);
0437 if ($Fields{'architecturetype'}) {$ArchitectureType{"$Fields{'architecture'} $Fields{'architecturejp'} "} = '';}#MAKE ARCHITECTURETYPE LIST
0438 }
0439 }
0440 @ArchitectureType = keys %ArchitectureType;
0441 @ArchitectureType = sort @ArchitectureType;#KEYS ARRANGE
0442 print "<blockquote><p>\n";
0443 foreach $ArchitectureType (@ArchitectureType) {print "$ArchitectureType \n";}
0444 print "</p></blockquote>\n\n\n";#CLOSE BLOCKQUOTE
0445 %ArchitectureType = <>;#CLEAR
0446 @LinesPlus = <>;#CLEAR
0447 }
0448 print "<hr noshade size=\"1\">\n\n\n";
0449 print $LineFooter;
0450 exit;#EXIT PROCESS
0451 }
0452 if ($Form{'queryindex'} eq '4') {#QUERY INDEX 4 KEYS
0453 open(IN,"$GenerateOriginPath") || &MakeErrorReport("Open Error : $GenerateOriginPath");
0454 @Lines = <IN>;
0455 close(IN);
0456 print "<title>$ScriptName</title>\n";
0457 print "</head>\n\n\n";
0458 print "<body bgcolor=\"#000000\" background=\"\" text=\"#FFFFFF\" link=\"#336699\" vlink=\"#B0C4DE\">\n\n\n";
0459 print "<p><i><font color=\"yellow\"><b><font size=\"5\">DebugMode $ScriptName Values $GenerateOriginPath</font></b></font></i></p>\n";
0460 foreach $LineNo (1 .. $#Lines) {
0461 @Fields{'documentno','architecturehead','architecture','architecturejp','architecturejpkana','url','photograph','country','countryjp','location','locationjp','architecthead','architect','architectjp','architecturetype','architecturetypejp','author','preparationdate','vague'} = split(/,/, $Lines[$LineNo]);#SPLIT LINE
0462 #@Fields = split(/,/, $Line);#FIELDS
0463 $ArchitectPlus{"$Fields{'architect'},$Fields{'architectjp'}"} += 1;
0464 $Country{"$Fields{'country'},$Fields{'countryjp'}"} += 1;
0465 $ArchitectureType{"$Fields{'architecturetype'},$Fields{'architecturetypejp'}"} += 1;
0466 $Author{"$Fields{'author'}"} += 1;
0467 $PreparationDate{"$Fields{'preparationdate'}"} += 1;
0468 $Fields{'vague'} =~ s/\n//;
0469 $Vague{"$Fields{'vague'}"} += 1;
0470 }
0471 #ARCHITECT
0472 print "<p><b><font size=\"5\">Architect</b></font></p>\n";
0473 @ArchitectPlusKey = keys %ArchitectPlus;
0474 @ArchitectPlusKey = sort @ArchitectPlusKey;
0475 print "<pre>\n";
0476 foreach (0 .. $#ArchitectPlusKey) {
0477 $_ = sprintf("%04d",$_);
0478 print "<font color=\"gray\">$_,</font>$ArchitectPlusKey[$_],$ArchitectPlus{$ArchitectPlusKey[$_]}\n";
0479 }
0480 print "</pre>\n";
0481 print "<hr noshade size=\"1\">\n\n\n";
0482 #COUNTRY
0483 print "<p><b><font size=\"5\">Country</b></font></p>\n";
0484 @CountryKey = keys %Country;
0485 @CountryKey = sort @CountryKey;
0486 print "<pre>\n";
0487 foreach (0 .. $#CountryKey) {
0488 $_ = sprintf("%04d",$_);
0489 print "<font color=\"gray\">$_,</font>$CountryKey[$_],$Country{$CountryKey[$_]}\n";
0490 }
0491 print "</pre>\n";
0492 print "<hr noshade size=\"1\">\n\n\n";
0493 #ARCHITECTURE TYPES
0494 print "<p><b><font size=\"5\">ArchitectureType</b></font></p>\n";
0495 @ArchitectureTypeKey = keys %ArchitectureType;
0496 @ArchitectureTypeKey = sort @ArchitectureTypeKey;
0497 print "<pre>\n";
0498 foreach (0 .. $#ArchitectureTypeKey) {
0499 $_ = sprintf("%04d",$_);
0500 print "<font color=\"gray\">$_,</font>$ArchitectureTypeKey[$_],$ArchitectureType{$ArchitectureTypeKey[$_]}\n";
0501 }
0502 print "</pre>\n";
0503 print "<hr noshade size=\"1\">\n\n\n";
0504 #AUTHOR
0505 print "<p><b><font size=\"5\">Author</b></font></p>\n";
0506 @AuthorKey = keys %Author;
0507 @AuthorKey = sort @AuthorKey;
0508 print "<pre>\n";
0509 foreach (0 .. $#AuthorKey) {
0510 $_ = sprintf("%04d",$_);
0511 print "<font color=\"gray\">$_,</font>$AuthorKey[$_],$Author{$AuthorKey[$_]}\n";
0512 }
0513 print "</pre>\n";
0514 print "<hr noshade size=\"1\">\n\n\n";
0515 #PREPARATIONDATE
0516 print "<p><b><font size=\"5\">PreparationDate</b></font></p>\n";
0517 @PreparationDateKey = keys %PreparationDate;
0518 @PreparationDateKey = sort @PreparationDateKey;
0519 @PreparationDateKey = reverse @PreparationDateKey;
0520 print "<pre>\n";
0521 foreach (0 .. $#PreparationDateKey) {
0522 $_ = sprintf("%04d",$_);
0523 print "<font color=\"gray\">$_,</font>$PreparationDateKey[$_],$PreparationDate{$PreparationDateKey[$_]}\n";
0524 }
0525 print "</pre>\n";
0526 print "<hr noshade size=\"1\">\n\n\n";
0527 #VAGUE
0528 print "<p><b><font size=\"5\">Vague</b></font></p>\n";
0529 @VagueKey = keys %Vague;
0530 @VagueKey = sort @VagueKey;
0531 print "<pre>\n";
0532 foreach (0 .. $#VagueKey) {
0533 $_ = sprintf("%04d",$_);
0534 print "<font color=\"gray\">$_,</font>$VagueKey[$_],$Vague{$VagueKey[$_]}\n";
0535 }
0536 print "</pre>\n";
0537 print "<hr noshade size=\"1\">\n\n\n";
0538 print $LineFooter;
0539 exit;#EXIT PROCESS
0540 }
0541 }
0542#VIEW
0543 if ($Form{'view'}) {#VIEW CODE
0544 if ($Form{'view'} eq 'code') {
0545 print "<title>$ScriptName</title>\n";
0546 print "</head>\n\n\n";
0547 print "<body bgcolor=\"#000000\" background=\"\" text=\"#FFFFFF\" link=\"#336699\" vlink=\"#B0C4DE\">\n\n\n";
0548 open(IN,"$ScriptPath") || &MakeErrorReport("Open Error : $ScriptPath");
0549 @Lines = <IN>;
0550 close(IN);
0551 #print "<p><i><font color=\"yellow\"><b><font size=\"5\">DebugMode $ScriptName BLOOD SWET &CODE</font></b></font></i></p>\n";
0552 print "<pre>\n";
0553 local($[) = 1;
0554 foreach (1 .. $#Lines) {
0555 $Lines[$_] =~s/</</g;
0556 $Lines[$_] =~s/>/>/g;
0557 $Lines[$_] =~s/#(.*)/<font color=\"red\"><b>#$1<\/b><\/font>/g;#MARK COMMENT Why couldn't I remove red?
0558 $Lines[$_] =~s/sub (.*)/<font color=\"yellow\"><b>sub $1<\/b><\/font>/g;#MARK SUBROUTINE
0559 $Lines[$_] =~s/\$/<b>\$<\/b>/g;#MARK VARIABLE
0560 $_ = sprintf("%04d",$_);
0561 print "<font color=\"gray\">$_</font>$Lines[$_]";
0562 }
0563 print "</pre>\n";
0564 print "<hr noshade size=\"1\">\n\n\n";
0565 print $LineFooter;
0566 exit;#EXIT PROCESS
0567 }
0568 if ($Form{'view'} eq 'list') {#VIEW LIST
0569 print "<title>$ScriptName</title>\n";
0570 print "</head>\n\n\n";
0571 print "<body bgcolor=\"#000000\" background=\"\" text=\"#FFFFFF\" link=\"#336699\" vlink=\"#B0C4DE\">\n\n\n";
0572 open(IN,"$GenerateOriginPath") || &MakeErrorReport("Open Error : $GenerateOriginPath");
0573 @Lines = <IN>;
0574 close(IN);
0575 foreach $LineNo (1 .. $#Lines) {
0576 &MakeLineContent($Lines[$LineNo], $LayoutStyle);
0577 print $LineContent;
0578 }
0579 print $LineFooter;
0580 exit;#EXIT PROCESS
0581 }
0582 if ($Form{'view'}) {#VIEW MATRIX MAKE A TABLE
0583 if ($Form{'view'} eq 'query' || $Form{'view'} eq 'error') {$GenerateOriginPath = './query.csv';}
0584 print "<title>$ScriptName</title>\n";
0585 print "</head>\n\n\n";
0586 print "<body bgcolor=\"#000000\" background=\"\" text=\"#FFFFFF\" link=\"#336699\" vlink=\"#B0C4DE\">\n\n\n";
0587 open(IN,"$GenerateOriginPath") || &MakeErrorReport("Open Error : $GenerateOriginPath");
0588 @Lines = <IN>;
0589 close(IN);
0590 print "<p><i><font color=\"yellow\"><b><font size=\"5\">DebugMode $ScriptName Matrix $GenerateOriginPath</font></b></font></i></p>\n";
0591 print "<p><table border=\"1\" cellspacing=\"0\"><tr>\n";
0592 foreach (@Lines) {
0593 $_ =~ s/([^=^\"]|^)(http\:\/\/[\w\.\~\-\/\?\&\=\;\#\:\%]+)/$1<a href=\"$2\" target=\"_top\">$2<\/a>/g;#MAKE HYPER LINK
0594 $_ =~s/,/<\/td><td nowrap>/g;
0595 print "<tr><td nowrap>$_</td></tr>\n\n\n";
0596 }
0597 print "</table></p>\n\n\n";
0598 print $LineFooter;
0599 exit;#EXIT PROCESS
0600 }
0601 }
0602
0603
0604#NO QUERY SRING
0605 if (1) {
0606 print "<title>$ScriptName</title>\n";
0607 print "</head>\n\n\n";
0608 print "<body bgcolor=\"#000000\" background=\"\" text=\"#FFFFFF\" link=\"#336699\" vlink=\"#B0C4DE\">\n\n\n";
0609 if ($QueryHow) {print $LineQueryHow;}
0610 print $LineQueryForm;
0611 print "<hr noshade size=\"1\">\n\n\n";
0612 print $LineFooter;
0613 exit;#EXIT PROCESS
0614 }
0615
0616
0617#FUNCTION MAKE AN ERROR REPORT
0618 sub MakeErrorReport {
0619 print "<hr noshade size=\"1\">\n";
0620 print "<p align=\"center\"><b>AN ERROR OCCURTED.</b></p>\n";
0621 print "<p align=\"center\"><font color=\"red\"><b>$_[0]</font></b></p>\n";
0622 }
0623
0624
0625#FUNCTION MAKE A LINE CONTENT
0626 sub MakeLineContent {
0627 if ($LayoutStyle eq 1 || $LayoutStyle eq 2) {#LAYOUT STYLE 1 BLACK / 2 WHITE
0628 @Fields{'documentno','architecturehead','architecture','architecturejp','architecturejpkana','url','photograph','country','countryjp','location','locationjp','architecthead','architect','architectjp','architecturetype','architecturetypejp','author','preparationdate','vague'} = split(/,/, $_[0]);#SPLIT LINE
0629 if ($Fields{'architect'}) {$Fields{'architect'} .= "<br>";}
0630 if ($Fields{'architectjp'}) {$Fields{'architectjp'} .= "<br>";}
0631 if (!$Fields{'url'}) {$Fields{'url'} = './error.html';}
0632 if (!$Fields{'photograph'} || !$DoYouSeeConnection) {@Fields{'photograph'} ='./error.gif';}
0633 $LineContent = "<p align=\"center\"><a name=\"$Fields{'documentno'}\"></a>
0634<a href=\"$Fields{'url'}\" target=\"_top\"><img border=\"4\" src=\"$Fields{'photograph'}\" alt=\"$Fields{'architecture'} $Fields{'architecturejp'}\"></a></p>
0635<p><b>$Fields{'architecture'}</b><br>
0636$Fields{'location'} $Fields{'country'}<br>
0637$Fields{'architect'}
0638<b>$Fields{'architecturejp'}</b><br>
0639$Fields{'countryjp'} $Fields{'locationjp'}<br>
0640$Fields{'architectjp'}
0641$Fields{'author'} $Fields{'documentno'}</p>
0642<hr noshade size=\"1\">\n\n\n";
0643 }
0644 if ($LayoutStyle eq 3) {#LAYOUT STYLE 3 WHITE
0645 &jcode::convert(\$Line, 'euc','sjis');#CONVERT TO EUC
0646 @Fields{'documentno','architecturehead','architecture','architecturejp','architecturejpkana','url','photograph','country','countryjp','location','locationjp','architecthead','architect','architectjp','architecturetype','architecturetypejp','author','preparationdate','vague'} = split(/,/, $_[0]);#SPLIT LINE
0647 if (!$Fields{'url'}) {$Fields{'url'} = "./error.html";}
0648 if (!$Fields{'photograph'} || !$DoYouSeeConnection) {$Fields{'photograph'} ='./error.gif';}
0649 $LineContent = "<p><a name=\"$Fields{'documentno'}\"></a>
0650<table border=\"0\" cellspacing=\"14\">
0651 <tr>
0652 <td valign=\"top\" width=\"140\"><a href=\"$Fields{'url'}\" target=\"_top\"><img border=\"1\" src=\"$Fields{'photograph'}\" alt=\"$Fields{'architecture'}\"></a></td>
0653 <td valign=\"top\">
0654 <p>Architecture Name : <a href=\"$Fields{'url'}\" target=\"_top\"><b>$Fields{'architecture'}</b></a><br>
0655 Architecture Type : $Fields{'architecturetype'}<br>
0656 Architect : $Fields{'architect'}<br>
0657 Location : $Fields{'location'}<br>
0658 Country : $Fields{'country'}<br>
0659 Note : $Fields{'note'}<br>
0660 Author : $Fields{'author'}<br>
0661 Preparation Date : $Fields{'preparationdate'}<br>
0662 Document Number : $Fields{'documentno'}</p>
0663 <p>建築物名称 : <a href=\"$Fields{'url'}\" target=\"_top\"><b>$Fields{'architecturejp'}</b></a><br>
0664 フリガナ : $Fields{'architecturejpkana'}<br>
0665 使用目的及び用途 : $Fields{'architecturetypejp'}<br>
0666 所在地名称 : $Fields{'locationjp'}<br>
0667 設計者名称 : $Fields{'architectjp'}<br>
0668 国名称 : $Fields{'countryjp'}<br>
0669 備考 : $Fields{'note'}<br>
0670 文責 : $Fields{'author'}<br>
0671 寄稿日 : $Fields{'preparationdate'}<br>
0672 文書番号 : $Fields{'documentno'}</p>
0673 </tr>
0674</table>
0675<hr noshade size=\"1\">\n\n\n";
0676 &jcode::convert(\$LineContent, 'sjis','euc');#CONVERT TO SJIS
0677 }
0678 }
GENERATOR CODE