<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>KiloBug</title>
	<atom:link href="http://www.kilobug.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kilobug.com</link>
	<description>努力学习，天天向上，做个和谐的三好人民...</description>
	<lastBuildDate>Sun, 05 Sep 2010 16:46:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>退出telnet命令</title>
		<link>http://www.kilobug.com/archives/284</link>
		<comments>http://www.kilobug.com/archives/284#comments</comments>
		<pubDate>Sun, 05 Sep 2010 16:46:50 +0000</pubDate>
		<dc:creator>kilobug</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kilobug.com/?p=284</guid>
		<description><![CDATA[1、ctrl+] 2、ctrl+c]]></description>
			<content:encoded><![CDATA[<p>1、ctrl+]<br />
2、ctrl+c</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kilobug.com/archives/284/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SSH证书配置</title>
		<link>http://www.kilobug.com/archives/275</link>
		<comments>http://www.kilobug.com/archives/275#comments</comments>
		<pubDate>Sun, 05 Sep 2010 04:33:46 +0000</pubDate>
		<dc:creator>kilobug</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.kilobug.com/?p=275</guid>
		<description><![CDATA[1、添加帐号 useradd test 2、使用test登录 su - test 3、创建公/密钥（会在当前目录生成两个文件：id_rsa和id_rsa.pub） ssh-keygen -t rsa 4、将生成的id_rsa.pub改名为 authorized_keys，并设置400权限 也可以不改名，但在第6步时需要更改AuthorizedKeysFile的路径 cd ./.ssh/ mv id_rsa.pub authorized_keys chmod<a href="http://www.kilobug.com/archives/275" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p><strong>1、添加帐号</strong></p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">useradd test</pre></div></div>

<p><strong>2、使用test登录</strong></p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">su - test</pre></div></div>

<p><strong>3、创建公/密钥（会在当前目录生成两个文件：id_rsa和id_rsa.pub）</strong></p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">ssh-keygen -t rsa</pre></div></div>

<p><strong>4、将生成的id_rsa.pub改名为 authorized_keys，并设置400权限</strong><br />
也可以不改名，但在第6步时需要更改AuthorizedKeysFile的路径</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">cd ./.ssh/
mv id_rsa.pub authorized_keys
chmod 400 authorized_keys</pre></div></div>

<p><strong>5、将id_rsa文件下载到本地，删除服务器的id_rsa文件</strong></p>
<p><strong>6、配置/etc/ssh/sshd-config</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">Protocol <span style="">2</span>
ServerKeyBits <span style="">1024</span>
PermitRootLogin no  #禁止root登录
&nbsp;
#RSA认证
RSAAuthentication yes
#开启公钥验证
PubkeyAuthentication yes
#验证文件路径
AuthorizedKeysFile    .ssh/authorized_keys
&nbsp;
#禁止密码认证
PasswordAuthentication no
#禁止空密码
PermitEmptyPasswords no</pre></div></div>

<p><strong>7、重启sshd服务</strong></p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">service sshd restart</pre></div></div>

<p><strong>8、连接工具使用下载的id_rsa文件做证书即可（如提示输入密码，表示该密码为本地证书加密密码，输入即可）</strong></p>
<p><strong style="color:red">ps: 如果是远程操作，建议先不禁止密码和root登录，待ssh证书登录正常后再禁止！</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kilobug.com/archives/275/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>过滤危险html标签及属性</title>
		<link>http://www.kilobug.com/archives/266</link>
		<comments>http://www.kilobug.com/archives/266#comments</comments>
		<pubDate>Sat, 28 Aug 2010 03:06:18 +0000</pubDate>
		<dc:creator>kilobug</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.kilobug.com/?p=266</guid>
		<description><![CDATA[&#160; /* 过滤危险html */ function filter_html&#40; $str &#41; &#123; /* 过滤style标签 */ return preg_replace_callback&#40; /* 过滤style标签内容 */ '/(\&#60;\s*style[^\&#62;]*\&#62;)((?:(?!\&#60;\s*\/\s*style\s*\&#62;).)*)(\&#60;\s*\/\s*style\s*\&#62;)?/i', create_function&#40;'$str', 'return<a href="http://www.kilobug.com/archives/266" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">/* 过滤危险html */</span>
<span style="color: #000000; font-weight: bold;">function</span> filter_html<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$str</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">/* 过滤style标签 */</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">preg_replace_callback</span><span style="color: #009900;">&#40;</span>
			<span style="color: #666666; font-style: italic;">/* 过滤style标签内容 */</span>
			<span style="color: #0000ff;">'/(\&lt;\s*style[^\&gt;]*\&gt;)((?:(?!\&lt;\s*\/\s*style\s*\&gt;).)*)(\&lt;\s*\/\s*style\s*\&gt;)?/i'</span><span style="color: #339933;">,</span>
			<span style="color: #990000;">create_function</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'$str'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'return $str[1] . filter_css($str[2]) . $str[3];'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span>
				<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
					<span style="color: #666666; font-style: italic;">/* 删除html注释 */</span>
					<span style="color: #0000ff;">'/\&lt;\!\-\-.*?\-\-\&gt;/i'</span><span style="color: #339933;">,</span>
					<span style="color: #666666; font-style: italic;">/* 删除标签：script、link、object、embed、iframe、frame、frameset */</span>
					<span style="color: #0000ff;">'/\&lt;\s*(script|object|embed|link|i?frame(set)?)[^\&gt;]*\&gt;(.*?\&lt;\s*\/\s*\\1\s*\&gt;)?/i'</span><span style="color: #339933;">,</span>
					<span style="color: #666666; font-style: italic;">/* 删除事件、javascript协议、css表达式 */</span>
					<span style="color: #0000ff;">'/\&lt;[^\&gt;]+((on[a-z]+\s*\=|(javascript|vbscript|behavior)\s*\:[^\;\&quot;\\\']|(import|expression)\s*\()[^\&gt;]*)+\&gt;?/i'</span><span style="color: #339933;">,</span>
				<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
				<span style="color: #000088;">$str</span>
			<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">/* 过滤样式正文 */</span>
<span style="color: #000000; font-weight: bold;">function</span> filter_css<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$str</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">/* 删除注释、javascript协议、表达式 */</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/(\/\*((?!\*\/).)*\*\/|\/\*|\*\/)/i'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'/(expression|import)\s*\((.*?\))?|(javascript|vbscript|behavior)\s*\:/i'</span><span style="color: #339933;">,</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>过滤步骤：</strong><br />
1、删除html注释（防止用这个来绕过第二步）；<br />
2、删除script、link、object、embed、iframe、frame、frameset以及拥有on开头、包含javascript:[^;]或expression的属性的标签；<br />
3、删除css中的注释（防止用这个来绕过第四步）；<br />
4、删除expression表达式、javascript协议、behavior属性、import属性、vbscript协议；</p>
<p><span style="color:red;"><strong>PS: 还有什么漏洞请email到 webmaster（a）kilobug.com</strong></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kilobug.com/archives/266/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php数组排序函数</title>
		<link>http://www.kilobug.com/archives/257</link>
		<comments>http://www.kilobug.com/archives/257#comments</comments>
		<pubDate>Thu, 26 Aug 2010 04:57:30 +0000</pubDate>
		<dc:creator>kilobug</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.kilobug.com/?p=257</guid>
		<description><![CDATA[/* 数组排序 */ function array_sort&#40; $data, $order = array&#40;&#41; &#41; &#123; if&#40; !$data &#124;&#124; !$order &#41; return $data; &#160; $arglist<a href="http://www.kilobug.com/archives/257" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/* 数组排序 */</span>
<span style="color: #000000; font-weight: bold;">function</span> array_sort<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #000088;">$order</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$data</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #000088;">$order</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$arglist</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$v2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arglist</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$arglist</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$arglist</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$k2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$argstr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$order</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$v</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$argstr</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">',$arglist[\''</span><span style="color: #339933;">.</span><span style="color: #000088;">$k</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'\'], SORT_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$v</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$argstr</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #990000;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'array_multisort('</span><span style="color: #339933;">.</span><span style="color: #000088;">$argstr</span><span style="color: #339933;">.</span><span style="color: #0000ff;">',$data);'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$data</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>说明：</strong>array_sort($data, $order)<br />
<strong>参数：</strong><br />
array $data: 需要排序的数组<br />
array $order: 排序，格式：array(&#8216;键名&#8217; => &#8216;DESC|ASC&#8217;&#8230;)</p>
<p><strong>实例：</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'uid'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'kilobug'</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'uid'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">99</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'kilobug'</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #339933;">....</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> array_sort<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'uid'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'DESC'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'username'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ASC'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.kilobug.com/archives/257/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>好友动态数据库设计思路</title>
		<link>http://www.kilobug.com/archives/250</link>
		<comments>http://www.kilobug.com/archives/250#comments</comments>
		<pubDate>Thu, 26 Aug 2010 04:37:02 +0000</pubDate>
		<dc:creator>kilobug</dc:creator>
				<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.kilobug.com/?p=250</guid>
		<description><![CDATA[table: behavior 行为表 table: friend_behavior 好友行为关系表 table [behavior] field: bid[int 10]:行为ID uid[int 10]: 用户ID event[varchar 20]:事件（如添加好友则用friend_add表示 behavior[text]: 行为内容（json序列化数组后的字符串） flagid: 标识ID，用于删除动态<a href="http://www.kilobug.com/archives/250" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>table: behavior 行为表<br />
table: friend_behavior 好友行为关系表</p>
<p><strong>table [behavior] field: </strong><br />
    bid[int 10]:行为ID<br />
    uid[int 10]: 用户ID<br />
    event[varchar 20]:事件（如添加好友则用friend_add表示<br />
    behavior[text]: 行为内容（json序列化数组后的字符串）<br />
    flagid: 标识ID，用于删除动态<br />
    lastime[int 10]: 最后时间<br />
<strong>table [behavior] index:</strong><br />
    bid: 主键<br />
    uid, event, flag: 联合唯一索引</p>
<p><strong>table [friend_behavior] field：</strong><br />
    uid: 用户ID<br />
    fuid: 好友ID<br />
    bid: 行为ID<br />
    lastime: 最后时间<br />
<strong>table [friend_behavior] index：</strong><br />
    uid, fuid: 联合普通索引<br />
    bid: 普通索引</p>
<p>实例：<br />
1、查询指定用户最新的好友动态：</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> fb<span style="color: #66cc66;">.</span>fuid<span style="color: #66cc66;">,</span> b<span style="color: #66cc66;">.</span>event<span style="color: #66cc66;">,</span> b<span style="color: #66cc66;">.</span>behavior<span style="color: #66cc66;">,</span> b<span style="color: #66cc66;">.</span>lastime <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`friend_behavior`</span> fb <span style="color: #993333; font-weight: bold;">LEFT</span> <span style="color: #993333; font-weight: bold;">JOIN</span> <span style="color: #ff0000;">`behavior`</span> b <span style="color: #993333; font-weight: bold;">ON</span><span style="color: #66cc66;">&#40;</span>b<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`uid`</span><span style="color: #66cc66;">=</span>fb<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`fuid`</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> fb<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`uid`</span><span style="color: #66cc66;">=</span>xxx <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> b<span style="color: #66cc66;">.</span><span style="color: #ff0000;">`lastime`</span> <span style="color: #993333; font-weight: bold;">DESC</span></pre></div></div>

<p>2、查询指定用户最新的动态</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> uid<span style="color: #66cc66;">,</span> event<span style="color: #66cc66;">,</span> behavior<span style="color: #66cc66;">,</span> lastime <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">`behavior`</span> <span style="color: #993333; font-weight: bold;">WHERE</span> <span style="color: #ff0000;">`uid`</span><span style="color: #66cc66;">=</span>xxx <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #ff0000;">`lastime`</span> <span style="color: #993333; font-weight: bold;">DESC</span></pre></div></div>

<p>&#8230;&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kilobug.com/archives/250/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>php生产指定范围长度的随机字符</title>
		<link>http://www.kilobug.com/archives/248</link>
		<comments>http://www.kilobug.com/archives/248#comments</comments>
		<pubDate>Thu, 26 Aug 2010 02:47:37 +0000</pubDate>
		<dc:creator>kilobug</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.kilobug.com/?p=248</guid>
		<description><![CDATA[function random&#40; $min, $max = NULL &#41; &#123; $len = isset&#40;$max&#41; ? mt_rand&#40;$min, $max&#41; : $min; $str = ''; for&#40;$i<a href="http://www.kilobug.com/archives/248" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> random<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$min</span><span style="color: #339933;">,</span> <span style="color: #000088;">$max</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$len</span> <span style="color: #339933;">=</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$max</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">mt_rand</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$min</span><span style="color: #339933;">,</span> <span style="color: #000088;">$max</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$min</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$len</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$str</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mt_rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">32</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">128</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$str</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>说明：random($min[, $max])<br />
参数：<br />
int $min: 最短长度<br />
int $max[option]: 最大长度</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kilobug.com/archives/248/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>原图无法显示时，加载指定图片显示</title>
		<link>http://www.kilobug.com/archives/246</link>
		<comments>http://www.kilobug.com/archives/246#comments</comments>
		<pubDate>Wed, 25 Aug 2010 03:51:43 +0000</pubDate>
		<dc:creator>kilobug</dc:creator>
				<category><![CDATA[(x)html/css]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.kilobug.com/?p=246</guid>
		<description><![CDATA[&#60;img src=&#34;&#34; onerror=&#34;this.onerror=null; this.src='替换图片路径';&#34; /&#62; Notes: 其中的this.onerror=null是为了防止指定图片无法加载导致内存溢出的问题；]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;img src=&quot;&quot; onerror=&quot;this.onerror=null; this.src='替换图片路径';&quot; /&gt;</pre></div></div>

<p><span style="color:red;"><strong>Notes:</strong> 其中的this.onerror=null是为了防止指定图片无法加载导致内存溢出的问题；</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kilobug.com/archives/246/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>js获取遮罩层所需的高度及宽度</title>
		<link>http://www.kilobug.com/archives/243</link>
		<comments>http://www.kilobug.com/archives/243#comments</comments>
		<pubDate>Wed, 25 Aug 2010 03:42:51 +0000</pubDate>
		<dc:creator>kilobug</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.kilobug.com/?p=243</guid>
		<description><![CDATA[width = document.body.scrollWidth; height = document.body.scrollHeight; if&#40;document.documentElement&#41;&#123; width = Math.max&#40;width, document.documentElement.scrollWidth&#41;; height = Math.max&#40;height, document.documentElement.scrollHeight&#41;; &#125; 说明： width：浏览器内容宽度 height：>=浏览器内容区域可见高度]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">width <span style="color: #339933;">=</span> document.<span style="color: #660066;">body</span>.<span style="color: #660066;">scrollWidth</span><span style="color: #339933;">;</span>
height <span style="color: #339933;">=</span> document.<span style="color: #660066;">body</span>.<span style="color: #660066;">scrollHeight</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">documentElement</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	width <span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>width<span style="color: #339933;">,</span> document.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">scrollWidth</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	height <span style="color: #339933;">=</span> Math.<span style="color: #660066;">max</span><span style="color: #009900;">&#40;</span>height<span style="color: #339933;">,</span> document.<span style="color: #660066;">documentElement</span>.<span style="color: #660066;">scrollHeight</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>说明：<br />
width：浏览器内容宽度<br />
height：>=浏览器内容区域可见高度</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kilobug.com/archives/243/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>动态执行html中的js</title>
		<link>http://www.kilobug.com/archives/235</link>
		<comments>http://www.kilobug.com/archives/235#comments</comments>
		<pubDate>Wed, 25 Aug 2010 03:34:41 +0000</pubDate>
		<dc:creator>kilobug</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.kilobug.com/?p=235</guid>
		<description><![CDATA[function execHtml&#40; str &#41;&#123; var match, reg = /\&#60;script[^\&#62;]*\&#62;(.*?)\&#60;\/script\&#62;/gi; while&#40; &#40;match = reg.exec&#40;str&#41;&#41; != null &#41; str = str.substr&#40;0, match.index&#41;<a href="http://www.kilobug.com/archives/235" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> execHtml<span style="color: #009900;">&#40;</span> str <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> match<span style="color: #339933;">,</span> reg <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/\&lt;script[^\&gt;]*\&gt;(.*?)\&lt;\/script\&gt;/gi</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>match <span style="color: #339933;">=</span> reg.<span style="color: #660066;">exec</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> match.<span style="color: #660066;">index</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span>match<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> str.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span>match.<span style="color: #660066;">index</span><span style="color: #339933;">+</span>match<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> str<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>说明：</strong>execHtml(str)<br />
<strong>参数：</strong><br />
string str: html和js混合字符串</p>
<p><span style="color: red;"><strong>Notes:</strong> 不支持document.write[ln]操作</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kilobug.com/archives/235/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>js停止冒泡事件</title>
		<link>http://www.kilobug.com/archives/233</link>
		<comments>http://www.kilobug.com/archives/233#comments</comments>
		<pubDate>Wed, 25 Aug 2010 03:29:58 +0000</pubDate>
		<dc:creator>kilobug</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.kilobug.com/?p=233</guid>
		<description><![CDATA[function cancelBubble&#40; e &#41; &#123; if &#40; e &#38;&#38; e.stopPropagation &#41; e.stopPropagation&#40;&#41;; else window.event.cancelBubble = true; &#125; 说明：cancelBubble(e) 参数： event<a href="http://www.kilobug.com/archives/233" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> cancelBubble<span style="color: #009900;">&#40;</span> e <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> e <span style="color: #339933;">&amp;&amp;</span> e.<span style="color: #660066;">stopPropagation</span> <span style="color: #009900;">&#41;</span> e.<span style="color: #660066;">stopPropagation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">else</span> window.<span style="color: #660066;">event</span>.<span style="color: #660066;">cancelBubble</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>说明：</strong>cancelBubble(e)<br />
<strong>参数：</strong><br />
event e: 元素事件</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kilobug.com/archives/233/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
