#!/usr/bin/perl
require "util41-47.cgi";
use CGI;
$obj = new CGI;
$keysearch = $obj->param( keysearch);
$type = $obj->param( type);

if ( $keysearch eq "" || $type eq "") {
  &makeFormInput;
  exit;
}

$typename = ( $type eq "name") ? "ชื่อ" :  ( $type eq "lname") ? "นามสกุล" : "วัด";

open( PALI, "$file") || &weberror( "Can not open $file for read [$!]\n");
flock( PALI, 2);
@allline = <PALI>;
flock( PALI, 8);
close( PALI);

print "Content-type: text/html\n\n";   
print qq(

<HTML>
<HEAD><TITLE>ผู้สอบผ่านประโยคบาลี  ๒๕๔๙</TITLE>
<meta http-equiv="Content-Language" content="th">
<meta http-equiv="content-Type" content="text/html; charset=window-874">
<meta http-equiv="content-Type" content="text/html; charset=tis-620"> 
<style TYPE="text/css">
        <!--
        A:link {text-decoration:underline;color:"#008080"}
        A:visited {color:#003399}
        A:hover {text-decoration:none;color:"red";}
       TD {font-family:MS Sans Serif,CordiaUPC,AngsanaUPC;}
        -->
 </style>
</HEAD>

		<body background ="/images/bg2.gif " text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

		<div align="center"><center>
<table WIDTH="100%" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td BGCOLOR="#553399" width="150"><img src="/images/a2.gif" align="right"> <b><font
    size="1"><a STYLE="color:#FFFFFF;text-decoration:none;"HREF="http://www.watpaknam.org/index.shtml">&nbsp;หน้าแรก</a></font></b></td>
    <td BGCOLOR="#553399" align="left"><b><font Size="1" COLOR="#FCB118">
    | <a STYLE="color:#FFFFFF;text-decoration:none;" HREF="../education/edu2.htm">ประวัติการศึกษาของสงฆ์</a>
    | <a STYLE="color:#FFFFFF;text-decoration:none;"HREF="http://www.paknam.org/htdocs/pali_hist.htm">ประวัติการศึกษาบาลี</a>
    | <a  STYLE="color:#FFFFFF;text-decoration:none;"HREF="http://www.watpaknam.org/history01.htm">แม่กองบาลีฯ</a>
    | <a  STYLE="color:#FFFFFF;text-decoration:none;"HREF="http://www.watpaknam.org/data_wat/paknam_info.htm">ประสัมพันธ์วัดปากน้ำ</a>
    | <a  STYLE="color:#FFFFFF;text-decoration:none;"HREF="http://www.watpaknam.org/cgi/webboard.pl">กระดานถาม-ตอบ</a>
    | <a  STYLE="color:#FFFFFF;text-decoration:none;"HREF="http://www.watpaknam.org/cgi/dcguest97/dcguest97.cgi">สมุดเยี่ยม</a> 
    </td>
  </tr>
</table>
</center>
</div>

 
<BODY background="/images/bg2.gif">
<p align="center">
<img src="/images/tra_pali.gif" width="130" height="130"></p>
<FONT FACE="MS Sans Serif" size="2">
<center><H3>ประกาศผลสอบบาลีสนามหลวงประจำปี ๔๑-๔๗</h3></center>
<center><H3>รายชื่อผู้สอบได้ประโยคบาลีสนามหลวง  ประโยค ๑-๒ ถึง ป.ธ. ๙ </h3>
<H3>ผลการค้นหา "$keysearch" มีรายละเอียดดังนี้</H3>
</center>
<HR>
<CENTER>
<TABLE  CELLSPACING="1">

		<TR ALIGN="CENTER" BGCOLOR="#D5DDCC">

	     <TD width="5%" ALIGN="RIGHT"><FONT FACE="MS Sans Serif" size="2"><B>ที่</B></TD>
	     <TD width="10%" ><FONT FACE="MS Sans Serif" size="2"><B>ชื่อ</B></TD>
	     <TD width="10%" ><FONT FACE="MS Sans Serif" size="2"><B>ฉายา</B></TD>
		 <TD width="10%" ><FONT FACE="MS Sans Serif" size="2"><B>นามสกุล</B></TD>
		 <TD width="5%"><FONT FACE="MS Sans Serif" size="2"><B>อายุ</B></TD>
		 <TD width="5%"><FONT FACE="MS Sans Serif" size="2"><B>พรรษา</B></TD>
 		 <TD width="10%"><FONT FACE="MS Sans Serif" size="2"><B>วัด</B></TD>
 		 <TD width="10%"><FONT FACE="MS Sans Serif" size="2"><B>สำนักเรียน</B></TD>
 		 <TD width="5%"><FONT FACE="MS Sans Serif" size="2"><B>เลขที่</B></TD>
		<TD width="5%"><FONT FACE="MS Sans Serif" size="2"><B>ชั้น</B></TD>
		 <TD width="5%"><FONT FACE="MS Sans Serif" size="2"><B>พ.ศ.</B></TD>



      </TR>
</CENTER>
);

$count = 0;
foreach $line ( @allline) {

   $match = 0;
   ( $name, $mname, $lname, $age, $odage, $rsname, $scname, $id,$class,$year,$code) = split( "\t", $line);
   $match = 1 if ( $type eq "name" && $name =~ /$keysearch/);
   $match = 1 if ( $type eq "lname" && $lname =~ /$keysearch/);
   $match = 1 if ( $type eq "rsname" && $rsname =~ /$keysearch/);
   $match = 1 if ( $type eq "class" && $class =~ /$keysearch/);
   $match = 1 if ( $type eq "scname" && $scname =~ /$keysearch/);

   if ( $match) {
   
      $count ++;
  
      print qq(
         <TR BGCOLOR="#EEEEEE" ALIGN="CENTER">
		  
            <TD width="5%"  ALIGN="RIGHT"><FONT FACE="MS Sans Serif" size="2"><B> $count. </B></TD>
			
			<TD ALIGN="LEFT" width="10%"><FONT FACE="MS Sans Serif" size="2"> $name </TD>
		    <TD ALIGN="LEFT"><FONT FACE="MS Sans Serif" width="10%" size="2"> $mname </TD>
		    <TD ALIGN="LEFT"><FONT FACE="MS Sans Serif" width="10%" size="2"> $lname </TD>
		    <TD ALIGN="CENTER" width="5%"><FONT FACE="MS Sans Serif" size="2"> $age </TD>
		    <TD ALIGN="CENTER" width="5%"><FONT FACE="MS Sans Serif" size="2"> $odage </TD>
			<TD ALIGN="CENTER" width="10%"><FONT FACE="MS Sans Serif" size="2"> $rsname </TD>
			<TD ALIGN="CENTER" width="10%"><FONT FACE="MS Sans Serif" size="2"> $scname </TD>
		    <TD ALIGN="CENTER" width="5%"><FONT FACE="MS Sans Serif" size="2"> $id</TD>
			<TD ALIGN="CENTER" width="5%"><FONT FACE="MS Sans Serif" size="2"> $class </TD>
		    <TD ALIGN="CENTER" width="5%"><FONT FACE="MS Sans Serif" size="2"> $year </TD>





			</TR>
      );
	  
   }
   	  		 
}

print qq(

</TABLE>
<Center>
<hr width="100%" color="#008080">
<p>
<font face="Ms Sans Serif" size="2" color="#c40063">

</font></Center>
</BODY>
<P>
<HR>
</HTML>

);

sub makeFormInput {   
   print "Content-type: text/html\n\n";   
   print qq(

<HTML>
<HEAD><TITLE>ค้นหารายชื่อผู้สอบประโยคบาลีสนามหลวงได้ปี ๔๑-๔๗</TITLE>
	<meta http-equiv="Content-Language" content="th">
<meta http-equiv="content-Type" content="text/html; charset=window-874">
<meta http-equiv="content-Type" content="text/html; charset=tis-620"> 
<style TYPE="text/css">
        <!--
        A:link {text-decoration:underline;color:"#008080"}
        A:visited {color:#003399}
        A:hover {text-decoration:none;color:"red";}
       TD {font-family:MS Sans Serif,CordiaUPC,AngsanaUPC;}
        -->
 </style>
</HEAD>

<body background ="/images/bg2.gif " text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<!--
<div align="center"><center>
<table WIDTH="100%" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <td BGCOLOR="#553399" width="150"><img src="http://www.watpaknam.org/images/a2.gif" align="right"> <b>
    <font  size="1"><a STYLE="color:#FFFFFF;text-decoration:none;"HREF="http://www.watpaknam.org/index.shtml">&nbsp;หน้าแรก</a>
    </font></b> </td>
    <td BGCOLOR="#553399" align="left"><b><font Size="1" COLOR="#FCB118">
    | <a STYLE="color:#FFFFFF;text-decoration:none;" HREF="/cgi/search_9.cgi">ประโยค ๙</a>
    | <a STYLE="color:#FFFFFF;text-decoration:none;" HREF="/cgi/search_8.cgi">ประโยค ๘</a>
    | <a STYLE="color:#FFFFFF;text-decoration:none;"HREF="/cgi/search_7.cgi">ประโยค ๗</a>
    | <a  STYLE="color:#FFFFFF;text-decoration:none;"HREF="/cgi/search_6.cgi">ประโยค ๖</a>
    | <a  STYLE="color:#FFFFFF;text-decoration:none;"HREF="/cgi/search_5.cgi">ประโยค ๕</a>
    | <a  STYLE="color:#FFFFFF;text-decoration:none;"HREF="/cgi/search_4.cgi">ประโยค ๔</a>
    | <a  STYLE="color:#FFFFFF;text-decoration:none;"HREF="/cgi/search_3.cgi">ประโยค ๓</a> 
    | <a  STYLE="color:#FFFFFF;text-decoration:none;"HREF="/cgi/search_12.cgi">ประโยค ๑-๒</a> 
    | <a  STYLE="color:#FFFFFF;text-decoration:none;"HREF="/cgi/search_pg.cgi">เก็บวิชา ประโยค ๑-๒</a> 

    </td>
  </tr>
</table>
</center></div>
   -->
<Center>
<p>
<center><img src="/images/tra_pali.gif" width="130" height="130" alt="tra_pali.gif"></center>

<Center>
<FONT FACE="MS Sans Serif" color="#008000" size="2">
<H3>ค้นหารายชื่อผู้สอบประโยคบาลีสนามหลวงได้ปี ๔๑-๔๗</H3>
<FORM METHOD="POST" ACTION="/cgi-bin/search41-47.cgi">
คำที่ต้องการค้นหา  :  <INPUT TYPE="TEXT" NAME="keysearch" SIZE="16">
<INPUT TYPE="SUBMIT" VALUE="Search">
<BR><font face="Ms Sans Serif" size="2" color="#FF0000">ค้นจาก: </font>
<INPUT TYPE="RADIO" NAME="type" VALUE="name"> ชื่อ
<INPUT TYPE="RADIO" NAME="type" VALUE="lname"> นามสกุล
<INPUT TYPE="RADIO" NAME="type" VALUE="class"> ป.ธ.
<INPUT TYPE="RADIO" NAME="type" VALUE="rsname" checked> วัด
<INPUT TYPE="RADIO" NAME="type" VALUE="scname"> สำนักเรียน/คณะจังหวัด
<BR>
</FORM>
<p>
<CENTER>

<font face="Ms Sans Serif" size="2" color="#008000">
<b>การค้นหา วัด</b>&nbsp;ชื่อวัดให้พิมพ์เฉพาะชื่อเท่านั้นไม่มีคำว่าวัด  เช่น  วัดปากน้ำ  ต้องพิมพ์ &nbsp; <b>ปากน้ำ</b><br>
<b>การค้นหา ประโยค</b>&nbsp;   เช่น  ประโยค ป.ธ. 3-9 ต้องพิมพ์ &nbsp; <b>ป.ธ.9 ( หรือ 3,4,5,6,7,8 ),ประโยค 1-2 ให้พิมพ์ ป.1-2</b><br>
<b>สำนักเรียน/คณะจังหวัด</b> ให้พิมพ์ชื่อวัด เช่น <b>วัดชนะสงคราม</b>  &nbsp; ส่วนจังหวัดพิมพ์เฉพาะชื่อจังหวัด เช่น &nbsp;<b>นนทบุรี</b></font>

</CENTER>
</p>
</Center>
</BODY>
<HR width="75%">
<center>
<font face="Ms Sans Serif" size="2" color="#000080">
Copyright &#169 2000 สำนักงานเลขานุการแม่กองบาลีสนามหลวง<br>
วัดปากน้ำ  ภาษีเจริญ  กรุงเทพฯ 10160<br>
โทรศัพท์ 0-2869-0485,0-2896-0487; โทรสาร 0-2869-0484 : E-mail : infopali\@yahoo.com
</font>
</center>
</HTML>

);

}
