php 安全
如何不使用prepared statment,而是用过滤的方法避免SQL注入呢?
一般来说mysql自带的过滤函数是比较可靠的。mysql_real_escape_string()
但是这个函数在某些字符集中有问题,比如GBK。如果你用UTF8那没关系。
在PHP里设置数据库的字符集不应该用:mysql_query("SET NAMES UTF8");
而应该用:mysql_set_charset()
这样mysql_real_escape_string()在处理GBK编码的时候就不会出问题了。
mysql_real_escape_string() not safe when SET NAMES is used
use mysql_set_charset() instead.
Note: This is the preferred way to change the charset. Using mysql_query() to execute SET NAMES .. is not recommended.
SET NAMES is usually used to switch the encoding from what is default to what the application needs. This is done in a way that mysql_real_escape_string doesn’t know about this. This means if you switch to some multi byte encoding that allows backslash as 2nd 3rd 4th… byte you run into trouble, because mysql_real_escape_string doesn’t escape correctly. UTF-8 is safe…
Safe way to change encoding is mysql_set_charset, but that is only available in new PHP versions
相关文档:
访客计数器的流程如下
第一位用户浏览某页。
服务器程序从数据库或文件中读取该页被浏览次数。
将次数加一储存,并将它送回第一位用户。
第二位用户浏览某页。
服务器程序从数据库或文件中读取该页被浏览次数。
将次数再加一储存,并将它送回第二位用户。
<?php
$filename="./visit";
$handle=fop ......
引用http://www.linuxtone.org/html/76/t-2776.html
有时候nginx,apache,mysql,php编译完了想看看编译参数可以用以下方法
nginx编译参数:
#/usr/local/nginx/sbin/nginx -V
CODE:
nginx version: nginx/0.6.32
built by gcc 4.1.2 20071124 (Red Hat 4.1.2-42)
configure arguments: --user=www --group=www --p ......
<?php
function remove_directory($dir) {
if ($handle = opendir("$dir")) {
while (false !== ($item = readdir($handle))) {
if ($item != "." && $item != "..") {
......
参考资料:
1.
2. http://www.phpeclipse.com/wiki/Howto/XDebugAndPHPEclipse
1.下载XDebug http://xdebug.org/download.php
选择于PHP版本相对应的的 5.2 VC6 (32 bit) 下载,改名成php_xdebug.dll后复制到E:/APMServ5.2.6/PHP/ext/中
2. 在php.ini中添加以下内容,并将zend的其他应用关掉(注释掉其他zend_extens ......
PHP5.0后,php面向对象提成更多方法,使得php更加的强大!!
一些在PHP叫魔术方法的函数,在这里介绍一下:其实在一般的应用中,我们都需要用到他们!!
1.__construct() 当实例化一个对象的时候,这个对象的这个方法首先被调用。
Java代码
class Test { function __construct() { ec ......