⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gbook.cgi

📁 信息管理系统
💻 CGI
字号:
#!/perl/bin/perl
require "./setup.pl";
&GetCookies;
$userid=$Cookies{'id'};
if ($userid) {$userflag=1;}
else {$userflag=0;}
&getform;
$action = $in{'action'};
$key = $in{'key'};
$name = $in{'name'};
$email = $in{'email'};
$comment = $in{'comment'};
$page = $in{'page'};
$id=$in{'id'};

for($i=0;$i<$pageview;$i++)
{
   $reply[$i]=$in{$i};
}

if($action eq "add")
{
  unless ($userflag) {&message("Please login");exit;}
   &add;
   exit;
}

if($action eq "view")
{
   &view;
   exit;
}

if($action eq "reply")
{
   &reply;
   exit;
}

if($action eq "delet")
{
   &delet;
   exit;
}

if($action eq "admin")
{
   &admin;
   exit;
}

&view;

sub add
{
   if(($name eq "") || ($comment eq "")||($email eq ""))
   {
      &message("name,email and leave word can't empty。");
      exit;
   }

if (($name=~/\`/g)||($comment=~/\`/g)||($email=~/\`/g)) {&message("Sorry,there are wrong word-symbol in our method of inputting . revise it please,thank you!");exit;}

($sec,$min,$hour,$day,$mon,$year,$week)=localtime(time); 
$mon=$mon+1;
if($mon <10){$mon="0".$mon;}
if($day<10){$day="0".$day;}
if($hour<10){$hour="0".$hour;}
if($min<10){$min="0".$min;}
if($sec <10){$sec="0".$sec;}
$year=$year+1900;
$month=$mon;
$dayofmonth=$day;
$time=$hour.":".$min.":".$sec;
   $date=join("-",$year,$month,$dayofmonth);
   $date=$date." ".$time;

   $comment=~s/  / /g;
   $comment=~s/\n/<br>/g; 

   $templine=join("\|",$name,$email,$comment,$date);

   open (FILE,">>$cgipath/comments.dat");
   print FILE "$templine\n";
   close (FILE);

   &view;
   exit;
}

sub view
{

if (-e "comments.dat") 
{
   open (FILE,"$cgipath/comments.dat");
   @lines=<FILE>;
   close (FILE);
   $counter=@lines;
   @lines=reverse(@lines);

   if( $pageview*($page-1)>=$counter)
   {
      if(@lines==0)
      {
		open (FILE,">$cgipath/comments.dat");
  		print FILE "浪子 |wb410\@163.net|感谢您的使用!<br>Thank you for choosing <b>LZ-Book </b>!|2003-10-10 00:47:47\n";
   		close (FILE);
   		&view;
   		exit;
      }
      &message("指定页不存在。");
      exit;
   }

   $page=1 if ($page eq "");

   $left=$counter%$pageview;
   $pages=($counter-$left)/$pageview;
   ($pages++) if ($left!=0);

   if($page == $pages)
   {
      $begin=$pageview*($page-1);
      $end=$begin+$left-1;
      $end=$begin+$pageview-1 if ($left==0);
   }
   else
   {
      $begin=$pageview*($page-1);
      $end=$begin+$pageview-1;
   }
}
else
{
   open (FILE,">$cgipath/comments.dat");
   print FILE "浪子 |wb410\@163.net|感谢您的使用!<br>Thank you for choosing <b>LZ-Book </b>!|2003-10-10 00:47:47\n";
   close (FILE);
   &view;
   exit;
}

print "Content-type: text/html\n\n";
print '<html>
<head>';
print "<title>$title</title>";
print '<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
.char {  font-family: "宋体", "楷体_GB2312", "仿宋_GB2312"; font-size: 9pt; color: #000000}
td {  font-family: "宋体", "楷体_GB2312", "仿宋_GB2312"; font-size: 9pt; color: #000000}
A:link {COLOR: blue; TEXT-DECORATION: none}
A:visited {COLOR:blue;TEXT-DECORATION: none}
A:active {COLOR:red;TEXT-DECORATION: none}
A:hover {COLOR: black; TEXT-DECORATION: underline}
</style>
</head>';

print "<body leftmargin=\"0\" topmargin=\"0\" background=\"$imagepath/gbbg.gif\">";
print '<table width="780" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="191" valign="top"> 
      <table width="85%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
          <td> 
            <p>&nbsp;</p>';
print qq~
<p align=center><a href=reg_html.cgi target=_blank><font color=red size=3>register</font></a><br><br><br><a href=login.cgi><font color=blue size=3>leave word</font></a><br><br><br></p>
~;
print "                <br><br><a href=\"$WebDir?action=admin\"><img src=\"$imagepath/admin.gif\" alt=\"manage\" border=\"0\"></a></font>";
print qq~
            <p>&nbsp;</p>
            <p align="right"><br><br><font color="#CCCCCC" face="Arial"><b>DV message board</b><br>
           
              </font></p>
          </td>
        </tr>
      </table>
    <td width="589" valign="top" align="center">
~; 
print "      <p><font color=\"#D28606\">$topinfo</font></p>" if ($page==1);
print '      <table width="93%" border="0" cellspacing="0" cellpadding="8">';
print "<form name=\"reply\" action=\"$WebDir\">" if ($key eq $password);
for ($count=$begin;$count<=$end;$count++)
{
   ($name,$email,$comment,$date,$reply,$date2)=split(/\|/,$lines[$count]);
   print '

        <tr>
          <td> 
            <table width="100%" border="0" cellspacing="0" cellpadding="3">
              <tr> 
                <td width="21%"> 
                  <div align="right"><b><font color="#3576B7">';
   print "<a href=\"$WebDir?action=delet&id=$count&page=$page&key=$password\"><img src=\"$imagepath/delet.gif\" width=\"15\" height=\"16\" alt=\"del\" align=\"absmiddle\" border=\"0\"></a> " if ($key eq $password);
   print "                    <img src=\"$imagepath/name.gif\" width=\"16\" height=\"16\" align=\"absmiddle\"> ";
   print '                    NAME:</font></b></div>
                </td>
                <td width="79%"><font color="#3366CC">';
   print " $name";
   print '</font></td>
              </tr>
              <tr> 
                <td width="18%" height="13"> 
                  <div align="right"><b><font color="#3576B7">';
   print "<img src=\"$imagepath/email.gif\" width=\"16\" height=\"16\" align=\"absmiddle\"> ";
   print '                    E-MAIL:</font></b></div>
                </td>
                <td width="82%" height="13"><font face="Arial, Helvetica, sans-serif" color="#3366CC">';
   print "<a href=mailto:$email>$email</a>";
   print '</font></td>
              </tr>
              <tr> 
                <td width="18%" valign="top"> 
                  <div align="right"><b><font color="#3576B7">';
   print "<img src=\"$imagepath/comment.gif\" width=\"16\" height=\"16\" align=\"absmiddle\"> ";
   print '                    LEAVEWORD:</font></b></div>
                </td>
                <td width="79%"> 
                  <p><font color="#3366CC">';
   print "$comment";
   print '                    </font><font color="#999999">';
   print "<br>$date";
   print '</font><font color="#3366CC"> 
                    </font></p>
                </td>
              </tr>';
if(($key eq $password)||($reply ne ""))
{
   print '              <tr> 
                <td width="18%" valign="top"> 
                  <div align="right"><font color="#D28606"><b>';
   print "<img src=\"$imagepath/reply.gif\" width=\"13\" height=\"15\" align=\"absmiddle\"> ";
   print '                    REPLY:</b></font></div>
                </td>
                <td width="82%" valign="top">';
   if(($key eq $password)&&($reply eq""))
   {
      print "                    <textarea name=\"$count\" cols=\"40\"></textarea>";
   }
   else
   {
      print "                  <font color=\"#CC9900\"> $reply</font><font color=\"#999999\"><br>$date2</font>";
   }
   print '                </td>
              </tr>';
}
print '</table>
          </td>
        </tr>
        <tr bgcolor="#E1EAF7"> 
          <td height="1"></td>
        </tr>';
}
print '<tr><td><p><input type="hidden" name="action" value="reply"><input type="submit" name="Submit" value="Do you identify the last reply?   "></p></td></tr>' if ($key eq $password);
print "<input type=\"hidden\" name=\"page\" value=\"$page\"></form>" if ($key eq $password);
print '<tr><td><p align="right">';
print "NO.$page ";
for($count=1;$count<=$pages;$count++)
{
   print " <a href=\"$WebDir?action=view&page=$count\">$count</a>" if ($key ne $password);
   print " <a href=\"$WebDir?action=view&page=$count&key=$key\">$count</a>" if ($key eq $password);
}
print '</p><td></tr>';
print '
      </table>
      <p>&nbsp; </p>
      </td>
  </tr>
</table>
</body>
</html>';
}

sub reply
{
   $ltime=localtime(time);
   ($day,$month,$dayofmonth,$time,$year)=split(/\s+/,$ltime);
   ($month="01") if ($month=="Jan");
   ($month="02") if ($month=="Feb");
   ($month="03") if ($month=="Mar");
   ($month="04") if ($month=="Apr");
   ($month="05") if ($month=="May");
   ($month="06") if ($month=="Jun");
   ($month="07") if ($month=="Jul");
   ($month="08") if ($month=="Aug");
   ($month="09") if ($month=="Sep");
   ($month="10") if ($month=="Oct");
   ($month="11") if ($month=="Nov");
   ($month="12") if ($month=="Dec");
   ($dayofmonth="0".$dayofmonth) if ($dayofmonth<10);
   $date=join("-",$year,$month,$dayofmonth);
   $date=$date." ".$time;

   open (FILE,"$cgipath/comments.dat");
   @lines=<FILE>;
   close (FILE);

   @lines=reverse(@lines);

   for($count=0;$count<$pageview;$count++)
   {
      if ($reply[$count] ne "")
      {
         $n=$count+($pageview*($page-1));
         $lines[$n]=~s/\n//g;
         $reply[$count]=~s/\n/<br>/g;
         $reply[$count]=~s/  / /g;
         $lines[$n]=$lines[$n]."|".$reply[$count]."|".$date;
      }
   }

   @lines=reverse(@lines);

   open (FILE,">$cgipath/comments.dat");
   foreach $temp (@lines)
   {
      $temp=~s/\n//g;
      print FILE "$temp\n";
   }
   close (FILE);

   $key=$password;
   &view;
   exit;
}


sub delet
{
   if($key ne $password)
   {
      &message("password error!");
      exit;
   }

   open (FILE,"$cgipath/comments.dat");
   @lines=<FILE>;
   close (FILE);

   @lines=reverse(@lines);
   
   $lines[$id]="deleted";
   
   @lines=reverse(@lines);

   open (FILE,">$cgipath/comments.dat");
   foreach $temp (@lines)
   {
      $temp=~s/\n//g;
      next if ($temp eq "deleted");
      print FILE "$temp\n";
   }
   close (FILE);

   $key=$password;
   &view;
   exit;   
}

sub admin
{
   print "Content-type: text/html\n\n";
   print '<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
.char {  font-family: "宋体", "楷体_GB2312", "仿宋_GB2312"; font-size: 9pt; color: #000000}
td {  font-family: "宋体", "楷体_GB2312", "仿宋_GB2312"; font-size: 9pt; color: #000000}
</style>
</head>

<body bgcolor="#FFFFFF">
<div align="center">
  <p>&nbsp;</p>';

   print "        <p class=\"char\"><form name=\"admin\" action=\"$WebDir\">MANAGERPASSWORD:";
   print '
<input type="password" name="key" size="25" style="font-family: 宋体; font-size: 9pt; background-color: rgb(224,237,254); color: rgb(5,64,129); border: 1px solid rgb(0,0,128)">
<input type="submit" name="Submit" value=" ENTER " style="font-family: 宋体; font-size: 9pt; background-color: rgb(224,237,254); color: rgb(5,64,129); border: 1px solid rgb(0,0,128)">
</form></p>
<p>&nbsp;</p>
</div>
<p align="right">
<span class="char">
<font color="#CCCCCC">
DV MESSAGE BOARD 
</font>
</span>
</p>
</body>
</html>';  
}

sub message
{
   print "Content-type: text/html\n\n";
   print '<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
.char {  font-family: "宋体", "楷体_GB2312", "仿宋_GB2312"; font-size: 9pt; color: #000000}
td {  font-family: "宋体", "楷体_GB2312", "仿宋_GB2312"; font-size: 9pt; color: #000000}
</style>
</head>

<body bgcolor="#FFFFFF">
<div align="center">
  <p>&nbsp;</p>';

   print "        <p>@_</p>";
   print '        </td>

  <p>&nbsp;</p>
</div>
<p align="right">
<span class="char">
<font color="#CCCCCC">
DV MESSAGE BOARD </font>
</span>
</p>
</body>
</html>';
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -