3月25日消息:据PHP官方网站发布新闻得知其wiki账号被盗,原因是wiki.php.net漏洞导致的,而wiki的账号和php代码源的SVN提交权限相关联,从而导致PHP代码受污染。

据了解,PHP5.3.6以及其后续版本的代码已经被污染,目前只能把未受污染的代码版本确保到PHP5.3.5,下载PHP代码的用户,需谨慎。

原文内容:
The wiki.php.net box was compromised and the attackers were able to collect wiki account credentials. No other machines in the php.net infrastructure appear to have been affected. Our biggest concern is, of course, the integrity of our source code. We did an extensive code audit and looked at every commit since 5.3.5 to make sure that no stolen accounts were used to inject anything malicious. Nothing was found. The compromised machine has been wiped and we are forcing a password change for all svn accounts.
We are still investigating the details of the attack which combined a vulnerability in the Wiki software with a Linux root exploit.
 

内容大致是:

由于wiki账号被盗,PHP的代码源极有可能被污染,当然,PHP团队已经做最大的努力以保证自PHP5.3.5版本的代码没有收到污染,并且强迫SVN修改现有的密码。

而事件目前的状态是,他们仍然没法锁定漏洞所在,因为他们仍在排查。

一个很明显的问题是,PHP5.3.6以及其后续版本的代码已经被污染,目前只能把未受污染的代码版本确保到PHP5.3.5,下载PHP代码的人,要小心了。

而windows.php.net和wiki.php.net也已经暂停访问。

分类: 电脑技巧 标签: 日期:2011-03-25

方法一:

<?php
function extend_1($file_name)
{
$retval="";
$pt=strrpos($file_name, ".");
if ($pt) $retval=substr($file_name, $pt+1, strlen($file_name) - $pt);
return ($retval);
}
?>
方法二:

