<?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>苗启源的部落格</title>
	<atom:link href="http://www.miaoqiyuan.cn/404.php/feed?404;http://www.miaoqiyuan.cn:80/feed" rel="self" type="application/rss+xml" />
	<link>http://www.miaoqiyuan.cn</link>
	<description></description>
	<lastBuildDate>Tue, 08 May 2012 04:46:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>看美女图秀秀的网站</title>
		<link>http://www.miaoqiyuan.cn/p/meinvtuxiuxiu</link>
		<comments>http://www.miaoqiyuan.cn/p/meinvtuxiuxiu#comments</comments>
		<pubDate>Tue, 08 May 2012 04:46:29 +0000</pubDate>
		<dc:creator>mqycn</dc:creator>
				<category><![CDATA[Life(生活)]]></category>

		<guid isPermaLink="false">http://www.miaoqiyuan.cn/?p=821</guid>
		<description><![CDATA[   最近查看美女图秀秀，发现美女秀秀图还是有很多市场的，如果开发一套软件，比如：美美图秀秀，发挥的潜力还是很大的。
   美图秀秀是一个非常简单好用的的图片处理软件，即使第一次打开美图秀秀也能使用。使用图片特效、美容等特效，很快就能做出一个非常漂亮的美女图秀秀。
   通过百度，发现已经都多家美女图秀秀的网站，但是很多都打不开了。想看美女图秀秀的朋友就比较郁闷了。所以我们已经加班加点，最近上线美女图秀秀工具。
   在这里先公布一下美女图秀秀制作的方法，通过这种方法，你也可以很快就能做出非常漂亮的美美图秀秀、美女秀秀图。
   1、下载美女图秀秀软件，然后用此软件打开美女秀秀图。
   2、使用特效，美容等工具优化您的秀秀图。
   3、点击保存，一个非常漂亮的美女图秀秀就做好了。
]]></description>
			<content:encoded><![CDATA[<p>   最近查看<strong>美女图秀秀</strong>，发现美女秀秀图还是有很多市场的，如果开发一套软件，比如：美美图秀秀，发挥的潜力还是很大的。</p>
<p>   美图秀秀是一个非常简单好用的的图片处理软件，即使第一次打开美图秀秀也能使用。使用图片特效、美容等特效，很快就能做出一个非常漂亮的<a href="http://www.miaoqiyuan.cn/p/meinvtuxiuxiu">美女图秀秀</a>。</p>
<p>   通过百度，发现已经都多家美女图秀秀的网站，但是很多都打不开了。想看美女图秀秀的朋友就比较郁闷了。所以我们已经加班加点，最近上线美女图秀秀工具。</p>
<p>   在这里先公布一下美女图秀秀制作的方法，通过这种方法，你也可以很快就能做出非常漂亮的美美图秀秀、美女秀秀图。</p>
<p>   1、下载美女图秀秀软件，然后用此软件打开美女秀秀图。</p>
<p>   2、使用特效，美容等工具优化您的秀秀图。</p>
<p>   3、点击保存，一个非常漂亮的美女图秀秀就做好了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miaoqiyuan.cn/p/meinvtuxiuxiu/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XAP服务器搭建工具 XAP Server 1.0发布</title>
		<link>http://www.miaoqiyuan.cn/p/hello-xapserver</link>
		<comments>http://www.miaoqiyuan.cn/p/hello-xapserver#comments</comments>
		<pubDate>Mon, 02 Apr 2012 03:47:22 +0000</pubDate>
		<dc:creator>mqycn</dc:creator>
				<category><![CDATA[Life(生活)]]></category>

		<guid isPermaLink="false">http://www.miaoqiyuan.cn/?p=816</guid>
		<description><![CDATA[
凭借此工具，我获得了wpxap论坛的开发之神的称号。Hoho~~~~~~~

谢谢以上朋友们的支持，特别是dakeng2008 ，我还没发布，就来支持了，不过评价可不咋滴哦~
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.miaoqiyuan.cn/images/uploads/2012/04/hoho.jpg"><img src="http://www.miaoqiyuan.cn/images/uploads/2012/04/hoho.jpg" alt="" title="hoho" width="777" height="550" class="aligncenter size-full wp-image-817" /></a></p>
<p>凭借此工具，我获得了wpxap论坛的开发之神的称号。Hoho~~~~~~~</p>
<p><a href="http://www.miaoqiyuan.cn/images/uploads/2012/04/h2.jpg"><img src="http://www.miaoqiyuan.cn/images/uploads/2012/04/h2.jpg" alt="" title="h2" width="600" height="805" class="aligncenter size-full wp-image-818" /></a></p>
<p>谢谢以上朋友们的支持，特别是dakeng2008 ，我还没发布，就来支持了，不过评价可不咋滴哦~</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miaoqiyuan.cn/p/hello-xapserver/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>G级Access网站优化</title>
		<link>http://www.miaoqiyuan.cn/p/asp-use-big-access-db</link>
		<comments>http://www.miaoqiyuan.cn/p/asp-use-big-access-db#comments</comments>
		<pubDate>Fri, 02 Mar 2012 16:18:18 +0000</pubDate>
		<dc:creator>mqycn</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[cache]]></category>

		<guid isPermaLink="false">http://www.miaoqiyuan.cn/?p=812</guid>
		<description><![CDATA[    如果做企业站，ASP+Access是一个最佳选择。但是如果Access的数据库达到G级别，那么性能可能就会大大的下降。如果数据库没有优化，打开asp页面几秒是常有的事情。如果一个Access表内几十万条数据，恰巧ASP页面又有几十个查询，可能就悲剧了。网站打开时间要按分钟计算了。
    Asp+Access以前数据量少的时候，没有任何问题。数据量一大，各种麻烦的问题就多了起来。总不能让客户等几分钟打开首页把。
    最早的解决方案是将index.asp修改成index.res.asp，用XMLHTTP请求index.res.asp，将结果保存为文件、调用时间到文件，然后调用文件的内容，和时间，如果超时后，重新调用。
    这种方案也用了很久，虽然解决了问题，但是效果仍不理想。多人同时访问的时候(经常，页面打开很慢)，恰巧内容又超时了。仍然会出现服务器宕机的情况。
    今天服务器有出现问题，实在受不了，为数据增加索引，效果仍然不明显。想到可以用Application来保存网页缓存。速度有提高，但是离理想的效果还是差很远。
    决心大改动，从18点~23点，耗时五个钟头，终于做出了一套比较完美的方案。

	function is_cache(na)
		if application(&#34;catseven_cache_&#34; &#38; na) = &#34;&#34; then
			is_cache = false
		else
			if not isdate(application(&#34;catseven_cachetime_&#34; &#38; na)) then
				is_cache = false
			else
				da = cdate(application(&#34;catseven_cachetime_&#34; &#38; na))
				if datediff(&#34;n&#34;,da,now()) &#62; 60 then
					is_cache = false
				else
					is_cache = true
				end if
			end if
		end [...]]]></description>
			<content:encoded><![CDATA[<p>    如果做企业站，ASP+Access是一个最佳选择。但是如果Access的数据库达到G级别，那么性能可能就会大大的下降。如果数据库没有优化，打开asp页面几秒是常有的事情。如果一个Access表内几十万条数据，恰巧ASP页面又有几十个查询，可能就悲剧了。网站打开时间要按分钟计算了。</p>
<p>    Asp+Access以前数据量少的时候，没有任何问题。数据量一大，各种麻烦的问题就多了起来。总不能让客户等几分钟打开首页把。<span id="more-812"></span></p>
<p>    最早的解决方案是将index.asp修改成index.res.asp，用XMLHTTP请求index.res.asp，将结果保存为文件、调用时间到文件，然后调用文件的内容，和时间，如果超时后，重新调用。</p>
<p>    这种方案也用了很久，虽然解决了问题，但是效果仍不理想。多人同时访问的时候(经常，页面打开很慢)，恰巧内容又超时了。仍然会出现服务器宕机的情况。</p>
<p>    今天服务器有出现问题，实在受不了，为数据增加索引，效果仍然不明显。想到可以用Application来保存网页缓存。速度有提高，但是离理想的效果还是差很远。</p>
<p>    决心大改动，从18点~23点，耗时五个钟头，终于做出了一套比较完美的方案。</p>
<pre class="brush: vb; title: ;">
	function is_cache(na)
		if application(&quot;catseven_cache_&quot; &amp; na) = &quot;&quot; then
			is_cache = false
		else
			if not isdate(application(&quot;catseven_cachetime_&quot; &amp; na)) then
				is_cache = false
			else
				da = cdate(application(&quot;catseven_cachetime_&quot; &amp; na))
				if datediff(&quot;n&quot;,da,now()) &gt; 60 then
					is_cache = false
				else
					is_cache = true
				end if
			end if
		end if
	end function

	function do_cache(na,va)
		application(&quot;catseven_cache_&quot; &amp; na) = va
		randomize()
		application(&quot;catseven_cachetime_&quot; &amp; na) = dateadd(&quot;s&quot;,cLng(rnd()*6000),now())
	end function

	function ech_cache(na)
		response.write application(&quot;catseven_cache_&quot; &amp; na)
	end function
</pre>
<p>	na是缓存名，不可重复</p>
<pre class="brush: vb; title: ;">
	call cachename = &quot;miaoqiyuan&quot;
	if not is_cache(cachename) then
		'执行代码(即以前的代码)，结果保存为 tmpstring
		call do_cache(cachename,tmpstring)
	end if
	call ech_cache(cachename)
</pre>
<p>	运行情况如下图所示。</p>
<p>	<center><img src="http://www.miaoqiyuan.cn/images/uploads/2012/03/asp-use-big-access-db.jpg" /></center></p>
<p>	第一个用户完整访问完一次后，其他用户不用读取数据库，直接访问缓存。</p>
<p>	在第一个用户访问期间，如果有其他用户访问，已经缓存的部分，也无需读取数据库。所以仅在启动程序池的时候速度会较慢，以后的访问者访问速度会越来越快(已完成的缓存越来越多)。</p>
<p>	假如仅一个人访问，一个小时后，缓存超时，再次访问，仍可能出现访问较慢。所以在保存缓存的时候增加了随机到期时间来提高访问速度。缓存有效期是50~60分钟不等。</p>
<p>	本文猫七原创，转帖请注明来自苗启源的博客:http://www.miaoqiyuan.cn</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miaoqiyuan.cn/p/asp-use-big-access-db/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP的Base64函数</title>
		<link>http://www.miaoqiyuan.cn/p/asp-base64-2</link>
		<comments>http://www.miaoqiyuan.cn/p/asp-base64-2#comments</comments>
		<pubDate>Fri, 30 Dec 2011 16:17:33 +0000</pubDate>
		<dc:creator>mqycn</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[VBscript]]></category>
		<category><![CDATA[base64]]></category>

		<guid isPermaLink="false">http://www.miaoqiyuan.cn/?p=807</guid>
		<description><![CDATA[
  Const BASE_64_CHARACTERS = &#34;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/&#34;
  Private sBASE_64_CHARACTERS

  Function Base64encode(ByVal asContents)
    asContents = strUnicode2Ansi(asContents)
    Dim lnPosition,lsResult,Char1,Char2,Char3,Char4,Byte1,Byte2,Byte3,SaveBits1,SaveBits2,lsGroupBinary,lsGroup64,M4, len1, len2
    len1 = LenB(asContents)
    If len1 &#60; 1 Then
      Base64encode = &#34;&#34;
      Exit Function
 [...]]]></description>
			<content:encoded><![CDATA[<pre class="brush: vb; title: ;">
  Const BASE_64_CHARACTERS = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/&quot;
  Private sBASE_64_CHARACTERS

  Function Base64encode(ByVal asContents)
    asContents = strUnicode2Ansi(asContents)
    Dim lnPosition,lsResult,Char1,Char2,Char3,Char4,Byte1,Byte2,Byte3,SaveBits1,SaveBits2,lsGroupBinary,lsGroup64,M4, len1, len2
    len1 = LenB(asContents)
    If len1 &lt; 1 Then
      Base64encode = &quot;&quot;
      Exit Function
    End If
    M4 = len1 Mod 3
    If M4 &gt; 0 Then asContents = asContents &amp; String(3 - M4, Chr(0))
    '补足位数是为了便于计算
    If M4 &gt; 0 Then
      len1 = len1 + (3 - M4)
      len2 = len1 - 3
    Else
      len2 = len1
    End If
    lsResult = &quot;&quot;
    sBASE_64_CHARACTERS = strUnicode2Ansi(BASE_64_CHARACTERS)
    For lnPosition = 1 To len2 Step 3
      lsGroup64 = &quot;&quot;
      lsGroupBinary = MidB(asContents, lnPosition, 3)
      Byte1 = AscB(MidB(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3
      Byte2 = AscB(MidB(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15
      Byte3 = AscB(MidB(lsGroupBinary, 3, 1))
      Char1 = MidB(sBASE_64_CHARACTERS, ((Byte1 And 252) \ 4) + 1, 1)
      Char2 = MidB(sBASE_64_CHARACTERS, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And &amp;HFF) + 1, 1)
      Char3 = MidB(sBASE_64_CHARACTERS, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And &amp;HFF) + 1, 1)
      Char4 = MidB(sBASE_64_CHARACTERS, (Byte3 And 63) + 1, 1)
      lsGroup64 = Char1 &amp; Char2 &amp; Char3 &amp; Char4
      lsResult = lsResult &amp; lsGroup64
    Next
    '处理最后剩余的几个字符
    If M4 &gt; 0 Then
      lsGroup64 = &quot;&quot;
      lsGroupBinary = MidB(asContents, len2 + 1, 3)
      Byte1 = AscB(MidB(lsGroupBinary, 1, 1)): SaveBits1 = Byte1 And 3
      Byte2 = AscB(MidB(lsGroupBinary, 2, 1)): SaveBits2 = Byte2 And 15
      Byte3 = AscB(MidB(lsGroupBinary, 3, 1))
      Char1 = MidB(sBASE_64_CHARACTERS, ((Byte1 And 252) \ 4) + 1, 1)
      Char2 = MidB(sBASE_64_CHARACTERS, (((Byte2 And 240) \ 16) Or (SaveBits1 * 16) And &amp;HFF) + 1, 1)
      Char3 = MidB(sBASE_64_CHARACTERS, (((Byte3 And 192) \ 64) Or (SaveBits2 * 4) And &amp;HFF) + 1, 1)
      If M4 = 1 Then
        lsGroup64 = Char1 &amp; Char2 &amp; ChrB(61) &amp; ChrB(61) '用=号补足位数
      Else
        lsGroup64 = Char1 &amp; Char2 &amp; Char3 &amp; ChrB(61) '用=号补足位数
      End If
      lsResult = lsResult &amp; lsGroup64
    End If
    Base64encode = strAnsi2Unicode(lsResult)
  End Function

  Function Base64decode(ByVal asContents)
    asContents = strUnicode2Ansi(asContents)
    Dim lsResult,lnPosition,lsGroup64, lsGroupBinary,Char1, Char2, Char3, Char4,Byte1, Byte2, Byte3,M4, len1, len2
    len1 = LenB(asContents)
    M4 = len1 Mod 4

    If len1 &lt; 1 Or M4 &gt; 0 Then
      '字符串长度应当是4的倍数
      Base64decode = &quot;&quot;
      Exit Function
    End If
    '判断最后一位是不是 = 号
    '判断倒数第二位是不是 = 号
    '这里m4表示最后剩余的需要单独处理的字符个数
    If MidB(asContents, len1, 1) = ChrB(61) Then M4 = 3
    If MidB(asContents, len1 - 1, 1) = ChrB(61) Then M4 = 2
    If M4 = 0 Then
      len2 = len1
    Else
      len2 = len1 - 4
    End If
    sBASE_64_CHARACTERS = strUnicode2Ansi(BASE_64_CHARACTERS)
    For lnPosition = 1 To len2 Step 4
      lsGroupBinary = &quot;&quot;
      lsGroup64 = MidB(asContents, lnPosition, 4)
      Char1 = InStrB(sBASE_64_CHARACTERS, MidB(lsGroup64, 1, 1)) - 1
      Char2 = InStrB(sBASE_64_CHARACTERS, MidB(lsGroup64, 2, 1)) - 1
      Char3 = InStrB(sBASE_64_CHARACTERS, MidB(lsGroup64, 3, 1)) - 1
      Char4 = InStrB(sBASE_64_CHARACTERS, MidB(lsGroup64, 4, 1)) - 1
      Byte1 = ChrB(((Char2 And 48) \ 16) Or (Char1 * 4) And &amp;HFF)
      Byte2 = lsGroupBinary &amp; ChrB(((Char3 And 60) \ 4) Or (Char2 * 16) And &amp;HFF)
      Byte3 = ChrB((((Char3 And 3) * 64) And &amp;HFF) Or (Char4 And 63))
      lsGroupBinary = Byte1 &amp; Byte2 &amp; Byte3
      lsResult = lsResult &amp; lsGroupBinary
    Next
    '处理最后剩余的几个字符
    If M4 &gt; 0 Then
      lsGroupBinary = &quot;&quot;
      lsGroup64 = MidB(asContents, len2 + 1, M4) &amp; ChrB(65) 'chr(65)=A，转换成值为0
      If M4 = 2 Then '补足4位，是为了便于计算
        lsGroup64 = lsGroup64 &amp; ChrB(65)
      End If
      Char1 = InStrB(sBASE_64_CHARACTERS, MidB(lsGroup64, 1, 1)) - 1
      Char2 = InStrB(sBASE_64_CHARACTERS, MidB(lsGroup64, 2, 1)) - 1
      Char3 = InStrB(sBASE_64_CHARACTERS, MidB(lsGroup64, 3, 1)) - 1
      Char4 = InStrB(sBASE_64_CHARACTERS, MidB(lsGroup64, 4, 1)) - 1
      Byte1 = ChrB(((Char2 And 48) \ 16) Or (Char1 * 4) And &amp;HFF)
      Byte2 = lsGroupBinary &amp; ChrB(((Char3 And 60) \ 4) Or (Char2 * 16) And &amp;HFF)
      Byte3 = ChrB((((Char3 And 3) * 64) And &amp;HFF) Or (Char4 And 63))
      If M4 = 2 Then
        lsGroupBinary = Byte1
      ElseIf M4 = 3 Then
        lsGroupBinary = Byte1 &amp; Byte2
      End If
      lsResult = lsResult &amp; lsGroupBinary
    End If
    Base64decode = strAnsi2Unicode(lsResult)
  End Function

  Function strUnicodeLen(ByVal asContents)
    '计算unicode字符串的Ansi编码的长度
    Dim asContents1
    Dim len1,k,i,asc1
    asContents1 = &quot;a&quot; &amp; asContents
    len1 = Len(asContents1)
    k = 0
    For i = 1 To len1
      asc1 = Asc(Mid(asContents1, i, 1))
      If asc1 &lt; 0 Then asc1 = 65536 + asc1
      If asc1 &gt; 255 Then
        k = k + 2
      Else
        k = k + 1
      End If
    Next
    strUnicodeLen = k - 1
  End Function

  Function strUnicode2Ansi(ByVal asContents)
    '将Unicode编码的字符串，转换成Ansi编码的字符串
    Dim len1,i,VarChar,varAsc,varHex, varlow, varhigh
    strUnicode2Ansi = &quot;&quot;
    len1 = Len(asContents)
    For i = 1 To len1
      VarChar = Mid(asContents, i, 1)
      varAsc = Asc(VarChar)
      If varAsc &lt; 0 Then varAsc = varAsc + 65536
      If varAsc &gt; 255 Then
        varHex = Hex(varAsc)
        varlow = Left(varHex, 2)
        varhigh = Right(varHex, 2)
        strUnicode2Ansi = strUnicode2Ansi &amp; ChrB(&quot;&amp;H&quot; &amp; varlow) &amp; ChrB(&quot;&amp;H&quot; &amp; varhigh)
      Else
        strUnicode2Ansi = strUnicode2Ansi &amp; ChrB(varAsc)
      End If
    Next
  End Function

  Function strAnsi2Unicode(asContents)
    '将Ansi编码的字符串，转换成Unicode编码的字符串
    Dim len1,i,VarChar,varAsc
    strAnsi2Unicode = &quot;&quot;
    len1 = LenB(asContents)
    If len1 = 0 Then Exit Function
    For i = 1 To len1
      VarChar = MidB(asContents, i, 1)
      varAsc = AscB(VarChar)
      If varAsc &gt; 127 Then
        strAnsi2Unicode = strAnsi2Unicode &amp; Chr(AscW(MidB(asContents, i + 1, 1) &amp; VarChar))
        i = i + 1
      Else
        strAnsi2Unicode = strAnsi2Unicode &amp; Chr(varAsc)
      End If
    Next
  End Function
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.miaoqiyuan.cn/p/asp-base64-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>猫七数据加密、解密类</title>
		<link>http://www.miaoqiyuan.cn/p/catseven-coding</link>
		<comments>http://www.miaoqiyuan.cn/p/catseven-coding#comments</comments>
		<pubDate>Fri, 30 Dec 2011 15:08:05 +0000</pubDate>
		<dc:creator>mqycn</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[Share(分享)]]></category>
		<category><![CDATA[Thinks(想法)]]></category>
		<category><![CDATA[Catseven]]></category>
		<category><![CDATA[加密]]></category>
		<category><![CDATA[解密]]></category>

		<guid isPermaLink="false">http://www.miaoqiyuan.cn/?p=803</guid>
		<description><![CDATA[   在很多场合，特别重要的要加密传输。使用成熟的加密算法是一个不错的选择，但是~ 有些算法这个语言支持而另一种语言不支持。或者直接要安装某某组件，实在是太烦琐了，为了方便以后使用，自己抽空写了一个。

'=====================================================================
'=                       猫七数据加密、解密类                         =
'=   [...]]]></description>
			<content:encoded><![CDATA[<p>   在很多场合，特别重要的要加密传输。使用成熟的加密算法是一个不错的选择，但是~ 有些算法这个语言支持而另一种语言不支持。或者直接要安装某某组件，实在是太烦琐了，为了方便以后使用，自己抽空写了一个。<span id="more-803"></span></p>
<pre class="brush: vb; title: ;">
'=====================================================================
'=                       猫七数据加密、解密类                         =
'=     Copyright (c) 2011 猫七(QQ:77068320) All rights reserverd.    =
'=              请尊重作者劳动成果，转载请保留代码的完整性             =
'=====================================================================
'= 作者：苗启源(博客:http://www.miaoqiyuan.cn)                        =
'= 讨论：http://www.miaoqiyuan.cn/p/catseven-coding
'= 最新：http://www.miaoqiyuan.cn/products/Catseven.Coding.rar
'=====================================================================
'=  文件名：Class.Catseven.Coding.asp                                =
'=  功  能：猫七数据加密、解密函数                                     =
'=====================================================================
  class Catseven_Coding
    public akey,ekey,keylen,keymax,autolen

    '类初始化
    '  akey    编码表
    '  ekey    密钥
    '  keylen  标准编码长度
    '  keymax  最大编码长度，默认1000，代表1000-数据长度必须是3位数字，即数据的长度可以为0-900
    '  autolen 如果不足，是否补全
    public sub class_initialize()
      akey   = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=&quot;
      ekey   = &quot;f67RSTUOPDp02qd34ABbMijQFxyr5szZnot89+Y/=EghkVavwuHCXWmKLJNGIcel1&quot;
      keylen = 900
      keymax = 1000
      autolen= true
    end sub

    '函数：randkey
    '功能：创建随机字符
    '参数：rndkeylen  随机字符长度
    private function randkey(byval rndkeylen)
      dim rndnum,keymap,rstr,i
      keymap = &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&quot;
      rstr = &quot;&quot;
      for i = 1 to rndkeylen
        randomize
        rndnum = cLng(len(keymap) - 1) * rnd() + 1
        rstr   = rstr &amp; mid(keymap,rndnum,1)
      next
      randkey = rstr
    end function

    '函数：encode
    '功能：加密字符串
    '参数：str    要加密的字符串
    public function encode(byval str)
      dim alen,i,vstr,kstr,vkey
      str  = replace(str,&quot;\&quot;,&quot;&quot;)
      alen = len(str)
      if alen = 0 then
        encode = &quot;&quot;
      else
        vstr = &quot;&quot;
        vkey = randkey(1)
        for i = 1 to len(str)
          kstr = mid(str,i,1)
          vstr = vstr &amp; mid(akey,instr(ekey,kstr),1)
        next
        alen = keymax - alen
        vstr = len(alen) &amp; vkey &amp; randkey(9 - len(keymax)) &amp; alen &amp; UCase(vkey) &amp; vstr
        alen = len(vstr)
        if keylen &lt; alen then keylen = alen
        if keylen &gt; keymax * 0.9 then keylen = keymax * 0.9
        vstr = mid(vstr,1,keylen)
        if alen &lt; keylen and autolen = true then
          vstr = vstr &amp; randkey(keylen - alen)
        end if
        encode = vstr
      end if
    end function

    '函数：decode
    '功能：解密字符串
    '参数：str    要解密的字符串
    public function decode(byval str)
      dim alen,i,vstr,kstr,vkey
      alen = mid(str,1,1)
      vkey = mid(str,2,1)
      if not isnumeric(alen) then
        decode = &quot;&quot;
      else
        alen = mid(str,11 - alen,alen)
        if not isnumeric(alen) then
          decode = &quot;&quot;
        else
          alen = keymax - alen + 1
          str = mid(str,11,alen)
          if mid(str,1,1) = UCase(vkey) then
            vstr = &quot;&quot;
            str = mid(str,2)
            for i = 1 to len(str)
              kstr = mid(str,i,1)
              vstr = vstr &amp; mid(ekey,instr(akey,kstr),1)
            next
            decode = vstr
          else
            decode = &quot;&quot;
          end if
        end if
      end if
    end function
  end class
</pre>
<p>    使用的时候比较简单，只支持英文加密，所以使用的时候，请配合<a href="http://www.miaoqiyuan.cn/p/tag/base64">base64函数</a>(相关代码：http://www.miaoqiyuan.cn/p/tag/base64)使用。加密的时候用encode。</p>
<pre class="brush: vb; title: ;">
  set a = new Catseven_Coding
  a.autolen = true
  a.keylen  = 150
  response.write a.encode(&quot;5qyi6L+O5ZKM5oiR6K6o6K6677yM5pys5paH5Y6f5paH5Zyw5Z2A77yaaHR0cDovL3d3dy5taWFvcWl5dWFuLmNuL3AvQ2F0c2V2ZW4tQ29kaW5n&quot;)

'base64编码后的字符
</pre>
<p>    解密的时候直接用decode。</p>
<pre class="brush: vb; title: ;">
  set a = new Catseven_Coding
  response.write a.decode(&quot;3kfRpeT888KcNaVB4lHcf3UchVDB3BhB3BBCCaUcKadcKuycmBAcKuycfawcfMRCCauuyDL9Jhv4POPOaciu1Yv91/cO1Yx426x4PRvXMYL9MtMf1QiXMksu1cgkwbbM5c2IZDXHMqcZSnkCb4C6LP&quot;)

'解码后，为base64编码
</pre>
<p>可以指定ekey指定对照表</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miaoqiyuan.cn/p/catseven-coding/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WinHttpRequest使用方法，WinHttpRequest演示实例</title>
		<link>http://www.miaoqiyuan.cn/p/winhttp-winhttprequest-5-1_demo</link>
		<comments>http://www.miaoqiyuan.cn/p/winhttp-winhttprequest-5-1_demo#comments</comments>
		<pubDate>Tue, 27 Dec 2011 15:51:56 +0000</pubDate>
		<dc:creator>mqycn</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[WinHttp.WinHttpRequest]]></category>
		<category><![CDATA[WinHttpRequest]]></category>

		<guid isPermaLink="false">http://www.miaoqiyuan.cn/?p=787</guid>
		<description><![CDATA[   最近经常需要开发API，Microsoft.XMLHttp、MSXML2.XMLHTTP 等组件不能满足我的要求(主要是不能自定义header等信息)，通过查资料发现了WinHttp.WinHttpRequest.5.1，但是关于winhttprequest的资料太少了。通过这几天摸索，勉强了解了WinHttpRequest使用方法。
   WinHttp.WinHttpRequest是一个非常实用的一个组件。作为站长，就会经常关注自己网站的流浪，今天以 免登陆获得cnzz统计信息 和 免登陆获得51.la统计信息 为例，一起了解下WinHttpRequest的使用方法。CNZZ会员系统没有使用验证码，而51.la使用了验证码，针对两种不同的系统，我们分两种方法讨论。

实时获取CNZZ统计信息 ASP版
WinHttp.WinHttpRequest采集无验证码会员系统实例
实时获取51.la统计信息 ASP版
WinHttp.WinHttpRequest采集有验证码会员系统实例

   
实时获取CNZZ统计信息 ASP版


  '=====================================================================
  '=            WinHttpRequest演示实例 - 实时获取CNZZ统计信息          =
  '=     Copyright (c) 2011 [...]]]></description>
			<content:encoded><![CDATA[<p>   最近经常需要开发API，Microsoft.XMLHttp、MSXML2.XMLHTTP 等组件不能满足我的要求(主要是不能自定义header等信息)，通过查资料发现了WinHttp.WinHttpRequest.5.1，但是关于<strong>winhttprequest</strong>的资料太少了。通过这几天摸索，勉强了解了<strong>WinHttpRequest使用方法</strong>。<span id="more-787"></span></p>
<p>   WinHttp.WinHttpRequest是一个非常实用的一个组件。作为站长，就会经常关注自己网站的流浪，今天以 免登陆获得cnzz统计信息 和 免登陆获得51.la统计信息 为例，一起了解下WinHttpRequest的使用方法。CNZZ会员系统没有使用验证码，而51.la使用了验证码，针对两种不同的系统，我们分两种方法讨论。</p>
<dl>
<dt><a href="#cnzz" style="color:#090;font-weight:800;font-size:18px;">实时获取CNZZ统计信息 ASP版</a></dt>
<dd style="color:#999">WinHttp.WinHttpRequest采集无验证码会员系统实例</dd>
<dt><a href="#51la" style="color:#090;font-weight:800;font-size:18px;">实时获取51.la统计信息 ASP版</a></dt>
<dd style="color:#999">WinHttp.WinHttpRequest采集有验证码会员系统实例</dd>
</dl>
<p>   <a name="cnzz"></a><br />
<h2>实时获取CNZZ统计信息 ASP版</h2>
<pre class="brush: vb; title: ;">

  '=====================================================================
  '=            WinHttpRequest演示实例 - 实时获取CNZZ统计信息          =
  '=     Copyright (c) 2011 猫七(QQ:77068320) All rights reserverd.    =
  '=              请尊重作者劳动成果，转载请保留代码的完整性           =
  '=====================================================================
  '= 作者：苗启源(博客:http://www.miaoqiyuan.cn)                       =
  '= 讨论：http://www.miaoqiyuan.cn/p/winhttp-winhttprequest-5-1_demo
  '= 最新：http://www.miaoqiyuan.cn/products/winhttprequest_demo.rar
  '=====================================================================
  '=  返回首页站点列表： winhttprequest_demo.asp                       =
  '=  返回某站统计数据： winhttprequest_demo.asp?act=data&amp;id=[站点ID]  =
  '=====================================================================
  '=  文件名：winhttprequest_demo.asp                                  =
  '=  功  能：免登陆查看CNZZ 网站流量统计信息                          =
  '=====================================================================

  Dim HttpID,AppName,CNZZ_User,CNZZ_Password
  HttpID        = 0
  AppName       = &quot;app_cnzz.com_demo&quot;                   '应用程序名前缀，防止感染其他程序Application变量
  CNZZ_User     = &quot;kefu@myw3.cn&quot;                        'CNZZ账号
  CNZZ_Password = &quot;CNZZTEST&quot;                            'CNZZ密码

  '函数名：OpenHttp
  '功  能：创建Http请求，并返回服务器处理结果
  '参  数：url          请求地址
  '        PostData     请求数据包，如果是Get请求，请以SENDTYPE=GET开头
  '        &amp;strlocation 如果是服务器重定向网址，则返回重定向的地址
  '特  点：自动保存/共享cookies，多次请求能保存登录状态
  Function OpenHttp(byval url,byval PostData,byref strlocation)
      dim xmlhttp,xmlget,bgpos,endpos,sendtype
      HttpID = HttpID + 1
      if HttpID &gt; 10 then
        response.write &quot;1,连接次数过多&quot;
        response.end
      end if
      strlocation = &quot;&quot;
      sendtype = &quot;SENDTYPE=GET&quot;
      Set xmlhttp = Server.CreateObject(&quot;WinHttp.WinHttpRequest.5.1&quot;)
      xmlhttp.Option(6)=0
      With xmlhttp
        .setTimeouts 200000,200000,200000,200000
        if left(PostData,len(sendtype)) = sendtype then
          url = url &amp; &quot;?&quot; &amp; replace(PostData,sendtype,&quot;&quot;)
          PostData = &quot;&quot;
          .Open &quot;GET&quot;, url , False
        else
          .Open &quot;POST&quot;, url, False
        end if
        .setRequestHeader &quot;CONTENT-TYPE&quot;,&quot;application/x-www-form-urlencoded&quot;
        .setRequestHeader &quot;Content-Length&quot;,Len(PostData)
        .setRequestHeader &quot;Referer&quot;,&quot;http://www.miaoqiyuan.cn/p/winhttp-winhttprequest-5-1_demo&quot;
        If Application(AppName &amp; &quot;APIOPcookie&quot;)&lt;&gt;&quot;&quot; Then .setRequestHeader &quot;COOKIE&quot;, Application(AppName &amp; &quot;APIOPcookie&quot;)
        .Send PostData
        If InStr(LCase(.GetAllResponseHeaders),&quot;location:&quot;) Then
          strlocation = .GetResponseHeader(&quot;location&quot;)
        end if
        If InStr(.GetAllResponseHeaders,&quot;Set-Cookie&quot;) Then
          If InStr(.getResponseHeader(&quot;Set-Cookie&quot;),&quot;PHPSESSID&quot;) or InStr(.getResponseHeader(&quot;Set-Cookie&quot;),&quot;SPSESSION&quot;) then
            Application(AppName &amp; &quot;APIOPcookie&quot;) = .getResponseHeader(&quot;Set-Cookie&quot;)
            Application(AppName &amp; &quot;APIOPcookie&quot;) = left(Application(AppName &amp; &quot;APIOPcookie&quot;),instr(1,Application(AppName &amp; &quot;APIOPcookie&quot;),&quot;;&quot;)-1)
          End if
        End If
        xmlget = bin2str(.responseBody)
      End With
      set xmlhttp = nothing
      OpenHttp = xmlget
  End Function

  '函数名：bin2str
  '功  能：将2进制值转换为GB2312编码的字符串
  '参  数：binstr       要转换的字符
  Function bin2str(byval binstr)
      Const adTypeBinary = 1
      Const adTypeText = 2
      Dim BytesStream,StringReturn
      Set BytesStream = Server.CreateObject(&quot;ADODB.Stream&quot;)
      With BytesStream
      .Type = adTypeText
      .Open
      .WriteText binstr
      .Position = 0
      .Charset = &quot;GB2312&quot;
      .Position = 2
      StringReturn = .ReadText
      .close
      End With
      Set BytesStream = Nothing
      bin2str = StringReturn
  End Function

  '函数名：OpenRegExp
  '功  能：创建正则对象，如果已经创建，则不重复创建
  '参  数：&amp;re       要创建的正则对象变量名称
  function OpenRegExp(byref re)
    if not isobject(re) then
      set re = new RegExp
      re.ignorecase = true
      re.global     = true
    end if
  end function

  '函数名：OnlyTd
  '功  能：去掉字体样式、换行符、空格
  '参  数：html      要处理的Html代码
  function OnlyTd(byval Html)
    Html = replace(Html,vbCrlf,&quot;&quot;)
    Html = replace(Html,&quot;&lt;br /&gt;&quot;,&quot;&quot;)
    Html = replace(Html,&quot;&lt;br&gt;&quot;,&quot;&quot;)
    Html = replace(Html,&quot;&lt;br/&gt;&quot;,&quot;&quot;)
    Html = replace(Html,&quot;&lt;/font&gt;&quot;,&quot;&quot;)
    Html = replace(Html,&quot;&amp;nbsp;&quot;,&quot;&quot;)
    call OpenRegExp(re)
    Html = re.replace(Html,&quot;&quot;)
    re.pattern = &quot;&lt;font([^&lt;]*)&gt;&quot;
    Html = re.replace(Html,&quot;&quot;)
    OnlyTd = Html
  end function

  '函数名：NotLink
  '功  能：去掉所有链接
  '参  数：html      要处理的Html代码
  function NotLink(byval Html)
    call OpenRegExp(re)
    Html = replace(Html,&quot;&lt;/a&gt;&quot;,&quot;&quot;)
    re.pattern = &quot;&lt;a([^&lt;]*)&gt;&quot;
    Html = re.replace(Html,&quot;&quot;)
    NotLink = Html
  end function

  '函数名：notImage
  '功  能：去掉所有图片标签
  '参  数：html      要处理的Html代码
  function notImage(byval Html)
    call OpenRegExp(re)
    re.pattern = &quot;&lt;img([^&lt;]*)&gt;&quot;
    Html = re.replace(Html,&quot;&quot;)
    notImage = Html
  end function

  '函数名：midtrim
  '功  能：去掉所有多余的空格
  '参  数：html      要处理的Html代码
  function midtrim(byval s)
    s = trim(s)
    s = replace(s,&quot;	&quot;,&quot;&quot;)
    for k = 0 to 50
      s = replace(s,&quot;  &quot;,&quot; &quot;)
    next
    midtrim = s
  end function

  '函数名：Connect
  '功  能：连接CNZZ并返回处理结果，如果没有登录，自动重新登录
  '参  数：act      操作名称，主要简化代码量(&quot;http://new.cnzz.com/[ACT].php&quot;)
  '        str      请求的数据
  Function Connect(byval act,byval str)
    dim html
    html = OpenHttp(&quot;http://new.cnzz.com/&quot; &amp; act &amp; &quot;.php&quot;,str,strlocation)
    '如果未登录状态
    if instr(html,&quot;已超时，请重新登录&quot;)&gt;0 then
      '重新登陆
      login = OpenHttp(&quot;http://new.cnzz.com/user/login.php&quot;,&quot;username=&quot; &amp; CNZZ_User &amp; &quot;&amp;password=&quot; &amp; CNZZ_Password &amp; &quot;&amp;list=1&amp;remuser=1&quot;,strlocation)
      if strlocation &lt;&gt; &quot;/v1/main.php?s=site_list&quot; then
        response.write &quot;//账号认证失败&quot;
      end if
      Connect = Connect(act,str)
    else
      Connect = html
    end if
  End Function

  '方法名：getData
  '功  能：从CNZZ返回某站点数据
  Sub getData()
    dim id,html
    id = request(&quot;id&quot;)
    if trim(id) = &quot;&quot; or not isnumeric(id) then
      response.write &quot;//非法请求&quot;
    else
      id = cLng(id)
      html = Connect(&quot;v1/data/site_list_data&quot;,&quot;SENDTYPE=GETsiteid=&quot; &amp; id)
      html = &quot;var data_arr = &quot; &amp; html &amp; &quot;;&quot; &amp; _
             &quot;var data_obj = document.getElementById('&quot; &amp; id &amp; &quot;_ty').getElementsByTagName('td');&quot; &amp; _
             &quot;data_obj[5].colSpan = 1;&quot; &amp; _
             &quot;var data_cel = data_obj[5].parentNode;&quot; &amp; _
             &quot;data_cel.insertCell();&quot; &amp; _
             &quot;data_cel.insertCell();&quot; &amp; _
             &quot;var outstr = '&lt;table width=&quot;&quot;100%&quot;&quot;&gt;';&quot; &amp; _
             &quot;data_obj[1].innerHTML = data_arr[0][0];&quot; &amp; _
             &quot;data_obj[2].innerHTML = data_arr[0][1];&quot; &amp; _
             &quot;data_obj[3].innerHTML = data_arr[0][2];&quot; &amp; _
             &quot;data_obj[5].innerHTML = data_arr[1][0];&quot; &amp; _
             &quot;data_obj[6].innerHTML = data_arr[1][1];&quot; &amp; _
             &quot;data_obj[7].innerHTML = data_arr[1][2];&quot; &amp; _
             &quot;&quot;
      response.write html
    end if
  End Sub

  '方法名：Main
  '功  能：从CNZZ返回站点列表
  Sub Main()
    dim html
    html = Connect(&quot;v1/main&quot;,&quot;SENDTYPE=GETs=site_list&quot;)
    html = onlyTd(html)
    html = notlink(html)
    html = notImage(html)
    Call OpenRegExp(re)
    html = replace(html,&quot;获取代码 | 设置 | 清零 | 删除&quot;,&quot;-&quot;)
    html = replace(html,&quot;cellspacing=&quot;&quot;0&quot;&quot; cellpadding=&quot;&quot;0&quot;&quot;&quot;,&quot;cellspacing=&quot;&quot;1&quot;&quot; cellpadding=&quot;&quot;1&quot;&quot;&quot;)
    re.pattern = &quot;&lt;span style=&quot;&quot;float:right;padding-top:5px; padding-left:8px;&quot;&quot;&gt;&lt;/span&gt;&lt;/div&gt;	   &lt;/div&gt;(.*)&lt;tr&gt;              &lt;td height=&quot;&quot;40&quot;&quot; colspan=&quot;&quot;5&quot;&quot; style=&quot;&quot;text-align:center;&quot;&quot;&gt;如希望继续添加站点，请点击此处&quot;
    set p = re.execute(html)
    if p.count &gt; 0 then
      MainUI p(0).submatches(0)
    else
      response.write &quot;对不起，CNZZ改版了。请访问：http://www.miaoqiyuan.cn/p/WinHttp-WinHttpRequest-5-1_DEMO 获取最新版本&quot;
    end if
  End Sub

  '方法名：MainUI
  '功  能：友好的显示处理结果
  '参  数：body     输出正文内容
  Sub MainUI(byval body)
    dim html
    body = midtrim(body)
    html = &quot;&lt;html&gt;&quot; &amp; _
           &quot;&lt;head&gt;&lt;meta http-equiv=&quot;&quot;Content-Type&quot;&quot; content=&quot;&quot;text/html;charset=gb2312&quot;&quot;&gt;&quot; &amp; _
           &quot;&lt;title&gt;WinHttpRequest DEMO by Miaoqiyuan.cn - 实时获取CNZZ统计信息&lt;/title&gt;&quot; &amp; _
           &quot;&lt;script type=&quot;&quot;text/javascript&quot;&quot;&gt;&quot; &amp; _
           &quot;function site_data(id){var s = document.createElement('script');s.src = '?act=data&amp;id=' + id;document.getElementsByTagName('head')[0].appendChild(s);}&quot; &amp; _
           &quot;&lt;/script&gt;&quot; &amp; _
           &quot;&lt;style type=&quot;&quot;text/css&quot;&quot;&gt;&quot; &amp; _
           &quot;.list_box{width:900px;background:#666;};&quot; &amp; _
           &quot;.list_box td,.list_box th{background:#FFF;line-height:25px;text-align:center;};&quot; &amp; _
           &quot;.tr-bg4 td,.tr-bg4 th{background:#666;line-height:25px;};&quot; &amp; _
           &quot;&lt;/style&gt;&quot; &amp; _
           &quot;&lt;/head&gt;&quot; &amp; _
           &quot;&lt;body&gt;&lt;center&gt;&lt;h1&gt;WinHttpRequest DEMO by Miaoqiyuan.cn&lt;/h1&gt;&lt;h2&gt;实时获取CNZZ统计信息&lt;/h2&gt;&lt;hr /&gt;&quot; &amp; _
           body &amp; _
           &quot;&lt;/table&gt;&lt;hr /&gt;Copyright: miaoqiyuan.cn 2011-&quot; &amp; year(now) &amp; &quot;&quot; &amp; _
           &quot;&lt;/center&gt;&lt;/body&gt;&lt;/html&gt;&quot;
    response.write html
  End Sub

  '入口
  select case request(&quot;act&quot;)
    case &quot;data&quot;
      Call getData()
    case else
      Call Main()
  end select
</pre>
<p><center><img src="/images/uploads/2011/12/winhttprequest_demo.jpg" /></center></p>
<p>   <a name="51la"></a><br />
<h2>实时获取51.la统计信息 ASP版</h2>
<pre class="brush: vb; title: ;">
  '=======================================================================
  '=            WinHttpRequest演示实例 - 实时获取51.la统计信息            =
  '=     Copyright (c) 2011 猫七(QQ:77068320) All rights reserverd.      =
  '=              请尊重作者劳动成果，转载请保留代码的完整性               =
  '=======================================================================
  '= 作者：苗启源(博客:http://www.miaoqiyuan.cn)                          =
  '= 讨论：http://www.miaoqiyuan.cn/p/winhttp-winhttprequest-5-1_demo
  '= 最新：http://www.miaoqiyuan.cn/products/winhttprequest_51lademo.rar
  '=======================================================================
  '=  返回首页站点列表： winhttprequest_demo_51la.asp                     =
  '=  读取并输出验证码： winhttprequest_demo_51la.asp?act=getcode         =
  '=  显示数据验证码框： winhttprequest_demo_51la.asp?act=login           =
  '=  验证验证码并登陆： winhttprequest_demo_51la.asp?act=dologin         =
  '=======================================================================
  '=  文件名：winhttprequest_demo_51la.asp                               =
  '=  功  能：免登陆查看51.la 网站流量统计信息                             =
  '=======================================================================

  Dim HttpID,AppName,CNZZ_User,CNZZ_Password
  HttpID        = 0
  AppName       = &quot;app_51.la_demo&quot;                      '应用程序名前缀，防止感染其他程序Application变量
  La51_User     = &quot;myw3demo&quot;                            '51.la账号
  La51_Password = &quot;la51test&quot;                            '51.la密码

  '函数名：OpenHttp
  '功  能：创建Http请求，并返回服务器处理结果
  '参  数：url          请求地址
  '        PostData     请求数据包，如果是Get请求，请以SENDTYPE=GET开头
  '        &amp;strlocation 如果是服务器重定向网址，则返回重定向的地址
  '特  点：自动保存/共享cookies，多次请求能保存登录状态，新增二进制获取
  Function OpenHttp(byval url,byval PostData,byref strlocation)
      dim xmlhttp,xmlget,bgpos,endpos,sendtype,imgtype,isbinstr
      HttpID = HttpID + 1
      if HttpID &gt; 10 then
        response.write &quot;1,连接次数过多&quot;
        response.end
      end if
      strlocation = &quot;&quot;
      '与CNZZ的实例对比，增加了获取验证码的功能
      sendtype = &quot;SENDTYPE=GET&quot;
      imgtype  = &quot;GETTYPE=IMAGE&quot;
      isbinstr = false
      Set xmlhttp = Server.CreateObject(&quot;WinHttp.WinHttpRequest.5.1&quot;)
      xmlhttp.Option(6)=0
      With xmlhttp
        .setTimeouts 200000,200000,200000,200000
        if left(PostData,len(sendtype)) = sendtype or left(PostData,len(imgtype)) = imgtype then
          if left(PostData,len(sendtype)) = sendtype then
            url = url &amp; &quot;?&quot; &amp; replace(PostData,sendtype,&quot;&quot;)
          else
            url = url &amp; &quot;?&quot; &amp; replace(PostData,imgtype,&quot;&quot;)
            isbinstr = true
          end if
          PostData = &quot;&quot;
          .Open &quot;GET&quot;, url , False
        else
          .Open &quot;POST&quot;, url, False
        end if
        .setRequestHeader &quot;CONTENT-TYPE&quot;,&quot;application/x-www-form-urlencoded&quot;
        .setRequestHeader &quot;Content-Length&quot;,Len(PostData)
        .setRequestHeader &quot;Referer&quot;,&quot;http://www.miaoqiyuan.cn/p/winhttp-winhttprequest-5-1_demo&quot;
        If Application(AppName &amp; &quot;APIOPcookie&quot;)&lt;&gt;&quot;&quot; Then .setRequestHeader &quot;COOKIE&quot;, Application(AppName &amp; &quot;APIOPcookie&quot;)
        .Send PostData
        If InStr(LCase(.GetAllResponseHeaders),&quot;location:&quot;) Then
          strlocation = .GetResponseHeader(&quot;location&quot;)
        end if
        '阿江的Cookies比较变态，有3个Set-Cookie，因为这个问题，浪费了好几个小时
        If InStr(.GetAllResponseHeaders,&quot;Set-Cookie&quot;) Then
            Application(AppName &amp; &quot;APIOPcookie&quot;) = getAJiangCookies(.GetAllResponseHeaders)
        End If
        if isbinstr then
          xmlget = .responseBody
        else
          xmlget = bin2str(.responseBody)
        end if
      End With
      set xmlhttp = nothing
      OpenHttp = xmlget
  End Function

  '函数名：bin2str
  '功  能：将2进制值转换为GB2312编码的字符串
  '参  数：binstr       要转换的字符
  Function bin2str(byval binstr)
      Const adTypeBinary = 1
      Const adTypeText = 2
      Dim BytesStream,StringReturn
      Set BytesStream = Server.CreateObject(&quot;ADODB.Stream&quot;)
      With BytesStream
      .Type = adTypeText
      .Open
      .WriteText binstr
      .Position = 0
      .Charset = &quot;GB2312&quot;
      .Position = 2
      StringReturn = .ReadText
      .close
      End With
      Set BytesStream = Nothing
      bin2str = StringReturn
  End Function

  '函数名：getAJiangCookies
  '功  能：从http头中返回多个cookies值
  '参  数：strHeader    HTTP头
  Function getAJiangCookies(byval strHeader)
    dim tmp,ltmp,sck
    tmp = &quot;&quot;
    sck = &quot;Set-Cookie:&quot;
    for each ltmp in split(strHeader,vbCrlf)
      if left(ltmp,len(sck)) = sck then
        if tmp &lt;&gt; &quot;&quot; then tmp = tmp &amp; &quot;;&quot;
        ltmp = mid(ltmp,len(sck) + 2)
        tmp = tmp &amp; split(ltmp,&quot;; &quot;)(0)
      end if
    next
    tmp = tmp &amp; &quot;; expires=Tue, 23-Sep-2014 16:00:00 GMT; path=/&quot;
    getAJiangCookies = tmp
  End Function

  '函数名：OpenRegExp
  '功  能：创建正则对象，如果已经创建，则不重复创建
  '参  数：&amp;re       要创建的正则对象变量名称
  Function OpenRegExp(byref re)
    if not isobject(re) then
      set re = new RegExp
      re.ignorecase = true
      re.global     = true
    end if
  End Function

  '函数名：NotLink
  '功  能：去掉所有链接
  '参  数：html      要处理的Html代码
  Function NotLink(byval Html)
    call OpenRegExp(re)
    Html = replace(Html,&quot;&lt;/a&gt;&quot;,&quot;&quot;)
    re.pattern = &quot;&lt;a([^&lt;]*)&gt;&quot;
    Html = re.replace(Html,&quot;&quot;)
    NotLink = Html
  End Function

  '函数名：notImage
  '功  能：去掉所有图片标签
  '参  数：html      要处理的Html代码
  function notImage(byval Html)
    call OpenRegExp(re)
    re.pattern = &quot;&lt;img([^&lt;]*)&gt;&quot;
    Html = re.replace(Html,&quot;&quot;)
    notImage = Html
  end function

  '函数名：midtrim
  '功  能：去掉所有多余的空格
  '参  数：html      要处理的Html代码
  Function midtrim(byval s)
    s = trim(s)
    s = replace(s,&quot;	&quot;,&quot;&quot;)
    for k = 0 to 50
      s = replace(s,&quot;  &quot;,&quot; &quot;)
    next
    midtrim = s
  End Function

  '函数名：Connect
  '功  能：连接51.la并返回处理结果，如果没有登录，自动重新登录
  '参  数：act      操作名称，主要简化代码量(&quot;http://www.51.la/[ACT].asp&quot;)
  '        str      请求的数据
  Function Connect(byval act,byval str)
    dim html
    html = OpenHttp(&quot;http://www.51.la/&quot; &amp; act &amp; &quot;.asp&quot;,str,strlocation)
    '如果未登录状态，则进入登录页面
    if strlocation = &quot;../login.asp&quot; then
      response.redirect &quot;?act=login&quot;
    elseif strlocation &lt;&gt; &quot;&quot; then
      Connect = strlocation
    else
      Connect = html
    end if
  End Function

  '方法名：getCode
  '功  能：获取验证码
  Sub getCode()
    dim html
    Response.Expires = -9999
    Response.AddHeader &quot;Pragma&quot;,&quot;no-cache&quot;
    Response.AddHeader &quot;cache-ctrol&quot;,&quot;no-cache&quot;
    Response.ContentType = &quot;Image/BMP&quot;
    response.binarywrite Connect(&quot;user/vcode&quot;,&quot;GETTYPE=IMAGE&quot;)
  End Sub

  '方法名：Main
  '功  能：从51.la返回站点列表
  Sub Main()
    dim html,pe,pa,pm,re,ra,rm
    html = Connect(&quot;user/index&quot;,&quot;SENDTYPE=GETall=yes&quot;)
    html = notImage(html)
    html = notLink(html)
    Call OpenRegExp(re)
    Call OpenRegExp(ra)
    Call OpenRegExp(rm)
    re.pattern = &quot;[\S\s]*点击“查看统计报表”可查看实时数据。&quot;
    ra.pattern = &quot;\( 合计当前显示的[\S\s]*&quot;
    rm.pattern = &quot;&lt;div class=&quot;&quot;sitelist_o&quot;&quot;&gt;[^&lt;]*&lt;/div&gt;&quot;
    set pe = re.execute(html)
    set pa = ra.execute(html)
    set pm = rm.execute(html)
    if pe.count = 0 or pa.count = 0  or pm.count = 0 then
      response.write &quot;对不起，51.la改版了。请访问：http://www.miaoqiyuan.cn/p/WinHttp-WinHttpRequest-5-1_DEMO 获取最新版本&quot;
    else
      html = re.replace(html,&quot;&quot;)
      html = ra.replace(html,&quot;&quot;)
      html = rm.replace(html,&quot;&quot;)
      html = &quot;&lt;div&gt;&quot; &amp; html &amp; &quot;&lt;/div&gt;&quot;
      Call MainUI(html)
    end if
  End Sub

  '方法名：Login
  '功  能：获取登录界面
  Sub Login()
    dim html
    html = &quot;&lt;form action=&quot;&quot;?act=dologin&quot;&quot; method=&quot;&quot;POST&quot;&quot;&gt;&quot; &amp; _
           &quot;第一次访问的时候，需要输入验证码：&quot; &amp; _
           &quot;&lt;input name=&quot;&quot;vcode&quot;&quot; size=&quot;&quot;4&quot;&quot; /&gt;&quot; &amp; _
           &quot; &lt;img src=&quot;&quot;?act=getcode&amp;timer=&quot; &amp; timer() &amp; &quot;&quot;&quot; /&gt; &quot; &amp; _
           &quot;&lt;input type=&quot;&quot;submit&quot;&quot; value=&quot;&quot;提交&quot;&quot;/&gt;&quot; &amp; _
           &quot;&lt;/form&gt;&quot;
    Call MainUI(html)
  End Sub

  '方法名：doLogin
  '功  能：登录51.la
  Sub doLogin()
    dim html,vcode,sendStr
    vcode   = request(&quot;vcode&quot;)
    sendStr = &quot;uname=&quot; &amp; La51_User &amp; _
              &quot;&amp;upass=&quot; &amp; La51_Password &amp; _
              &quot;&amp;vcode=&quot; &amp; vcode &amp; _
              &quot;&amp;remb=yes&quot;
    html = Connect(&quot;login&quot;,sendStr)
    if html = &quot;user/&quot; then
      response.redirect &quot;?act=list&quot;
    elseif instr(html,&quot;验证码不正确&quot;) then
      Call MainUI(&quot;&lt;a href=&quot;&quot;?act=login&quot;&quot;&gt;验证码不正确，请重新登录&lt;/a&gt;&quot;)
    else
      Call MainUI(&quot;&lt;a href=&quot;&quot;?act=login&quot;&quot;&gt;账号或密码错误，请修改配置并重新登录&lt;/a&gt;&quot;)
    end if
  End Sub

  '方法名：MainUI
  '功  能：友好的显示处理结果
  '参  数：body     输出正文内容
  Sub MainUI(byval body)
    dim html
    body = midtrim(body)
    html = &quot;&lt;html&gt;&quot; &amp; _
           &quot;&lt;head&gt;&lt;meta http-equiv=&quot;&quot;Content-Type&quot;&quot; content=&quot;&quot;text/html;charset=gb2312&quot;&quot;&gt;&quot; &amp; _
           &quot;&lt;title&gt;WinHttpRequest DEMO by Miaoqiyuan.cn - 实时获取51.la统计信息&lt;/title&gt;&quot; &amp; _
           &quot;&lt;style type=&quot;&quot;text/css&quot;&quot;&gt;&quot; &amp; _
           &quot;.sitelist_n{height:35px;width:620px;background:#CCC;color:#000;line-height:35px;text-align:left;text-indent:10px;font-weight:800;}&quot; &amp; _
           &quot;.sitelist_s{height:35px;width:620px;color:#666;line-height:35px;font-size:13px;text-align:left;text-indent:20px;}&quot; &amp; _
           &quot;&lt;/style&gt;&quot; &amp; _
           &quot;&lt;/head&gt;&quot; &amp; _
           &quot;&lt;body&gt;&lt;center&gt;&lt;h1&gt;WinHttpRequest DEMO by Miaoqiyuan.cn&lt;/h1&gt;&lt;h2&gt;实时获取51.la统计信息&lt;/h2&gt;&lt;hr /&gt;&quot; &amp; _
           body &amp; _
           &quot;&lt;hr /&gt;Copyright: miaoqiyuan.cn 2011-&quot; &amp; year(now) &amp; &quot;&quot; &amp; _
           &quot;&lt;/center&gt;&lt;/body&gt;&lt;/html&gt;&quot;
    response.write html
  End Sub

  '入口
  select case request(&quot;act&quot;)
    case &quot;getcode&quot;
      Call getCode()
    case &quot;login&quot;
      Call Login()
    case &quot;dologin&quot;
      Call doLogin()
    case else
      Call Main()
  end select
</pre>
<p><center><img src="/images/uploads/2011/12/winhttprequest_demo_51la.jpg" /></center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.miaoqiyuan.cn/p/winhttp-winhttprequest-5-1_demo/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>自己写的ASP汉字转拼音的程序</title>
		<link>http://www.miaoqiyuan.cn/p/asp-pinyin</link>
		<comments>http://www.miaoqiyuan.cn/p/asp-pinyin#comments</comments>
		<pubDate>Fri, 23 Dec 2011 14:56:31 +0000</pubDate>
		<dc:creator>mqycn</dc:creator>
				<category><![CDATA[ASP]]></category>

		<guid isPermaLink="false">http://www.miaoqiyuan.cn/?p=781</guid>
		<description><![CDATA[    自己写的ASP汉字转拼音的程序，支持部分不常见汉字的拼音。更多不常见汉字的拼音正在整理中，更新地址：http://www.miaoqiyuan.cn/product/update/pinyin.db.rar

  '=====================================================================
  '  意见反馈地址：http://www.miaoqiyuan.cn/p/asp-pinyin
  '  最新数据库：http://www.miaoqiyuan.cn/Products/update/pinyin.db.zip
  '=====================================================================
  '函数名：GET_PINYIN
  '  功能：返回拼音
  '  参数：word  - 要转换的汉字，只支持一个汉字
  Function GET_PINYIN(word)
    if asc(word) &#62; 0 and asc(word) &#60; 128 then
      GET_PINYIN = word
   [...]]]></description>
			<content:encoded><![CDATA[<p>    自己写的ASP汉字转拼音的程序，支持部分不常见汉字的拼音。更多不常见汉字的拼音正在整理中，更新地址：http://www.miaoqiyuan.cn/product/update/pinyin.db.rar</p>
<pre class="brush: vb; title: ;">
  '=====================================================================
  '  意见反馈地址：http://www.miaoqiyuan.cn/p/asp-pinyin
  '  最新数据库：http://www.miaoqiyuan.cn/Products/update/pinyin.db.zip
  '=====================================================================
  '函数名：GET_PINYIN
  '  功能：返回拼音
  '  参数：word  - 要转换的汉字，只支持一个汉字
  Function GET_PINYIN(word)
    if asc(word) &gt; 0 and asc(word) &lt; 128 then
      GET_PINYIN = word
      exit function
    end if
    if word = &quot;，&quot; or word = &quot;。&quot; or word = &quot;、&quot; or word = &quot;’&quot; or word = &quot;‘&quot;  or word = &quot;“&quot;  or word = &quot;”&quot; or word = &quot;：&quot; then
      GET_PINYIN = word
      exit function
    end if
    set pydb = server.createobject(&quot;ADODB.Connection&quot;)
    pydb.open &quot;provider=microsoft.jet.oledb.4.0;data source=&quot; &amp; Server.Mappath(&quot;py.db&quot;)
    set pyrs = pydb.execute(&quot;select pinyin from PinYin where content like '%&quot; &amp; word &amp; &quot;%'&quot;)
    if pyrs.eof then
      GET_PINYIN = &quot;__&quot;
    else
      GET_PINYIN = pyrs(0)
    end if
    pyrs.close
    set pyrs = nothing
    pydb.close
    set pydb = nothing
  End Function

  dim str,tmp
  str = &quot;猫七，一个不知名程序员，博客地址是：http://www.miaoqiyuan.cn/&quot;
  tmp = &quot;&quot;
  for i = 1 to len(str)
    tmp = tmp &amp; mid(str,i,1)
  next
  response.write tmp
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.miaoqiyuan.cn/p/asp-pinyin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>决定把WP升级到3.2</title>
		<link>http://www.miaoqiyuan.cn/p/wp32</link>
		<comments>http://www.miaoqiyuan.cn/p/wp32#comments</comments>
		<pubDate>Wed, 23 Nov 2011 13:38:48 +0000</pubDate>
		<dc:creator>mqycn</dc:creator>
				<category><![CDATA[Life(生活)]]></category>

		<guid isPermaLink="false">http://www.miaoqiyuan.cn/?p=776</guid>
		<description><![CDATA[从2007-03-09开始，我的博客已经运行了1720天了。曾经更换过多次程序，最终运到Wordpress才稳定下来。结婚前坚持每月写几篇文章，Wordpress一直都是更新到最新版。
09年结婚后，事情太多，基本不写博客了。Wordpress之后基本没升级过，如今官方竟然升级到了3.2，我的博客却永远的定格了2.6。
最近决定升级，好好整理整理，重新开始博客生活。
]]></description>
			<content:encoded><![CDATA[<p>从2007-03-09开始，我的博客已经运行了1720天了。曾经更换过多次程序，最终运到Wordpress才稳定下来。结婚前坚持每月写几篇文章，Wordpress一直都是更新到最新版。</p>
<p>09年结婚后，事情太多，基本不写博客了。Wordpress之后基本没升级过，如今官方竟然升级到了3.2，我的博客却永远的定格了2.6。</p>
<p>最近决定升级，好好整理整理，重新开始博客生活。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miaoqiyuan.cn/p/wp32/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows8不是怪胎，我们都是out man</title>
		<link>http://www.miaoqiyuan.cn/p/hello-world</link>
		<comments>http://www.miaoqiyuan.cn/p/hello-world#comments</comments>
		<pubDate>Wed, 23 Nov 2011 13:24:10 +0000</pubDate>
		<dc:creator>mqycn</dc:creator>
				<category><![CDATA[Life(生活)]]></category>
		<category><![CDATA[Thinks(想法)]]></category>

		<guid isPermaLink="false">http://www.miaoqiyuan.cn/?p=772</guid>
		<description><![CDATA[谷歌的Chrome系统终于出现了，它的最大的优点是开机速度超快、入手超简单。进入ChromeOS，唯一的程序就是一个浏览器。所以可以说对所有木马和病毒免疫。所有文档均云存储在互联网上，不用担心丢失，也令其成为最安全的操作系统，另外几秒钟便可启动并接入互联网，也让同类上网本黯然失色。目前Win8是唯一能与之抗衡的系统。
可能用过Win8的用户，会感觉Win8是个怪胎。如果同时用ChromeOS和Win8的用户，会无奈的发现。这是一场革命。就像Win取代Dos，一部留神。我们都Out了。要知道当初Dos用户也说自己用的最优秀的系统，Win98/Win2000到05年的时候，仍占半壁江山。

2001年的XP到2011，已经在我们的PC上运行了十年，仍然占86%的市场。微软已经明确表示于2014年取消WinXP的技术支持，这就意味着2014年后漏洞满天飞。就在国人还没准备升级到Win7的时候。Win8已经悄悄的来了。也许有人说Win8是怪胎。
2010年1月，Win7国内市场占用率2.9%，7月达到4.87%，2011年1月8.91%，2011年6月12.21%，2011年10月15.32。曾经自诩是电脑高手我，今天才发现电脑竟然是如此的陌生。
云计算的概念已经炒了几年，到目前仍然没有一个标准。但是云计算的概念却越来越清晰。谷歌期待着ChromeOS操作系统使谷歌更深入地进入云计算领域，作为微软Windows和苹果Mac计算机的替代产品。谷歌将用ChromeOS操作系统把赌注押在云计算方面。
使用ChromeOS操作系统，用户不需要下载软件或者在内部存储数据。数据位于谷歌的云计算中，在世界各地的数据中心中的并行排列的服务器支持谷歌的云计算。
未来的电脑应该朝移动，带宽，云计算发展。可能仍然有人会站出来说：功能是不错，那我们常用的PhotoShop怎么运行的。这点你可以去了解下Native Client。
第一，移动，移动就意味这有限的电池容量，意味着小屏幕，这对于基于Chrome OS这样的精简系统是天然友好的。未来取决于公司愿意员工走出去，还是留在办公室。这是手机和PC之争。
第二，带宽，由于Chrome OS的应用第一次使用时都要从网上下载，高带宽会大大提高系统的可用性。这就看3G,4G的发展速度。
第三，云计算， 是否有足够的云端应用供Chrome OS来使用。
您可以说讨厌Win8、讨厌ChromeOS，但是你阻止不了他的发展。抛弃WindowsXP是迟早的事情。
曾经记得哪位高人说过：人生最大的敌人是自己。现在看来果然不错，Microsoft的Windows打败了无数对手，目前最大的敌人就是IE6和WinXP。Google的Android目前是安装量最多的手机操作系统，他的最大的麻烦就是出现了太多的自己(版本太多)。
猫七 于 2011.11.23
]]></description>
			<content:encoded><![CDATA[<p>谷歌的Chrome系统终于出现了，它的最大的优点是开机速度超快、入手超简单。进入ChromeOS，唯一的程序就是一个浏览器。所以可以说对所有木马和病毒免疫。所有文档均云存储在互联网上，不用担心丢失，也令其成为最安全的操作系统，另外几秒钟便可启动并接入互联网，也让同类上网本黯然失色。目前Win8是唯一能与之抗衡的系统。</p>
<p>可能用过Win8的用户，会感觉Win8是个怪胎。如果同时用ChromeOS和Win8的用户，会无奈的发现。这是一场革命。就像Win取代Dos，一部留神。我们都Out了。要知道当初Dos用户也说自己用的最优秀的系统，Win98/Win2000到05年的时候，仍占半壁江山。</p>
<p><span id="more-772"></span></p>
<p>2001年的XP到2011，已经在我们的PC上运行了十年，仍然占86%的市场。微软已经明确表示于2014年取消WinXP的技术支持，这就意味着2014年后漏洞满天飞。就在国人还没准备升级到Win7的时候。Win8已经悄悄的来了。也许有人说Win8是怪胎。</p>
<p>2010年1月，Win7国内市场占用率2.9%，7月达到4.87%，2011年1月8.91%，2011年6月12.21%，2011年10月15.32。曾经自诩是电脑高手我，今天才发现电脑竟然是如此的陌生。</p>
<p>云计算的概念已经炒了几年，到目前仍然没有一个标准。但是云计算的概念却越来越清晰。谷歌期待着ChromeOS操作系统使谷歌更深入地进入云计算领域，作为微软Windows和苹果Mac计算机的替代产品。谷歌将用ChromeOS操作系统把赌注押在云计算方面。</p>
<p>使用ChromeOS操作系统，用户不需要下载软件或者在内部存储数据。数据位于谷歌的云计算中，在世界各地的数据中心中的并行排列的服务器支持谷歌的云计算。</p>
<p>未来的电脑应该朝移动，带宽，云计算发展。可能仍然有人会站出来说：功能是不错，那我们常用的PhotoShop怎么运行的。这点你可以去了解下Native Client。</p>
<p>第一，移动，移动就意味这有限的电池容量，意味着小屏幕，这对于基于Chrome OS这样的精简系统是天然友好的。未来取决于公司愿意员工走出去，还是留在办公室。这是手机和PC之争。</p>
<p>第二，带宽，由于Chrome OS的应用第一次使用时都要从网上下载，高带宽会大大提高系统的可用性。这就看3G,4G的发展速度。</p>
<p>第三，云计算， 是否有足够的云端应用供Chrome OS来使用。</p>
<p>您可以说讨厌Win8、讨厌ChromeOS，但是你阻止不了他的发展。抛弃WindowsXP是迟早的事情。</p>
<p>曾经记得哪位高人说过：人生最大的敌人是自己。现在看来果然不错，Microsoft的Windows打败了无数对手，目前最大的敌人就是IE6和WinXP。Google的Android目前是安装量最多的手机操作系统，他的最大的麻烦就是出现了太多的自己(版本太多)。</p>
<p style="text-align: right;">猫七 于 2011.11.23</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miaoqiyuan.cn/p/hello-world/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>程序员买房的笑话</title>
		<link>http://www.miaoqiyuan.cn/p/programmer-buyhouse</link>
		<comments>http://www.miaoqiyuan.cn/p/programmer-buyhouse#comments</comments>
		<pubDate>Mon, 31 Oct 2011 09:02:31 +0000</pubDate>
		<dc:creator>mqycn</dc:creator>
				<category><![CDATA[ASP]]></category>
		<category><![CDATA[Life(生活)]]></category>
		<category><![CDATA[VBscript]]></category>

		<guid isPermaLink="false">http://www.miaoqiyuan.cn/?p=761</guid>
		<description><![CDATA[google很给力的笔试题：现在北京有一套房子，价格200万，假设房价每年上涨10%，一个软件工程师每年固定能赚40万。如果他想买这套房子，不贷款，不涨工资，没有其他收入，每年不吃不喝不消费，那么他需要几年才能攒够钱买这套房子？
A, 5年
B, 7年
C, 8年
D, 9年
E, 永远买不起
而且出现在一个笑话网站上，那么程序员到底能不能买到房子呢？

'===============================================================================
' 程序员买房 by 苗启源
'===============================================================================
'    google很给力的笔试题：现在北京有一套房子，价格200万，假设房价每年上涨10%，一个软件工程师每年固定能赚40万。如果他想买这套房子，不贷款，不涨工资，没有其他收入，每年不吃不喝不消费，那么他需要几年才能攒够钱买这套房子？
'     A, 5年
'     B, 7年
'     C, 8年
'     D, 9年
'     E, 永远买不起
'===============================================================================

function buyHouse(byval iyear)
  dim price,rise,wage
  price = 200
  rise  [...]]]></description>
			<content:encoded><![CDATA[<p>google很给力的笔试题：现在北京有一套房子，价格200万，假设房价每年上涨10%，一个软件工程师每年固定能赚40万。如果他想买这套房子，不贷款，不涨工资，没有其他收入，每年不吃不喝不消费，那么他需要几年才能攒够钱买这套房子？<br />
<span id="more-761"></span>A, 5年<br />
B, 7年<br />
C, 8年<br />
D, 9年<br />
E, 永远买不起</p>
<p>而且出现在一个笑话网站上，那么程序员到底能不能买到房子呢？</p>
<pre class="brush: vb; title: ;">
'===============================================================================
' 程序员买房 by 苗启源
'===============================================================================
'    google很给力的笔试题：现在北京有一套房子，价格200万，假设房价每年上涨10%，一个软件工程师每年固定能赚40万。如果他想买这套房子，不贷款，不涨工资，没有其他收入，每年不吃不喝不消费，那么他需要几年才能攒够钱买这套房子？
'     A, 5年
'     B, 7年
'     C, 8年
'     D, 9年
'     E, 永远买不起
'===============================================================================

function buyHouse(byval iyear)
  dim price,rise,wage
  price = 200
  rise  = 0.1
  wage  = 40
  buyHouse = outStatus(iyear,cLng(price * (1 + rise)^iyear),wage * iyear)
end function

function outStatus(byval iyear,byval price,byval rise)
  dim dif
  dif = price - rise
  'debug
  wscript.echo  &quot; ==&gt; 第&quot; &amp; iyear &amp; &quot;年&quot; &amp;_
           &quot; 房价:&quot; &amp; price &amp; &quot;万&quot; &amp;_
           &quot; 存款：&quot; &amp; rise &amp; &quot;万&quot; &amp;_
           &quot; 还差：&quot; &amp; dif &amp; &quot;万&quot;
  if dif &gt; 0 then
    outStatus = &quot;失败&quot;
  else
    outStatus = &quot;成功&quot;
  end if
end function

'假如程序员工作时间35年(25毕业、60退休)
for iyear = 1 to 35
  status = buyHouse(iyear)
  if status = &quot;成功&quot; then exit for
  wscript.echo &quot; ==&gt;程序员在工作第&quot; &amp; iyear &amp; &quot;年时，买房结果：&quot;  &amp; status
next
</pre>
<p>运算结果是：买不起房子的不用抱怨了，如果房价不降，年薪40万不吃不喝，买房子也没门。<br />
<img src=http://www.miaoqiyuan.cn/images/uploads/2011/10/buyhouse-result.jpg /><br />
附上源码和测试：<br />
<img src=http://www.miaoqiyuan.cn/images/uploads/2011/10/buyhouse-code.jpg /><br />
一直努力工作，似乎第八年似乎买房就快买到房子了(差109万)，第九年以后，长时间买不起房子也就称习惯了，而且里买到房子的目标越来越远了。到50岁的时候，不禁要感慨一下。前一个25年在大学荒废了，后一个25年在一直活在买房的幻想。大半生过去了，不吃不喝不生病，买房还差1000多万。<br />
<img src=http://www.miaoqiyuan.cn/images/uploads/2011/10/buyhouse-debug.jpg /></p>
<p>本程序仅是按题目而写，当然房价会降的，我们买房还是有希望的。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miaoqiyuan.cn/p/programmer-buyhouse/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

