<?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>刘华栋的博客 &#187; PHP/Mysql</title>
	<atom:link href="http://www.liuhuadong.com/archives/category/php/feed" rel="self" type="application/rss+xml" />
	<link>http://www.liuhuadong.com</link>
	<description>Thinking different</description>
	<lastBuildDate>Mon, 06 Feb 2012 09:14:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>mysql中主键重新重新计数的方法</title>
		<link>http://www.liuhuadong.com/archives/1334/index.html</link>
		<comments>http://www.liuhuadong.com/archives/1334/index.html#comments</comments>
		<pubDate>Sat, 10 Dec 2011 17:24:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/Mysql]]></category>

		<guid isPermaLink="false">http://www.liuhuadong.com/?p=1334</guid>
		<description><![CDATA[今天操作mysql数据库，发现一个问题。当一个表里面有一个自增长的主键时，插入了10条数据，主键id自动增长到10，由于某原因需要删除第10条数据，再插入新的数据时，新的主键会是11，而不是10。 问题分析： 这里的主键（AUTO_INCREMENT）对于数据库来说就是一个不重复且自增长的数值，一旦删除后再补上，有可能会造成数据库的内部紊乱，例如当数据量很大的时候要把数据都提前一个，那是需要相当大代价的。 解决办法： 如果确实需要把这个AUTO_INCREMENT设置为1开始计数，只有清空表，是“清空”表，phpmyadmin里面有该按钮。语法使用TRUNCATE语句。例如 TRUNCATE table &#8216;abc&#8217;。这时候数据库会更新该表为初始状态，计数器自然也开始从1开始了。]]></description>
			<content:encoded><![CDATA[<p>今天操作mysql数据库，发现一个问题。当一个表里面有一个自增长的主键时，插入了10条数据，主键id自动增长到10，由于某原因需要删除第10条数据，再插入新的数据时，新的主键会是11，而不是10。</p>
<p>问题分析：<br />
这里的主键（AUTO_INCREMENT）对于数据库来说就是一个不重复且自增长的数值，一旦删除后再补上，有可能会造成数据库的内部紊乱，例如当数据量很大的时候要把数据都提前一个，那是需要相当大代价的。</p>
<p>解决办法：<br />
如果确实需要把这个AUTO_INCREMENT设置为1开始计数，只有清空表，是“清空”表，phpmyadmin里面有该按钮。语法使用TRUNCATE语句。例如 TRUNCATE table &#8216;abc&#8217;。这时候数据库会更新该表为初始状态，计数器自然也开始从1开始了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuhuadong.com/archives/1334/index.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一些更新细节</title>
		<link>http://www.liuhuadong.com/archives/1092/index.html</link>
		<comments>http://www.liuhuadong.com/archives/1092/index.html#comments</comments>
		<pubDate>Sat, 25 Dec 2010 16:51:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/Mysql]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.liuhuadong.com/?p=1092</guid>
		<description><![CDATA[1.垃圾评论一直是让人极其深恶痛绝的意见事情。尝试了一些防spam插件依然不好用，索性更改为数字验证。这样评论只需多作一下数字运算即可。 2.超过一个月的文章不允许再被评论。 3.服务器新增了memcached，同时博客启用了memcache，服务器响应速度大增，相当畅快。ping值25ms的情况下，几乎感受不到服务器反应时间，速度终于提升n倍。随后还要整理一下关于memcached在linux的安装教程。 4.博客改名为“刻程”后感觉实在没有深度，还是换回原来的“因思而变”吧，只可惜网上很多叫这个名字的博客，小不爽。 5.这里下雪了，u know? 6.这张图片有必要着重标记一下： 今天是圣诞节，顺祝我认识的所有人节日快乐……晕，好像这会儿已经是26日凌晨了]]></description>
			<content:encoded><![CDATA[<p>1.垃圾评论一直是让人极其深恶痛绝的意见事情。尝试了一些防spam插件依然不好用，索性更改为数字验证。这样评论只需多作一下数字运算即可。<br />
2.超过一个月的文章不允许再被评论。<br />
3.服务器新增了memcached，同时博客启用了memcache，服务器响应速度大增，相当畅快。ping值25ms的情况下，几乎感受不到服务器反应时间，速度终于提升n倍。随后还要整理一下关于memcached在linux的安装教程。<br />
4.博客改名为“刻程”后感觉实在没有深度，还是换回原来的“因思而变”吧，只可惜网上很多叫这个名字的博客，小不爽。<br />
5.这里下雪了，u know?<br />
6.这张图片有必要着重标记一下：<br />
<a href="http://xhatblog-wordpress.stor.sinaapp.com/uploads/2010/12/IMAG0049.jpg"><img src="http://xhatblog-wordpress.stor.sinaapp.com/uploads/2010/12/IMAG0049.jpg" alt="" title="IMAG0049" width="200"  class="alignnone size-full wp-image-1102" /></a><br />
今天是圣诞节，顺祝我认识的所有人节日快乐……晕，好像这会儿已经是26日凌晨了</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuhuadong.com/archives/1092/index.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP和串口通信的方法介绍</title>
		<link>http://www.liuhuadong.com/archives/1074/index.html</link>
		<comments>http://www.liuhuadong.com/archives/1074/index.html#comments</comments>
		<pubDate>Wed, 01 Dec 2010 20:48:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/Mysql]]></category>

		<guid isPermaLink="false">http://www.liuhuadong.com/?p=1074</guid>
		<description><![CDATA[工作原因，php在部分应用偶尔和串口直接通信，需要和rs232、rs485接口上的数据进行通信。网上搜索众多解决方案，出现很多问题，这里总结一下php与串口通信的方法大全。 php与串口通信，基本有两种途径 1.通过php扩展dio。 下载dio扩展：http://www.cyberspice.org.uk/downloads/dio-0.0.4rc3.tgz 在php.ini打开dio扩展。 dio开启后可以通过dio_open dio_read等函数进行通信。但dio默认只是在linux下的，好像pecl也有编译后的php_dio.dll，但我在win下测试其实无法正常使用，可能是我php版本太高（5.3.3）。 dio扩展如果能打开，网上自然有很多实例 &#60;?php &#160; $c = stream_context_create(array('dio' =&#62; &#160;&#160; &#160;array('data_rate' =&#62; 115200, &#160;&#160; &#160; &#160; &#160; &#160;'data_bits' =&#62; 8, &#160;&#160; &#160; &#160; &#160; &#160;'stop_bits' =&#62; 1, &#160;&#160; &#160; &#160; &#160; &#160;'parity' =&#62; 0, &#160;&#160; &#160; &#160; &#160; &#160;'is_canonical' =&#62; 1)));&#160;&#160; if (PATH_SEPARATOR != &#34;;&#34;) {&#160;&#160; &#160;$filename = &#34;dio.serial:///dev/ttyS0&#34;;&#160; } [...]]]></description>
			<content:encoded><![CDATA[<p>工作原因，php在部分应用偶尔和串口直接通信，需要和rs232、rs485接口上的数据进行通信。网上搜索众多解决方案，出现很多问题，这里总结一下php与串口通信的方法大全。</p>
<p>php与串口通信，基本有两种途径<br />
1.通过php扩展dio。<br />
下载dio扩展：http://www.cyberspice.org.uk/downloads/dio-0.0.4rc3.tgz<br />
在php.ini打开dio扩展。<br />
dio开启后可以通过dio_open dio_read等函数进行通信。但dio默认只是在linux下的，好像pecl也有编译后的php_dio.dll，但我在win下测试其实无法正常使用，可能是我php版本太高（5.3.3）。<br />
dio扩展如果能打开，网上自然有很多实例</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">&lt;?php</span><span style="color: Gray;"> <br />&nbsp; </span><span style="color: #00008b;">$c</span><span style="color: Gray;"> = </span><span style="color: Blue;">stream_context_create</span><span style="color: Olive;">(</span><span style="color: Green;">array</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">dio</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> =&gt; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">array</span><span style="color: Olive;">(</span><span style="color: #8b0000;">'</span><span style="color: Red;">data_rate</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> =&gt; </span><span style="color: Maroon;">115200</span><span style="color: Gray;">, <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #8b0000;">'</span><span style="color: Red;">data_bits</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> =&gt; </span><span style="color: Maroon;">8</span><span style="color: Gray;">, <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #8b0000;">'</span><span style="color: Red;">stop_bits</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> =&gt; </span><span style="color: Maroon;">1</span><span style="color: Gray;">, <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #8b0000;">'</span><span style="color: Red;">parity</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> =&gt; </span><span style="color: Maroon;">0</span><span style="color: Gray;">, <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #8b0000;">'</span><span style="color: Red;">is_canonical</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> =&gt; </span><span style="color: Maroon;">1</span><span style="color: Olive;">)))</span><span style="color: Gray;">;<br />&nbsp;<br />&nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Green;">PATH_SEPARATOR</span><span style="color: Gray;"> != </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">;</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: #00008b;">$filename</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">dio.serial:///dev/ttyS0</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">;<br />&nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;"> </span><span style="color: Green;">else</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: #00008b;">$filename</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">dio.serial://COM1</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">;<br />&nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;"><br />&nbsp;<br /></span><span style="color: Blue;">?&gt;</span></div></div>
<p>2.PHP_SER扩展<br />
这是一个第三方扩展，可以在php5.3.3上正常使用，我测试结果是比较稳定，提供了单字节流通信和异步通信。对于单字节流通信我还专门请教了作者，发现原来可以通过loop读取数据流的。需要注意的是ser_write()的数据是字符型，但是ser_read()的数据则是10进制。所以发送的时候最好转换为hex，接收后由十进制再转为十六进制才能正常使用。<br />
还有就是php_ser作为第三方扩展，作者是收费的。免费版本没有功能限制，只是每次收发字节数不能超过1024字节。</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Green;">function</span><span style="color: Gray;"> </span><span style="color: Blue;">x_get_cgqbh</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: #00008b;">$str</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">'</span><span style="color: Red;">at+ver?</span><span style="color: #8b0000;">'</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: #00008b;">$str</span><span style="color: Gray;"> = </span><span style="color: Blue;">hexToStr</span><span style="color: Olive;">(</span><span style="color: #00008b;">$str</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">ser_open</span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">COM1</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Maroon;">9600</span><span style="color: Gray;">, </span><span style="color: Maroon;">8</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">None</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">1</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">None</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;">; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Blue;">ser_isopen</span><span style="color: Olive;">())</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">opened, post data ......</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Green;">else</span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">false</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br />&nbsp;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">ser_write</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: #00008b;">$str</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">sleep</span><span style="color: Olive;">(</span><span style="color: Maroon;">1</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: #00008b;">$str</span><span style="color: Gray;"> = </span><span style="color: Blue;">ser_read</span><span style="color: Olive;">()</span><span style="color: Gray;">;<br />&nbsp;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">ser_close</span><span style="color: Olive;">()</span><span style="color: Gray;">;<br />&nbsp;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: #00008b;">$str</span><span style="color: Gray;">;<br />&nbsp;<br /></span><span style="color: Olive;">}</span><span style="color: Gray;"></span></div></div>
<p>php_ser地址：忘了，回头补上。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuhuadong.com/archives/1074/index.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tx的编程风格</title>
		<link>http://www.liuhuadong.com/archives/1066/index.html</link>
		<comments>http://www.liuhuadong.com/archives/1066/index.html#comments</comments>
		<pubDate>Thu, 18 Nov 2010 20:54:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/Mysql]]></category>

		<guid isPermaLink="false">http://www.liuhuadong.com/?p=1066</guid>
		<description><![CDATA[腾讯开放平台下载的sdk中的代码。上图不说话： 运行错误提示，php5.3下修正后才能正常使用： 仔细想想，我还是不由得想说：大公司又怎样。]]></description>
			<content:encoded><![CDATA[<p>腾讯开放平台下载的sdk中的代码。上图不说话：<br />
<img src="http://xhatblog-wordpress.stor.sinaapp.com/uploads/2010/11/png" alt="" title="未命名" width="422" height="124" class="alignnone size-full wp-image-1067" /><br />
运行错误提示，php5.3下修正后才能正常使用：<br />
<img src="http://xhatblog-wordpress.stor.sinaapp.com/uploads/2010/11/2.png" alt="" title="未命名2" width="451" height="124" class="alignnone size-full wp-image-1068" /><br />
仔细想想，我还是不由得想说：大公司又怎样。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuhuadong.com/archives/1066/index.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>mysql字段内容大小写转换问题解决方案</title>
		<link>http://www.liuhuadong.com/archives/1012/index.html</link>
		<comments>http://www.liuhuadong.com/archives/1012/index.html#comments</comments>
		<pubDate>Fri, 13 Aug 2010 19:44:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/Mysql]]></category>

		<guid isPermaLink="false">http://www.liuhuadong.com/?p=1012</guid>
		<description><![CDATA[有需求转换mysql大小写，查了半天，网上竟然没有现成函数，都是用存贮过程来解决的，不太合理。于是想到使用替换功能，把A变成a，从a到z执行26次，但想想这办法也太二了。。强迫症又犯了，所以能得到下边的解决方案： update table set mediafile = lower(mediafile) 说明：mysql 的 lower(), uppper() 和 lcase(), ucase()支持字段的 小写，大写，]]></description>
			<content:encoded><![CDATA[<p>有需求转换mysql大小写，查了半天，网上竟然没有现成函数，都是用存贮过程来解决的，不太合理。于是想到使用替换功能，把A变成a，从a到z执行26次，但想想这办法也太二了。。强迫症又犯了，所以能得到下边的解决方案：<br />
<code>update table set mediafile = lower(mediafile)</code><br />
说明：mysql 的 lower(), uppper() 和 lcase(), ucase()支持字段的 小写，大写，</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuhuadong.com/archives/1012/index.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在线生成二维码</title>
		<link>http://www.liuhuadong.com/archives/927/index.html</link>
		<comments>http://www.liuhuadong.com/archives/927/index.html#comments</comments>
		<pubDate>Sun, 20 Jun 2010 05:46:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/Mysql]]></category>
		<category><![CDATA[互联网]]></category>

		<guid isPermaLink="false">http://www.liuhuadong.com/?p=927</guid>
		<description><![CDATA[二维码在国外（特别是日本，因为二维码发源于日本）用的移动互联应用比较多，由于国内近年来智能手机和移动互联网的发展迅速，二维码的应用也渐渐发热。国内目前最为广泛的二维码应用就是新版火车票，虽然现在检票还没有全面进入扫描时代，但这是早晚的事情。 二维码的方便之处在于可以以更加规范、简单的存储信息，简单的说，有点“世界普通话”的味道，这个标准可以让数据在各种物理设备间方便的存贮、转存信息和数据。 于是我抽时间写了一个在线生成二维码的程序，规范来自ISO/IEC 18004:2006，这个规范不支持中文，但在全球通用，一般应用于网址、电话的存贮。 你能看出来这个图片存贮的一句歌词么： 以上大小在htc G2-G7手机上都能被识别(一句歌词，你能读出来么:P)。 想象一下：网页的重要内容旁边都有一个二维码来表示当前内容，用户如果想把这个信息转存到手机，只需要扫描一下该二维码即可瞬间以文字信息存储到手机上；反之，如果一个纸质的内容旁边富有二维码，想转换为电脑文字数据，有是多面的方便。 再想一下：肯德基的优惠券信息直接可以以二维码方式发放和读取（事实上听同事说kfc已经这样了）。 如果生活变成这样，科技和人类智慧带给我们的幸福感是不是会更加多一点。 我刚写的一个在线生成二维码地址程序： http://www.liuhuadong.com/labs/2weima/index.php 欢迎大家使用并提出宝贵意见 Android下扫描软件：Barcode Scanner]]></description>
			<content:encoded><![CDATA[<p>二维码在国外（特别是日本，因为二维码发源于日本）用的移动互联应用比较多，由于国内近年来智能手机和移动互联网的发展迅速，二维码的应用也渐渐发热。国内目前最为广泛的二维码应用就是新版火车票，虽然现在检票还没有全面进入扫描时代，但这是早晚的事情。<br />
<img src="http://jb.sznews.com/res/1/1161/2009-12/09/A16/res07_attpic_brief.jpg" alt="" /><br />
二维码的方便之处在于可以以更加规范、简单的存储信息，简单的说，有点“世界普通话”的味道，这个标准可以让数据在各种物理设备间方便的存贮、转存信息和数据。<br />
于是我抽时间写了一个在线生成二维码的程序，规范来自ISO/IEC 18004:2006，这个规范不支持中文，但在全球通用，一般应用于网址、电话的存贮。<br />
你能看出来这个图片存贮的一句歌词么：<br />
<img src="http://www.liuhuadong.com/labs/2weima/temp/test5e30e08d1e9a6cf60993ab0ce58a1800.png" alt="" /><br />
以上大小在htc G2-G7手机上都能被识别(一句歌词，你能读出来么:P)。<br />
想象一下：网页的重要内容旁边都有一个二维码来表示当前内容，用户如果想把这个信息转存到手机，只需要扫描一下该二维码即可瞬间以文字信息存储到手机上；反之，如果一个纸质的内容旁边富有二维码，想转换为电脑文字数据，有是多面的方便。<br />
再想一下：肯德基的优惠券信息直接可以以二维码方式发放和读取（事实上听同事说kfc已经这样了）。<br />
如果生活变成这样，科技和人类智慧带给我们的幸福感是不是会更加多一点。</p>
<p>我刚写的一个<strong><span style="color:red">在线生成二维码地址</span></strong>程序：<br />
<a href="http://www.liuhuadong.com/labs/2weima/index.php">http://www.liuhuadong.com/labs/2weima/index.php</a><br />
欢迎大家使用并提出宝贵意见</p>
<p>Android下扫描软件：<a href="http://www.liuhuadong.com/labs/2weima/scan.apk">Barcode Scanner</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuhuadong.com/archives/927/index.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Assigning the return value of new by reference is deprecated in xxxx的解决办法</title>
		<link>http://www.liuhuadong.com/archives/904/index.html</link>
		<comments>http://www.liuhuadong.com/archives/904/index.html#comments</comments>
		<pubDate>Tue, 20 Apr 2010 12:18:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/Mysql]]></category>

		<guid isPermaLink="false">http://www.liuhuadong.com/?p=904</guid>
		<description><![CDATA[自从php5.3，越来越多的人会遇到“Assigning the return value of new by reference is deprecated in xxxx”这样的提示，尤其是在国外产品中（例如wordpress、joolma），很多人的解决办法很简单：把php版本换回就版本就ok了。毫无疑问这是个好办法，对这种遇到问题不求甚解的态度可能会让人看到些什么。我认为要换回php的旧版本，其实是对php技术爱好者的一种羞辱（用词不当，大致是这个意思）。解决办法：php5.3开始后，废除了php中的”=&#038;”符号，所以要想复制，直接用=引用即可。详细如下： 1、PHP5对象复制是采用引用的方式；2、如果不采用引用方式，则需要在复制对象时加关键字 clone;3、如果在复制的过程中，同时要变更某些属性，则增加函数_clone();]]></description>
			<content:encoded><![CDATA[<p>自从php5.3，越来越多的人会遇到“Assigning the return value of new by reference is deprecated in xxxx”这样的提示，尤其是在国外产品中（例如wordpress、joolma），很多人的解决办法很简单：把php版本换回就版本就ok了。毫无疑问这是个好办法，对这种遇到问题不求甚解的态度可能会让人看到些什么。我认为要换回php的旧版本，其实是对php技术爱好者的一种羞辱（用词不当，大致是这个意思）。解决办法：php5.3开始后，废除了php中的”=&#038;”符号，所以要想复制，直接用=引用即可。详细如下：</p>
<div class="hl-surround"><div class="hl-main">1、PHP5对象复制是采用引用的方式；<br />2、如果不采用引用方式，则需要在复制对象时加关键字 clone;<br />3、如果在复制的过程中，同时要变更某些属性，则增加函数_clone();</div></div>
]]></content:encoded>
			<wfw:commentRss>http://www.liuhuadong.com/archives/904/index.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>中国移动飞信通信协议分析</title>
		<link>http://www.liuhuadong.com/archives/867/index.html</link>
		<comments>http://www.liuhuadong.com/archives/867/index.html#comments</comments>
		<pubDate>Mon, 12 Apr 2010 18:13:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/Mysql]]></category>
		<category><![CDATA[不知所云]]></category>

		<guid isPermaLink="false">http://www.liuhuadong.com/?p=867</guid>
		<description><![CDATA[作者：刘华栋 2010.4.13 本文目的在于探讨学习，请勿用于非学习外的任何用途，否则后果自负。 出于某些需求，要用到手机短信提醒功能，自然还是免费的好。网上流传了很多版本关于飞信的通信协议，大同小异（基本都是基于2.0的，飞信现在2010协议版本为4.0），当飞信更新了一部分协议内容时，这些流行的协议似乎有些问题出现，最典型的就是： 旧版本飞信协议支持输入任何手机号码，只要是发送者好友，即可发送手机短信。新版本飞信协议支持输入任何飞信号码，只要是发送者好友，即可发送手机短信。新旧版本都支持发送登陆者自身手机号码为接收手机的短信。 如果我有100个飞信好友，莫非我要记住100个飞信号码？如果我要提供一个飞信接口给大伙，莫非大伙要记住他们好友的飞信号码？ 当然，写本文的目的就在于从根本上解决上述两个问题（其实是一回事）。 通过对飞信协议多个版本进行了抓包分析，发现数据包格式没什么大的变化。唯一重要的变化是第五行： M fetion.com.cn SIP-C/4.0F:88888888I: 10 Q: 2 MT: sip:99999999@fetion.com.cn;p=640//上面一行旧版本协议这里是://T: tel:13599999999C: text/plainK: SaveHistoryL: 4 这里就出现一个问题，要想发送手机短信，提交过来手机号不行，需要提交手机号对应的飞信号码才能识别，如何才能把手机号码转换为飞信号码就是解决问题的关键。经对新协议抓包分析，发现并不能直接从手机号码转换成飞信号码，但是中间有一个很不错的变量叫做”user-id”，每个手机号对应一个飞信号码，同样对应每个user-id（至于为什么会多出来一个user-id，我想可能是飞信公司准备把飞信号码当做一种商业资源来使用吧）。其实我们用户的真正的飞信号码是这个user-id，所谓飞信号码，无非是一个数字昵称(another nickname)而已。明白这些，问题就好办了： 1.发送接收者手机号码，抓包获取该号码的user-id；2.发送请求好友列表信息（登陆后自动完成）；3.匹配1中user-id，对应的飞信号码(注意格式:fetion_num@fetion.com.cn)；4.发送飞信号码、短信内容，Done 具体代码省略，关键正则函数： //获取飞信号码function get_fetion_id($userid, $rst) {&#160;&#160; &#160;preg_match(&#34;/ri=&#34;sip:(d{6,10}+)@fetion.com.cn;p=(d{0,6}+)&#34;&#160;&#160; &#160; &#160; &#160;user-id=&#34;$userid/i&#34;,$rst, $matches);&#160;&#160; &#160;//同理重构函数获取user-id&#160;&#160; &#160;//preg_match(&#34;/user-id=&#34;([0-9]+)&#34;/i&#34;, $rst, $matches);&#160;&#160; &#160;return $matches[1];}?&#62; 这样同样还会存在一个问题：给自己手机号码发送的时候转换不到自己的自己的user-id。解决办法也很简单，只需要在手机号码提交过来最初判断一下是否为登陆号码即可，如果是，取消所有转换，直接进行第4步骤即可发送。 纸上谈兵无用，演示： Demo1：http://www.liuhuadong.com/phoneme Demo2：http://labs.liuhuadong.com/cmcc/index.php(暂无，睡醒后继续) QQREADERC927A243851272DC]]></description>
			<content:encoded><![CDATA[<p>作者：<strong>刘华栋</strong> 2010.4.13<br />
本文目的在于探讨学习，请勿用于非学习外的任何用途，否则后果自负。</p>
<p>出于某些需求，要用到手机短信提醒功能，自然还是免费的好。网上流传了很多版本关于飞信的通信协议，大同小异（基本都是基于2.0的，飞信现在2010协议版本为4.0），当飞信更新了一部分协议内容时，这些流行的协议似乎有些问题出现，最典型的就是：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Gray;">旧版本飞信协议支持输入任何手机号码，只要是发送者好友，即可发送手机短信。<br />新版本飞信协议支持输入任何飞信号码，只要是发送者好友，即可发送手机短信。<br />新旧版本都支持发送登陆者自身手机号码为接收手机的短信。</span></div></div>
<p>如果我有100个飞信好友，莫非我要记住100个飞信号码？如果我要提供一个飞信接口给大伙，莫非大伙要记住他们好友的飞信号码？<br />
当然，写本文的目的就在于从根本上解决上述两个问题（其实是一回事）。</p>
<p>通过对飞信协议多个版本进行了抓包分析，发现数据包格式没什么大的变化。唯一重要的变化是第五行：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Blue;">M</span><span style="color: Gray;"> </span><span style="color: Blue;">fetion</span><span style="color: Gray;">.</span><span style="color: Blue;">com</span><span style="color: Gray;">.</span><span style="color: Blue;">cn</span><span style="color: Gray;"> </span><span style="color: Blue;">SIP</span><span style="color: Gray;">-</span><span style="color: Blue;">C</span><span style="color: Gray;">/</span><span style="color: Maroon;">4.0</span><span style="color: Gray;"><br /></span><span style="color: Blue;">F</span><span style="color: Gray;">:</span><span style="color: Maroon;">88888888</span><span style="color: Gray;"><br /></span><span style="color: Blue;">I</span><span style="color: Gray;">: </span><span style="color: Maroon;">10</span><span style="color: Gray;"> <br /></span><span style="color: Blue;">Q</span><span style="color: Gray;">: </span><span style="color: Maroon;">2</span><span style="color: Gray;"> </span><span style="color: Blue;">M</span><span style="color: Gray;"><br /></span><span style="color: Blue;">T</span><span style="color: Gray;">: </span><span style="color: Blue;">sip</span><span style="color: Gray;">:</span><span style="color: Maroon;">99999999</span><span style="color: Gray;">@</span><span style="color: Blue;">fetion</span><span style="color: Gray;">.</span><span style="color: Blue;">com</span><span style="color: Gray;">.</span><span style="color: Blue;">cn</span><span style="color: Gray;">;</span><span style="color: Blue;">p</span><span style="color: Gray;">=</span><span style="color: Maroon;">640</span><span style="color: Gray;"><br /></span><span style="color: #ffa500;">//上面一行旧版本协议这里是:</span><span style="color: Gray;"><br /></span><span style="color: #ffa500;">//T: tel:13599999999</span><span style="color: Gray;"><br /></span><span style="color: Blue;">C</span><span style="color: Gray;">: </span><span style="color: Blue;">text</span><span style="color: Gray;">/</span><span style="color: Blue;">plain</span><span style="color: Gray;"><br /></span><span style="color: Blue;">K</span><span style="color: Gray;">: </span><span style="color: Blue;">SaveHistory</span><span style="color: Gray;"><br /></span><span style="color: Blue;">L</span><span style="color: Gray;">: </span><span style="color: Maroon;">4</span><span style="color: Gray;"></span></div></div>
<p>这里就出现一个问题，要想发送手机短信，提交过来手机号不行，需要提交手机号对应的飞信号码才能识别，如何才能把手机号码转换为飞信号码就是解决问题的关键。经对新协议抓包分析，发现并不能直接从手机号码转换成飞信号码，但是中间有一个很不错的变量叫做”user-id”，每个手机号对应一个飞信号码，同样对应每个user-id（至于为什么会多出来一个user-id，我想可能是飞信公司准备把飞信号码当做一种商业资源来使用吧）。其实我们用户的真正的飞信号码是这个user-id，所谓飞信号码，无非是一个数字昵称(another nickname)而已。明白这些，问题就好办了：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: Maroon;">1</span><span style="color: Gray;">.发送接收者手机号码，抓包获取该号码的</span><span style="color: Blue;">user</span><span style="color: Gray;">-</span><span style="color: Blue;">id</span><span style="color: Gray;">；<br /></span><span style="color: Maroon;">2</span><span style="color: Gray;">.发送请求好友列表信息（登陆后自动完成）；<br /></span><span style="color: Maroon;">3</span><span style="color: Gray;">.匹配</span><span style="color: Maroon;">1</span><span style="color: Gray;">中</span><span style="color: Blue;">user</span><span style="color: Gray;">-</span><span style="color: Blue;">id</span><span style="color: Gray;">，对应的飞信号码</span><span style="color: Olive;">(</span><span style="color: Gray;">注意格式:</span><span style="color: Blue;">fetion_num</span><span style="color: Gray;">@</span><span style="color: Blue;">fetion</span><span style="color: Gray;">.</span><span style="color: Blue;">com</span><span style="color: Gray;">.</span><span style="color: Blue;">cn</span><span style="color: Olive;">)</span><span style="color: Gray;">；<br /></span><span style="color: Maroon;">4</span><span style="color: Gray;">.发送飞信号码、短信内容，</span><span style="color: Blue;">Done</span><span style="color: Gray;"></span></div></div>
<p>具体代码省略，关键正则函数：</p>
<div class="hl-surround"><div class="hl-main"><span style="color: #ffa500;">//获取飞信号码</span><span style="color: Gray;"><br /></span><span style="color: Green;">function</span><span style="color: Gray;"> </span><span style="color: Blue;">get_fetion_id</span><span style="color: Olive;">(</span><span style="color: #00008b;">$userid</span><span style="color: Gray;">, </span><span style="color: #00008b;">$rst</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">preg_match</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">/ri=</span><span style="color: #8b0000;">&quot;</span><span style="color: Blue;">sip</span><span style="color: Gray;">:</span><span style="color: Olive;">(</span><span style="color: Blue;">d</span><span style="color: Olive;">{</span><span style="color: Maroon;">6</span><span style="color: Gray;">,</span><span style="color: Maroon;">10</span><span style="color: Olive;">}</span><span style="color: Gray;">+</span><span style="color: Olive;">)</span><span style="color: Gray;">@</span><span style="color: Blue;">fetion</span><span style="color: Gray;">.</span><span style="color: Blue;">com</span><span style="color: Gray;">.</span><span style="color: Blue;">cn</span><span style="color: Gray;">;</span><span style="color: Blue;">p</span><span style="color: Gray;">=</span><span style="color: Olive;">(</span><span style="color: Blue;">d</span><span style="color: Olive;">{</span><span style="color: Maroon;">0</span><span style="color: Gray;">,</span><span style="color: Maroon;">6</span><span style="color: Olive;">}</span><span style="color: Gray;">+</span><span style="color: Olive;">)</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;user-id=</span><span style="color: #8b0000;">&quot;</span><span style="color: #00008b;">$userid</span><span style="color: Gray;">/</span><span style="color: Blue;">i</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">,</span><span style="color: #00008b;">$rst</span><span style="color: Red;">, </span><span style="color: #00008b;">$matches</span><span style="color: Red;">);<br />&nbsp;&nbsp; &nbsp;//同理重构函数获取user-id<br />&nbsp;&nbsp; &nbsp;//preg_match(</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">/</span><span style="color: Blue;">user</span><span style="color: Gray;">-</span><span style="color: Blue;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">([0-9]+)</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">/</span><span style="color: Blue;">i</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">, </span><span style="color: #00008b;">$rst</span><span style="color: Red;">, </span><span style="color: #00008b;">$matches</span><span style="color: Red;">);<br />&nbsp;&nbsp; &nbsp;return </span><span style="color: #00008b;">$matches</span><span style="color: Red;">[1];<br />}<br />?&gt;</span></div></div>
<p>这样同样还会存在一个问题：给自己手机号码发送的时候转换不到自己的自己的user-id。解决办法也很简单，只需要在手机号码提交过来最初判断一下是否为登陆号码即可，如果是，取消所有转换，直接进行第4步骤即可发送。</p>
<p>纸上谈兵无用，演示：<br />
Demo1：<a href="http://www.liuhuadong.com/phoneme">http://www.liuhuadong.com/phoneme</a><br />
Demo2：<a href="http://labs.liuhuadong.com/cmcc/index.php">http://labs.liuhuadong.com/cmcc/index.php</a>(暂无，睡醒后继续)<br />
QQREADERC927A243851272DC</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuhuadong.com/archives/867/index.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>测试一下你的最快击键速度[附排行榜]</title>
		<link>http://www.liuhuadong.com/archives/837/index.html</link>
		<comments>http://www.liuhuadong.com/archives/837/index.html#comments</comments>
		<pubDate>Sun, 04 Apr 2010 07:22:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP/Mysql]]></category>

		<guid isPermaLink="false">http://www.liuhuadong.com/?p=837</guid>
		<description><![CDATA[输入速度全球排行榜。 作者：刘华栋 2010.4 原创作品，欢迎转载流传 具体使用方法很简单，打开下边这个页面，直接用键盘开始输入字母a到z，顺序不能弄错，输入完成即会自动显示用时。 虽然这可能是个无聊的作品，但还是花了我不少时间才搞定，中间涉及js、css、php、mysql，我自己的26个字母的输入记录是]]></description>
			<content:encoded><![CDATA[<p>输入速度全球排行榜。<br />
作者：<strong>刘华栋</strong> 2010.4 原创作品，欢迎转载流传<br />
<a href="http://www.liuhuadong.com/labs/top.php"><img src="http://xhatblog-wordpress.stor.sinaapp.com/uploads/2010/04/4.png" alt="无标题" title="无标题" width="500" class="alignnone size-full wp-image-841" /></a><br />
具体使用方法很简单，打开下边这个页面，直接用键盘开始输入字母a到z，顺序不能弄错，输入完成即会自动显示用时。<br />
虽然这可能是个无聊的作品，但还是花了我不少时间才搞定，中间涉及js、css、php、mysql，我自己的26个字母的输入记录是<5秒，具体多少忘了。我的目标是达到4s以内，不过看来希望不大。<br />
挑战地址：<a href="http://www.liuhuadong.com/labs/top.php">http://www.liuhuadong.com/labs/top.php</a></p>
<p>tips:<br />
数据库中使用group by的时候，可以同时使用min(字段名)/max(字段名)来获取每个group中的最值，这个sql语法简直太棒了，大大减少坐在电脑前呼出的二氧化碳含量，节能环保。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuhuadong.com/archives/837/index.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>vim之gg=G</title>
		<link>http://www.liuhuadong.com/archives/827/index.html</link>
		<comments>http://www.liuhuadong.com/archives/827/index.html#comments</comments>
		<pubDate>Sat, 03 Apr 2010 04:07:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP/Mysql]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://www.liuhuadong.com/?p=827</guid>
		<description><![CDATA[无论你是vim老手还是菜鸟，vim总会给你一些惊喜甚至是惊奇。就像今天发现gg=G全文缩进这个命令一样（或者说发现=为缩进） 例如目前代码： 使用命令：=}（当然不是标题中的gg=G，vim的微妙之处就在于你看到一个命令会联想到很多自己想要的组合命令）]]></description>
			<content:encoded><![CDATA[<p>无论你是vim老手还是菜鸟，vim总会给你一些惊喜甚至是惊奇。就像今天发现gg=G全文缩进这个命令一样（或者说发现=为缩进）<br />
例如目前代码：<br />
<img src="http://xhatblog-wordpress.stor.sinaapp.com/uploads/2010/04/png" alt="无标题" title="无标题" width="389" height="290" class="alignnone size-full wp-image-828" /><br />
使用命令：<strong>=}</strong>（当然不是标题中的gg=G，vim的微妙之处就在于你看到一个命令会联想到很多自己想要的组合命令）<br />
<img src="http://xhatblog-wordpress.stor.sinaapp.com/uploads/2010/04/2.png" alt="无标题" title="无标题" width="424" height="290" class="alignnone size-full wp-image-831" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.liuhuadong.com/archives/827/index.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

