#!/usr/bin/perl
#Kyoma TAKAHASHI www@kyoma.org 1999.10.23
#                              1999.12.24
#SUGIYAMA Ko-ichiro sugiyama@gfd-dennou.org 2000-07-22
#                              
#Manabu YAMADA 		       2005.12.04	
#		gate で得られたメンバー一覧から, 各アカウント名を
#		分離する部分のバグ修正
#
#	epnetfan-html-list.pl > output_html_file
#
#Yumura Tsubasa                2005.12.29
#       epnetfan@ep.sci.～ の @ を全角＠に書き直し
#

$grpn = 'epnetfan';

$servername = 'www.ep.sci.hokudai.ac.jp';
$htmldir = 'public_html';
$indexfile = 'index.html';
$operator = 'epnetfan＠ep.sci.hokudai.ac.jp';
$gateus = '/usr/local/bin/gate-user-show';
$scripturl = 'http://www.ep.sci.hokudai.ac.jp/~epnetfan/member/epnetfan-html-list.pl';



print '<DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Traditional//EN" "http://www.w3.org/TR/REC-html140/loose.dtd">',"\n";
print '<HTML lang="ja">',"\n" ;
print '<HEAD>',"\n" ;
print '<TITLE>EPnetFaN Member</TITLE>',"\n";
print '</HEAD>',"\n";
print '<BODY text="#000000" link="#0000CC" alink="#0000CC" vlink="#0000CC" BGCOLOR="#FFFFFF" background="/~epnetfan/images/bg-s.png">',"\n"; 
print '<table border=0 cellpadding=0 cellspacing=0>',"\n";
print '<tr>',"\n";
print '<td width=80>',"\n";
print '<!--幅あわせのための透過画像-->',"\n";
print '<img src="/~epnetfan/images/spacer.gif" width=80 height=1 vspace=0 hspace=0>',"\n"; 
print '</td>',"\n";
print '<td valign=top width=120 align=right>',"\n";
print '<!--幅あわせのための透過画像-->',"\n";
print '<img src="/~epnetfan/images/spacer.gif" width=120 height=1 vspace=0 hspace=0>',"\n";
print '<!--リンクを張る場所．ここから-->',"\n";
print '<p><a href="/~epnetfan/shoukai/"><big><b>[Policy]</b></big></a>',"\n";
print '<p><a href="/~epnetfan/project/"><big><b>[Project]</b></big></a>',"\n";
print '<p><A HREF="/~epnetfan/zagaku/"><b><big>[座学編]</big></b></A>',"\n";
print '<p><a href="/~epnetfan/tebiki/"><big><b>[手引き集]</b></big></a>',"\n";
print '<p><a href="/~epnetfan/photo/"><big><b>[写真集]</b></big></a>',"\n";
print '<p><a href="/~epnetfan/link/"><big><b>[リンク集]</b></big></a>',"\n";
print '<p><a href="/~epnetfan/member/"><big><b>[メンバー]</b></big></a>',"\n";
print '<p><a href="/~epnetfan/keiei/"><big><b>[運営資料]</b></big></a>',"\n";
print '<p><a href="/~epnetfan/"><big><b>[HOME]</b></big></a>',"\n";
print '<!--リンクの張り場所．ここまで-->',"\n";
print '</td>',"\n";
print '<td width=50>',"\n";
print '<!--幅あわせのための透過画像-->',"\n";
print '<img src="/~epnetfan/images/spacer.gif" width=50 height=1 vspace=0 hspace=0>',"\n";
print '</td>',"\n";
print '<td>' ,"\n";
print '<!--ここから右側の領域-->',"\n";
print '<center>',"\n";
print '<p><font color="#9999FF">',"\n";
print '<b><big>E</big>arth and <big>P</big>lanetaly science <big>net</big>work <big>FaN</big>club</b>',"\n";
print '</font> </p>',"\n";

print '<H1>Member list of group ',$grpn,'</H1>',"\n", '</center>', "\n";

