Home  >  Article  >  php教程  >  我的论坛源代码(五)_php基础

我的论坛源代码(五)_php基础

WBOY
WBOYOriginal
2016-05-17 09:07:22724browse

okey.php主要处理用户登录和发布的信息处理



if ($username)                       //是否有用户信息
$useinfo=$username."|".$userpass;
setcookie("FlyFoxNet",$useinfo,time()+3600);   

if ($d==q) setcookie("FlyFoxNet");     //如果是退出的话,把COOKIE置为空
?>

发表文章


include "linkfox.inc.php";
include "info.inc.php";
function postf($useinfo,$title,$message)        //发帖信息处理
{
       $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 "";
       else{
         $time=date(Y年n月j日G时i分);
         $filename=date(YmjGis);               //文件名取当前的时间
         $gip=getenv("REMOTE_ADDR");        //写入信息
         $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("",">",$message));
            $message=nl2br($message);    //先去除符号再变换行,免得换行符也变成字符显示出来。
            $f=fputs($fp,$message);
            $fp=@fclose($fp);
            echo "";
            }
         else {
            echo "";
              }
        }

}
function userr($username,$userpass,$title,$message)        //用户信息校验函数
{
    $query="select * from useinfo where usename='".$username."'";
    $req=mysql_query($query);
    $useinfo=mysql_fetch_array($req);
     if ($useinfo[0]==$username)
     {
//如果通过校检就调用信息处理函数
       if ($userpass==$useinfo[1])  {postf($useinfo,$title,$message);return $useinfo;}
       else {
       echo "";
       echo "";
       }
     }
     else
     {
       echo "";
     }
}
?>




$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 "
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn