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

社区(php&&mysql)一

程序员文章站 2022-07-02 21:31:44
function cook_cooloff(){     global $php_self,$aid,$pgno;  &n...
function cook_cooloff(){
    global $php_self,$aid,$pgno;
    setcookie("open_list",0,time()+ 31536000);
    header("location:$php_self?aid=$aid&pgno=$pgno");
    exit;
}
//===============================================================
function cook_coolon(){
    global $php_self,$aid,$pgno;
    setcookie("open_list",1,time()+ 31536000);
    header("location:$php_self?aid=$aid&pgno=$pgno");
    exit;
}
function check_mail($semail)
{
    $str=strchr($semail,'@');   
    if ($str=="") return false;
    $str=strchr($semail,".");
    if ($str=="") return false;
    return true;
}
//================================================================
function addhitviews($sid,$rid) {
    $droot=getenv('document_root');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    if($sid==$rid)     $qsql="select * from bbs_subj where id='$rid'";
    else $qsql="select * from bbs_docs where id='$rid'";
    $rs=mysql_db_query($sql['db'],$qsql);
    $row=mysql_fetch_array($rs);
    $views=$row['views'];
    $views++;
    if($sid==$rid)     $qsql="update bbs_subj set views='$views' where id='$rid'";
    else $qsql="update bbs_docs set views='$views' where id='$rid'";

    mysql_db_query($sql['db'],$qsql);
}

//===============================================================
function mail_list(){
    global $php_self,$http_host,$email;
    global $aid,$sid,$rid;
    global $way1,$way2;

    if(check_mail($email)) {
    $mailtype=0; //璹綷
    if(strlen($way2)) $mailtype=1;//

    $droot=getenv('document_root');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    if($mailtype==0) { //璹綷
        $qsql="select * from bbs_sml where sid='$sid' and email='$email'";
        $rs=mysql_db_query($sql['db'],$qsql);
        if(mysql_num_rows($rs)==0) { //临⊿
          $qsql="insert into  bbs_sml (sid,email) values('$sid','$email')";
          $rs=mysql_db_query($sql['db'],$qsql);
        } else {
          echo "
          <script language=javascript>
          alert('竒,ぃ惠狡');
          </script>
         ";     
        }
    } else { //璹綷
        $qsql="select * from bbs_sml where sid='$sid' and email='$email'";
        $rs=mysql_db_query($sql['db'],$qsql);
        if(mysql_num_rows($rs) > 0) { //虫
          $qsql="delete from  bbs_sml where sid='$sid' and email='$email'";
          $rs=mysql_db_query($sql['db'],$qsql);
        } else {
          echo "
          <script language=javascript>
            alert('﹟ゼ虫ず!');
          </script>
         ";

        }

    }

    } else {
        echo "
          <script language=javascript>
              alert('e-mailα岿粇');
          </script>
         ";  
    }
    echo "
          <script language=javascript>
          document.location='$php_self?proc=view&aid=$aid&sid=$sid&rid=$rid'
          </script>
         ";  
}

//===============================================================
function send_the_doc_to_mail_list($aid,$sid,$rid){
    global $php_self,$http_host;
    $droot=getenv('document_root');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);  
    if($sid==$rid)     $qsql="select * from bbs_subj where id='$sid'";
    else $qsql="select * from bbs_docs where id='$rid'";

    $rs=mysql_db_query($sql['db'],$qsql);
    $row=mysql_fetch_array($rs);
    $poster=$row['poster'];
    $banner=$row['banner'];
    $body=$row['body'];

    $subj=$c_poster."ㄓ璹綷ゅ彻";
    $message=":$poster\n";
    $message.="ゅ彻夹肈:$banner\n";
    $message.="ゅ彻ず甧:$body\n";
    $message.="\nㄤ闽ゅ彻叫 http://$http_host$php_self?proc=view&aid=$aid&sid=$sid&rid=$rid\n";
    $message.="<<舧>>\n";
    $mailfrom="from:magic jerry";


    $qsql="select * from bbs_sml where sid='$sid'";
    $rs=mysql_db_query($sql['db'],$qsql);
    while($row=mysql_fetch_array($rs)) { //mail_list
        $email=$row['email'];
        mail($email,$subj,$message,$mailfrom);
        echo $email;
    }
    //盚倒恨瞶
    $qsql="select * from bbs_area where id='$aid'";
    $rs=mysql_db_query($sql['db'],$qsql);
    $row=mysql_fetch_array($rs);
    $email=$row['email'];
    $banner=$row['banner'];

    mail($email,"$banner 穝秈ゅ彻",$message,$mailfrom);


}
//===============================================================
function mail_friend(){
    global $php_self,$http_host,$c_email,$c_poster,$frmail;
    global $aid,$sid,$rid;
    if(check_mail($frmail)) {
    $droot=getenv('document_root');
    include("sql.php3");
    $db=mysql_connect($sql['host'], $sql['user'] , $sql['passwd']);
    if($sid==$rid) {  
        $qsql="select * from bbs_subj where id='$rid' ";
    } else {
        $qsql="select * from bbs_docs where id='$rid' ";
    }
    $rs=mysql_db_query($sql['db'],$qsql);
    $row=mysql_fetch_array($rs);

    $banner=$row['banner'];
    $body=$row['body'];

    $subj=$c_poster."ざ残ゅ彻";
    $message="狟ね: $c_poster ざ残硂ゅ彻\n";
    $message.="ゅ彻夹肈:$banner\n";
    $message.="ゅ彻ず甧:$body\n";
    $message.="\nㄤ闽ゅ彻叫 http://$http_host$php_self?proc=view&sid=$sid&aid=$aid&rid=$rid\n";
    $message.="<<舧>>\n";
    $mailfrom="from:".$c_email;

    mail($frmail,$subj,$message,$mailfrom);
    }else {
        echo "
          <script language=javascript>
              alert('e-mailα岿粇');
          </script>
         ";  
    }
    //echo "rid=$rid a=$aid s=$sid p=$pgno";

    echo "
          <script language=javascript>
          document.location='$php_self?proc=view&aid=$aid&sid=$sid&rid=$rid'
          </script>
         ";  
}

待续......