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

社区(php&&mysql)三

程序员文章站 2022-03-31 12:11:45
function prev_subj($id){     $droot=getenv('document_root');  ...
function prev_subj($id){
    $droot=getenv('document_root');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    $qstr="select id,aid from bbs_subj where id='$id'";
    $rs=mysql_db_query($sql['db'],$qstr);     
    $row=mysql_fetch_array($rs);
    $aid=$row['aid'];

    $qstr="select id from bbs_subj where aid='$aid' order by wdate desc";
    $rs=mysql_db_query($sql['db'],$qstr);
    $pid=$id;     
    while($row=mysql_fetch_array($rs)){
        $tid=$row['id'];     
        if($id==$tid) break;
        $pid=$tid;
    }

    return $pid;
}
// 絞
function next_subj($id){
    $droot=getenv('document_root');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    $qstr="select id,aid from bbs_subj where id='$id'";
    $rs=mysql_db_query($sql['db'],$qstr);     
    $row=mysql_fetch_array($rs);
    $aid=$row['aid'];

    $qstr="select id from bbs_subj where aid='$aid' order by wdate desc";
    $rs=mysql_db_query($sql['db'],$qstr);
    $pid=$id;     
    while($row=mysql_fetch_array($rs)){
        $pid=$row['id'];     
        if($id==$pid) break;
    }
    if($row=mysql_fetch_array($rs)) {
        $pid=$row['id'];
    }
    return $pid;
}

//======================================================================
function viewbar() {
    global $pgno;
    global $php_self;
    global $aid,$sid;
    //global $open_list;
    echo "<table width=85% border=0 cellpadding=0 cellspacing=1 align=center align=center class='num'>";
    echo "<tr><td align=center>";
        $nextid=next_subj($sid);
        $previd=prev_subj($sid);
        echo "<a href=$php_self?aid=$aid&sid=$sid>[夹肈跋]</a>";
        echo "<a href=#re>[莱セ絞]</a>";
        echo "<a href=$php_self?proc=view&aid=$aid>[祇穝ゅ彻]</a>";
        echo "<a href=$php_self?proc=view&aid=$aid&sid=$nextid&rid=$nextid>[絞]</a>";
        echo "<a href=$php_self?proc=view&aid=$aid&sid=$previd&rid=$previd>[絞]</a>";
        //echo "<a href=$php_self?proc=view&pgno=$pgno&aid=$aid&sid=$previd&rid=$previd>[程絞]</a>";

    echo "</td>";

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

}
//======================================================================
function view() {
    global $php_self,$aid,$sid,$rid;
    global $c_poster,$c_email;
    //echo "$php_self,$aid,$sid,$rid,$pgno";
    $type=0; //秨穝杠肈
  if($sid && $rid) {
      addhitviews($sid,$rid);
    $type=1; //莱
    $db_table="bbs_subj";
    if($sid!=$rid)    $db_table="bbs_docs";
    $droot=getenv('document_root');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    $qstr="select banner from bbs_area where id='$aid'";
    $rs=mysql_db_query($sql['db'],$qstr);
    echo mysql_error();
    $row=mysql_fetch_array($rs);
    $abanner=$row['banner'];

    $qsql="select * from $db_table where id='$rid' ";
    $rs=mysql_db_query($sql['db'],$qsql);
    $row=mysql_fetch_array($rs);
    $poster=$row['poster'];
    $pip=$row['pip'];
    $wdate=$row['wdate'];
    $rebanner=$banner=$row['banner'];
    $body=$row['body'];
    $body=htmlspecialchars($body);
    $pbody=ereg_replace("n","<br>",$body);
    $pbody =preg_replace( "/[www *]([\x0-\xff]*?)[/www *]/", '<a href="\1"  target="_blank">\1</a>', $pbody );  
    $pbody =preg_replace( "/[www +([a-za-z0-9.:/_-]+)]([\x0-\xff]*?)[/www *]/", '<a href="\1"  target="_blank">\2</a>', $pbody );  

    echo "<center>";
    echo "<font color=green size=5><b>[$abanner]<br>";
    echo "$banner</b></font></center>";
    echo "<table border=0 width=95%  align=center cellpadding=1 cellspacing=0 class='tablefont'>";
            echo "<tr><td >";
                viewbar();
            echo "</td></tr>";
            echo "<tr><td>";
            //====ゅ彻==============
            echo "<table border=0 width=100%  align=center cellpadding=1 cellspacing=0 class='tablefont'>";
            echo "<tr>";
                echo "<td  width='120' align='right'>";
                    echo ":";
                echo "</td>";
                echo "<td align='left'>";
                    echo $poster;
                echo "</td>";
            echo "</tr>";
            echo "<tr>";
                echo "<td width='120' align='right'>";
                    echo "ㄓ:";
                echo "</td>";
                echo "<td align='left'>";
                    echo $pip;
                echo "</td>";
            echo "</tr>";
            echo "<tr>";
                echo "<td width='120' align='right' valign='top'>";
                    echo "ゅ彻ず甧:";
                echo "</td>";
                echo "<td valign='top' class='bodycolor' align='left'>";
                            echo $pbody;
                            echo "<hr size=1>";
                echo "</td>";
            echo "</tr>";
            echo "</td></tr>";
            echo "</table>";
            echo "<tr><td >";

                //=======籔狟ねだㄉ===============
                echo "<table border=0 width=100%   align=center cellpadding=3 cellspacing=0 class='menufont'>";     
                echo "<form  name=mtab enctype=multipart/form-data method=post action=$php_self?proc=mail_friend>";
                echo "<input type='hidden' name=sid value='$sid'>";
                echo "<input type='hidden' name=aid value='$aid'>";
                echo "<input type='hidden' name=rid value='$rid'>";
                echo "<input type='hidden' name=poster value='$c_poster'>";
                echo "<input type='hidden' name=email value='$c_email'>";
                    echo "<tr>";
                       echo "<td align='right' width=250>";
                        echo "籔狟ねだㄉ硂絞ゅ彻:";
                       echo "</td>";
                       echo "<td>";
                        echo "<input type='text' name='frmail' size=25 value='ねe-mail'>";

                        echo "<input type='submit'value='癳'>";
                       echo "</td>";
                    echo "</tr>";
                echo "</form>";     
                echo "</table>";                 
            echo "</td></tr>";
            echo "<tr><td >";
                //=======mail list===============
            echo "<table border=0 width=100%   align=center cellpadding=3 cellspacing=0 class='menufont'>";     
            echo "<form  name=mtab enctype=multipart/form-data method=post action=$php_self?proc=mail_list>";
                echo "<input type='hidden' name=sid value='$sid'>";
                echo "<input type='hidden' name=aid value='$aid'>";
                echo "<input type='hidden' name=rid value='$rid'>";
                echo "<input type='hidden' name=poster value='$c_poster'>";
                echo "<input type='hidden' name=email value='$c_email'>";

            echo "<tr >";
               echo "<td align='right' width=250>";
                echo "璹境o肈尿癚阶:";
               echo "</td>";
               echo "<td>";
                if(strlen($c_email)) $addmail=$c_email;
                else $addmail="e-mail";
                echo "<input type='text' name='email' size=25 value='$addmail'>";
                echo "<input type='submit' name='way1' value='璹?>";
                echo "<input type='submit' name='way2' value='璹?>";
                $qsql="select id from bbs_sml where sid='$sid'";
                $rs=mysql_db_query($sql['db'],$qsql);
                $nums=mysql_num_rows($rs);
                echo "<br>硂肈ヘ玡璹兢h计:$nums";
               echo "</td>";
            echo "</tr>";     
            echo "</form>";
            echo "</table>";     

            echo "</td></tr>";
            echo "<tr><td >";
                viewbar();
            echo "</td></tr>";
        echo "</table>";

         
待续........