SoFunction
Updated on 2025-04-09

Forum based on mysql (6)

#
<?php
require("");
$sql="select * from boardinfo where name='$board'";
$sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result);
?>
<html>
<head>
<title>Send new posts</title>
<link rel="stylesheet" type="text/css" href="css/">
</head>
<body bgcolor="#666666">
<?php include "";?><br>
<hr noshade width="80%" size="1">
<table width="80%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolorlight="#686898" bordercolordark="#FFFFFF">
  <tr align="center" valign="top" bgcolor="#666699">  
<td><font size="3" color="#336699"><b><font color="#CCFFFF">Send a post</font></b></font><br>
    </td>
  </tr>
  <tr bgcolor="#ffffef">  
<td>(You <b>must register</b> before you can publish a new topic, otherwise you can only view the topic.<br>
If you are not registered yet, please <a href="" target="_blank"><font color="#FF0000">Click here</font></a> to go to the registration page)</td>
  </tr>
  <tr bgcolor="#e8eee0">  
    <td><br>
Your post will be posted in the <b><?php echo $sql_row[chinesename];?></b> section </td>
  </tr>
</table>
<br>
<form method="post" action="">
  <table width="98%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolorlight="#336699" bordercolordark="#FFFFFF" bgcolor="#666699">
    <tr>  
<td width="89" bgcolor="#acc0fa" align="right">Username:</td>
      <td width="224">  
        <input type="text" name="name" style="font-size: 9pt; background-color: #FFFFFF; color: #3366FF; border: 1 solid #000000" value="<?php echo $jl_forum[name];?>" size="17" maxlength="16">
        <font color="#FF0000">* </font> </td>
<td width="63" bgcolor="#acc0fa" align="right">Password:</td>
      <td width="160">  
        <input type="password" name="password" size="10" maxlength="16" style="font-size: 9pt; background-color: #FFFFFF; color: #FF0000; border: 1 solid #000000">
        <font color="#FF0000">*</font> <font color="#FF0000"> </font> </td>
    </tr>
    <tr>  
<td colspan="4"><font color="#FFFFF">Template:</font>
        <input type="text" name="title" size="50" maxlength="50" style="font-size: 9pt; background-color: #FFFFFF; color: ##3366FF; border: 1 solid #000000">
        <font color="#FF0000">* </font></td>
    </tr>
    <tr>  
<td colspan="4"> <font color="#FFFFFF">Content:</font><br>
           
        <textarea name="cont" cols="70" rows="12" wrap="VIRTUAL"></textarea>
        <br>
<input type="button" name="Submit2" value="Cancel" onclick="()">
<input type="submit" name="add" value="submit">
        <input type="checkbox" name="qm" value="qm" checked>
<font color="#FFFFF">Use signature</font>
        <input type="hidden" name="board" value="<?php echo $board;?>">
      </td>
    </tr>
  </table>
  </form>
<?php include "";?><br>
</body>
</html>
#
<?php
    require("");
    $sql="select * from boardinfo";
    $sql_result=mysql_query($sql);
?>
<html>
<head>
<title>main</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="css/">
</head>

<body bgcolor="#FFFFFF" background="image/">
<table width="90%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolorlight="#FFCC99" bordercolordark="#FFCC99">
  <tr bgcolor="#CCFF99">  
    <td>
<div align="center"><b>Forum post query</b></div>
    </td>
  </tr>
  <tr align="center">  
    <td>
      <form method="post" action="query_list.php">
exist
        <select name="board">
<option selected>Please select the layout</option>
<?php
while($sql_row=mysql_fetch_array($sql_result)){
?>  
          <option value="<?php echo $sql_row[name];?>"><?php echo $sql_row[chinesename];?></option>
<?php
}
?>
        </select>
Inquiry<br>
        <input type="text" name="query_str" size="40" maxlength="40">
        <br>
<input type="submit" name="title" value="Query by topic">
<input type="submit" name="cont" value="Query by content">
<input type="submit" name="writer" value="Query by author">
      </form>
    </td>
  </tr>
  <tr bgcolor="#CCFF99">  
    <td>
