js收藏网址

On 08/25/2010, in javascript, by kilobug
function favorite(){
	if( arguments[0] ) var url = arguments[0], title = arguments[1] ? arguments[1] : url;
	else var url = location.href, title = document.title ? document.title : url;
 
	if (typeof(document.all) == 'object') external.addFavorite(url, title);
	else if (typeof(sidebar) == 'object') sidebar.addPanel(title, url, '');
	else alert('您使用的浏览器不支持javascript收藏网址!\n请手动收藏,或使用IE/火狐浏览器!');
}

说明:favorite([url[, title]])
参数:
string url[option]: 收藏的网址,默认当前网址
string title[option]: 收藏的网址标题,默认当前网址标题
Notes: 不支持chrome

Tagged with:  

js操作cookie

On 08/25/2010, in javascript, by kilobug
function cookie(key){
	var key = arguments[0], val = arguments[1], item;
	if( !val ) return (item = (new RegExp('(?:\\;\\s?|^)'+$.regexp.quote(key)+'\\=([^\\;]+)','i')).exec(document.cookie)) ? decodeURIComponent(item[1]) : null;
	else{
		var expire = arguments[2], path = arguments[3], domain = arguments[4], secure = arguments[5];
		item = key + '=' + encodeURIComponent(val);
		if( expire ) item += ';expires=' + new Date( (new Date).getTime() + expire*1000 );
		item += ';path=' + (path ? path : '/');
		if( domain ) item += ';domain=' + domain;
		if( secure ) item += ';secure=' + secure;
		document.cookie = item;
		return true;
	}
}

说明:cookie(key[, val[, expire[, path[, domain[, secure]]]]])
参数:
string key: cookie键名(当只有该参数时,返回键名对应的值)
string val: 值
string path: 路径
string domain: 所属域名
bool secure: 是否只允许https协议访问

Tagged with:  

google首页报错:404

On 08/13/2010, in webserver, by kilobug

google用jsp?

Tagged with:  

apache多用户虚拟机配置

On 08/06/2010, in linux, webserver, by kilobug
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<VirtualHost *:80>
    ServerAdmin webmaster@xxxx.com
    DocumentRoot "/home/httpd/xxxx.com/wwwroot"
    ServerName xxxx.com
    ServerAlias www.xxxx.com *.xxxx.com
    ErrorLog logs/xxxx.com-error_log
    CustomLog logs/xxxx.com-access_log common
    <Directory /home/httpd/xxxx.com/wwwroot>
        AllowOverride None
        Order deny,allow
    </Directory>
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^[^\.]+\.xxxx\.com$
        RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
        RewriteRule ^([^\.]+)\.xxxx\.com(.*)$ /home/httpd/xxxx.com/wwwroot/$1$2 [L]
    </IfModule>
</VirtualHost>
Tagged with:  

php5.x扩展:xxtea可逆加密

On 08/05/2010, in c, php, by kilobug

最近在学习开发php5.x扩展,就拿xxtea加密算法来练手;

此扩展采用国外的xxtea加密算法,配合md5、base64,实现php下可逆加密功能;

扩展函数:
xxtea加密函数

function xxtea_encode(string $str, string $key[, bool $is_base64])

parameter:
$str: 需加密的内容,可以是二进制内容
$key: 密钥
$is_base64[可选]: 结果是否进行base64编码,默认为true
return: [二进制|字符串]

xxtea解密函数

function xxtea_decode($str, $key[, $is_base64])

parameter:
$str: 需解密的内容,可以是二进制内容
$key: 密钥
$is_base64[可选]: 密文是否base64编码过,默认为true
return: [二进制|字符串]

扩展源码下载:php_xxtea.zip

BUG: 当加密的字符长度小于2,无法加密,返回原值

有关tea算法资料:http://en.wikipedia.org/wiki/XXTEA

算法描述:

“微型加密算法(TEA)及其相关变种(XTEA,Block TEA,XXTEA) 都是分组加密算法,它们很容易被描述,实现也很简单(典型的几行代码)。

TEA 算法最初是由剑桥计算机实验室的 David Wheeler 和 Roger Needham 在 1994 年设计的。该算法使用 128 位的密钥为 64 位的信息块进行加密,它需要进行 64 轮迭代。该算法使用了一个神秘常数δ作为倍数,它来源于黄金比率,以保证每一轮加密都不相同。但δ的精确值似乎并不重要,这里 TEA 把它定义为 δ=「(√5 – 1)231」(也就是程序中的 0×9E3779B9 )。”

其实,TEA跟我们的关系非常密切,因为QQ就是使用16轮迭代的TEA算法。

XXTEA是其最新的变种,于1998年提出。目前还没有人找到对其进行攻击的方法,是对前面一些变种的改进。XXTEA 算法很安全,而且非常快速,非常适合应用于 Web 开发中。

Tagged with:  

判断是否空对象

On 08/04/2010, in javascript, by kilobug
1
2
3
4
5
function isEmptyObj( o ) {
    if( typeof(o) != 'object' ) return false;
    for( var k in o ) return false;
    return true;
}
Tagged with:  

清空文件命令

On 08/03/2010, in linux, by kilobug
1
true > 路径
Tagged with:  

在RHEL系列中,当apache启动或运行时报错,并根据提示进行配置后,仍然报错,可尝试关闭SELINUX

Continue reading »

Tagged with:  
1
2
3
4
5
6
7
8
9
10
11
iptables -F /* 清除所有规则 */
 iptables -A INPUT -p tcp --dport 22 -j ACCEPT /*允许包从22端口进入*/
 iptables -A OUTPUT -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT /*允许从22端口进入的包返回*/
 iptables -A OUTPUT -p udp --dport 53 -j ACCEPT /* 域名解析端口,一般不开 */
 iptables -A INPUT -p udp --sport 53 -j ACCEPT /* 域名解析端口,一般不开 */
 iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT /*允许本机访问本机*/
 iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
 iptables -A INPUT -p tcp -s 0/0 --dport 80 -j ACCEPT /*允许所有IP访问80端口*/
 iptables -A OUTPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
 iptables-save > /etc/sysconfig/iptables /*保存配置*/
 iptables -L /* 显示iptables列表 */
Tagged with:  

无觅相关文章插件,快速提升流量