Calendar

2010年三月
« 二    
1234567
891011121314
15161718192021
22232425262728
293031  

Translator

PHP-MVC-UML

http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/

是个很好的php mvc实现过程展示,已经说地很翔实了。我比较笨,为了更好的理解他的代码实现,用UML把它的设计思路画了一下。

class 

sequence

PCI Data Security Standards (PCI DSS)

写paypal程序有一段时间了。关于电子支付,安全问题非同小可,总是要反复留心。但不管怎么谨慎,按照个人主观标准做的东西总不能保证质量。近日开始系统阅读paypal开发文档,没想到第一课就是PCI DSS(Payment Card Industry Data Security Standards支付卡数据安全工业标准)。有了标准就有质量保证的依据,应该是做电子支付的必修课了。

什么是PCI DSS?

  • PCI DSS是:支付卡数据安全工业标准
    • 按照支付卡行业安全标准委员会(PCI SSC)需求设计
    • 保护持卡人在支付卡欺诈、遗失、偷盗情况下的数据安全规范
  • PCI SSC 管理此标准
  • 支付卡公司执行此标准(如:Visa, MasterCard, DiscoverCard and American Express)
  • PCI DSS适用于持卡人数据存储、处理与传输的全过程 

PCI DSS 目标概略

  • 建设与维护安全网络
  • 保护持卡人数据
  • 维护系统弱点
  • 实行健壮的访问控制
  • 监控与测试网络
  • 维护一个安全策略

遵守PCI DSS

遵守PCI DSS不是一次性目标,它是不断评估与执行的过程。

  • 评估:确定持卡人数据与相关IT设施清单,分析弱点
  • 纠正:修正弱点并保持只对指定数据进行处理
  • 报告:记录所有的行动日志,并通知收单行与有关经营体

PCI DSS 12 Core Requirements

Build and Maintain a Secure Network
Requirement 1 Install and maintain a firewall configuration to protect cardholder data
Requirement 2 Do not use vendor-supplied defaults for system passwords and other security parameters

Protect Cardholder Data
Requirement 3 Protect stored cardholder data
Requirement 4 Encrypt transmission of cardholder data across open, public networks

Maintain a Vulnerability Management Program
Requirement 5 Use and regularly update anti-virus software
Requirement 6 Develop and maintain secure systems and applications

Implement Strong Access Control Measures
Requirement 7 Restrict access to cardholder data by business need-to-know
Requirement 8 Assign a unique ID to each person with computer access
Requirement 9 Restrict physical access to cardholder data

Regularly Monitor and Test Networks
Requirement 10 Track and monitor all access to network resources and cardholder data
Requirement 11 Regularly test security systems and processes

Click to continue reading

PHP防止错误显示

防止错误信息出现在浏览器上,可以在相应的语句前面加上@符号,比如下面的连接数据库的语句,在数据库连接失败时不在浏览器上显示错误信息:
$db=@mysql_connect(…);

JavaScript 调用SOAP

一直想直接用JavaScrip调用Xurrency.com 的 SOAP,实现汇率的AJAX,找到个JavaScript SOAP Client做了测试。本机上IE,Chrome成功返回,firefox与在host上报错,”access to restricted URI DENIED”不知其所以然。

决定放弃。改用php soapclient+jquery ajax实现。

JavaScript SOAP Client测试代码如下:

?Download test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>XHTML-document</title>
<script type="text/javascript" src="soapclient.js"></script>
<script type="text/javascript">
 
	function currency (){
		var url = "http://xurrency.com/servidor_soap.php";
		var pl = new SOAPClientParameters();
		pl.add("amount", 5);
		pl.add("base", "usd");
		pl.add("target", "eur");
		SOAPClient.invoke(url, "getValue", pl, true, Currency_callBack);
	}
 
	function Currency_callBack(r){
		 alert(r);
		}
 
</script>
</head>
<body>
	<form action="">
<input type=button value="Invoke" onclick="currency();" />
</form>
</body>
</html>

Zend Studio debug Tips

How to Set $_GET and $_POST vars in the debugger

  1. Click on the ‘variables’ tab of your debug window. You will notice a lot of global, server, and environment vairables. Among them, you should see the empty $_GET and $_POST arrays.
  2. Right-click on either array and choose ‘assign value.’ To input an array, type it in this format:array(value1 => foo, value2 => bar, name => ‘James Cricket’)