<div align="center"><b>Forum Information</b></div>
    </td>
  </tr>
  <tr>
    <td>
<?php include "";?>
    </td>
  </tr>
</table>
</body>
</html>
# query_list.php
<?php
require("");
if (!empty($query_str)) {

if(!is_board_exits($board)){
    $board="computer";
}
if ($title){
    $submit="title";
}
elseif ($cont) {
    $submit="cont";
}
elseif ($writer) {
    $submit="writer";
}
else {
    $submit="title";
}
$sql="select * from $board where ($submit like '%$query_str%')";
$temp=mysql_query($sql);
$sum=mysql_num_rows($temp);
if ($sum!=0) {
$sql="select * from boardinfo where name='$board'";
$sql_result=mysql_query($sql);
$sql_row=mysql_fetch_array($sql_result);
$chinesename=$sql_row[chinesename];
setcookie ("jl_forum[chinesename]",$chinesename);
$sql="select name from user where slaveboard='$board'";
$sql_result=mysql_query($sql);
?>
<html>
<head>
<title>List</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="css/">
<script language="javascript">
function openwin(board,id){                ("good_read.php?board="+board+"&","height=460,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
function post(board){                ("?board="+board,"","height=500,width=600,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
</script>
</head>

<body bgcolor="#FFFFFF" background="image/">
<?php include "";?> <br>
<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#FFFFFF">
  <tr>
<td height="20" width="22%" bgcolor="#E8E8E8">List: <?php
echo $chinesename;
?></td>
<td height="20" width="29%" bgcolor="#E8E8E8">Moderator: <?php
while ($sql_row=mysql_fetch_array($sql_result))
{
echo "$sql_row[name]"."&nbsp;";
}
# Select a message record;

$totalpage=ceil($sum/$pagesize);
# Pagination
if($page<1 or empty($page)){
    $page=1;
}
elseif ($page>$totalpage){
         $page=$totalpage;
}
elseif ($totalpage==0) {
    $page=0;
}
$offset=($page-1)*$pagesize;
$sql="select * from $board where ($submit like '%$query_str%') order by id desc limit $offset,$pagesize";
$sql_result=mysql_query($sql);
?> </td>
<?php echo $sum; ?> record</td>
<td height="20" colspan="2" width="32%"><a href='javascript:post("<?php echo $board;?>")'><img src="image/" width="92" height="21" border="0" alt="Send a new post"></a></td>
  </tr>
</table>
<br>
<table width="100%" border="1" cellspacing="0" cellpadding="1" bordercolorlight="#CCCCCC" bordercolordark="#eeeeee">
  <tr bgcolor="#995100" align="center">
<td width="6%"><font color="#FFFFFF">Response</font></td>
<td width="67%" bgcolor="#995100"><font color="#FFFFF">Main topic</font></td>
<td width="20%"><font color="#FFFFF">Time</font></td>
<td width="7%"><font color="#FFFFF">Popularity</font></td>
  </tr>
  <tr bgcolor="#FFCC99">
    <td colspan="5" height="2">&nbsp;</td>
  </tr>
  <?php
while ($sql_row=mysql_fetch_array($sql_result))
{
echo"<tr>";
echo"<td width="6%" bgcolor="#E8E8E8" align="center">";
echo "[*]";
echo"</td>";
echo"<td bgcolor="#E8FDEE" width="56%"><font face="Song style"><a href='javascript:openwin("$board",$sql_row[id])' title="Author:$sql_row[writer] Size:$sql_row[size]bytes">$sql_row[title]</a></font></td>";
  echo"<td width="18%" bgcolor="#FFF5DD" align="center">$sql_row[writetime]</td>";
  echo"<td width="6%" bgcolor="#E8FDEE" align="center">$sql_row[hits]</td>";
  echo"</tr>";
}
?>
  <tr bgcolor="#FFCC99">
    <td colspan="5" align="center" height="2">&nbsp;</td>
  </tr>
</table>
<div align="right">
<form method="post" action="<?php echo $php_self;?>">
    <input type="hidden" name="<?php echo $submit;?>" value="y">
    <input type="hidden" name="query_str" value="<?php echo $query_str;?>">
Total<b><?php echo $totalpage;?></b> pages <b><?php echo $page;?></b> pages·<?php
if ($page!=1){
     $back=$page-1;
echo"<a href="$php_self?board=$board&page=1&$submit=y&query_str=$query_str">Home</a> <a href="$php_self?board=$board&page=$back&$submit=y&query_str=$query_str">Previous page</a>";
}
if ($page==1){
echo "Homepage Previous Page";
}
if($page!=$totalpage){
    $next=$page+1;
echo" <a href="$php_self?board=$board&page=$next&$submit=y&query_str=$query_str">Next page</a> <a href="$php_self?board=$board&page=$totalpage&$submit=y&query_str=$query_str">Last page</a>";
}
if($page==$totalpage){
echo"Next page Last page";
}
?>·Go to
<input type="submit" name="goto" value="Go to">
    <input type="text" name="page" size="2">
Page
  </form>
</div>
<?php include "";?>
</body>
</html>
<?php
}
else
    {
    show_error(10);
}
}
else {
    show_error(9);
}
#
<?php
require ("");
if ($re){
     $sql="select slaveid from $board where id=$id";
     $sql_result=mysql_query($sql);
     $sql_row=mysql_fetch_array($sql_result);
     if($sql_row[slaveid]!=0){
         show_error(1);
         $founderr=1;
     }
     if (!check_user_password($name,$password)){
          show_error(4);
          $founderr=1;
     }
     if (empty($title)){
         show_error(2);
         $founderr=1;
     }
     if ($qm){
          $qm=expl_qm($name);
     }
     if(!$founderr){
         re_doc($board,$id);
         setcookie ("jl_forum[name]",$name);
         $sql="select * from $board where id=$id";
         $sql_result=mysql_query($sql);
         $sql_row=mysql_fetch_array($sql_result);
         $title=$sql_row[title];
         $writer=$sql_row[writer];
         $cont=$sql_row[cont];
         $writetime=$sql_row[writetime];
         $hits=$sql_row[$hits];
         $fromip=$sql_row[fromip];
         $sql="select * from $board where slaveid=$id";
         $sql_result=mysql_query($sql);
        # $sql_row=mysql_fetch_array($sql_result);
     }

}
elseif ($add){
     if (!is_board_exits($board)){
          show_error(7);
          $founderr=1;
     }
     if (empty($title)){
         show_error(2);
         $founderr=1;
     }
     if (!check_user_password($name,$password)){
          show_error(4);
          $founderr=1;
     }
     if ($qm){
          $qm=expl_qm($name);
     }
     if (!$founderr){
           add_doc($board);
           $add=1;
           setcookie ("jl_forum[name]",$name);
     }
}
else {
     if (!is_board_exits){
          show_error(7);
     }
     add_one_hit($board,$id);
     $sql="select * from $board where id=$id";
     $sql_result=mysql_query($sql);
     $sql_row=mysql_fetch_array($sql_result);
     $title=$sql_row[title];
     $writer=$sql_row[writer];
     $cont=$sql_row[cont];
     $writetime=$sql_row[writetime];
     $hits=$sql_row[$hits];
     $fromip=$sql_row[fromip];
     $sql="select * from $board where slaveid=$id";
     $sql_result=mysql_query($sql);
  #   $sql_row=mysql_fetch_array($sql_result);
}
?>
<html>
<head>
<title><?php echo $title;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="css/">
<script language="javascript">
function sendmsg(name){                ("?name="+name,"","height=200,width=500,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
}
</script>

</head>

<body bgcolor="#666699">
<?php include "";?><br>
<hr noshade width="98%" size="1">
<table width="98%" border="1" cellspacing="0" cellpadding="2" align="center" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
  <tr bgcolor="#666666">
<td><font color="#FFcc00"><b>Title: <?php echo $title;?></b></font></td>
  </tr>
  <tr>
<a href="javascript:sendmsg('<?php echo "$writer";?>')"><img src="image/" width="18" height="17" alt="Leave a message to the author" border="0"></a> <a href="?name=<?php echo $writer;?>"><img src="image/" width="16" height="15" alt="View user profile" border="0"></a></td>
  </tr>
  <tr bgcolor="#ffffef">  
    <td><?php echo $cont;?></td>
  </tr>
  <tr bgcolor="#e8eee0">
<td>※ Source: <?php echo $jl_forum[chinesename];?> [◆FROM: <?php echo $fromip;?>]</td>
  </tr>
</table>
<br>
<?php
if ($add!=1){
while($sql_row=mysql_fetch_array($sql_result)) {
?>
<table width="98%" border="1" cellspacing="0" cellpadding="2" align="center" bordercolorlight="#CCCCCC" bordercolordark="#FFFFFF">
  <tr bgcolor="#015C71">
<td><font color="#ffffffff">Title: <?php echo $sql_row[title];?></font></td>
  </tr>
  <tr bgcolor="#eeeeee">
<?php echo "$sql_row[writer]";?>(<?php echo $sql_row[writetime];?>) <a href="javascript:sendmsg('<?php echo "$sql_row[writer]";?>')"><img src="image/" width="18" height="17" alt="Leave a message to the author" border="0"></a> <a href="?name=<?php echo "$sql_row[writer]";?>"><img src="image/" width="17" height="15" alt="View user profile" border="0"></a></td>
  </tr>
  <tr bgcolor="#ffffef">  
    <td><?php echo $sql_row[cont];?></td>
  </tr>
  <tr bgcolor="#e8eee0">
<td>※ Source: <?php echo $jl_forum[chinesename];?> [◆FROM: <?php echo $sql_row[fromip];?>]</td>
  </tr>
</table>
<?php
}
?>
<form method="post" action="">
  <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
    <tr>
      <td>
        <table width="40" border="1" cellspacing="0" cellpadding="0" height="20" bordercolorlight="#000099" bordercolordark="#FFFFFF">
          <tr valign="middle" align="center" bgcolor="#acc0fa">
<td height="17">Reply</td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
  <table width="98%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolorlight="#686898" bordercolordark="#CCCCCC">
    <tr>
<td width="8%" align="right" bgcolor="#acc0fa">username</td>
      <td width="33%">
        <input type="text" name="name" size="17" maxlength="16" value="<?php echo "$jl_forum[name]";?>">
        <font color="#FFFFFF">* </font></td>
<td width="7%" bgcolor="#acc0fa" align="center">Password</td>
      <td width="52%">
        <input type="password" name="password" size="17" maxlength="16">
        <font color="#FFFFFF">* </font></td>
    </tr>
    <tr>
<td width="8%" align="right" bgcolor="#acc0fa">Title:</td>
      <td colspan="3">
        <input type="text" name="title" size="40" maxlength="50">
        <font color="#FFFFFF"> * </font></td>
    </tr>
    <tr>
<td width="8%" align="right" bgcolor="#acc0fa">Content:</td>
      <td colspan="3">
        <textarea name="cont" cols="60" rows="3" wrap="VIRTUAL"></textarea>
      </td>
    </tr>
    <tr>
      <td width="8%" align="right" bgcolor="#acc0fa">&nbsp;</td>
      <td colspan="3">
<input type="button" name="clear" value="Close window" onclick="()">
<input type="submit" name="re" value="submit">
        <input type="checkbox" name="qm" value="qm" checked>
Use signature
        <input type="hidden" name="board" value="<?php echo $board;?>">
        <input type="hidden" name="id" value="<?php echo $id;?>">
        </font></td>
    </tr>
  </table>
  <?php
  }
  ?>
  <br>
</form>
<?php include"";?><br>
</body>
</html>