SoFunction
Updated on 2025-04-12

My forum source code (V)

Mainly handles user login and publishing information


<?
if ($username)
$useinfo=$username."|".$userpass;
setcookie("FlyFoxNet",$useinfo,time()+3600);   

if ($d==q) setcookie("FlyFoxNet");     //If it is exiting, set COOKIE to empty
?>
<HTML><HEAD><TITLE>Publish an article</TITLE>
<LINK href="js/" rel=stylesheet /LINK>
<?
include "";
include "";
function postf($useinfo,$title,$message)          //Posting information processing
{
       $query="select * from foxbbs order by id desc limit 1";
       $row=@mysql_query($query);
       $info=@mysql_fetch_array($row);
if ($useinfo[2]==$info[1]&&$title==$info[3])                                               �
echo "<script language='JavaScript'> alert('Please do not post repeatedly, thank you for your cooperation!'); </script>";
       else{
$time=date(Y year n month j day G hour i minute);
$filename=date(YmjGis);
$gip=getenv("REMOTE_ADDR");         //Write information
         $query="insert into foxbbs (usename,ftbq,title,ftdate,mesname,djnum,hfnum,ip) values ('".$useinfo[0]."','".$useinfo[14]."','".$title."','".$time."','".$filename."',1,0,'".$gip."')";
         $req=@mysql_query($query);
if ($req) {                                                                                                                           �
            $query="select ftnum from useinfo where usename='".$useinfo[0]."'";
            $req=@mysql_query($query);
            $ftnum=@mysql_fetch_array($req);
            $ftnum=$ftnum[0]+1;
            $query="update useinfo set ftnum='$ftnum' where usename='".$useinfo[0]."'";
            $req=@mysql_query($query);
            $ft=$filename;
$fp=fopen($ft,"w");                                                                                                                                                                                                                                                        �
            $message=str_replace("<","&lt;",str_replace(">","&gt;",$message));
$message=nl2br($message);    //Remove the symbol first and then change the line to avoid the line breaks from becoming characters to display.
            $f=fputs($fp,$message);
            $fp=@fclose($fp);
echo "<script language='JavaScript'> alert('".$useinfo[2]."!Congratulations, posting successfully!'); </script>";
            }
         else {
echo "<script language='JavaScript'> alert('I apologize very much, your post failed to save due to database reasons!'); </script>";
              }
        }

}
function userr($username,$userpass,$title,$message)           //User information verification function
{
    $query="select * from useinfo where usename='".$username."'";
    $req=mysql_query($query);
    $useinfo=mysql_fetch_array($req);
     if ($useinfo[0]==$username)
     {
//If the calibration check is passed, the information processing function will be called
       if ($userpass==$useinfo[1])  {postf($useinfo,$title,$message);return $useinfo;}
       else {
echo "<script language='JavaScript'> alert('Password is incorrect, please check!'); </script>";
       echo "<meta HTTP-EQUIV='REFRESH' CONTENT='2;URL='>";
       }
     }
     else
     {
echo "<script language='JavaScript'> alert('The user does not exist, please confirm that it has been registered!'); </script>";
     }
}
?>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<meta HTTP-EQUIV="REFRESH" CONTENT="2;URL=">
</head><body topmargin="0">
<?
$tem=$HTTP_COOKIE_VARS[FlyFoxNet];
$temp=explode("|",$tem);
$cookiem=$temp[0];
$useinfo=cuser($cookiem,$action);
if (isset($message))
{
  if($username)
  {
     $useinfo=userr($username,$userpass,$title,$message);
  }
  else if($useinfo) {
     userr($useinfo[0],$useinfo[1],$title,$message);
     }
else {echo "<script language='JavaScript'> alert('You are not a legal user, you cannot post on this forum!'); </script>";}

}
if ($d==q)
{
echo "<script language='JavaScript'> alert('You are logged out and will return to the forum as a tourist'); </script>";
}
?>
<br><br><br><br><br>
<div align="center"><a href=>If the system does not return to the page automatically, please click here to return.</a></div>
</body>
</html>