function extend_2($file_name)
{
$extend = pathinfo($file_name);
$extend = strtolower($extend["extension"]);
return $extend;

方法三:

function extend_3($file_name)
{
$extend =explode("." , $file_name);
$va=count($extend)-1;
return $extend[$va];
}

分类: 网页设计 标签: 日期:2011-02-07

<?php
class word
{
function start()
{
ob_start();
print'<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">';
}
function save($path)
{
print "</html>";
$data = ob_get_contents();
ob_end_clean();
$this->wirtefile ($path,$data);
}
function wirtefile ($fn,$data)
{
$fp=fopen($fn,"wb");
fwrite($fp,$data);
fclose($fp);
}
}
?>

分类: 网页设计 标签:, 日期:2011-01-01

插入数据

include 'pdbm.php';

$timestart = explode(' ', microtime());
$timestart = $timestart[0] + $timestart[1];

$pdbm = new Pdbm('test');
$pdbm->open(PDBM_CREAT | PDBM_REWD);

for ($i = 0; $i < 100000; $i++) {
    $pdbm->insert("key{$i}", "value{$i}");
}

$timetime = explode(' ', microtime());
$timetime = $timetime[0] + $timetime[1];

echo $timetime - $timestart;
//*/

获取数据

include 'pdbm.php';

$timestart = explode(' ', microtime());
$timestart = $timestart[0] + $timestart[1];

$pdbm = new Pdbm('test');
$pdbm->open(PDBM_REWD);

$val = $pdbm->fetch('key9999');
if ($val == NULL) {
    echo 'Not found</br>';
} else {
    echo $val."<br/>";
}

//$pdbm->delete('key100'); //delete data

$val = $pdbm->fetch('key100');
if ($val == NULL) {
    echo 'Not found</br>';
} else {
    echo $val."<br/>";
}

$timetime = explode(' ', microtime());
$timetime = $timetime[0] + $timetime[1];

echo $timetime - $timestart;
//*/

(更多...)

分类: 网页设计 标签: 日期:2010-12-30

网上有很多探针,不过各种版本都很老了,而且目前很少人在更新这个东西,最近测试服务器环境网上下了一些探针,各有优缺点。于是找了个时间把各个版本的探针功能揉在了一起,去掉了广告,清爽了许多。

这个探针是自己用来的,不过还是习惯性的分享出来,对于原版的探针不好意思去掉了链接和广告,服务器性能去掉了过时很久的信息,如果有机会,以后会添加上一些最新服务器的测试信息的。

PHP探针下载地址:php探针

分类: 网页设计 标签:, 日期:2010-12-21

一、如何选择 PHP5.3 的 VC9 版本和 VC6 版本
VC6 版本是使用 Visual Studio 6 编译器编译的,如果你的 PHP 是用 Apache 来架设的,那你就选择 VC6 版本。
VC9 版本是使用 Visual Studio 2008 编译器编译的,如果你的 PHP 是用 IIS 来架设的,那你就选择 VC9 版本。
二、如何选择 PHP5.3 的 Thread Safe 和 Non Thread Safe 版本
先从字面意思上理解,Thread Safe 是线程安全,执行时会进行线程(Thread)安全检查,以防止有新要求就启动新线程的 CGI 执行方式而耗尽系统资源。Non Thread Safe 是非线程安全,在执行时不进行线程(Thread)安全检查。
再来看 PHP 的两种执行方式:ISAPI 和 FastCGI。
ISAPI 执行方式是以 DLL 动态库的形式使用,可以在被用户请求后执行,在处理完一个用户请求后不会马上消失,所以需要进行线程安全检查,这样来提高程序的执行效率,所以如果是以 ISAPI 来执行 PHP,建议选择 Thread Safe 版本;
而 FastCGI 执行方式是以单一线程来执行操作,所以不需要进行线程的安全检查,除去线程安全检查的防护反而可以提高执行效率,所以,如果是以 FastCGI 来执行 PHP,建议选择 Non Thread Safe 版本。
官方并不建议你将Non Thread Safe 应用于生产环境,所以我们选择Thread Safe 版本的PHP来使用。

分类: 电脑技巧 标签: 日期:2010-12-15

安装Apache Mysql PHP
安装之前,保证你的版本是最新的。使用命令:(“#”表示你应该以root的身份来运行)。

 # aptitude update && aptitude upgrade
mysql
使用下面的命令来安装mysql:

 # aptitude install mysql-server mysql-client
安装完mysql server后,你应该修改下root的密码。*此步骤对debian Lenny版本无效,因为在安装的时候你将会被要求输入mysql root用户的密码。

# /usr/bin/mysqladmin -u root password 'enter-your-good-new-password-here'
为了安全起见,你应该不使用root账户来运行数据库,而是新建一个账户来从一个PHP脚本来连接你的mysql数据库。

apache2
 # aptitude install apache2 apache2-doc
PHP
# aptitude install php5 php5-mysql libapache2-mod-php5
配置Apache Mysql PHP
Apache2 配置文件: /etc/apache2/apache2.conf

当需要的时候,你可以编辑此配置文件。

测试PHP
为了测试php接口, 编辑文件 /var/www/apache2-default/test.php:

# nano /var/www/apache2-default/test.php
插入下面代码

<?php phpinfo(); ?>
最后,使用浏览器访问 http://SERVERIP/apache2-default/test.php 来检测下.

分类: 电脑技巧 标签:, , , 日期:2010-11-16

使用PHP开发应用程序,尤其是网站程序,常常需要生成随机密码,如用户注册生成随机密码,用户重置密码也需要生成一个随机的密码。随机密码也就是一串固定长度的字符串,这里我收集整理了几种生成随机字符串的方法,以供大家参考。

方法一:

1、在 33 – 126 中生成一个随机整数,如 35,

2、将 35 转换成对应的ASCII码字符,如 35 对应 #

3、重复以上 1、2 步骤 n 次,连接成 n 位的密码

该算法主要用到了两个函数,mt_rand ( int $min , int $max )函数用于生成随机整数,其中 $min – $max 为 ASCII 码的范围,这里取 33 -126 ,可以根据需要调整范围,如ASCII码表中 97 – 122 位对应 a – z 的英文字母,具体可参考 ASCII码表; chr ( int $ascii )函数用于将对应整数 $ascii 转换成对应的字符。

function create_password($pw_length = 8  )
{
    $randpwd = '';
    for ($i = 0; $i < $pw_length; $i++)
    {
        $randpwd .= chr(mt_rand(33, 126));
    }
    return $randpwd;
}

// 调用该函数,传递长度参数$pw_length = 6
echo create_password(6);
  (更多...)

分类: 网页设计 标签: 日期:2010-08-25

PHP代码的最后一行可以不带 ;分号 不会导致PHP错误。
&& 运算符有时候可以代替 if  比如 $zhuxiaotian='123'; echo !$zhuxiaotian && die('你是笨蛋');
三元操作符时执行多条件运算代替if..众所周知 三元操作符就两句 中间不能插入; 分号否则就会报错,有时候需要添加什么东西或者运算就会导致PHP错误,但是我们通过这样格式做很多事。

<?php
$a='sadsad';/若是空则 C变量为333 则不空 C变量为 sss
$a?($b='123').($c='333'):($b='456').($c='sss');
echo $c;
?>

分类: 网页设计 标签: 日期:2010-01-29

作用:取得随机字符串

参数:
1、(int)$length = 32 #随机字符长度
2、(int)$mode = 0 #随机字符类型,0为大小写英文和数字,1为数字,2为小写字母,3为大写字母,4为大小写字母,5为大写字母和数字,6为小写字母和数字

定义类代码

< ?php
class getRandstrClass
{
function getCode ($length = 32, $mode = 0)
{
switch ($mode) {
case '1':
$str = '1234567890';
break;
case '2':
$str = 'abcdefghijklmnopqrstuvwxyz';
break;
case '3':
$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
case '4':
$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
break;
case '5':
$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
break;
case '6':
$str = 'abcdefghijklmnopqrstuvwxyz1234567890';
break;
default:
$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
break;
}

使用说明:
1.将以上代码另存为random.php
2.在需要的页面引入random.php
< ?php require_once('random.php'); ?>
3. 使用之前定义的类

$randString = '';
$len = strlen($str)-1;

for($i = 0;$i < $length;$i ++){
$num = mt_rand(0, $len);
$randString .= $str[$num];
}
return $randString ;
}
}
?>

代码:
< ?php
$code = new getRandstrClass();
$length = 32;
$mode = 0;
$str = $code->getCode($length, $mode);
echo $str;
?>

分类: 网页设计 标签:, 日期:2009-11-13