网站地图    收藏   

主页 > php专栏 > php综合实列 >

社区(php&&mysql)一-PHP实例

来源:自学PHP网    时间:2014-12-25 09:57 作者: 阅读:

[导读] 社区phpamp;amp;mysql一,functioncook_cooloff{nbsp;nbsp;nbsp;nbsp;global$php_SELF,$aid,$pgno;nbsp;nbsp;nbsp;nbsp;setcookiequot;OPEN_LISTquot;,0,time+31536000;nbsp;nbsp;nbsp;nbsp;Headerquot;Location:$PHP_SELF?aid=$aidamp;pgno=$pgnoquot;;nbsp...

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) { //临⊿[J
          $qsql="INSERT INTO  bbs_sml (sid,email) values('$sid','$email')";
          $rs=mysql_db_query($sql['db'],$qsql);
        } else {
          echo "
          <script language=javascript>
          alert('Aw竒[J,ぃ惠狡[J');
          </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) { //wbW虫
          $qsql="DELETE FROM  bbs_sml where sid='$sid' AND email='$email'";
          $rs=mysql_db_query($sql['db'],$qsql);
        } else {
          echo "
          <script language=Javascript>
            alert('﹟ゼbW虫ず!');
          </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."ㄓ郗q綷氦宄";
    $message="@:$poster\n";
    $message.="ゅ彻夹肈:$banner\n";
    $message.="ゅ彻ず甧:$body\n";
    $message.="\nㄤL勖訾宄菇笑 http://$HTTP_HOST$PHP_SELF?proc=view&aid=$aid&sid=$sid&rid=$rid\n";
    $message.="<<舧铵A亥[J>>\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 ┓s秈氦宄",$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."ざ残An氦宄";
    $message="A害n狟ね: $c_poster ざ残A莩o胜宄筡n";
    $message.="ゅ彻夹肈:$banner\n";
    $message.="ゅ彻ず甧:$body\n";
    $message.="\nㄤL勖訾宄菇笑 http://$HTTP_HOST$PHP_SELF?proc=view&sid=$sid&aid=$aid&rid=$rid\n";
    $message.="<<舧铵A亥[J>>\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>
         ";  
}

待续...... 

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论