清除网页病毒方法
清除网页病毒方法哈哈,这次升级了,以前保存在数据现在全部以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
允许用户上传文件是必要的,许多网站,所以,我们如何做到这一点,正是?但话又说回来,有一些方便的书面文件上。审议了麻烦呢?那么,这里的一些帮助是稍微更容易消化。
首先,您需要HTML网页的形式将谎言。这种形式必须确定文件最大规模的上传,并必须有文件上传领域本身
<form enctype="multipart/form-data" action="upload.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<input type="submit" value="Send File" />
</form>
MAX_FILE_SIZE界定的尽可能多的文件大小,以字节为单位,当然。名称属性上传领域(指定的档案价值的type属性)的重要组成部分,正如我们稍后将使用此在我们的脚本来知道哪些要上传的文件(这是用来支持多种上传) 。
下一步,我们要上传文件。但首先,重要的是要理解美元_FILE [ ]数组。
在美元_FILE [ ]数组,有一个项目,每一个领域中上传的形式发送用户此脚本。因此,在我们的案例,有一个指数命名为' userfield ' ,为一个外地与这个名字在我们的形式。每个值的数组也是一个关联数组,以下项和值(改写明确从文件) :
<?php
$target_file = '/path/to/upload/'.basename($_FILES['userfile']['name']);
?>
关键价值
'名称'文件名使用客户的计算机。
'型'的MIME类型的文件(如图像/ gif格式) 。该浏览器并不总是提供这方面的,和价值不应假定是正确的。
'大小'的大小上传的文件(以字节为单位) 。
' tmp_name '的文件给上传的文件,其中应立即转移,并更名后的成功上传。地点是无关紧要的,因为你使用的方法把文件( move_uploaded_file ,我使用后)都知道的位置。
'错误'的错误代码(或成功的代码,如果0 )的问题发生在上传。 (错误代码)
表1 :简要介绍了钥匙和价值观
所以,现在我们可以开始进行业务。首先,我们得到的文件名,我们将想给上传的文件,而且目录,我们希望把它。
<?php
$target_file = '/path/to/upload/'.basename($_FILES['userfile']['name']);
?>
使用basename是绝对必要的。没有这一点,您正在运行一个巨大的安全风险。如果用户要上传文件的名称,开始使用相对路径上升,如../../../, ,他们最终将得到根除,可以随时随地浏览到的文件的落实更多的目录后,原来的起点的道路。
警告:这是非常重要的是,可以确保服务器的权限写信给这个目录。如果您的服务器正在运行的任何发行版的Linux或Mac OS X ,您可能会需要属性的目录。
下一步,您只需将上传的文件为target_file 。我认为这样做的,如果为了试验的成功。
<?php
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $target_file)) {
// Succeeded
echo 'Yay!';
} else {
// Failed
echo 'No!';
}
?>
这真的就是这么回事。很简单,啊?您可以展开这一点,通过阅读PHP的文件序列和unserializing对象。如果您有任何疑问,可随时张贴的论坛。
根据客户的要求他们可以在后台手动的设置和过滤一些不应该出现的关键字,所以就写出下面的代码了喽,字符过滤程序
<!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
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
相关文章
php 中file_get_contents超时问题的解决方法
file_get_contents超时我知道最多的原因就是你机器访问远程机器过慢,导致php脚本超时了,但也有其它很多原因,下面我来总结file_get_contents超时问题的解决方法总结。...2016-11-25- 相信很多站长都遇到过这样一个问题,访问页面时出现408错误,下面一聚教程网将为大家介绍408错误出现的原因以及408错误的解决办法。 HTTP 408错误出现原因: HTT...2017-01-22
- php如何实现抓取网页图片,相较于手动的粘贴复制,使用小程序要方便快捷多了,喜欢编程的人总会喜欢制作一些简单有用的小软件,最近就参考了网上一个php抓取图片代码,封装了一个php远程抓取图片的类,测试了一下,效果还不错分享...2015-10-30
- 下面我们来看一篇关于Android子控件超出父控件的范围显示出来方法,希望这篇文章能够帮助到各位朋友,有碰到此问题的朋友可以进来看看哦。 <RelativeLayout xmlns:an...2016-10-02
- ps软件是现在非常受大家喜欢的一款软件,有着非常不错的使用功能。这次文章就给大家介绍下ps把文字背景变透明的操作方法,喜欢的一起来看看。 1、使用Photoshop软件...2017-07-06
intellij idea快速查看当前类中的所有方法(推荐)
这篇文章主要介绍了intellij idea快速查看当前类中的所有方法,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下...2020-09-02- 1.在没有设置默认值的情况下: 复制代码 代码如下:SELECT userinfo.id, user_name, role, adm_regionid, region_name , create_timeFROM userinfoLEFT JOIN region ON userinfo.adm_regionid = region.id 结果:...2014-05-31
js导出table数据到excel即导出为EXCEL文档的方法
复制代码 代码如下: <!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 ht...2013-10-13- 批量更新mysql更新语句很简单,更新一条数据的某个字段,一般这样写:复制代码 代码如下:UPDATE mytable SET myfield = 'value' WHERE other_field = 'other_value';如果更新同一字段为同一个值,mysql也很简单,修改下where即...2013-10-04
- 本文涉及的主题虽然很基础,在许多人看来属于小伎俩,但在JavaScript基础知识中属于一个综合性的话题。这里会涉及到对象属性的封装、原型、构造函数、闭包以及立即执行表达式等知识。公有方法 公有方法就是能被外部访问...2015-11-08
- ps软件是一款非常不错的图片处理软件,有着非常不错的使用效果。这次文章要给大家介绍的是ps怎么制作倒影,一起来看看设计倒影的方法。 用ps怎么做倒影最终效果̳...2017-07-06
安卓手机wifi打不开修复教程,安卓手机wifi打不开解决方法
手机wifi打不开?让小编来告诉你如何解决。还不知道的朋友快来看看。 手机wifi是现在生活中最常用的手机功能,但是遇到手机wifi打不开的情况该怎么办呢?如果手机wifi...2016-12-21- 最近想自学PHP ,做了个验证码,但不知道怎么搞的,总出现一个如下图的小红叉,但验证码就是显示不出来,原因如下 未修改之前,出现如下错误; (1)修改步骤如下,原因如下,原因是apache权限没开, (2)点击打开php.int., 搜索extension=ph...2013-10-04
- 单个字符分割 string s="abcdeabcdeabcde"; string[] sArray=s.Split('c'); foreach(string i in sArray) Console.WriteLine(i.ToString()); 输出下面的结果: ab de...2020-06-25
- javascript控制页面控件隐藏显示的两种方法,方法的不同之处在于控件隐藏后是否还在页面上占位 方法一: 复制代码 代码如下: document.all["panelsms"].style.visibility="hidden"; document.all["panelsms"].style.visi...2013-10-13
连接MySql速度慢的解决方法(skip-name-resolve)
最近在Linux服务器上安装MySql5后,本地使用客户端连MySql速度超慢,本地程序连接也超慢。 解决方法:在配置文件my.cnf的[mysqld]下加入skip-name-resolve。原因是默认安装的MySql开启了DNS的反向解析。如果禁用的话就不能...2015-10-21- 本篇文章是对C#方法进行了详细的总结与介绍,需要的朋友参考下...2020-06-25
- 步骤:Window -> PHP -> Editor -> Templates,这里可以设置(增、删、改、导入等)管理你的模板。新建文件注释、函数注释、代码块等模板的实例新建模板,分别输入Name、Description、Patterna)文件注释Name: 3cfileDescriptio...2013-10-04
- EXCEL数据上传到SQL SERVER中的方法需要注意到三点!注意点一:要把EXCEL数据上传到SQL SERVER中必须提前把EXCEL传到服务器上.做法: 在ASP.NET环境中,添加一个FileUpload上传控件后台代码的E.X: 复制代码 代码如下: if...2013-09-23
- mysql锁定单个表的方法 复制代码 代码如下:mysql>lock table userstat read; mysql>unlock tables; 页级的典型代表引擎为BDB。 表级的典型代表引擎为MyISAM,MEMORY以及很久以前的ISAM。 行级的典型代表引擎为INN...2014-05-31