<?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>Hyperblue&#039;s Blog</title>
	<atom:link href="http://www.kushu.net/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kushu.net</link>
	<description>Web dev,php+mysql,js,div+css,wordpress,magento,typo3,dedecms,ecshop,discuz!</description>
	<lastBuildDate>Thu, 21 Jul 2011 06:39:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PHP 面向对象(OO)</title>
		<link>http://www.kushu.net/813.html</link>
		<comments>http://www.kushu.net/813.html#comments</comments>
		<pubDate>Thu, 21 Jul 2011 06:39:57 +0000</pubDate>
		<dc:creator>hyperblue</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[const]]></category>
		<category><![CDATA[extends]]></category>
		<category><![CDATA[final]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[oo]]></category>
		<category><![CDATA[protected]]></category>
		<category><![CDATA[public]]></category>
		<category><![CDATA[static]]></category>
		<category><![CDATA[多态]]></category>
		<category><![CDATA[面对对象]]></category>

		<guid isPermaLink="false">http://www.kushu.net/?p=813</guid>
		<description><![CDATA[Simple Example public、protected、private、__get、__set: public 表示全局，类内部外部子类都可以访问 protected表示受保护的，只有本类或子类或父类中可以访问 private表示私有的，只有本类内部可以使用 View Code PHP1 2 3 4 5 6 7 8 9 10 11...]]></description>
			<content:encoded><![CDATA[<h2>Simple Example</h2>
<p><strong>public、protected、private、__get、__set:</strong></p>
<ul>
<li>public 表示全局，类内部外部子类都可以访问</li>
<li>protected表示受保护的，只有本类或子类或父类中可以访问</li>
<li>private表示私有的，只有本类内部可以使用</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p813code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8136"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
</pre></td><td class="code" id="p813code6"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> T<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$c</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __get<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$n</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __set<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n</span><span style="color: #339933;">,</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$n</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'-'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$v</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>        
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> usechild<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>        
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'T'</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> M <span style="color: #000000; font-weight: bold;">extends</span> T<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1000</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> show<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">d</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'-'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">c</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'M'</span><span style="color: #339933;">.</span>parent<span style="color: #339933;">::</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>        
<span style="color: #000000; font-weight: bold;">class</span> N <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> M<span style="color: #339933;">::</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">// __get() __set()</span>
<span style="color: #000088;">$t</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> T<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$t</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">a</span><span style="color: #339933;">;</span>                <span style="color: #666666; font-style: italic;">//'a'</span>
<span style="color: #000088;">$t</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">c</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'value'</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// 'c-value'</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// extends</span>
<span style="color: #000088;">$m</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> M<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$m</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">usechild</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">//1000-1</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// overload</span>
<span style="color: #000088;">$n</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> N<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$n</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">//'MT'</span></pre></td></tr></table></div>

<h2>abstract</h2>
<ul>
<li>类中至少有一个抽象方法</li>
<li>抽象方法前需要加abstract</li>
<li>抽象方法无需{}</li>
<li>继承后重载的方法，必须同抽象方法的参数个数相同</li>
<li>本身都不能被实例化，必须被继承</li>
<li>继承后，需要把所有抽象方法重载在才可使用</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p813code7'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8137"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p813code7"><pre class="php" style="font-family:monospace;">abstract <span style="color: #000000; font-weight: bold;">class</span> C1<span style="color: #009900;">&#123;</span>
    abstract <span style="color: #000000; font-weight: bold;">function</span> fun1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    abstract <span style="color: #000000; font-weight: bold;">function</span> fun2<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n</span><span style="color: #339933;">,</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> C2 <span style="color: #000000; font-weight: bold;">extends</span> C1 <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> fun1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> fun2<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//参数书目必须一致</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$a</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$b</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$c2</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> C2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>static const final</h2>
<ul>
<li>static 通过self访问, 可在static fun 或 普通函数中访问</li>
<li>const 通过self访问, 可在static fun 或 普通函数中访问</li>
<li>static fun 不能访问非static或const变量</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p813code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8138"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p813code8"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> S<span style="color: #009900;">&#123;</span>
    static <span style="color: #000088;">$n</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$m</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">const</span> J <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getj<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">J</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    static <span style="color: #000000; font-weight: bold;">function</span> getm<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #000088;">$m</span><span style="color: #339933;">;</span>        
        <span style="color: #666666; font-style: italic;">// $s = new S(); $s-&gt;getm();</span>
        <span style="color: #666666; font-style: italic;">// 'error'</span>
        <span style="color: #666666; font-style: italic;">// 访问不到非static const变量</span>
        <span style="color: #666666; font-style: italic;">// 想象JS就OK了</span>
    <span style="color: #009900;">&#125;</span>
    static <span style="color: #000000; font-weight: bold;">function</span> getn<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$n</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #004000;">J</span> <span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> S<span style="color: #339933;">::</span><span style="color: #000088;">$n</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">//1</span>
S<span style="color: #339933;">::</span><span style="color: #004000;">getn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">//1</span>
<span style="color: #000088;">$s</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> S<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$s</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getj</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>interface</h2>
<ul>
<li>类中全部为抽象方法</li>
<li>方法前不需要加abstract</li>
<li>接口抽象方法必须为public</li>
<li>成员属性必须为常量</li>
<li>本身都不能被实例化，必须被继承或者引用</li>
<li>继承或引用，需要把所有抽象方法重载才可使用</li>
<li>方法无需{}</li>
<li>继承后重载的方法，必须同抽象方法的参数个数相同</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p813code9'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8139"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code" id="p813code9"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">interface</span> I<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">const</span> N <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">function</span> fun<span style="color: #009900;">&#40;</span><span style="color: #000088;">$n</span><span style="color: #339933;">,</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">function</span> fun2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">class</span> II implements I <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">function</span> fun<span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #339933;">,</span> <span style="color: #000088;">$b</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">function</span> fun2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$ii</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> II<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>多态</h2>
<p>语言具有根据对象的类型不同，使用不同方式的处理</p>
<ul>
<li>instanceof：用来测定一个给定对象是否来自制定的类</li>
</ul>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p813code10'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p81310"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code" id="p813code10"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> A<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">class</span> B <span style="color: #000000; font-weight: bold;">extends</span> A<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$b</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> B<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span> instanceof A<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'A'</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// 'A'</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$b</span> instanceof B<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'B'</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// 'B'</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>其他细节</h2>
<ul>
<li>普通的成员方法如果定义的名字和类名相同，那么就变成构造方法</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.kushu.net/813.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Protected: UCWEB-PHP工程师面试笔试题(武汉)</title>
		<link>http://www.kushu.net/804.html</link>
		<comments>http://www.kushu.net/804.html#comments</comments>
		<pubDate>Tue, 24 May 2011 07:18:37 +0000</pubDate>
		<dc:creator>hyperblue</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP面试题]]></category>
		<category><![CDATA[UCWEB]]></category>
		<category><![CDATA[笔试题]]></category>
		<category><![CDATA[面试题]]></category>

		<guid isPermaLink="false">http://www.kushu.net/?p=804</guid>
		<description><![CDATA[There is no excerpt because this is a protected post.]]></description>
			<content:encoded><![CDATA[<form action="http://www.kushu.net/wp-pass.php" method="post">
<p>This post is password protected. To view it please enter your password below:</p>
<p><label for="pwbox-804">Password:<br />
<input name="post_password" id="pwbox-804" type="password" size="20" /></label><br />
<input type="submit" name="Submit" value="Submit" /></p></form>
]]></content:encoded>
			<wfw:commentRss>http://www.kushu.net/804.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stock API 股票数据接口</title>
		<link>http://www.kushu.net/800.html</link>
		<comments>http://www.kushu.net/800.html#comments</comments>
		<pubDate>Fri, 06 May 2011 11:10:19 +0000</pubDate>
		<dc:creator>hyperblue</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[google股票]]></category>
		<category><![CDATA[stock]]></category>
		<category><![CDATA[stock api]]></category>
		<category><![CDATA[stock webservice]]></category>
		<category><![CDATA[股票api]]></category>
		<category><![CDATA[股票接口]]></category>

		<guid isPermaLink="false">http://www.kushu.net/?p=800</guid>
		<description><![CDATA[首选： http://www.google.com/ig/api?stock=GOOG 其中GOOG是股票代码，返回xml数据: View Code XML1 2 3 4 5 6 7 8 9 10 11 12 13 14 15...]]></description>
			<content:encoded><![CDATA[<p>首选： http://www.google.com/ig/api?stock=GOOG<br />
其中GOOG是股票代码，返回xml数据:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p800code13'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p80013"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code" id="p800code13"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xml_api_reply</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;finance</span> <span style="color: #000066;">module_id</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">tab_id</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">mobile_row</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">mobile_zipped</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">row</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">section</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;symbol</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;GOOG&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pretty_symbol</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;GOOG&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;symbol_lookup_url</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;/finance?client=ig&amp;q=GOOG&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;company</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;Google Inc.&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exchange</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;Nasdaq&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exchange_timezone</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;ET&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exchange_utc_offset</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;+05:00&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exchange_closing</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;960&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;divisor</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;2&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;currency</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;USD&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;last</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;534.27&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;high</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;539.42&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;low</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;531.50&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;volume</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;avg_volume</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;3023&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;market_cap</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;171779.61&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;open</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;533.86&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;y_close</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;535.79&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;change</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;-1.52&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;perc_change</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;-0.28&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;delay</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;trade_timestamp</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;14 小时前&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;trade_date_utc</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;20110505&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;trade_time_utc</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;200010&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;current_date_utc</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;20110506&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;current_time_utc</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;105725&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;symbol_url</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;/finance?client=ig&amp;q=GOOG&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;chart_url</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;/finance/chart?q=NASDAQ:GOOG&amp;tlf=12&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;disclaimer_url</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;/help/stock_disclaimer.html&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ecn_url</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isld_last</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;535.25&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isld_trade_date_utc</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;20110505&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;isld_trade_time_utc</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;235920&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;brut_last</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;brut_trade_date_utc</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;brut_trade_time_utc</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;daylight_savings</span> <span style="color: #000066;">data</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/finance<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xml_api_reply<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>其次：webservicex.net  stock webservice. 可以采取get post soap方式获取数据。<br />
这种方式没有google稳定，连接数过多，webservice网站就挂了。</p>
<p>http://www.webservicex.net/stockquote.asmx?op=GetQuote</p>
<p>返回xml数据：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p800code14'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p80014"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code" id="p800code14"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;StockQuotes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Stock<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Symbol<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>GOOG<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Symbol<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Last<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>534.27<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Last<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Date<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>5/5/2011<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Date<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Time<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4:00pm<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Time<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Change<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0.00<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Change<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Open<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>N/A<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Open<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;High<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>N/A<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/High<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Low<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>N/A<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Low<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Volume<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Volume<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;MktCap<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>171.8B<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/MktCap<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;PreviousClose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>534.27<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/PreviousClose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;PercentageChange<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>0.00%<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/PercentageChange<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;AnnRange<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>433.63 - 642.96<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/AnnRange<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Earns<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>27.291<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Earns<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;P-E<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>19.58<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/P-E<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Google Inc.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Stock<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/StockQuotes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.kushu.net/800.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tetris with jQuery [基于jQuery的俄罗斯方块]</title>
		<link>http://www.kushu.net/796.html</link>
		<comments>http://www.kushu.net/796.html#comments</comments>
		<pubDate>Fri, 06 May 2011 10:53:48 +0000</pubDate>
		<dc:creator>hyperblue</dc:creator>
				<category><![CDATA[Collect]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jquery游戏]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[俄罗斯方块]]></category>

		<guid isPermaLink="false">http://www.kushu.net/?p=796</guid>
		<description><![CDATA[http://fmarcia.info/jquery/tetris/tetris.html]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.kushu.net/wp-content/uploads/2011/05/tetris_jquery.jpg" rel="lightbox[796]"><img src="http://www.kushu.net/wp-content/uploads/2011/05/tetris_jquery.jpg" alt="" title="tetris_jquery" width="518" height="482" class="alignnone size-full wp-image-797" /></a></p>
<p>http://fmarcia.info/jquery/tetris/tetris.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kushu.net/796.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WinXP配置apache + wsgi + Python2.6＋web.py</title>
		<link>http://www.kushu.net/792.html</link>
		<comments>http://www.kushu.net/792.html#comments</comments>
		<pubDate>Fri, 06 May 2011 08:13:33 +0000</pubDate>
		<dc:creator>hyperblue</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mod_wsgi]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python web]]></category>
		<category><![CDATA[webpy]]></category>
		<category><![CDATA[wsgi]]></category>

		<guid isPermaLink="false">http://www.kushu.net/?p=792</guid>
		<description><![CDATA[web.py 官网: http://www.webpy.org 最近对 python 的一个web框架 web.py 发生了浓厚的兴趣，虽然 web.py 自带webserver，但是我还是想把它和 apache 结合起来，所以研究了一下 web.py 在 apache 环境下的环境架设。 仔细研究了一下 web.py 的官方网站install文档，原来 web.py...]]></description>
			<content:encoded><![CDATA[<p>web.py 官网: http://www.webpy.org</p>
<p>最近对 python 的一个web框架 web.py 发生了浓厚的兴趣，虽然 web.py 自带webserver，但是我还是想把它和 apache 结合起来，所以研究了一下 web.py 在 apache 环境下的环境架设。<br />
     仔细研究了一下 web.py 的官方网站install文档，原来 web.py 可以通过很多种方式和 apache 结合：</p>
<blockquote><p>
      1、使用CGI实现。<br />
      2、使用mod_python模块实现。<br />
      3、和fastCGI实现。<br />
      4、使用SCGI实现。<br />
      5、使用mod_wsgi模块实现。
</p></blockquote>
<p>       查阅了一些资料，最后在 google 上发现了几种实现方法的对比，其中mod_wsgi模块实现的方法效率最高，而且在 apache 其中的设置和 web.py 程序中设置也相对简单，所以就选用了此种方法来做，虽然有文档，但是也很费了一番周折，现将自己的一点小小经验拿出来共享。</p>
<p>       1、先去sourceforge.net下载mod_wsgi模块，其他地方也有下载，不过去sf下可以保证最新。这个模块是 apache 的wsgi模块，模块文件名为：mod_wsgi.so，下载后拷贝到apache的安装目录下的modules目录中。Google code: http://code.google.com/p/modwsgi/<br />
<a class="downloadlink" href="http://www.kushu.net/download/6" title=" downloaded 230 times" >mod_wsgi.so [Google code] (230)</a> <a class="downloadlink" href="http://www.kushu.net/download/7" title=" downloaded 159 times" >mod_wsgi.so 本站下载 (159)</a></p>
<p>       2、在 apache 的配置文件httpd.conf文件中加入以下内容：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p792code21'); return false;">View Code</a> APACHE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p79221"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p792code21"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">LoadModule</span> wsgi_module modules/mod_wsgi.so
&nbsp;
WSGIScriptAlias /pydemo E:/mypro/python/www/helloworld.py/
<span style="color: #00007f;">Alias</span> /pydemo/static E:/mypro/python/www/static/
&nbsp;
&lt;<span style="color: #000000; font-weight:bold;">Directory</span> E:/mypro/python/www/&gt;
<span style="color: #00007f;">Order</span> <span style="color: #00007f;">deny</span>,<span style="color: #00007f;">allow</span>
<span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
&lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;</pre></td></tr></table></div>

<p>        下面讲解一下具体设置的说明，我的系统环境是windowsxp，linux下路径应该有改变。</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p792code22'); return false;">View Code</a> APACHE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p79222"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p792code22"><pre class="apache" style="font-family:monospace;">WSGIScriptAlias /pydemo E:/mypro/python/www/helloworld.py/</pre></td></tr></table></div>

<p>         这一句是说明给wsgi脚本文件指定一个别名，好让你使用http://localhost/pydemo 访问到E:/mypro/python/www/helloworld.py这个文件。请注意在 helloworld.py后面有一个/，这个/很重要，必须加上。因为如果不加，就必须在访问这个页面的url的最后加上/，应该是这样的 url:http://localhost/pydemo/。当然我想很多人不愿意这样吧？那就在设置后面加上/吧！</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p792code23'); return false;">View Code</a> APACHE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p79223"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p792code23"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">Alias</span> /pydemo/static E:/mypro/python/www/static/</pre></td></tr></table></div>

<p>        这一句是做了一个静态目录的别名，static这个目录中存放一些静态文件，比如css,图片,js文件等等。</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p792code24'); return false;">View Code</a> APACHE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p79224"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p792code24"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">Directory</span> E:/mypro/python/www/&gt;
<span style="color: #00007f;">Order</span> <span style="color: #00007f;">deny</span>,<span style="color: #00007f;">allow</span>
<span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
&lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;</pre></td></tr></table></div>

<p>        这几句是 apache 的目录权限设置了，只要和那个cgi-bin的目录设置一样就行。具体含义请查阅 apache 的设置文档，这里不再叙述。</p>
<p>        3、 apache 的设置已经好了，下面是 web.py 程序需要注意的地方。我就根据官方的helloworld.py来说明一下。当然，环境和上面是对应的，文件就在E:/mypro/python/www/helloworld.py。<br />
         helloworld.py内容如下：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p792code25'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p79225"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code" id="p792code25"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> web
&nbsp;
urls = <span style="color: black;">&#40;</span> <span style="color: #483d8b;">'/(.*)'</span>, <span style="color: #483d8b;">'hello'</span> <span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> hello:
    <span style="color: #ff7700;font-weight:bold;">def</span> GET<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, name<span style="color: black;">&#41;</span>:
        i = web.<span style="color: #008000;">input</span><span style="color: black;">&#40;</span>times=<span style="color: #ff4500;">4</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> name:
            name = <span style="color: #483d8b;">'world'</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> c <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>i.<span style="color: black;">times</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Hello,'</span>,name+<span style="color: #483d8b;">'!'</span>
&nbsp;
web.<span style="color: black;">webapi</span>.<span style="color: black;">internalerror</span>=web.<span style="color: black;">debugerror</span>
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">&quot;__main__&quot;</span>:
    web.<span style="color: black;">run</span><span style="color: black;">&#40;</span>urls, <span style="color: #008000;">globals</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>,web.<span style="color: black;">reloader</span><span style="color: black;">&#41;</span>
application = web.<span style="color: black;">wsgifunc</span><span style="color: black;">&#40;</span>web.<span style="color: black;">webpyfunc</span><span style="color: black;">&#40;</span>urls, <span style="color: #008000;">globals</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>      看到上面的程序，稍微学过 web.py 的朋友一定都很熟悉，这是官方给的一个标准helloworld程序例子。但是不同的就在最下那一条语句：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p792code26'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p79226"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p792code26"><pre class="python" style="font-family:monospace;">application = web.<span style="color: black;">wsgifunc</span><span style="color: black;">&#40;</span>web.<span style="color: black;">webpyfunc</span><span style="color: black;">&#40;</span>urls, <span style="color: #008000;">globals</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>这一句是 web.py 调用wsgi的语句，必须加上，就这一个地方有变化。没其他的了。</p>
<p>转载至： http://hi.baidu.com/xiaoxiaolq/blog/item/751841da2466bfd1b7fd48f0.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kushu.net/792.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux安装配置LAMP环境(基于ubuntu9.10)</title>
		<link>http://www.kushu.net/778.html</link>
		<comments>http://www.kushu.net/778.html#comments</comments>
		<pubDate>Wed, 06 Apr 2011 17:57:19 +0000</pubDate>
		<dc:creator>hyperblue</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[apt-get]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[linux+apache+php+mysql]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.kushu.net/?p=778</guid>
		<description><![CDATA[PHP开发和服务器运行环境首选LAMP组合，即Linux+Apache+Mysql+Php/Perl/Python 终端命令: View Code BASH1 sudo apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql 提示:在操作中经常会遇到权限问题Permission denied. 要适当得给文件或文件夹相应的权限，一般是755或777.(sudo chmod -R 777...]]></description>
			<content:encoded><![CDATA[<p>PHP开发和服务器运行环境首选LAMP组合，即Linux+Apache+Mysql+Php/Perl/Python<br />
<a href="http://www.kushu.net/wp-content/uploads/2011/04/lamp.gif" rel="lightbox[778]"><img src="http://www.kushu.net/wp-content/uploads/2011/04/lamp.gif" alt="" title="lamp" width="340" height="172" class="alignnone size-full wp-image-780" /></a></p>
<p><strong style="color:red;">终端命令:</strong></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code42'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77842"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code42"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> apache2 mysql-server mysql-client php5 php5-gd php5-mysql</pre></td></tr></table></div>

<p><strong style="color:red;">提示:在操作中经常会遇到权限问题Permission denied. 要适当得给文件或文件夹相应的权限，一般是755或777.(sudo chmod -R 777 folder)</strong></p>
<p><strong style="color:blue;">设置Ubuntu文件执行读写权限</strong><br />
LAMP组建安装好之后，PHP网络服务器根目录默认设置是在：/var/www。由于Linux系统的安全性原则，改 目录下的文件读写权限是只允许root用户操作的，所以我们不能在www文件夹中新建php文件，也不能修改和删除，必须要先修改/var/www目录的 读写权限。<br />
在界面管理器中通过右键属性不能修改文件权限，得执行root终端命令：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code43'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77843"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code43"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> <span style="color: #000000;">777</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www</pre></td></tr></table></div>

<p>然后就可以写入html或php文件了。如果对777表示的文件权限不是很清楚可参考chmod命令。 </p>
<p><strong style="color:blue;">设置Apache支持.htm .html .php</strong></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code44'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77844"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code44"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gedit <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>apache2.conf</pre></td></tr></table></div>

<p>或sudo gedit /etc/apache2/mods-enabled/php5.conf<br />
在打开的文件中加上</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code45'); return false;">View Code</a> TXT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77845"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code45"><pre class="txt" style="font-family:monospace;">AddType application/x-httpd-php .php .htm .html</pre></td></tr></table></div>

<p>即可。 </p>
<p><strong style="color:blue;">Ubuntu LAMP 如何配置Apache</strong><br />
<strong>1. 启用 mod_rewrite 模块</strong><br />
终端命令：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code46'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77846"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code46"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod rewrite</pre></td></tr></table></div>

<p>重启Apache服务器：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code47'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77847"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code47"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></td></tr></table></div>

<p>Apache重启后我们可以测试一下，在/var/www目录下新建文件test.php，写入代码：  <?php phpinfo(); ?> 保存，在地址栏输入http://127.0.0.1/test.php 或 http://localhost/test.php ，如果正确出现了php 配置信息则表明LAMP Apache已经正常工作了(记得重启Apache服务器后再测试)。</p>
<p><strong style="color:blue;">LAMP配置之Mysql测试</strong><br />
上面php,Apache 都已经测试过了，下面我们再测试一下Mysql 数据库是否已经正确启用。<br />
在/var/www目录下新建 mysql_test.php：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code48'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77848"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p778code48"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$link</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_connect"><span style="color: #990000;">mysql_connect</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;root&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Could not connect: '</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/mysql_error"><span style="color: #990000;">mysql_error</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Success!&quot;</span><span style="color: #339933;">;</span>
<a href="http://www.php.net/mysql_close"><span style="color: #990000;">mysql_close</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$link</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><span style="color:red;">其中password是数据库密码.</span><br />
保存退出，在地址栏输入http://127.0.0.1/mysql_test.php，显示&#8221;Mysql 已经正确配置&#8221;则表示OK了，如果不行，重启Apache服务器后再试一下。 </p>
<p><strong style="color:blue;">接下来安装phpmyadmin</strong></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code49'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77849"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code49"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> phpmyadmin</pre></td></tr></table></div>

<p>在安装过程中会要求选择Webserver：apache2或lighttpd，选择apache2，按tab键然后确定。然后会要求输入设置的Mysql数据库密码连接密码 Password of the database&#8217;s administrative user。<br />
然后将phpmyadmin与apache2建立连接，以我的为例：www目录在/var/www，phpmyadmin在/usr/share /phpmyadmin目录，所以就用命令：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code50'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77850"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p778code50"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> <span style="color: #000000;">755</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>phpmyadmin<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>phpmyadmin<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span></pre></td></tr></table></div>

<p>建立连接。<br />
phpmyadmin测试：在浏览器地址栏中打开http://localhost/phpmyadmin。 </p>
<p><strong style="color:red;">解决Firefox浏览器显示中文乱码等问题</strong><br />
上面在FireFox浏览器中打开mysql_test.php或phpmyadmin测试时，如果出现了中文乱码，则是默认语言设置问题，解决方法如下：<br />
打开apache配置文件：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code51'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77851"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code51"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gedit <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>apache2.conf</pre></td></tr></table></div>

<p>在最后面加上：AddDefaultCharset UTF-8，如果还是乱码的，再将UTF-8改用gb2312。<br />
重启Apache：sudo /etc/init.d/apache2 restart  再刷新mysql_test.php 中文乱码没有了。<br />
如果要人工启动mysql：mysql -u root -p，根据提示输入密码。<br />
如果重启Apache时出现：<br />
* Restarting web server apache2<br />
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName<br />
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName<br />
则还是修改apache配置文件：sudo gedit /etc/apache2/apache2.conf，在文件最后设置：ServerName 127.0.0.1</p>
<p><strong style="color:blue;">LAMP组件经常使用的几个终端命令</strong><br />
重启 apache：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code52'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77852"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code52"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></td></tr></table></div>

<p>重启mysql：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code53'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77853"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code53"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>mysql restart</pre></td></tr></table></div>

<p>配置 php.ini：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code54'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77854"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code54"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gedit <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>php.ini</pre></td></tr></table></div>

<p>配置 apache2.conf：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code55'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77855"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code55"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gedit <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>apache2.conf</pre></td></tr></table></div>

<p>PHP CGI ：</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p778code56'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p77856"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p778code56"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>cgi-bin<span style="color: #000000; font-weight: bold;">/</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.kushu.net/778.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ubuntu 9.10 安装 Thinkpad SL410 无线网卡驱动</title>
		<link>http://www.kushu.net/775.html</link>
		<comments>http://www.kushu.net/775.html#comments</comments>
		<pubDate>Sat, 02 Apr 2011 04:12:21 +0000</pubDate>
		<dc:creator>hyperblue</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[RTL8192SE]]></category>
		<category><![CDATA[sl410]]></category>
		<category><![CDATA[Thinkpad]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[无线网卡驱动]]></category>

		<guid isPermaLink="false">http://www.kushu.net/?p=775</guid>
		<description><![CDATA[先下载驱动： 　　驱动下载地址：http://www.thinkwiki.org/wiki/ThinkPad_11b/g/n_Wireless_LAN_Mini-PCI_Express_Adapter_II 　　点进Linux driver链接 website: http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&#038;PNid=21&#038;PFid=48&#038;Level=5&#038;Conn=4&#038;ProdID=226&#038;DownTypeID=3&#038;GetDown=false&#038;Downloads=true#2302 　　选择驱动RTL8192SE，然后download 解压安装： 　　$ tar -zxvf rtl8192se_linux_2.6.0010.1012.2009.tar.gz 　　$ cd rtlrtl8192se_linux_2.6.0010.1012.2009 　　$ make 　　$ sudo -s...]]></description>
			<content:encoded><![CDATA[<p><strong>先下载驱动：</strong></p>
<p>　　驱动下载地址：http://www.thinkwiki.org/wiki/ThinkPad_11b/g/n_Wireless_LAN_Mini-PCI_Express_Adapter_II</p>
<p>　　点进Linux driver链接 website: http://www.realtek.com.tw/downloads/downloadsView.aspx?Langid=1&#038;PNid=21&#038;PFid=48&#038;Level=5&#038;Conn=4&#038;ProdID=226&#038;DownTypeID=3&#038;GetDown=false&#038;Downloads=true#2302</p>
<p>　　选择驱动RTL8192SE，然后download</p>
<p><strong>解压安装：</strong></p>
<p>　　$ tar -zxvf  rtl8192se_linux_2.6.0010.1012.2009.tar.gz<br />
　　$ cd rtlrtl8192se_linux_2.6.0010.1012.2009<br />
　　$ make<br />
　　$ sudo -s<br />
　　# make install<br />
　　# modprobe r8192se_pci</p>
<p>查看一下你的网络连接，相信已经可以检测无线网络了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kushu.net/775.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>初试PHP开发Android应用程序</title>
		<link>http://www.kushu.net/721.html</link>
		<comments>http://www.kushu.net/721.html#comments</comments>
		<pubDate>Fri, 21 Jan 2011 03:39:17 +0000</pubDate>
		<dc:creator>hyperblue</dc:creator>
				<category><![CDATA[PFA]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[pfa]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php应用程序]]></category>
		<category><![CDATA[php手机开发]]></category>

		<guid isPermaLink="false">http://www.kushu.net/?p=721</guid>
		<description><![CDATA[先看下Android模拟器运行hello_world.php的效果： 看到这样的效果，还是比较激动，毕竟一直从事PHP基于PC的B/S的开发，看到手机这样的效果，太爽了。不用去琢磨Java了。 目前还在学习中，稍后会整理下。]]></description>
			<content:encoded><![CDATA[<p>先看下Android模拟器运行hello_world.php的效果：<br />
<a href="http://www.kushu.net/wp-content/uploads/2011/01/1.jpg" rel="lightbox[721]"><img src="http://www.kushu.net/wp-content/uploads/2011/01/1.jpg" alt="" title="1" width="793" height="561" class="alignnone size-full wp-image-722" /></a></p>
<p>看到这样的效果，还是比较激动，毕竟一直从事PHP基于PC的B/S的开发，看到手机这样的效果，太爽了。不用去琢磨Java了。<br />
目前还在学习中，稍后会整理下。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kushu.net/721.html/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Merry Christmas 2011</title>
		<link>http://www.kushu.net/705.html</link>
		<comments>http://www.kushu.net/705.html#comments</comments>
		<pubDate>Thu, 23 Dec 2010 05:48:13 +0000</pubDate>
		<dc:creator>hyperblue</dc:creator>
				<category><![CDATA[Essay]]></category>
		<category><![CDATA[12月24日]]></category>
		<category><![CDATA[christmas]]></category>
		<category><![CDATA[Merry christmas]]></category>
		<category><![CDATA[元旦]]></category>
		<category><![CDATA[圣诞]]></category>
		<category><![CDATA[圣诞节]]></category>

		<guid isPermaLink="false">http://www.kushu.net/?p=705</guid>
		<description><![CDATA[一年一度的圣诞节又要到了，接着又是2011年元旦，今年两个“蛋”可以一起过了。放假10天，太爽了。 Merry christmas 2011 各位圣诞快乐，元旦快乐！]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.kushu.net/wp-content/uploads/2010/12/merry_christmas_2011.jpg" rel="lightbox[705]"><img src="http://www.kushu.net/wp-content/uploads/2010/12/merry_christmas_2011.jpg" alt="" title="merry_christmas_2011" width="548" height="300" class="alignnone size-full wp-image-706" /></a></p>
<p>一年一度的圣诞节又要到了，接着又是2011年元旦，今年两个“蛋”可以一起过了。放假10天，太爽了。</p>
<p>Merry christmas 2011 各位圣诞快乐，元旦快乐！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kushu.net/705.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP APC扩展下载以及实现文件上传进度条</title>
		<link>http://www.kushu.net/686.html</link>
		<comments>http://www.kushu.net/686.html#comments</comments>
		<pubDate>Wed, 15 Dec 2010 08:48:21 +0000</pubDate>
		<dc:creator>hyperblue</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[APC_UPLOAD_PROGRESS]]></category>
		<category><![CDATA[php_apc.dll]]></category>
		<category><![CDATA[文件上传]]></category>
		<category><![CDATA[进度条]]></category>

		<guid isPermaLink="false">http://www.kushu.net/?p=686</guid>
		<description><![CDATA[php_apc.dll文件下载： 放在 php目录/ext/下 修改php.ini，添加： extension=php_apc.dll apc.rfc1867 = on upload_max_filesize = 100M post_max_size = 100M apc.max_file_size = 200M 文件上传进度条效果图： 提示：在用以下代码单用户可以实现，但多用户同时上传，进度条就会交叉出错，暂时还没想到方法，欢迎交流。 upload.php...]]></description>
			<content:encoded><![CDATA[<p>php_apc.dll文件下载： 放在 php目录/ext/下<br />
<a class="downloadlink dlimg" href="http://www.kushu.net/download/5" title=" downloaded 463 times" ><img src="http://www.kushu.net/wp-content/plugins/download-monitor/img/download.gif" alt="Download php_apc.dll " /></a><br />
修改php.ini，添加：</p>
<blockquote><p>
extension=php_apc.dll<br />
apc.rfc1867 = on<br />
upload_max_filesize = 100M<br />
post_max_size = 100M<br />
apc.max_file_size = 200M
</p></blockquote>
<p><strong>文件上传进度条效果图：</strong><br />
<a href="http://www.kushu.net/wp-content/uploads/2010/12/php_arc_uploadfile.jpg" rel="lightbox[686]"><img src="http://www.kushu.net/wp-content/uploads/2010/12/php_arc_uploadfile.jpg" alt="" title="php_arc_uploadfile" width="536" height="252" class="alignnone size-full wp-image-689" /></a></p>
<p><span style="color:red">提示：在用以下代码单用户可以实现，但多用户同时上传，进度条就会交叉出错，暂时还没想到方法，欢迎交流。</span></p>
<p><strong>upload.php (文件上传表单,提交到target.php)</strong></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p686code61'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p68661"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p686code61"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span>form enctype<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;multipart/form-data&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;upload_form&quot;</span> action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;target.php&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;POST&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;hidden&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;APC_UPLOAD_PROGRESS&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;progress_key&quot;</span>  value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&lt;?php echo <span style="color: #006699; font-weight: bold;">$id</span>?&gt;&quot;</span><span style="color: #339933;">/&gt;</span>
  <span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;file&quot;</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;test_file&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;test_file&quot;</span><span style="color: #339933;">/&gt;&lt;</span>br<span style="color: #339933;">/&gt;</span>
  <span style="color: #339933;">&lt;</span>input onclick<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;window.parent.startProgress(); return true;&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Upload!&quot;</span><span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p><strong>target.php (接收upload.php上传表单提交页面)</strong></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p686code62'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p68662"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p686code62"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<a href="http://www.php.net/set_time_limit"><span style="color: #990000;">set_time_limit</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_METHOD'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #0000ff;">'POST'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <a href="http://www.php.net/move_uploaded_file"><span style="color: #990000;">move_uploaded_file</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;test_file&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;tmp_name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
  <a href="http://www.php.net/dirname"><span style="color: #990000;">dirname</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SCRIPT_FILENAME'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/UploadTemp/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_FILES</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;test_file&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//UploadTemp文件夹位于此脚本相同目录下</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;File uploaded.  Thank you!&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>getprogress.php (用来得到文件上传状态信息,让js来调用)</strong></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p686code63'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p68663"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p686code63"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<a href="http://www.php.net/session_start"><span style="color: #990000;">session_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'progress_key'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$status</span> <span style="color: #339933;">=</span> apc_fetch<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload_'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'progress_key'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'current'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">/</span><span style="color: #000088;">$status</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'total'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>progress.php (调用getprogress.php和upload.php,显示进度条)</strong></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p686code64'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p68664"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
</pre></td><td class="code" id="p686code64"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/md5"><span style="color: #990000;">md5</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/uniqid"><span style="color: #990000;">uniqid</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/rand"><span style="color: #990000;">rand</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;&lt;</span>title<span style="color: #339933;">&gt;</span>Upload Example<span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;&lt;/</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;script language</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #000000; font-weight: bold;">var</span> xmlHttp<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">var</span> proNum<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">var</span> loop<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> Try <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
 these<span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">var</span> returnValue<span style="color: #339933;">;</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> arguments<span style="color: #339933;">.</span>length<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">var</span> lambda <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
   try <span style="color: #009900;">&#123;</span>
    returnValue <span style="color: #339933;">=</span> lambda<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">return</span> returnValue<span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> createXHR<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">return</span> Try<span style="color: #339933;">.</span>these<span style="color: #009900;">&#40;</span>
  <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Msxml2.XMLHTTP'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
  <span style="color: #000000; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Microsoft.XMLHTTP'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> xmlHttp<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sendURL<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 xmlHttp<span style="color: #339933;">=</span>createXHR<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">var</span> url<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;getprogress.php?progress_key=&lt;?php echo <span style="color: #006699; font-weight: bold;">$id</span>;?&gt;&quot;</span><span style="color: #339933;">;</span>
 xmlHttp<span style="color: #339933;">.</span>onreadystatechange <span style="color: #339933;">=</span> doHttpReadyStateChange<span style="color: #339933;">;</span>
 xmlHttp<span style="color: #339933;">.</span>open<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;GET&quot;</span><span style="color: #339933;">,</span>url<span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 xmlHttp<span style="color: #339933;">.</span>send<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> doHttpReadyStateChange<span style="color: #009900;">&#40;</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>xmlHttp<span style="color: #339933;">.</span>readyState <span style="color: #339933;">==</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  proNum<span style="color: #339933;">=</span>parseInt<span style="color: #009900;">&#40;</span>xmlHttp<span style="color: #339933;">.</span>responseText<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  document<span style="color: #339933;">.</span>getElementById<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;progressinner&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>style<span style="color: #339933;">.</span>width <span style="color: #339933;">=</span> proNum<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;%&quot;</span><span style="color: #339933;">;</span>
  document<span style="color: #339933;">.</span>getElementById<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;showNum&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>innerHTML <span style="color: #339933;">=</span> proNum<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;%&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> proNum <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
   setTimeout<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;getProgress()&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> getProgress<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 loop<span style="color: #339933;">++;</span>
 document<span style="color: #339933;">.</span>getElementById<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;showNum2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>innerHTML <span style="color: #339933;">=</span> loop<span style="color: #339933;">;</span>
 sendURL<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">var</span> interval<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> startProgress<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 document<span style="color: #339933;">.</span>getElementById<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;progressouter&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>style<span style="color: #339933;">.</span>display<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;block&quot;</span><span style="color: #339933;">;</span>
 setTimeout<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;getProgress()&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>iframe id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;theframe&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;theframe&quot;</span>
src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;upload.php?id=&lt;?php echo(<span style="color: #006699; font-weight: bold;">$id</span>); ?&gt;&quot;</span>
style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;border: none; height: 100px; width: 400px;&quot;</span> <span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>iframe<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>br<span style="color: #339933;">/&gt;&lt;</span>br<span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;progressouter&quot;</span> style<span style="color: #339933;">=</span>
<span style="color: #0000ff;">&quot;width: 500px; height: 20px; border: 6px solid red; display:none;&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;progressinner&quot;</span> style<span style="color: #339933;">=</span>
<span style="color: #0000ff;">&quot;position: relative; height: 20px; background-color: purple; width: 0%; &quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">'showNum'</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;&lt;</span>br<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">'showNum2'</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.kushu.net/686.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

