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

防范php木马

1、防止跳出web目录 (严重采用)
  首先修改httpd.conf,如果你只允许你的php脚本程序在web目录里操作,还可以修改httpd.conf文件限制php的操作路径。比如你的web目录是/usr/local/apache/htdocs,那么在httpd.conf里加上这么几行:
  php_admin_value open_basedir /usr/local/apache/htdocs
  这样,如果脚本要读取/usr/local/apache/htdocs以外的文件将不会被允许,如果错误显示打开的话会提示这样的错误:
  Warning: open_basedir restriction in effect. File is in wrong directory in /usr/local/apache/htdocs/open.php on line 4 等等。
如果有多个基于域名的虚拟主机
<VirtualHost *>
ServerName     www.test1.com
DocumentRoot /usr/local/apache/htdocs/test1
<Directory /usr/local/apache/htdocs/test1>
     php_admin_value open_basedir     /usr/local/apache/htdocs/test1
</Directory>
</VirtualHost>
注意:在php_admin_value open_basedir别忘了加上php.ini中指定的PHP临时上传目录和session保存目录,不然会无法上传文件、存取session
php.ini中按如下配置:
upload_tmp_dir = "/tmp"
session.save_path = "/var/phpsession"
  2、防止php木马执行webshell (严重采用)
  打开safe_mode,
  在,php.ini中设置
  disable_functions= passthru,exec,shell_exec,system
  二者选一即可,也可都选
  3、防止php木马读写文件目录 (好像没有要求这么严格,不推荐采用。)
  在php.ini中的
  disable_functions= passthru,exec,shell_exec,system
  后面加上php处理文件的函数
  主要有
  fopen,mkdir,rmdir,chmod,unlink,dir
  fopen,fread,fclose,fwrite,file_exists
  closedir,is_dir,readdir.opendir
  fileperms.copy,unlink,delfile
  即成为
  disable_functions= passthru,exec,shell_exec,system,fopen,mkdir,rmdir,chmod,unlink,dir
  ,fopen,fread,fclose,fwrite,file_exists
  ,closedir,is_dir,readdir.opendir
  ,fileperms.copy,unlink,delfile
  ok,大功告成,php木马拿我们没辙了.


相关文档:

CentOS通过yum升级php到5.2.9版本的方法

CentOS的php版本默认为5.1.6,然后在5.2.9版本之前的的php都存在一个漏洞,但是目前网上很多地方都无法使用yum update php*升级到5.2.9,比较常见的是升级到5.2.6版本的,经过搜索国外资料,现在终于找到一种升级CentOS的php到5.2.9的方法。
运行下面命令:
# wget http://download.fedora.redhat.com/pub/epel/5/i386/ep ......

Berkeley 5.0.21提供的PHP扩展的Bug

今天装了个Berkeley 5.0.21进行测试。
顺利编译了自带的php_db4模块后,进行测试。发现del操作报错:
illegal flag specified to DB->del
<?php
dl('db4.so');
$db = new Db4();
$db->open(null, 'info.db', 'info');
$db->put('key', 'value');
var_dump($db->del('key'));
$db->close();
$db ......

如何将php获得的时间转换为北京时间

从php5.10开始,php中加入了时区的设置,在php中显示的时间都是格林威治标准时间,这就造成了我们中国的用户会差八个小时的问题!
相关设置是修改php.ini中的 date.timezone 参数:
[Date]
; Defines the default timezone used by the date functions
;date.timezone =
默认是关闭的,只需把注释去掉,改为即可
[Dat ......

PHP函数

extract() //将数组中的键名作为变量名,键值作为变量值
例:
form.html
<form action="action.php" method="post">
<input type="text" name="username">
<input type="password" name="password">
<input type="submit&quo ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号