Oh sure, cheers alot, really appriciate it.
html_view_success.
Code:
##########################################################
## Home Page ##
##########################################################
sub html_home {
# --------------------------------------------------------
# The database manager home page.
open(FILE, "< $db_file_name") or &cgierr("can't open $db_file_name: $!");
$count++ while <FILE>;
close FILE;
$date = (stat($db_file_name))[9];
($day, $month, $year) = (localtime($date))[3,4,5,];
$month++; $year = $year + 1900;
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: 主選單</title>
</head>
<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=4 COLOR="#FFFFFF">
<b>$html_title: 主選單</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
主選單
</b></font></center><br>
<font face="verdana,arial,helvetica" size="2" Color=#003399><b>
權限: |;
print " 搜尋 " if ($per_view);
print " 新增 " if ($per_add);
print " 刪除 " if ($per_del);
print " 修改 " if ($per_mod);
print " 管理 " if ($per_admin);
print " None " if (!($per_view | | $per_add | | $per_del | | per_mod));
print qq|</b></font><p>
$main_text
最新資料輸入日期: $day-$month-$year
|; &html_footer;
##########################################################
# Stats mod
##########################################################
$in{$db_key} = "*";
my ($status,@hits)=&query();
for (0 .. $db_total_hits - 1) {
%cattmp = &array_to_hash($_,@hits);
if ($cattmp{'Category'}) { ++$catcount{$cattmp{'Category'}}; }}
foreach my $Category (keys %catcount) {
print "$Category: $catcount{$Category}<br>\n";
}
##########################################################
# End Stats mod
###########################################
print qq|
</td></tr>
</table>
</center>
</body>
</html>
|;
}
sub html_footer {
# --------------------------------------------------------
# Print the menu and the footer and logo. It would be nice if you left
# the logo in.
#
# We only print options that the user have permissions for.
#
my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';
print qq! <br><P align=center><$font>!;
print qq!<HR WIDTH="100%"><center>[ <A HREF="$db_script_link_url">主頁</A> !;
print qq!| <A HREF="$db_script_link_url&add_form=1">新增</A> ! if ($per_add);
print qq!| <A HREF="$db_script_link_url&view_search=1">搜尋</A> ! if ($per_view);
print qq!| <A HREF="$db_script_link_url&delete_search=1">刪除</A> ! if ($per_del);
print qq!| <A HREF="$db_script_link_url&modify_search=1">修改</A> ! if ($per_mod);
print qq!| <A HREF="$db_script_link_url&view_records=1&$db_key=*">觀看所有紀錄</A> ! if ($per_view);
print qq!| <A HREF="$db_script_link_url&admin_display=1">管理</A> ! if ($per_admin);
print qq!| <A HREF="$db_script_link_url&logoff=1">退出</A> ]</center><HR WIDTH="100%">!;
print qq!</font></p>!;
# Print the Footer.
print qq!
<table border=0 width=100%>
<tr><td align=left><$font>請到 <A HREF="http://home.hkstar.com/~kwl1/recipe/forum/">中文食譜搜尋器臨時討論區</A> 發表意見。<p>
[ <a href="$db_script_link_url&%A5%5B%A4J%A4%E9%B4%C1=%3E$Last&view_records=1">最近三天加入的紀錄</a> ] 現時資料庫已載有 $count 個食譜資料!<br>
</font></td></table><p>
!;
}
sub html_search_options {
# --------------------------------------------------------
# Search options to be displayed at the bottom of search forms.
#
print qq~
<P><strong>搜尋選項:</strong><br>
<INPUT TYPE="CHECKBOX" NAME="ma"> 任何字相同
<INPUT TYPE="CHECKBOX" NAME="cs"> 大小寫相同
<INPUT TYPE="CHECKBOX" NAME="ww"> 全字相同
<INPUT TYPE="CHECKBOX" NAME="re"> 規則詞句<BR>
<INPUT TYPE="TEXT" NAME="keyword" SIZE=15 MAXLENGTH=255> 關鍵字搜尋 <FONT SIZE=-1> (自動配對所有欄目)</FONT><BR>
<INPUT TYPE="TEXT" NAME="mh" VALUE="$db_max_hits" SIZE=3 MAXLENGTH=3> 最多顯示合選結果<BR>
排序選項:
<SELECT NAME="sb">
<OPTION>---
~; for (my $i =0; $i <= $#db_cols; $i++) { print qq~<OPTION VALUE="$i">$db_cols[$i]</OPTION>\n~ if ($db_form_len{$db_cols[$i]} >= 0); } print qq~
</SELECT>
排序方式:
<SELECT NAME="so">
<OPTION VALUE="ascend">遞增
<OPTION VALUE="descend">遞減
</SELECT><p>
<strong>
搜尋小貼士:</strong><p>
- 在欄內用 '*' 號來配對所有紀綠<BR>
- 在開首加 '>' 或 '<' 號 即可作範圍搜尋<BR>
<p><b> 列印格式:</b>
<SELECT NAME="format">
<OPTION>---
<OPTION VALUE="long">詳細列表
<OPTION VALUE="short">簡單列表
</SELECT><br>
~;
}
##########################################################
## Adding ##
##########################################################
sub html_add_form {
# --------------------------------------------------------
# The add form page where the user fills out all the details
# on the new record he would like to add. You should use
# &html_record_form to print out the form as it makes
# updating much easier. Feel free to edit &get_defaults
# to change the default values.
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: 新增資料</title>
</head>
<body bgcolor="#DDDDDD">
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=4 COLOR="#FFFFFF">
<b>$html_title: 新增資料</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
加入新資料
</b></font></center><br>
<$font>
|; &html_record_form (&get_defaults); print qq|
</font></p>
<p><center> <INPUT TYPE="SUBMIT" NAME="add_record" VALUE="新增紀錄"> </center></p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</form>
</body>
</html>
|;
}
sub html_add_success {
# --------------------------------------------------------
# The page that is returned upon a successful addition to
# the database. You should use &get_record and &html_record
# to verify that the record was inserted properly and to make
# updating easier.
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: 新增紀錄完成</title>
</head>
<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=4 COLOR="#FFFFFF">
<b>$html_title: 新增紀錄完成</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
新增紀錄完成
</b></font></center><br>
<$font>
<P>新增以下紀錄:</FONT>
|; &html_record(&get_record($in{$db_key})); print qq|
</p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</body>
</html>
|;
}
sub html_add_failure {
# --------------------------------------------------------
# The page that is returned if the addition failed. An error message
# is passed in explaining what happened in $message and the form is
# reprinted out saving the input (by passing in %in to html_record_form).
my ($message) = $_[0];
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: 系統錯誤:不能加入資料</title>
</head>
<body bgcolor="#DDDDDD">
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=4 COLOR="#FFFFFF">
<b>$html_title: 系統錯誤:不能加入資料</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
錯誤: <font color=red> 不能加入紀錄</font>
</b></font></center><br>
<$font>
以下欄目出現問題: <FONT COLOR="red"><B>$message</B></FONT>
<P>請修正錯誤後再新增紀錄。</p></font>
|; &html_record_form (%in); print qq|
</font></p>
<p><center> <INPUT TYPE="SUBMIT" NAME="add_record" VALUE="新增紀錄"> </center></p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</form>
</body>
</html>
|;
}
##########################################################
## Viewing ##
##########################################################
sub html_record_short {
my (%rec) = @_;
my $font_color = 'Font face="arial" size=-1 Color=#003399';
my $font = 'Font face="arial" size=-1 ';
print qq|
<a href="$db_script_link_url&ID=$rec{'ID'}&format=long&view_records=1&ww=on">$rec{'菜名'}</a>
</TR>
</TABLE>
|;
}
sub html_view_search {
# --------------------------------------------------------
# This page is displayed when a user requests to search the
# database for viewing.
# Note: all searches must use GET method.
#
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: 搜尋紀錄庫</title>
</head>
<body bgcolor="#DDDDDD">
<form action="$db_script_url" method="GET">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=4 COLOR="#FFFFFF">
<b>$html_title: 搜尋紀錄庫</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
搜尋紀錄庫
</b></font></center><br>
<$font>
|; &html_record_form(); print qq|
|; &html_search_options; print qq|
</font></p>
<p><center> <INPUT TYPE="SUBMIT" NAME="view_records" VALUE="搜尋紀錄"> <INPUT TYPE="RESET" VALUE="重設表格"></center></p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</form>
</body>
</html>
|;
}
sub html_view_success {
# --------------------------------------------------------
# This page displays the results of a successful search.
# You can use the following variables when displaying your
# results:
#
# $numhits - the number of hits in this batch of results.
# $maxhits - the max number of hits displayed.
# $db_total_hits - the total number of hits.
# $db_next_hits - html for displaying the next set of results.
#
my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: 搜尋結果</title>
</head>
|;
if ($in{'format'} eq "long") {
print qq|
<body bgcolor="#DDDDDD">
<blockquote>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td colspan=2 bgcolor="navy"><FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: 搜尋結果</b>
</font></td></tr>
</table>
<p><$font>
閣下是次搜尋合選紀錄為 <b>$db_total_hits</b> 項。</font>
|;
if ($db_next_hits) {
print "<br><$font>Number of test entries: $catcount{'one'}</font>";
print "<br><$font>頁數: $db_next_hits</font>";
}
# Go through each hit and convert the array to hash and send to
# html_record for printing.
for (0 .. $numhits - 1) {
print "<P><br><br>";
&html_record (&array_to_hash($_, @hits));
}
if ($db_next_hits) {
print "<br><$font>頁數: $db_next_hits</font>";
}
print qq|
<p>
<table border=0 bgcolor="#DDDDDD" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td>|; &html_footer; print qq|</td></tr>
</table>
</blockquote>
</body>
</html>
|;
}
else {
print qq|
<body bgcolor="#DDDDDD">
<blockquote>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td colspan=2 bgcolor="navy"><FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: 搜尋結果</b>
</font></td></tr>
</table>
<p><$font>
閣下是次搜尋合選紀錄為 <b>$db_total_hits</b> 項。</font>p
|;
if ($db_next_hits) {
print "<br><$font>頁數: $db_next_hits</font>";
}
print " <TABLE border=1 cellpadding=1> ";
# Go through each hit and convert the array to hash and send to
# html_record for printing.
for (0 .. $numhits - 1) {
print "<P>";
&html_record_short (&array_to_hash($_, @hits));
}
if ($db_next_hits) {
print "<br><p><$font>頁數: $db_next_hits</font></table>";
}
print qq|
<p>
<table border=0 bgcolor="#DDDDDD" cellpadding=5 cellspacing=3 width=500 valign=top>
<tr><td>|; &html_footer; print qq|</td></tr>
</table>
</blockquote>
</body>
</html>
|;
}
}