&dateget;

print 'Processed on <STRONG>' . $date . '</STRONG>',"\n";
print ' by using <A HREF="',$scripturl,'">a Perl script</A>',"\n";
print '<HR>',"\n";

open(GATEG,"$gateus".' '."$grpn"." |");
while (<GATEG>) {
	if (/member/) { ($member) = /member: \s*(.*)\s*/; }
}
close (GATEG);

while ($member) {
        my($user);
	if($member =~ s/^\s*([A-Za-z0-9]+)\s*(.*)$/$2/){
          $user = $1;
        }
	open(GATE,"$gateus".' '."$user"." |");
	while(<GATE>) {
	if (/^status/) { ($statusq) = /^status: (.*)/; }
	if (/^name/) { ($nameq) = /^name: (.*)/; }
	if (/^kname/) { ($knameq) = /^kname: (.*)/; }
#	if (/^email/) { ($emailq) = /^email: (.*)/; }
	}
	close (GATE);

	$emailq = $user.'@ep.sci.hokudai.ac.jp';

	$webq = '<LI><A HREF="/~'.$user.'/">'.$knameq.' '.$nameq.'</A><BR>'."\n";
	$mailq = '<A HREF="mailto:'.$emailq.'">'.$emailq.'</A>'."\n";
#	$htmlq = $webq.$mailq;
	$htmlq = $webq;

		if ( $statusq eq 'insei' ) { $html2grad .= $htmlq; }
		else { if ( $statusq eq 'gakubu' ) { $html2ugrad .= $htmlq; }
		else { if ( $statusq eq 'kyoukan' ) { $html2edu .= $htmlq; }
                else { if ( $statusq eq 'staff' ) { $html2tecsec .= $htmlq; }
		else { if ( $statusq eq 'visitor' ) { $html2vis .= $htmlq; }
		else { if ( $statusq eq 'kenkyuusei' ) { $html2posd .= $htmlq; }
		else { if ( $statusq eq 'others' ) { $html2othauth .= $htmlq; }
		else { $html2oth .= $htmlq; }}}}}}}

}

$hnum = 2; $type = 'undergraduate student'; $html = $html2ugrad; &write;
$hnum = 2; $type = 'graduate student'; $html = $html2grad; &write;
$hnum = 2; $type = 'postdoctoral student / research student / occasional student'; $html = $html2posd; &write;
$hnum = 2; $type = 'education staff'; $html = $html2edu; &write;
$hnum = 2; $type = 'technician / secretary'; $html = $html2tecsec; &write;
$hnum = 2; $type = 'visitor'; $html = $html2vis; &write;
$hnum = 2; $type = 'others'; $html = $html2othauth; &write;
$hnum = 2; $type = 'undefined'; $html = $html2oth; &write;

print '<HR>',"\n";
print '<ADDRESS>',$operator,'</ADDRESS>',"\n";


print '<!--下に付く青い線-->',"\n";
print '<center>',"\n";
print '<p><img src="/~epnetfan/images/blue.gif" width="90%" height=2 vspace=0 hspace=0><br>',"\n";
print '<img src="/~epnetfan/images/blue.gif" width="90%" height=1 vspace=1 hspace=0><br>',"\n";
print '<small>Copyright &copy; 2000 EPnetFan. All rights reserved.<br>',"\n";

print '<!--更新日-->',"\n";
print 'This page updated on July 21, 2000</small>',"\n";
print '</center>',"\n";

print '</td></tr></table>',"\n";

print '</BODY></HTML>',"\n";




sub write {
if ( $html ne '' ) {
print '<H',$hnum,'>',$type,'</H',$hnum,'>',"\n";
print '<UL>',"\n";
print $html;
print '</UL>',"\n";
}}


sub dateget {
open(DATE,"date ".'"+%a %b/%d/%Y %H:%M %Z"'."$dateopt"." |");
	$date = $_ while(<DATE>);
	chop($date = $date);
close(DATE);
}