ZendDebugger for Freebad

Requester:

disable your ZendOptimizer and eaccelerator
download ZendDebugger.os place to /usr/local/lib/php/20060613/ 

  ZendDebugger.so for freebsd (2.2 MiB, 37 hits)
You need to be a registered user to download this file.

Install:

edit your php.ini. For me php.ini is in /usr/local/etc/

[Zend]
zend_extension=/usr/local/lib/php/20060613/ZendDebugger.so
zend_debugger.allow_hosts=10.10.2.0/24
zend_debugger.expose_remotely=always
zend_debugger.connector_port=10001

restart your apache

Look in the phpinfo( ) got the result below!

zenddebugger

Click to continue reading

php防止恶意访问小程序

本来写PAYPAL IPN response 时用来防止反复尝试的函数,保护性很差,后来改成原地址审核($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);if(!preg_match(‘/paypal\.com$/’, $hostname)) {…..),所以个就弃用了。在删之前记录不来,应该有更好的算法,不知道谁有研究。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
if (!avoid_refresh ('15')) die ("Hacking Attempt!!");
.....
.....
.....
function avoid_refresh ($time){
	session_start();
  if (isset($_SESSION["post_sep"])) {
      if (time() - $_SESSION["post_sep"] < $time)  {
      	$_SESSION["post_sep"] = time();
        return false;
      } else {
          $_SESSION["post_sep"] = time();
          return true;
      }
  } else {
      $_SESSION["post_sep"] = time();
      return true;
  }
}

PHP 数据加密

数据加密在我们生活中的地位已经越来越重要了,尤其是考虑到在网络上发生的大量交易和传输的大量数据。如果对于采用安全措施有兴趣的话,也一定会有兴趣了解PHP提供的一系列安全功能。在本篇文章中,我们将介绍这些功能,提供一些基本的用法,以便你能够为自己的应用软件中增加安全功能。

预备知识

在详细介绍PHP的安全功能之前,我们需要花点时间来向没有接触过这方面内容的读者介绍一些有关密码学的基本知识,如果对密码学的基本概念已经非常熟悉,就可以跳过去这一部分。

密码学可以通俗地被描述为对加/解密的研究和实验,加密是将易懂的资料转换为不易懂资料的过程,解密则是将不易懂的资料转换为原来易懂资料的过程。不易懂的资料被称作密码,易懂的资料被称作明码。

数据的加/解密都需要一定的算法,这些算法可以非常地简单,如著名的凯撒码,但当前的加密算法要相对复杂得多,其中一些利用现有的方法甚至是无法破译的 。

PHP的加密功能只要有一点使用非Windows平台经验的人可能对crypt()也相当熟悉,这一函数完成被称作单向加密的功能,它可以加密一些明码,但不能够将密码转换为原来的明码。尽管从表面上来看这似乎是一个没有什么用处的功能,但它的确被广泛用来保证系统密码的完整性。因为,单向加密的口令一旦落入第三方人的手里,由于不能被还原为明文,因此也没有什么大用处。在验证用户输入的口令时,用户的输入采用的也是单向算法,如果输入与存储的经加密后的口令相匹配,则输入的口信一定是正确的。

crypt()函数

PHP同样提供了使用其crypt()函数完成单向加密功能的可能性。我将在这里简要地介绍该函数:

string crypt (string input_string [, string salt])

其中的input_string参数是需要加密的字符串,第二个可选的salt是一个位字串,它能够影响加密的暗码,进一步地排除被称作预计算攻击的可能性。缺省情况下,PHP使用一个2个字符的DES干扰串,如果你的系统使用的是MD5(我将在以后介绍MD5算法),它会使用一个12个字符的干扰串。顺便说一下,可以通过执行下面的命令发现系统将要使用的干扰串的长度:

print “My system salt size is: ”. CRYPT_SALT_LENGTH;

系统也可能支持其他的加密算法。crypt()支持四 种算法,下面是它支持的算法和相应的salt参数的长度:

算法 Salt长度
CRYPT_STD_DES 2-character (Default)
CRYPT_EXT_DES 9-character
CRYPT_MD5 12-character beginning with $
CRYPT_BLOWFISH 16-character beginning with $

Click to continue reading

Pages: 1 2

Page 1 of 6123456