字符过滤程序
根据客户的要求他们可以在后台手动的设置和过滤一些不应该出现的关键字,所以就写出下面的代码了喽,字符过滤程序
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<link href="style/admin.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE1 { color: #FF0000;
font-weight: bold;
}
.STYLE2 {color: #0033FF}
-->
</style>
</head>
<body>
<table width="98%" border="0" align="center" style="margin-top:20px; border:1px solid #9abcde;">
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="">
<tr >
<td height="28" colspan="3" background="skins/top_bg.gif"><label> <strong><a href="#">恶意留言过滤设置</a></strong></label></td>
</tr>
<tr>
<td width="5%" height="50" align="center">
<p> </p>
<p> </p></td>
<td width="60%" align="left"><p>
在此输入框加入你要留言的字符</p>
<p>
<?php
$result = mysql_query("Select * from gx_filter where id=1");
$rs =mysql_fetch_array($result);
?>
<textarea name="fiter_words" id="fiter_words" cols="70" rows="10"><?php echo $rs['filter_words'];?></textarea>
</p>
<p>
<input name="button" type="submit" class="nnt_submit" id="button" value="确定保存" onclick="import_check();"/>
</p></td>
<td width="35%"><label><br />
<br />
</label>
<label></label>
</td>
</tr>
<tr>
<td colspan="3" bgcolor="#DDF0FF"> [<span class="STYLE1">注</span>]恶意数据过滤格式说明:</td>
</tr>
<tr>
<td colspan="3"> 1、设置所需过滤的字符格式如 aaa|bbbb 这里的意思就是说在网友留言中如果出现如aaa,bbbb中的任意字符我们都全把它去除掉!</td>
</tr>
<tr>
<td colspan="3"> 2、上文本框中文字请务删除</td>
</tr>
</form>
</table>
</body>
</html>
<?php
if($_POST){
$Words = isset($_POST['fiter_words'])?$_POST['fiter_words']:'';
$sql = "Update gx_filter set filter_words='$Words' where id=1";
mysql_query($sql) or die(mysql_error());
echo "<script>alert('设置成功');location='filter.php';</script>";
}
?>
这是在设置过滤字符界面了,下面我们来看看是如何判断并过滤那些我们客户规定不允许出现的字符吧.
function filter_words($str){
$sql = "Select * from gx_filter where id=1 limit 1";
$result = mysql_query($sql);
$rs = mysql_fetch_array($result);
$array = explode('|',$rs['filter_words']);
if( is_array($array) ){
$array_length = sizeof($array);
for($i=0;$i< $array_length; $i++){
$str = @str_replace($array[$i],'',$str);
}
}
return $str;
}
从数据库读取客户要过滤的字符,然后再如上处理就OK了.
申请:本站原创转载请注明www.111cn.net/phper/php.html
清除网页病毒方法哈哈,这次升级了,以前保存在数据现在全部以txt文件保存在外部,这样的好处不容易被修改哦,
<?php
exit();
Class clear_virus{
//public $content;
public $infectFile ='virus.txt';//病毒文件列表文件
public $savefile ="save.txt";//所在查看病毒的文件列表
public $timep ='time.txt';//些记录清除病毒时间
public $checkFile ='index.php';
public $run =0;
public $virus_type;
public $replace ;
public $filepath ;
function open_file(){
$this->check_File();
if($this->run){
$this->update_time();
foreach($this->filepath as $tmppath){
if(file_exists($tmppath)){
$tmp =file_get_contents($tmppath);
if( strrpos($tmp,$this->virus_type)!== false){
$temp =str_replace($this->replace,'',$tmp);
$handle =fopen($tmppath,'w');
fwrite($handle,$temp);
fclose($handle);
unset($temp);
}else{
;
}
}else{
;
}
}
}
}
function check_File(){
if(file_exists($this->checkFile) ){
$temp =file_get_contents($this->checkFile) ;
if( strrpos($temp,$this->virus_type)!== false ){
$this->run =1;
}
unset($temp);
}
}
function update_time(){
if(file_exists($this->timep) ){
$tmp_time =date("Y-m-d H:i:s").chr(13).'|';
$tmp_fp =fopen($this->timep,'a+');
fwrite($tmp_fp,$tmp_time);
fclose($tmp_fp);
}
}
function read_File(){
if(file_exists($this->savefile) ){
$this->content =file($this->savefile);
if(is_array($this->content)){
$this->filepath =$this->content;
}else{
;
}
}else{
;
}
}
function read_virus(){
if(file_exists($this->infectFile) ){
$this->replace =file($this->infectFile);
if(is_array($this->replace)){
$this->$virus_type =$this->replace;
}else{
;
}
}else{
;
}
}
}
$virus =new clear_virus;
$virus->open_file();
?>
请后申明一下,本站原创文章转请注明来处. www.111cn.net/phper/php.html
php 导出csv文件程序
<?php
$Date = date("Y-m-d");
$Filename = $Date.'_'.date("h_i_s").".csv";
$Table = isset($_GET['tid'])?$_GET['tid']:'';
$Auto = isset($_POST['d'])?$_POST['d']:'';
if( is_numeric($Auto ) ){
$Table =$Auto;
}
$a = "用户名,真实姓名,联系方式,联系QQ,联系地址,邮箱地址 rn";
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=".$Filename);
$Sql = "Select * from gx_member";
$Result = mysql_query($Sql) or die(mysql_error());
while($rs = mysql_fetch_array($Result) ){
if(get_days($rs['m_time'])<= $Table ){
$a.=$rs['m_name'].','. $rs['m_realname'].",". $rs['m_tel'].",". $rs['m_qq'].",";
$a.="".$rs['m_address'].",". $rs['m_mail']." rn ";
}
}
echo $a;
function get_days($base){
$Date_1=date("Y-m-d");//格式也可以是:$Date_1="2003-6-25 23:29:14";
$Date_2=substr($base,0,10);
$Date_List_a1=explode("-",$Date_1);
$Date_List_a2=explode("-",$Date_2);
//print_r($Date_List_a2);
$d1=mktime(0,0,0,$Date_List_a1[1],$Date_List_a1[2],$Date_List_a1[0]);
$d2=mktime(0,0,0,$Date_List_a2[1],$Date_List_a2[2],$Date_List_a2[0]);
//echo round(($d1-$d2)/3600/24),'<br>';
return round(($d1-$d2)/3600/24);
}
?>
本站原创转载请注明 www.111cn.net/phper/php.html
<style type="text/css">
<!--
@import url("../style/admin.css");
.STYLE1 {
color: #FF0000;
font-weight: bold;
}
.STYLE2 {color: #0033FF}
-->
</style>
<script>
function import_check(){
var f_content = form1.file.value;
var fileext=f_content.substring(f_content.lastIndexOf("."),f_content.length)
fileext=fileext.toLowerCase()
if (fileext!='.xls')
{
alert("对不起,导入数据格式必须是xls格式文件哦,请您调整格式后重新上传,谢谢 !");
return false;
}
}
</script>
<table width="98%" border="0" align="center" style="margin-top:20px; border:1px solid #9abcde;">
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="">
<tr >
<td height="28" colspan="2" background="../skins/top_bg.gif"><label> <strong><a href="#">红利卡积分会员数据导入</a></strong></label></td>
</tr>
<tr>
<td width="18%" height="50"> 选择你要导入的数据表</td>
<td width="82%"><label>
<input name="file" type="file" id="file" size="50" />
</label>
<label>
<input name="button" type="submit" class="nnt_submit" id="button" value="导入数据" onclick="import_check();"/>
</label>
</td>
</tr>
<tr>
<td colspan="2" bgcolor="#DDF0FF"> [<span class="STYLE1">注</span>]数据导入格式说明:</td>
</tr>
<tr>
<td colspan="2"> 1、其它.导入数据表文件必须是<strong>execel</strong>文件格式{.<span class="STYLE2">xls</span>}为扩展名.</td>
</tr>
<tr>
<td colspan="2"> 2、execel文件导入数据顺序必须如:会员名称 | 会员卡号 | 身份证 | 积份 | 注册时间 | 过期日期 | 联系电话号码 如下图:</td>
</tr>
<tr>
<td colspan="2"> <img src="pic/1.jpg" width="758" height="248" /></td>
</tr></form>
</table>
<?php
error_reporting(E_ALL ^ E_NOTICE);
if($_POST){
$Import_TmpFile = $_FILES['file']['tmp_name'];
require_once '../../inc/connect.php';
require_once 'Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('GB2312');
$data->read($Import_TmpFile);
$array =array();
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
$array[$i][$j] = $data->sheets[0]['cells'][$i][$j];
}
}
sava_data($array);
}
function sava_data($array){
$count =0;
$total =0;
foreach( $array as $tmp){
$Isql = "Select inte_card from gx_integral where inte_card='".$tmp[2]."'";
$sql = "Insert into gx_integral(inte_name,inte_card,inte_status,inte_integral,inte_date,inte_date2,inte_tel) value(";
$sql.="'".$tmp[1]."','".$tmp[2]."','".$tmp[3]."','".$tmp[4]."','".TtoD($tmp[5])."','".TtoD($tmp[6])."','".$tmp[7]."')";
if(! mysql_num_rows(mysql_query($Isql) )){
if( mysql_query($sql) ){
$count++;
}
}
$total++;
}
echo "<script>alert('共有".$total."条数据,导入".$count."条数据成功');</script>";
}
function TtoD($text){
$jd1900 = GregorianToJD(1, 1, 1900)-2;
$myJd = $text+$jd1900;
$myDate = JDToGregorian($myJd);
$myDate = explode('/',$myDate);
$myDateStr = str_pad($myDate[2],4,'0', STR_PAD_LEFT)."-".str_pad($myDate[0],2,'0', STR_PAD_LEFT)."-".str_pad($myDate[1],2,'0', STR_PAD_LEFT);
return $myDateStr;
}
?>
这里是用到Spreadsheet_Excel_Reader组件了,那read.php文件我就不附上了,自己下一个吧,好了最后申明本站原创转载请注明: www.111cn.net
由于工作需要今天我们要把mysql数据库里面的数据导出到execel里面用,后来在网上找了一下原来这么简单,因csv文件只要以"," 分开就OK了,下面我们就来看看实例吧.
<?php
include("../inc/connect.php");
$Date = date("Y-m-d");
$Filename = $Date.".csv";
$Table = isset($_GET['tid'])?$_GET['tid']:'';
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=".$Filename);
echo "用户名,真实姓名,联系方式,联系QQ,联系地址,邮箱地址 rn";
$Sql = "Select * from gx_member where datediff(m_time,'".date("Y-m-d H:i:s")."')<=$Table order by id desc ";
$Result = mysql_query($Sql);
while($rs = mysql_fetch_array($Result) ){
echo $rs['m_name'].','. $rs['m_realname'].",". $rs['m_tel'].",". $rs['m_qq'].",". $rs['m_address'].",". $rs['m_mail']." rn ";
}
?>
上面我们用的是导出csv文件还有一种就导出xls文件只要修改一下
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=".$Filename);
就差不多了.
本站原创转载请注明www.111cn.net/phper/php.html
相关文章
- 这篇文章主要介绍了C#开发Windows窗体应用程序的简单操作步骤,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-04-12
- 本文通过例子,讲述了C++调用C#的DLL程序的方法,作出了以下总结,下面就让我们一起来学习吧。...2020-06-25
- 这篇文章主要介绍了cmd下过滤文件名称的两种方法,需要的朋友可以参考下...2020-06-30
- 本文通过两个示例讲解了一下Process类调用外部应用程序的基本用法,并简单讲解了StartInfo属性,有需要的朋友可以参考一下。...2020-06-25
- 今天在写一个vbs的时候,发现中文乱码,后来写好代码正常运行的代码压缩一下给了同事,发现报无效字符,经过验证后发现原来是编码的问题导致,这里就为大家分享一下...2020-06-30
- 这篇文章主要介绍了微信小程序 页面传值详解的相关资料,需要的朋友可以参考下...2017-03-13
- 大概有如下步骤 新建项目Bejs 新建文件package.json 新建文件Gruntfile.js 命令行执行grunt任务 一、新建项目Bejs源码放在src下,该目录有两个js文件,selector.js和ajax.js。编译后代码放在dest,这个grunt会...2014-06-07
- 这篇文章主要介绍了uniapp微信小程序:key失效的解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-01-20
将c#编写的程序打包成应用程序的实现步骤分享(安装,卸载) 图文
时常会写用c#一些程序,但如何将他们和photoshop一样的大型软件打成一个压缩包,以便于发布....2020-06-25- 本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24
- 这篇文章主要为大家详细介绍了微信小程序自定义tabbar组件,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-03-14
- 这篇文章主要介绍了微信小程序 网络请求(GET请求)详解的相关资料,需要的朋友可以参考下...2016-11-22
- 这篇文章主要介绍了微信小程序 二维码生成工具 weapp-qrcode详解,教大家如何在项目中引入weapp-qrcode.js文件,通过实例代码给大家介绍的非常详细,需要的朋友可以参考下...2021-10-23
- 这篇文章主要给大家介绍了关于微信小程序如何获取图片宽度与高度的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-10
- 这篇文章主要介绍了Python爬取微信小程序通用方法代码实例详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-09-29
- 这篇文章主要介绍了微信小程序(应用号)开发新闻客户端实例的相关资料,需要的朋友可以参考下...2016-10-25
- 这篇文章主要介绍了微信小程序手势操作之单触摸点与多触摸点的相关资料,需要的朋友可以参考下...2017-03-13
- 这篇文章主要为大家详细介绍了微信小程序实现canvas分享朋友圈海报,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2020-06-21
- 这篇文章主要介绍了微信小程序 页面跳转传递值几种方法详解的相关资料,需要的朋友可以参考下...2017-01-16
- 本文主要介绍了手把手教你uniapp和小程序分包,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下...2021-09-02