<?php

$timestamp=time()+(3600*$time_hour);
$cookietime=$timestamp+(3600*24*365);
$stime=strftime("%Y-%m-%d.%H:%M:%S",$timestamp);
$dtime=strftime("%Y-%m-%d",$timestamp);
$istime=strftime("%Y%m%d%H%M%S",$timestamp);
$imtime=strftime("%Y%m%d%H%M",$timestamp);

$uip=($GLOBALS['HTTP_X_FORWARDED_FOR'])?$GLOBALS['HTTP_X_FORWARDED_FOR']:$GLOBALS['REMOTE_ADDR'];

session_cache_limiter('none');
session_start();
unset($sv_user); $sv_user=$HTTP_SESSION_VARS['sv_user'];

function checkRepeat()
{
 global $timestamp, $HTTP_SESSION_VARS;

 if(($timestamp-$HTTP_SESSION_VARS['sv_checktime'])<30){
  errorview("为防止有人用程序灌水，本BBS限制一个人两次发帖间隔必须大于30秒！");
  exit;
 }
 $HTTP_SESSION_VARS['sv_checktime']=$timestamp;
}

function win($url)
{
 global $sv_user;

 print <<<EOT
<html><head>
<meta http-equiv=Content-Type content=text/html;charset=gb2312>
<meta http-equiv=refresh content=2;url=$url>
</head><body>
<table cellpadding=0 cellspacing=0 border=0 width=95% align=center height=85%>
<tr align=center valign=middle><td>
 <table cellpadding=10 cellspacing=0 border=0 width=80% align=center>
 <tr><td valign=middle align=center>
谢谢{$sv_user}，您的信息已成功发出！<br><br>请等待系统将自动返回... <br><br>
(<a href=$url>如果您不愿意等待，请点击这里返回</a>)
 </td></tr>
 </table>
</td></tr>
</table>
EOT;

 exit;
}

function page_header($title='',$bgpic='')
{
 global $cssfile;

 print <<<EOT
<HTML><HEAD>
<meta http-equiv=Content-Type content=text/html; charset=gb2312>
<TITLE>$title</TITLE>
<link href=./style/$cssfile rel=stylesheet>
<script src=./bin/zbb.js></script></HEAD>
<body background=$bgpic>
EOT;
}

function page_footer()
{
 global $ver;

 print <<<EOT
<BR><BR><CENTER>Powered by zChain Bulletin Board (ZBB) Version $ver<br>
Copyright &copy; 2001-2002,
<a target=_blank href=http://www.zchain.net>zChain.net</a>.
All rights reserved</CENTER>
</BODY></HTML>
EOT;
}

function errorview($msg)
{
 page_header('ZBB 出错提示');

 print <<<EOT
<table border=0 width=95% align=center height=85%>
<tr align=center valign=middle><td>
 <TABLE cellSpacing=1 border=0 width=275 class="forumLine">
 <TR><TD>
  <table cellspacing=0 cellpadding=2 width=100% border=0>
  <tr>
   <td align="left" class="rowCaption">¤ 出错提示 </td>
   <td width=18 class="rowCaption">
    <table cellspacing=0 bordercolordark=#ffffff cellpadding=0 bgcolor=e0e0e0 bordercolorlight=#666666 border=1>
    <tr><td>× </td></tr>
    </table></td>
  </tr>
  </table></TD>
 </TR>
 <TR><TD align=center class="row1">
  <table cellpadding=4 width=100% border=0>
  <tr>
   <td valign=top align=center width=47><font size=7 face=Wingdings color=ff0000>L</font></td>
   <td>$msg</td>
  </tr>
  </table>
  <input onClick=javascript:history.back() type=submit value=' 确 定 '><BR><BR></TD>
 </TR>
 </TABLE>
</td></tr>
</table>
EOT;

 page_footer();
 exit;
}

function okview($msg)
{
print <<<EOT
<html><head>
<META http-equiv=Content-Type content=text/html; charset=gb2312>
</head><body>
<script>alert('$msg');history.back();</script>
<script language=javascript>window.close();</script>
EOT;

  exit;
}

function jumpTo($url,$msg='')
{
 print <<<EOT
<html><head>
<meta http-equiv=Content-Type content=text/html;charset=gb2312>
<meta http-equiv=refresh content=0;url=$url>
</head>
<body>$msg</body></html>
EOT;
}

function menu_bar($a_text,$a_url='',$a_width='95%')
{
 global $imgurl;

 $urlText=($a_url=='')?'&nbsp;':
   "<a href='$a_url' target=_blank><img border=0 src='$imgurl/gohome.gif'></a>";

 print <<<EOT
<table align=center border=0 cellspacing=1 cellpadding=0 width=$a_width class=mainmenu>
<tr><td>
 <table border=0 cellpadding=2 cellspacing=0 width="100%"><tr>
 <td class="rowMenu">$a_text</td>
 <td align=right class="rowMenu">$urlText</td>
 </tr></table>
</td></tr></table>
EOT;
}

function cleanText($a_text)
{
 $a_text=stripslashes($a_text); $a_text=str_replace("\n",'',$a_text);
 return $a_text;
}

function cleanHtml($a_text)
{
 $a_text=stripslashes($a_text); $a_text=str_replace("\n",'<BR>',$a_text);
 return $a_text;
}

function getRootText()
{
 global $ck_root,$ck_bid,$ck_bname;

 $tmp=($ck_root) ?
  "<a href=viewblist.php>$ck_bname</a>" :
  "<a href=viewboard.php?bid=$ck_bid>$ck_bname</a>";
 $tmp='您当前位置：'.$tmp;
 return $tmp;
}
?>