欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

社区(php&&mysql)五

程序员文章站 2022-07-02 21:32:56
function post2() {     global $sid,$aid,$php_self;   &nb...
function post2() {
    global $sid,$aid,$php_self;
    global $banner,$body,$poster,$email,$type,$char_gb;

     
    if(strlen($banner)==0 || strlen($body)==0 || strlen($poster)==0 || strlen($email)==0) {
        echo "
          <script language=javascript>
            alert('恶糶ぃч俱');
            history.back();
          </script>
         ";
        return;
    }

    //$banner=addslashes($banner);
    //$body=addslashes($body);
    $rip=getenv('remote_addr');

    $droot=getenv('document_root');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    $now=date('y')."-".date('m')."-".date('d')." ".date('h').":".date('i').":".date('s');

    if($char_gb==1) {
        include("ccharset.php3");
        $code=new ccharset;
        $banner=$code->gb_big5($banner);
        $body=$code->gb_big5($body);
        $poster=$code->gb_big5($poster);             
    }

    if($type==1) {
        $qsql="insert into bbs_docs (aid,sid,banner,body,poster,email,pip,wdate)
           values('$aid','$sid','$banner','$body','$poster','$email','$rip','$now')";
    } else {
        $qsql="insert into bbs_subj (aid,banner,body,poster,email,pip,wdate)
           values('$aid','$banner','$body','$poster','$email','$rip','$now')";
    }     
    $rs=mysql_db_query($sql['db'],$qsql);
    $id=mysql_insert_id();

     

    if($type==0) { //笆mail_list
        $qsql="insert into  bbs_sml (sid,email) values('$id','$email')";
        $rs=mysql_db_query($sql['db'],$qsql);

    }
    if($type==0)  send_the_doc_to_mail_list($aid,$id,$id);
    else           send_the_doc_to_mail_list($aid,$sid,$id);     
    //incdocs($aid);
    if($type==0) { $sid=$rid=$id;}
    else         { $rid=$id;}
    echo "
          <script language=javascript>
          document.location='$php_self?proc=view&aid=$aid&sid=$sid&rid=$rid'
          </script>
         ";  

}
//======================================================================
function search_docs($aid,$skey) {
    $droot=getenv('document_root');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    //$qsql="select * from bbs_docs where sid='$id' and (banner like '$skey' or poster like '$skey' or body like '$skey') order by wdate desc";
    if($aid) $qsql="select * from bbs_docs where aid='$aid' and (banner like '$skey' or poster like '$skey' or body like '$skey') order by wdate desc";
    else $qsql="select * from bbs_docs where  (banner like '$skey' or poster like '$skey' or body like '$skey') order by wdate desc";     
    $rs=mysql_db_query($sql['db'],$qsql);
        while($row=mysql_fetch_array($rs)) {
        $id=$row['id'];
            $banner=$row['banner'];
            $poster=$row['poster'];
            $views=$row['views'];
            $wdate=sdatetime($row['wdate']);
            $aid=$row['aid'];
            $sid=$row['sid'];

            echo "<tr bgcolor='#f0f0f0'>";
                echo "<td>";
                    echo "<a href=$php_self?proc=view&aid=$aid&sid=$sid&rid=$id>";
                    echo "  <font color=#836fff>$banner</font>";
                    echo "</a>";

                echo "</td>";
                echo "<td>";
                    echo $poster;
                echo "</td>";
                echo "<td class='num'>";
                    echo " ";
                echo "</td>";
                echo "<td class='num'>";
                    echo $views;
                echo "</td>";
                echo "<td class='num'>";
                    echo $wdate;
                echo "</td>";

            echo "</tr>";
    }

}
//======================================================================
function search() {
    global $php_self;
    global $key,$aid;
    if(!strlen($key)) {
    echo "
          <script language=javascript>
            history.back();
          </script>
         ";
    }
    echo "<table width=85% border=0 cellpadding=0 cellspacing=1 align=center class='tablefont'>";
    echo "<form  name=mtab  enctype=multipart/form-data method=post action=$php_self?proc=search>";

      echo "<tr><td>";

              echo "<input type='hidden' name=aid value='$aid'>";     
              echo "穓碝ゅ彻:";
              echo "<input type='text' name='key' value='$key' size=25 class='tablefont'>";
              echo "<input type='submit'value='琩高' class='tablefont'>";

      echo "</td></tr>";
      echo "</form>";  
    echo "</table>";  

     
    $skey="%$key%";
    $droot=getenv('document_root');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    if($aid) $qsql="select * from bbs_subj where aid='$aid' and (banner like '$skey' or poster like '$skey' or body like '$skey') order by wdate desc";
    else $qsql="select * from bbs_subj where  (banner like '$skey' or poster like '$skey' or body like '$skey') order by wdate desc";     
    //echo $qsql;
    $rs=mysql_db_query($sql['db'],$qsql);

    echo "<table width=85% border=0 cellpadding=0 cellspacing=1 align=center bgcolor='#6ca6cd'>";
      echo "<tr><td>";
      echo "<table width=100% cellpadding=1 cellspacing=1 bgcolor=white class='tablefont'>";
        echo "<tr bgcolor=#f1e1ff>";
            echo "<th >夹肈</th>";
            echo "<th>祇癬</th>";
            echo "<th width=30>莱</th>";
            echo "<th width=30></th>";
            echo "<th width=70>ら戳</th>";
        echo "</tr>";
        while($row=mysql_fetch_array($rs)) {
            $id=$row['id'];
            $paid=$row['aid'];
            $banner=$row['banner'];
            $poster=$row['poster'];
            $views=$row['views'];
            $wdate=sdatetime($row['wdate']);
            $docs=reanum($id);
            echo "<tr bgcolor='#f0f8ff'>";
                echo "<td>";
                    echo "<a href=$php_self?proc=view&aid=$paid&sid=$id&rid=$id>";
                        echo $banner;
                    echo "</a>";
                echo "</td>";
                echo "<td>";
                    echo $poster;
                echo "</td>";
                echo "<td class='num'>";
                    echo $docs;
                echo "</td>";
                echo "<td class='num'>";
                    echo $views;
                echo "</td>";
                echo "<td class='num'>";
                    echo $wdate;
                echo "</td>";
            echo "</tr>";

        }
        search_docs($aid,$skey);
      echo "</td></tr></table>";
    echo"</td></tr></table>";       

     

     
}
//======================================================================

if($proc=="post2") {
    setcookie("c_poster",$poster,time()+ 31536000);
    setcookie("c_email",$email,time()+ 31536000);
}

//if($proc!="do_sel" &&  $proc!="post2" && $proc!="colloff" && $proc!="collon") include("frame_top.php3");
switch($proc) {
        case search:
             search();
             break;
        case mail_list:
             mail_list();
             break;
        case mail_friend:
             mail_friend();
             break;
        case post2:
             post2();
             break;
        case colloff:
             cook_cooloff();
             break;
        case collon:
             cook_coolon();
             break;
        case view;
             view();
             break;      
        default:
            area();
            break;
    }
//if($proc!="do_sel" && $proc!="post2" && $proc!="colloff" && $proc!="collon") include("frame_bottom.php3");     
?>

以上前五篇为一个页面