易截截图软件、单文件、免安装、纯绿色、仅160KB

php 防注入攻击函数

/*php 防注入函数
string  $feifa  限制元素组成
如有非法字符跳转到上一页 返回 0  没有返回 1
*/
//使用方法
//$feifa=array("select","delete","from","update","create","destory","drop","alter","and","or","like","exec","count","*","chr","mid","master","truncate","char","declare",";","-","+");
//$arrpostget=array("http://www.baidu.select cretecomdmin","wangw");
//echo saftsql($feifa,$arrpostget);
function saftsql($feifa,$arrpostget){
//
$arrpostget=array_merge((array)$HTTP_PSOT_VARS,(array)$HTTP_GET_VARS);
  if($arrpostget){
         foreach($arrpostget as $key=>$value){
              for($i=0;$i<count($feifa);$i++){
                //找非法字符在$value中的位置
                $flag=strpos($value,$feifa[$i]);              
                if($flag)
                {                    
                 echo "<script
type=\"text/javascript\">alert('URL有非法字符');</script>";
               


相关文档:

PHP 在线聊天系统的实现

在线实时聊天系统,一直是一个比较麻烦的东西。
一般实现在线实时聊天,是利用JS在客户端使用ajax每隔一定的时间就返回服务器请求数据,如果有新的聊天信息则用JS呈现给用户
我们不说这样做的利弊,直接切入正题,如何来实现服务器推的在线聊天系统
首先,我先请大家看一个例子
复制代码
<?php
while(true){
&n ......

PHP数据库链接代码

 <?php
$mydbhost ="localhost"; //配置主机
$mydbuser ="root"; //数据库用户
$mydbpw ="8312836"; //数据库密码
$mydbname ="jingyun"; //数据库名
//$mydbcharset ="GBK";
$conn=mysql_connect($mydbhost,$mydbuser,$mydbpw) or die ("服务器连接错误".mysql_error());
mysql_select_db($myd ......

PHP分页代码

头部调用
 <?
require('conn.php');
$sql1="select id from news";
$query1=mysql_query($sql1,$conn);
$sun_num=mysql_num_rows($query1);
$gs=20;
$page_num=ceil($sun_num/$gs);
include("../subpage.php");
//传过来的页数参数
$PB_page=$_GET['PB_page'];
if ($PB_page==1 or empty($PB_page)){
$ ......

php 函数

htmlspecialchars()    
函数把一些预定义的字符转换为 HTML 实体。
      ENT_COMPAT - 默认。仅编码双引号。
          eg:" (双引号) 成为 &quot;
implode()    
函数把
数组元素组合为一个字 ......

PHP中文乱码解决办法


一.         首先是PHP网页的编码
1.     php文件本身的编码与网页的编码应匹配
a.     如果欲使用gb2312编码,那么php要输出头:header(“Content-Type: text/html; charset=gb2312"),静态页面添加<meta http-equiv="Cont ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号