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

<channel>
	<title>程序笔记</title>
	<atom:link href="http://www.2816.com.cn/feed" rel="self" type="application/rss+xml" />
	<link>http://www.2816.com.cn</link>
	<description>专注于WEB技术的发展</description>
	<lastBuildDate>Mon, 12 Jul 2010 02:47:48 +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>弹出窗口屏幕居中代码</title>
		<link>http://www.2816.com.cn/archives/popwin</link>
		<comments>http://www.2816.com.cn/archives/popwin#comments</comments>
		<pubDate>Mon, 12 Jul 2010 02:47:47 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[居中]]></category>
		<category><![CDATA[屏幕]]></category>
		<category><![CDATA[弹出]]></category>
		<category><![CDATA[窗口]]></category>

		<guid isPermaLink="false">http://www.2816.com.cn/?p=89</guid>
		<description><![CDATA[function opennewwindow(URLtoOpen,windowName,width,height){ var xposition=0; var yposition=0; if ((parseInt(navigator.appVersion) >= 4 )){ xposition = (screen.width - width) / 2; yposition = (screen.height - height-25) / 2; } var windowFeatures = 'width='+width+',height='+height+',left='+xposition+',top='+yposition+',resizable=1,scrollbars=1,menubar=0,status=0'; var NewWindow = window.open(URLtoOpen, windowName, windowFeatures); }]]></description>
			<content:encoded><![CDATA[<pre name="code" class="js">
function opennewwindow(URLtoOpen,windowName,width,height){
	var xposition=0;
	var yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 )){
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height-25) / 2;
	  }
	var windowFeatures = 'width='+width+',height='+height+',left='+xposition+',top='+yposition+',resizable=1,scrollbars=1,menubar=0,status=0';
	var NewWindow = window.open(URLtoOpen, windowName, windowFeatures);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.2816.com.cn/archives/popwin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>文件夹树形结构生成器</title>
		<link>http://www.2816.com.cn/archives/dir</link>
		<comments>http://www.2816.com.cn/archives/dir#comments</comments>
		<pubDate>Tue, 15 Jun 2010 06:21:45 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[文件夹]]></category>
		<category><![CDATA[树形结构]]></category>
		<category><![CDATA[生成器]]></category>

		<guid isPermaLink="false">http://www.2816.com.cn/?p=85</guid>
		<description><![CDATA[将以下代码保存为.bat文件执行即可。 title 文件夹树形结构 生成器 echo off cls echo 在下面 输入/或粘贴 文件夹路径，例如“d:\1\图片” set /p 目录=目录= set 输出文件=%temp%\文件夹树形目录.txt tree /f &#8220;%目录%&#8221;&#62;%输出文件% start /max &#8220;&#8221; %输出文件% title 文件夹树形结构 生成器echo offcls echo 在下面 输入/或粘贴 文件夹路径，例如“d:\1\图片”set /p 目录=目录=set 输出文件=%temp%\文件夹树形目录.txt tree /f &#8220;%目录%&#8221;&#62;%输出文件%start /max &#8220;&#8221; %输出文件%]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste"><strong>将以下代码保存为.bat文件执行即可。</strong></div>
<div></div>
<div>title 文件夹树形结构 生成器</div>
<div id="_mcePaste">echo off</div>
<div id="_mcePaste">cls</div>
<div id="_mcePaste">echo 在下面 输入/或粘贴 文件夹路径，例如“d:\1\图片”</div>
<div id="_mcePaste">set /p 目录=目录=</div>
<div id="_mcePaste">set 输出文件=%temp%\文件夹树形目录.txt</div>
<div id="_mcePaste">tree /f &#8220;%目录%&#8221;&gt;%输出文件%</div>
<div id="_mcePaste">start /max &#8220;&#8221; %输出文件%</div>
<p>title 文件夹树形结构 生成器echo offcls<br />
echo 在下面 输入/或粘贴 文件夹路径，例如“d:\1\图片”set /p 目录=目录=set 输出文件=%temp%\文件夹树形目录.txt<br />
tree /f &#8220;%目录%&#8221;&gt;%输出文件%start /max &#8220;&#8221; %输出文件%</p>
]]></content:encoded>
			<wfw:commentRss>http://www.2816.com.cn/archives/dir/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP获取第N个指定字符的位置</title>
		<link>http://www.2816.com.cn/archives/php%e8%8e%b7%e5%8f%96%e7%ac%acn%e4%b8%aa%e6%8c%87%e5%ae%9a%e5%ad%97%e7%ac%a6%e7%9a%84%e4%bd%8d%e7%bd%ae</link>
		<comments>http://www.2816.com.cn/archives/php%e8%8e%b7%e5%8f%96%e7%ac%acn%e4%b8%aa%e6%8c%87%e5%ae%9a%e5%ad%97%e7%ac%a6%e7%9a%84%e4%bd%8d%e7%bd%ae#comments</comments>
		<pubDate>Fri, 11 Jun 2010 09:12:35 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[位置]]></category>

		<guid isPermaLink="false">http://www.2816.com.cn/?p=83</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre name="code" class="php">
<?php
function check($s, $s1, $n){
    $s = '@'.$s;
    $j = $x = $y = 0;
    for($i = 0; $i < strlen($s); $i++){
        if($index = strpos($s, $s1, $y? ($y + 1):$y)){
            $j++;
            if($j == $n){
                $x = $index;
                break;
            }else{
                $y = $index;
            }
        }
    }
    return $x - 1;
}

$s = 'abcdefghijklacfag';
$s1 = 'a';
echo check($s, $s1, 3);
?>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.2816.com.cn/archives/php%e8%8e%b7%e5%8f%96%e7%ac%acn%e4%b8%aa%e6%8c%87%e5%ae%9a%e5%ad%97%e7%ac%a6%e7%9a%84%e4%bd%8d%e7%bd%ae/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ubuntu下架设svn服务器及在windows建立svn+ssh客户端</title>
		<link>http://www.2816.com.cn/archives/ubuntu-svn-windows-svnssh</link>
		<comments>http://www.2816.com.cn/archives/ubuntu-svn-windows-svnssh#comments</comments>
		<pubDate>Thu, 27 May 2010 15:09:31 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.2816.com.cn/?p=81</guid>
		<description><![CDATA[今天配置了一个ubuntu6.06 LTS下的svn服务器和windows下通过svn+ssh://访问的svn客户端，以备以后使用，特记录如下： 1、安装ssh sudo apt-get install ssh 2、安装subversion sudo apt-get install subversion 3、为参与项目开发的成员建立用户帐户 sudo adduser xiao 4、建立名为svn的用户组 sudo addgroup svn sudo addgroup xiao svn       /*把xiao加入组svn*/ 注：这里可以根据不同的权限建立多个用户组，把有相应权限的用户放入相应的组中 5、建立项目文件存储目录 sudo mkdir /usr/local/svn sudo mkdir /usr/local/svn/trunk 6、创建SVN文件仓库 sudo svnadmin create /usr/local/svn/trunk 7、为组成员赋予相应的权限 &#8230; <a href="http://www.2816.com.cn/archives/ubuntu-svn-windows-svnssh">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>今天配置了一个ubuntu6.06 LTS下的svn服务器和windows下通过svn+ssh://访问的svn客户端，以备以后使用，特记录如下：<br />
1、安装ssh<br />
sudo apt-get install ssh<br />
2、安装subversion<br />
sudo apt-get install subversion<br />
3、为参与项目开发的成员建立用户帐户<br />
sudo adduser xiao<br />
4、建立名为svn的用户组<br />
sudo addgroup svn<br />
sudo addgroup xiao svn       /*把xiao加入组svn*/<br />
注：这里可以根据不同的权限建立多个用户组，把有相应权限的用户放入相应的组中<br />
5、建立项目文件存储目录<br />
sudo mkdir /usr/local/svn<br />
sudo mkdir /usr/local/svn/trunk</p>
<p><span id="more-81"></span>6、创建SVN文件仓库<br />
sudo svnadmin create /usr/local/svn/trunk<br />
7、为组成员赋予相应的权限<br />
sudo chown -R root:svn /usr/local/svn/trunk<br />
sudo chmod -R g+rws /usr/local/svn/trunk   /*给svn组赋予读写权限，可以根据需要更改相应权限*/<br />
sudo chmod -R o-rwx /usr/local/svn/trunk   /*删除其他无关人员的读、写、执行权限，默认情况下可能其他人有读权限*/<br />
注：有关权限修改的问题可以查看相关linux命令<br />
8、为每个成员生成密钥对（以用户xiao为例）<br />
   切换为xiao用户登录：su xiao （提示输入xiao的密码）<br />
   输入：cd ~/<br />
   输入：whoami，如果登录成功则显示xiao<br />
   执行：ssh-keygen -b 1024 -t dsa -N passphrase -f xiaokey<br />
       注：其中passphrase为密钥关键字，根据你的需要修改，xiaokey为文件名；这里使用的是DSA加密，可以改用RSA加密，把其中的“dsa”改为“rsa”就可以了。<br />
   这时产生两个文件：xiaokey和xiaokey.pub，前一个为秘密密钥后一个为公开密钥<br />
   然后，创建目录/home/xiao/.ssh，把公钥拷贝到/home/xiao/.ssh目录下：cp xiaokey.pub /home/xiao/.ssh/authorized_keys<br />
       注：文件名必须为authorized_keys<br />
   退出：exit<br />
9、在windows下安装svn客户端，则需安装“TortoiseSVN”、“Puttygen”和“Pageant”<br />
   9.1、下载：<br />
       http://sourceforge.net/projects/tortoisesvn<br />
       http://www.chiark.greenend.org.uk/~sgtatham/putty/<br />
   9.2、安装：略<br />
   9.3、转换私钥格式：<br />
       9.3.1、将xiaokey拷贝到windows下，运行Puttygen；<br />
       9.3.2、选择菜单conversions-&gt;Import Key，<br />
       9.3.3、选择文件xiaokey，提示“Enter passphrase for key&#8221;，输入创建公私钥对示使用的passphrase关键字，<br />
       9.3.4、然后选择Parameters为“SSH-2 DSA”（如果公私钥是使用RSA生成，则选择“SSH-2 RSA”），<br />
       9.3.5、点击按钮Save private key，<br />
       9.3.6、保存文件名为xiaokey.ppk。<br />
   9.4、建立TortoiseSVN与Pageant的关联，并将私钥加入Pageant：<br />
       9.4.1、鼠标右键选择TortoiseSVN-&gt;Settings-&gt;Network-&gt;SSH client，输入：<br />
                                C:\Program Files\TortoiseSVN\bin\TortoisePlink.exe；<br />
       9.4.2、鼠标右键选择TortoiseSVN-&gt;RepoBrowser 输入URL：<br />
                                svn+ssh://xiao@SvnServiceIP/usr/local/svn/trunk；<br />
       9.4.3、运行Pageant，右键点击屏幕右下角的图标-〉Add Key，将私钥文件xiaokey.ppk加入。<br />
       注：如果不想缓存ssh密码，则第8、9步不需要，只保留9.4.2，但每次check out、check in中每进入一个文件夹都要输入两次密码，烦死你:)</p>
<p>//TODO:这样的客户端服务器安全性？</p>
]]></content:encoded>
			<wfw:commentRss>http://www.2816.com.cn/archives/ubuntu-svn-windows-svnssh/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ubuntu下SVN服务器安装配置</title>
		<link>http://www.2816.com.cn/archives/ubuntu-svn</link>
		<comments>http://www.2816.com.cn/archives/ubuntu-svn#comments</comments>
		<pubDate>Thu, 27 May 2010 15:07:07 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.2816.com.cn/?p=79</guid>
		<description><![CDATA[一、SVN安装 1.安装包 $ sudo apt-get install subversion 2.添加svn管理用户及subversion组 $ sudo adduser svnuser $ sudo addgroup subversion $ sudo addgroup svnuser subversion        3.创建项目目录 $ sudo mkdir /home/svn $ cd /home/svn $ sudo mkdir fitness $ sudo chown -R root:subversion fitness $ &#8230; <a href="http://www.2816.com.cn/archives/ubuntu-svn">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>一、SVN安装<br />
1.安装包<br />
$ sudo apt-get install subversion</p>
<p>2.添加svn管理用户及subversion组<br />
$ sudo adduser svnuser<br />
$ sudo addgroup subversion<br />
$ sudo addgroup svnuser subversion       </p>
<p>3.创建项目目录<br />
$ sudo mkdir /home/svn<br />
$ cd /home/svn<br />
$ sudo mkdir fitness<br />
$ sudo chown -R root:subversion fitness<br />
$ sudo chmod -R g+rws fitness</p>
<p>4.创建SVN文件仓库<br />
$ sudo svnadmin create /home/svn/fitness</p>
<p>5.访问方式及项目导入：<br />
$ svn co file:///home/svn/fitness<br />
或者<br />
$ svn co file://localhost/home/svn/fitness<br />
* 注意：<br />
如果您并不确定主机的名称，您必须使用三个斜杠(///)，而如果您指定了主机的名称，则您必须使用两个斜杠(//).<br />
//&#8211;<br />
下面的命令用于将项目导入到SVN 文件仓库：<br />
$ svn import -m &#8220;New import&#8221; /home/svn/fitness file:///home/svnuser/src/fitness<br />
一定要注明导入信息</p>
<p>//&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;//<br />
6.访问权限设置<br />
修改 /home/svn/fitness目录下：<br />
svnserve.conf 、passwd 、authz三个文件,行最前端不允许有空格<br />
//&#8211;<br />
编辑svnserve.conf文件,把如下两行取消注释<br />
password-db = password<br />
authz-db = authz<br />
<span id="more-79"></span>//补充说明<br />
# [general]<br />
anon-access = read<br />
auth-access = write<br />
password-db = passwd<br />
其中 anon-access 和 auth-access 分别为匿名和有权限用户的权限，默认给匿名用户只读的权限,但如果想拒绝匿</p>
<p>名用户的访问，只需把 read 改成 none 就能达到目的。</p>
<p>//&#8211;<br />
编辑/home/svnuser/etc/passwd  如下:<br />
[users]<br />
mirze = 123456<br />
test1 = 123456<br />
test2 = 123456<br />
//&#8211;<br />
编辑/home/svnuser/etc/authz如下<br />
[groups]<br />
admin = mirze,test1<br />
test = test2<br />
[/]<br />
@admin=rw<br />
*=r<br />
这里设置了三个用户mirze,test1,test2密码都是123456<br />
其中mirze和test1属于admin组，有读和写的权限,test2属于test组只有读的权限</p>
<p>7.启动SVN服务<br />
svnserve -d -r /home/svn<br />
描述说明：<br />
-d 表示svnserver以“守护”进程模式运行<br />
-r 指定文件系统的根位置（版本库的根目录），这样客户端不用输入全路径，就可以访问版本库<br />
如: svn://192.168.12.118/fitness</p>
<p>这时SVN安装就完成了.<br />
局域网访问方式：<br />
例如：svn checkout svn://192.168.12.118/fitness &#8211;username mirze &#8211;password 123456 /var/www/fitness</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>二、HTTP:// [apache]<br />
1.安装包 [已安装subversion]<br />
$ sudo apt-get install libapache2-svn</p>
<p>创建版本仓库：<br />
sudo svnadmin create /目录地址<br />
目录地址必须存在，这个就是保存版本仓库的地方，不同的版本仓库创建不同的文件夹即可，比如：<br />
sudo svnadmin create /home/svn/project<br />
本来/home/svn/project这个目录下什么都没有，执行下面的命令之后再去看一下，多出一些文件和文件夹，我们需要操作的是conf这个文件夹，这个文件夹下有一个文件，叫做passwd，用来存放用户名和密码。<br />
然后把这个版本仓库目录授权给apache读写：<br />
sudo chown -R www-data:www-data /目录地址<br />
然后来到打开apache配置文件：<br />
sudo gedit /etc/apache2/mods-available/dav_svn.conf</p>
<p>加入如下内容：<br />
&lt;Location /project&gt;<br />
DAV svn<br />
SVNPath /home/svn/project<br />
AuthType Basic<br />
AuthName “myproject subversion repository”<br />
AuthUserFile /home/svn/project/conf/passwd<br />
#&lt;LimitExcept GET PROPFIND OPTIONS REPORT&gt;<br />
Require valid-user<br />
#&lt;/LimitExcept&gt;<br />
&lt;/Location&gt;</p>
<p>location说的是访问地址，比如上述地址，访问的时候就是</p>
<p>http://127.0.0.1/project</p>
<p>其中有两行被注释掉了，以保证每次都需要用户名密码。<br />
最后一步就是创建访问用户了，建议将用户名密码文件存放在当前版本仓库下conf文件夹下，这样版本仓库多的时候无至于太乱。<br />
因为conf文件夹下已经存在passwd文件了，所以直接添加用户：<br />
sudo htpasswd -c /home/svn/project/conf/passwd test<br />
然后输入两遍密码，laoyang这个用户就创建好了。<br />
打开/home/svn/project/conf/passwd这个文件，会开到形如如下形式的文本：<br />
test:WEd.83H.gealA  //后面是加密后的密码。<br />
创建以后，再次需要往别的版本仓库添加这个用户，直接把这一行复制过去就可以了。<br />
重启apache就可以了。<br />
sudo /etc/init.d/apache2 restart</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>三、同步更新 [勾子]</p>
<p><span style="font-weight: bold;">同步程序思路</span>：用户提交程序到SVN，SVN触发hooks,按不同的hooks进行处理，这里用到的是post-commit，利用post-commit到代码检出到SVN服务器的本地硬盘目录，再通过rsync同步到远程的WEB服务器上。</p>
<p>知识点：<br />
1、SVN的hooks<br />
# start-commit 提交前触发事务<br />
# pre-commit 提交完成前触发事务<br />
# post-commit 提交完成时触发事务<br />
# pre-revprop-change 版本属性修改前触发事务<br />
# post-revprop-change 版本属性修改后触发事务<br />
通过上面这些名称编写的脚本就就可以实现多种功能了，相当强大。<br />
2、同步命令rsync的具体参数使用<br />
3、具有基个语言的编程能力bash python perl都可以实现</p>
<p>post-commit具体实现细节<br />
post-commit脚本</p>
<p> 编辑文件：<span style="font-weight: bold;">sudo vim /home/svn/fitness/hooks/post-commit</span></p>
<p><span style="font-weight: bold;">注意：编辑完成post-commit后，执行：sudo chmod 755 post-commit<br />
</span></p>
<p>内容：</p>
<p><span style="color: #0000ff;">#!/bin/sh</span><br style="color: #0000ff;" /><span style="color: #0000ff;">export LANG=zh_CN.UTF-8</span><br style="color: #0000ff;" /><span style="color: #0000ff;">sudo /usr/bin/svn update /var/www/www &#8211;username mirze &#8211;password 123456</span></p>
<p style="font-weight: bold;">或</p>
<p><span style="color: #ff0000;">#Set variable</span><br style="color: #ff0000;" /><span style="color: #ff0000;">SVN=/usr/bin/svn</span><br style="color: #ff0000;" /><span style="color: #ff0000;">WEB=/home/test_nokia/</span><br style="color: #ff0000;" /><span style="color: #ff0000;">RSYNC=/usr/bin/rsync</span><br style="color: #ff0000;" /><span style="color: #ff0000;">LOG=/tmp/rsync_test_nokia.log</span><br style="color: #ff0000;" /><span style="color: #ff0000;">WEBIP=&#8221;192.168.0.23&#8243;</span><br style="color: #ff0000;" /><span style="color: #ff0000;">export LANG=en_US.UTF-8</span><br style="color: #ff0000;" /><span style="color: #ff0000;"> </span><br style="color: #ff0000;" /><span style="color: #ff0000;">#update the code from the SVN</span><br style="color: #ff0000;" /><span style="color: #ff0000;">$SVN update $WEB &#8211;username user &#8211;password  password</span><br style="color: #ff0000;" /><span style="color: #ff0000;">#If the previous command completed successfully, to continue the following</span><br style="color: #ff0000;" /><span style="color: #ff0000;">if [ $? == 0 ]</span><br style="color: #ff0000;" /><span style="color: #ff0000;">then</span><br style="color: #ff0000;" /><span style="color: #ff0000;">    echo &#8220;&#8221;     &gt;&gt; $LOG</span><br style="color: #ff0000;" /><span style="color: #ff0000;">    echo `date` &gt;&gt; $LOG</span><br style="color: #ff0000;" /><span style="color: #ff0000;">    echo &#8220;##############################&#8221; &gt;&gt; $LOG</span><br style="color: #ff0000;" /><span style="color: #ff0000;">    chown -R nobody:nobody /home/test_nokia/</span><br style="color: #ff0000;" /><span style="color: #ff0000;">    #Synchronization code from the SVN server to the WEB server, notes:by the key</span><br style="color: #ff0000;" /><span style="color: #ff0000;">    $RSYNC -vaztpH  &#8211;timeout=90   &#8211;exclude-from=/home/svn/exclude.list $WEB root@$WEBIP:/www/ &gt;&gt; $LOG</span><br style="color: #ff0000;" /><span style="color: #ff0000;">fi</span></p>
<p>以上是具体的post-commit程序<br />
注意事项：<br />
1、一定要定义变量，主要是用过的命令的路径。因为SVN的考虑的安全问题，没有调用系统变量，如果手动执行是没有问题，但SVN自动执行就会无法执行了。<br />
2、SVN update 之前一定要先手动checkout一份出来，还有这里一定要添加用户和密码如果只是手动一样会更新，但自动一样的不行。<br />
3、加上了对前一个命令的判断，如果update的时候出了问题，程序没有退出的话还会继续同步代码到WEB服务器上，这样会造成代码有问题<br />
4、记得要设置所属用户，因为rsync可以同步文件属性，而且我们的WEB服务器一般都不是root用户，用户不正确会造成WEB程序无法正常工作。<br />
5、建议最好记录日志，出错的时候可以很快的排错<br />
6、最后最关键的数据同步，rsync的相关参数一定要清楚，这个就不说了。注意几个场景：<br />
这里的环境是SVN服务器与WEB服务器是开的<br />
把SVN服务器定义为源服务器 WEB服务器为目的服务器<br />
场景一、如果目的WEB服务器为综合的混杂的，像只有一个WEB静态资源，用户提交的，自动生成的都在WEB的一个目录下，建议不要用–delete这个参数<br />
上面这个程序就是这样，实现的是源服务器到目的服务器的更新和添加，而没有删除操作，WEB服务器的内容会多于源SVN的服务器的<br />
场景二、实现镜像，即目的WEB服务器与源SVN服务器一样的数据，SVN上任何变化WEB上一样的变化，就需要–delete参数<br />
场景三、不需要同步某些子目录，可能有些目录是缓存的临时垃圾目录，或者是专用的图片目录（而不是样式或者排版的）要用exclude这个参数<br />
注意：这个参数的使用不用写绝对路径，只要目录名称就行 aa代表文件 aa/ 代表目录 ，缺点就是如果有多个子目录都是一样的名称那么这些名称就都不会被同步<br />
建议用–exclude-from=/home/svn/exclude.list 用文件的形式可以方便的添加和删除<br />
exclude.list</p>
<p>.svn/<br />
.DS_Store<br />
images/</p>
<p>利用SVN的钩子还可以写出很多的程序来控制SVN 如代码提交前查看是否有写日志，是否有tab，有将换成空格，是否有不允许上传的文件，是否有超过限制大小的文件等等。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.2816.com.cn/archives/ubuntu-svn/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>这个图片不错</title>
		<link>http://www.2816.com.cn/archives/underconstruction</link>
		<comments>http://www.2816.com.cn/archives/underconstruction#comments</comments>
		<pubDate>Thu, 20 May 2010 01:42:21 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Picture]]></category>
		<category><![CDATA[网站建设中]]></category>

		<guid isPermaLink="false">http://www.2816.com.cn/?p=75</guid>
		<description><![CDATA[这个网站正在建设中的图片不错～]]></description>
			<content:encoded><![CDATA[<p>这个网站正在建设中的图片不错～</p>
<p><img title="underconstruction" src="http://www.2816.com.cn/wp-content/uploads/2010/05/underconstruction.jpg" alt="" width="450" height="372" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.2816.com.cn/archives/underconstruction/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在CentOS5.3上安装Apache2+PHP5+MySQL(LAMP)</title>
		<link>http://www.2816.com.cn/archives/centos-lampp</link>
		<comments>http://www.2816.com.cn/archives/centos-lampp#comments</comments>
		<pubDate>Sun, 16 May 2010 15:10:06 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[lampp]]></category>

		<guid isPermaLink="false">http://www.2816.com.cn/archives/centos-lampp</guid>
		<description><![CDATA[LAMP是Linux，Apache，Mysql，PHP的缩写。这篇教程将会为您讲解如何在一台CentOS5.3服务器上安装带有PHP5（mod­_php）和Mysql支持Apache2的网站服务器。 我不保证这篇教程里的内容，完全适合您。 1.首项附注 在这篇教程中，我将使用的主机名是 server1.example.com ，IP 地址是192.168.0.100.这些设置可能与你的机器不同，因此你需要在合适的地方更换下。 2.安装MySQL5.0 我们通过执行下面的命令来安装MySQl： yum install mysql mysql-server 然后我们为MySQL创建系统启动快捷键（这样的话，MySQL就会在系统启动的时候自动启动）并且启动MySQL服务器： chkconfig –levels 235 mysqld on /etc/init.d/mysqld start 运行 mysqladmin -u root password yourrootsqlpassword mysqladmin -h server1.example.com -u root password yourrootsqlpassword 来为root用户设置一个密码（否则的话任何人都可以访问你的MySQL数据库！）。 3安装Apache2 Apache2 是CentOS的一个可供选择的包，因此我们可以使用下列命令安装它： yum install &#8230; <a href="http://www.2816.com.cn/archives/centos-lampp">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>LAMP是Linux，Apache，Mysql，PHP的缩写。这篇教程将会为您讲解如何在一台CentOS5.3服务器上安装带有PHP5（mod­_php）和Mysql支持Apache2的网站服务器。</p>
<p>我不保证这篇教程里的内容，完全适合您。</p>
<h5>1.首项附注</h5>
<p>在这篇教程中，我将使用的主机名是 server1.example.com ，IP 地址是192.168.0.100.这些设置可能与你的机器不同，因此你需要在合适的地方更换下。</p>
<h5>2.安装MySQL5.0</h5>
<p>我们通过执行下面的命令来安装MySQl：</p>
<p>yum install mysql mysql-server</p>
<p>然后我们为MySQL创建系统启动快捷键（这样的话，MySQL就会在系统启动的时候自动启动）并且启动MySQL服务器：</p>
<p>chkconfig –levels 235 mysqld on   <br />/etc/init.d/mysqld start</p>
<p>运行</p>
<p>mysqladmin -u root password yourrootsqlpassword   <br />mysqladmin -h server1.example.com -u root password yourrootsqlpassword</p>
<p>来为root用户设置一个密码（否则的话任何人都可以访问你的MySQL数据库！）。</p>
<h5>3安装Apache2</h5>
<p>Apache2 是CentOS的一个可供选择的包，因此我们可以使用下列命令安装它：</p>
<p>yum install httpd</p>
<p>现在配置你的系统使得Apache可以自动启动。。。</p>
<p>chkconfig –levels 235 httpd on</p>
<p>… 并且启动Apache</p>
<p>/etc/init.d/httpd start</p>
<p>现在你可以在你的浏览器中转到<a href="http://192.168.0.100">http://192.168.0.100</a>,你应该看到Apache2的预留页：</p>
<p><img style="display: inline" title="1" alt="1" src="http://www.2816.com.cn/wp-content/uploads/2010/05/1.png" width="550" height="398" /> </p>
<dl>
<dd>apache preloadpage</dd>
</dl>
<p>在CentOS里Apache的默认文档路径的位置是在/var/www/html，配置文件的路径是/etc/httpd/conf/httpd.conf。其他的配置存储在/etc/httpd/conf.d/ 文件夹里。</p>
<p> <span id="more-74"></span><br />
<h5>4 安装PHP5</h5>
<p>我们可以使用下列命令来安装PHP5和Apache的PHP5模块：</p>
<p>yum install php</p>
<p>然后我们必须重新启动Apache:</p>
<p>/etc/init.d/httpd start</p>
<h5>5测试PHP5/获取PHP5安装的一些信息</h5>
<p>网站的默认文档的路径是/var/www/html.我们可以在这个目录里创建一个简单的php文件（info.php）并且在浏览器中调用。这文件将会显示很多关于PHP安装时候的有用的细节，例如PHP的安装的版本。</p>
<p>vi /var/www/html/info.php</p>
<p>&lt;?php</p>
<p>phpinfo();</p>
<p>?&gt;</p>
<p>现在我们可以再浏览器中访问这个文件（例如http://192.168.0.100/info.php）：</p>
<p><img style="display: inline" title="2" alt="2" src="http://www.2816.com.cn/wp-content/uploads/2010/05/2.png" width="550" height="398" /> </p>
<dl>
<dd>phpinfo</dd>
</dl>
<p>正如你所看到的，PHP5现在正在工作，正如Server API这一行中显示的一样，它是工作在Apache 2.0 Handler模式下。如果你向下滑动的话，你将会看到所有的模块都可以在PHP5中使用了，MySQL并没有在这里被列出来，这也就意味着PHP5并不支持MySQL。</p>
<h5>6 使得PHP5支持MySQL</h5>
<p>要使得在PHP中支持MySQL，我们可以安装 php-mysql这个包。最好的办法是安装一些其他的PHP5模块，这些模块可能其他应用程序会用到。你可以使</p>
<p>用search命令寻找可用的PHP5模块：</p>
<p>yum search php</p>
<p>选择你所需要的包，然后通过下列命令安装他们：</p>
<p>yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc</p>
<p>现在重新启动Apache2</p>
<p>/etc/init.d/httpd restart</p>
<p>现在在你的浏览器中重新加载http://192.168.0.100/info.php 这个页面，并再次查看模块部分，你现在就能看到多了很多模块，包括我们刚刚安装的MySQL模块。</p>
<p><img style="display: inline" title="3" alt="3" src="http://www.2816.com.cn/wp-content/uploads/2010/05/3.png" width="550" height="398" /> </p>
<dl>
<dd>mysql module</dd>
</dl>
<h5>7 phpMyAdmin</h5>
<p><a href="http://www.phpmyadmin.net/">phpMyAdmin</a>是一款MySQL数据库web化的管理工具。</p>
<p>第一步我们先使我们的CentOS支持<a href="https://rpmrepo.org/RPMforge/Using">RPMforge repository</a>，因为phpMyAdmin并不在CentOS5.3官方的依赖包里：</p>
<p>对于 x86_64 系统:</p>
<p>wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm   <br />rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm</p>
<p>对于 i386系统</p>
<p>wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm   <br />rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm</p>
<p>现在你就可以使用下列命令来安装phpMyAdmin了:</p>
<p>yum install phpmyadmin</p>
<p>现在我们配置下phpMyAdmin。我们改下Apache的配置文件，使的 phpMyAdmin不单单是本机访问。 (取消注释&lt;Directory “/usr/share/phpmyadmin”&gt; 节):</p>
<p>vi /etc/httpd/conf.d/phpmyadmin.conf</p>
<p>#</p>
<p># Web application to manage MySQL</p>
<p>#</p>
<p>#&lt;Directory “/usr/share/phpmyadmin”&gt;</p>
<p># Order Deny,Allow</p>
<p># Deny from all</p>
<p># Allow from 127.0.0.1</p>
<p>#&lt;/Directory&gt;</p>
<p>Alias /phpmyadmin /usr/share/phpmyadmin</p>
<p>Alias /phpMyAdmin /usr/share/phpmyadmin</p>
<p>Alias /mysqladmin /usr/share/phpmyadmin</p>
<p>下面我们改变下phpMyAdmin的认证方式，从cookie改成http：</p>
<p>vi /usr/share/phpmyadmin/config.inc.php</p>
<p>[...]</p>
<p>/* Authentication type */</p>
<p>$cfg['Servers'][$i]['auth_type'] = ‘http’;</p>
<p>[...]</p>
<p>最后，你就可以通过<a href="http://192.168.0.100/phpmyadmin/">http://192.168.0.100/phpmyadmin/</a>当问phpMyAdmin了：</p>
<p><img style="display: inline" title="4" alt="4" src="http://www.2816.com.cn/wp-content/uploads/2010/05/4.png" width="550" height="398" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.2816.com.cn/archives/centos-lampp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOS常用命令</title>
		<link>http://www.2816.com.cn/archives/centos</link>
		<comments>http://www.2816.com.cn/archives/centos#comments</comments>
		<pubDate>Sun, 16 May 2010 15:01:40 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos]]></category>

		<guid isPermaLink="false">http://www.2816.com.cn/archives/centos</guid>
		<description><![CDATA[一：使用CentOS常用命令查看cpu more /proc/cpuinfo &#124; grep &#34;model name&#34;&#160;&#160; grep &#34;model name&#34; /proc/cpuinfo&#160;&#160; [root@localhost /]# grep &#34;CPU&#34; /proc/cpuinfo&#160;&#160; model name&#160;&#160;&#160;&#160;&#160; : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz&#160;&#160; model name&#160;&#160;&#160;&#160;&#160; : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz&#160;&#160; 如果觉得需要看的更加舒服 grep &#34;model name&#34; &#8230; <a href="http://www.2816.com.cn/archives/centos">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>一：使用CentOS常用命令查看cpu</strong> </p>
<p>more /proc/cpuinfo | grep &quot;model name&quot;&#160;&#160; <br />grep &quot;model name&quot; /proc/cpuinfo&#160;&#160; <br />[root@localhost /]# grep &quot;CPU&quot; /proc/cpuinfo&#160;&#160; <br />model name&#160;&#160;&#160;&#160;&#160; : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz&#160;&#160; <br />model name&#160;&#160;&#160;&#160;&#160; : Intel(R) Pentium(R) Dual CPU E2180 @ 2.00GHz&#160;&#160; <br />如果觉得需要看的更加舒服     <br />grep &quot;model name&quot; /proc/cpuinfo | cut -f2 -d: </p>
<p><strong>二：使用CentOS常用命令查看内存</strong> </p>
<p>grep MemTotal /proc/meminfo&#160; grep MemTotal /proc/meminfo | cut -f2 -d:&#160; free -m |grep &quot;Mem&quot; | awk &#8216;{print $2}&#8217; </p>
<p><strong>三：使用CentOS常用命令查看cpu是32位还是64位</strong> </p>
<p>查看CPU位数(32 or 64)    <br />getconf LONG_BIT </p>
<p><strong>四：使用CentOS常用命令查看当前linux的版本</strong> </p>
<p>more /etc/redhat-release    <br />cat /etc/redhat-release</p>
<p> <span id="more-69"></span>
<p><strong>五：使用CentOS常用命令查看内核版本</strong> </p>
<p>uname -r    <br />uname -a </p>
<p><strong>六：使用CentOS常用命令查看当前时间</strong> </p>
<p>date上面已经介绍如何同步时间了 </p>
<p><strong>七：使用CentOS常用命令查看硬盘和分区</strong> </p>
<p>df -h    <br />fdisk -l     <br />也可以查看分区     <br />du -sh     <br />可以看到全部占用的空间     <br />du /etc -sh     <br />可以看到这个目录的大小 </p>
<p><strong>八：使用CentOS常用命令查看安装的软件包</strong> </p>
<p>查看系统安装的时候装的软件包    <br />cat -n /root/install.log     <br />more /root/install.log | wc -l     <br />查看现在已经安装了那些软件包     <br />rpm -qa     <br />rpm -qa | wc -l     <br />yum list installed | wc -l     <br />不过很奇怪，我通过rpm，和yum这两种方式查询的安装软件包，数量并不一样。没有找到原因。 </p>
<p><strong>九：使用CentOS常用命令查看键盘布局</strong> </p>
<p>cat /etc/sysconfig/keyboard    <br />cat /etc/sysconfig/keyboard | grep KEYTABLE | cut -f2 -d= </p>
<p><strong>十：使用CentOS常用命令查看selinux情况</strong> </p>
<p>sestatus    <br />sestatus | cut -f2 -d:     <br />cat /etc/sysconfig/selinux </p>
<p><strong>十一：使用CentOS常用命令查看ip，mac地址</strong> </p>
<p>在ifcfg-eth0 文件里你可以看到mac，网关等信息。&#160; ifconfig&#160; cat /etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR&#160; cat /etc/sysconfig/network-scripts/ifcfg-eth0 | grep IPADDR | cut -f2 -d=&#160; ifconfig eth0 |grep &quot;inet addr:&quot; |awk &#8216;{print $2}&#8217;|cut -c 6-&#160; ifconfig&#160;&#160; | grep &#8216;inet addr:&#8217;| grep -v &#8217;127.0.0.1&#8242; | cut -d: -f2 | awk &#8216;{ print $1}&#8217;&#160; 查看网关&#160; cat /etc/sysconfig/network&#160; 查看dns&#160; cat /etc/resolv.conf&#160; 十二：使用CentOS常用命令查看默认语言    <br />echo $LANG $LANGUAGE     <br />cat /etc/sysconfig/i18n </p>
<p><strong>十二：使用CentOS常用命令查看所属时区和是否使用UTC时间</strong> </p>
<p>cat /etc/sysconfig/clock </p>
<p><strong>十三：使用CentOS常用命令查看主机名</strong> </p>
<p>hostname    <br />cat /etc/sysconfig/network     <br />修改主机名就是修改这个文件，同时最好也把host文件也修改。 </p>
<p><strong>十四：使用CentOS常用命令查看开机运行时间</strong> </p>
<p>uptime    <br />09:44:45 up 67 days, 23:32, &#8230; </p>
]]></content:encoded>
			<wfw:commentRss>http://www.2816.com.cn/archives/centos/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paypal Auto Return, PDT and IPN</title>
		<link>http://www.2816.com.cn/archives/paypal-auto-return-pdt-and-ipn</link>
		<comments>http://www.2816.com.cn/archives/paypal-auto-return-pdt-and-ipn#comments</comments>
		<pubDate>Fri, 07 May 2010 16:56:46 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Paypal]]></category>
		<category><![CDATA[Auto Return]]></category>
		<category><![CDATA[IPN]]></category>
		<category><![CDATA[PDT]]></category>

		<guid isPermaLink="false">http://www.2816.com.cn/archives/paypal-auto-return-pdt-and-ipn</guid>
		<description><![CDATA[There are several ways PayPal returns payment data to you after the payment is completed. You get to choose how you get the data back. But you have to use the correct technology for your choice. I see some confusion &#8230; <a href="http://www.2816.com.cn/archives/paypal-auto-return-pdt-and-ipn">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There are several ways PayPal returns payment data to you after the payment is completed. You get to choose how you get the data back. But you have to use the correct technology for your choice. I see some confusion about the ways you receive and process data from PayPal. Often times the technology is mismatched with the settings you made and you get unexpected results. I hope this article will help clear things up.</p>
<p><strong>Option 1: POST to Return Page</strong></p>
<p>How does it work?</p>
<ol>
<li>After finishing the payment on PayPal, the customer <strong>clicks on a button</strong>. </li>
<li>PayPal posts payment data to your URL in a HTML form. </li>
<li>You post a form (format is described in the IPN section below) to PayPal. PayPal responds with a single word VERIFIED or INVALID. </li>
<li>If you receive VERIFIED, you can be confident that the form you received came from PayPal and wasn&#8217;t tampered with. Do whatever you need to do with the form data.</li>
</ol>
<p>Settings:</p>
<p>specify a return url in the <strong>return</strong> variable in your html form. The return url must be an absolute url.Code:</p>
<pre name="code" class="html:collapse">
<input type="hidden" name="return" value="your_url_here"></pre>
<p>set the <strong>rm</strong> variable to 2. Code:</p>
<pre name="code" class="html:collapse">
<input type="hidden" name="rm" value="2"></pre>
<p><span id="more-57"></span></p>
<p>Auto Return = Disabled in account profile (if Auto Return = Enabled, you won&#8217;t get any data) </p>
<p>PDT = Disabled in account profile </p>
<p>IPN = Disabled in account profile</p>
<p>Sample script: <a href="http://paypaltech.com/SG2/">http://paypaltech.com/SG2/</a></p>
<p>I don&#8217;t recommend this as a stand-alone solution because you can&#8217;t guarantee that the customer will click on that button. Many customers simply close their browser or navigate away because they are done with their payment.</p>
<p><strong>Option 2: Payment Data Transfer (PDT)</strong></p>
<p>How does it work?</p>
<ol>
<li>After finishing the payment on PayPal, the customer is <strong>automatically redirected</strong> to your page. </li>
<li>PayPal sends a <strong>GET</strong> request to your page. If your URL contains a query string, PayPal will append parameters to the URL. For example: Code:
<pre name="code" class="html:collapse"><a href="http://yoursite/yourpage?yourparam=yourvalue&amp;tx=3KK900354R868601V">http://yoursite/yourpage?yourparam=yourvalue&amp;tx=3KK900354R868601V</a>&amp;......</pre>
</li>
<li>You post a form to PayPal with <strong>cmd=_notify-synch</strong>, the <strong>tx</strong> token you received in the query string and the identity token in your account profile when you turned on PDT.Code:
<pre name="code" class="html:collapse">
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="POST">
<input type="hidden" name="cmd" value="_notify-synch">
<input type="hidden" name="tx" value="3KK900354R868601V">
<input type="hidden" name="at" value="lpeb7DhJWXz5BU43tiarWlo42x5g-Nvv0oJCORuEVsmY9JiRuVUDW2jAHUI">
</form>
</pre>
</li>
<li>PayPal responds with <strong>a block of text</strong> with SUCCESS or FAIL on the top. If it&#8217;s SUCCESS, name value pairs on separate lines follow the SUCCESS line. </li>
<li>If the response has SUCCESS on the top, you read the rest of the lines from the response.</li>
</ol>
<p>Settings:</p>
<p>specify an url for PDT in your account profile or in the <strong>return</strong> variable in your html form. The url must be an absolute url.Code:</p>
<pre name="code" class="html:collapse">
<input type="hidden" name="return" value="your_return_url_here"></pre>
<p>Auto Return = Enabled in account profile </p>
<p>PDT = Enabled in account profile </p>
<p>IPN = Disabled in account profile</p>
<p>Sample script: <a href="http://paypaltech.com/PDTGen/">http://paypaltech.com/PDTGen/</a></p>
<p>Moreinfo: <a href="https://www.paypal.com/IntegrationCenter/ic_pdt.html">https://www.paypal.com/IntegrationCenter/ic_pdt.html</a></p>
<p><strong>This approach is better</strong> than Option 1 but there still may be breakage from the auto redirect after the payment is done. For example the customer could close the browser or navigate away before redirect is completed. If the redirect breaks, you won&#8217;t know about the payment. It is possible for the customer to refresh the page. So if you are inserting records to a database, you must check for duplicates. Don&#8217;t count on the PDT url being called only once. Use PDT if you must know <strong>immediately</strong> whether the payment went through, while the customer is still on your site, for example for providing immediate access to digital downloads. If you are shipping physical goods, you can wait for the IPN (see Option 3 below). Because PDT is a front end technology, you will only get data for the initial payment. You won&#8217;t get data on eCheck clearance and other events. If you want to get notified programmatically about those events, you will still have to do IPN.</p>
<p><strong>Option 3: Instant Payment Notification (IPN)</strong></p>
<p>How does it work?</p>
<ol>
<li>After finishing the payment on PayPal, the customer is <strong>auto-redirected</strong> to your page (&quot;return&quot; variable) </li>
<li>Customer returns to your page. PayPal does <strong>NOT</strong> send any payment data there. </li>
<li><strong>Separately</strong> in the background, you receive a form POST from PayPal at a <strong>different</strong> URL (notify_url variable). </li>
<li>You post back a form with <strong>cmd=_notify-validate</strong> and all fields you received from PayPal. PayPal responds with a single word VERIFIED or INVALID </li>
<li>If you receive VERIFIED, you can be confident that the form you received came from PayPal and wasn&#8217;t tampered with. Do whatever you need to do with the form fields.</li>
</ol>
<p>Settings:</p>
<p>Specify an auto return url in your profile or in the <strong>return</strong> variable in your html form. The url must be an absolute url. This is just a generic page with no PayPal processing logic. Display something like &quot;Thank you and your order will be processed shortly.&quot; Code:</p>
<pre name="code" class="html:collapse">
<input type="hidden" name="return" value="your_return_url_here"></pre>
<p>Specify an IPN url in your profile or in the <strong>notify_url</strong> variable in your html form. This is where you process payment data from PayPal. The IPN url must be an absolute url. It must also allow anonymous access from outside of your network. If you must open your firewall to a specific host, please note the Sandbox sends IPNs from ipn.sandbox.paypal.com. PayPal live site sends IPNs from notify.paypal.com. Code:</p>
<pre name="code" class="html:collapse">
<input type="hidden" name="notify_url" value="your_ipn_url_here"></pre>
<p>Auto Return = Enabled in account profile </p>
<p>PDT = Disabled in account profile </p>
<p>IPN = Enabled in account profile</p>
<p>Sample script: <a href="http://paypaltech.com/SG2/">http://paypaltech.com/SG2/</a></p>
<p>Test your IPN listener: <a href="http://paypaltech.com/Stephen/test/ipntest3.htm">http://paypaltech.com/Stephen/test/ipntest3.htm</a></p>
<p>More info: <a href="https://www.paypal.com/IntegrationCenter/ic_ipn.html">https://www.paypal.com/IntegrationCenter/ic_ipn.html</a></p>
<p><strong>I recommend this approach</strong> over the 2 options above because there is less chance for breakage. It&#8217;s independent of the customer&#8217;s action. If the customer closes the browser or navigates away, you will still receive notifications from PayPal at your notify_url. IPN also has built-in retry mechanism. If there&#8217;s a problem reaching your notify_url, PayPal will re-try for several days. With either of the 2 options above, you only have one shot at getting the payment data.</p>
<p><strong>Option 4: PDT IPN</strong></p>
<p>This is a belt and suspenders strategy. You use PDT to get most of your data but use IPN as a backup to catch the redirect breakage and for receiving other event notifications. For each IPN you receive, you will first check to see if you already got it from PDT.</p>
<p>Settings:</p>
<p>Specify a return url in your account profile or in the <strong>return</strong> variable in your html form. The script there processes the GET request from PayPal as described under PDT above.Code:</p>
<pre name="code" class="html:collapse">
<input type="hidden" name="return" value="your_pdt_url_here"></pre>
<p>Also specify an IPN url in your profile or in the <strong>notify_url</strong> variable in your html form. This script processes the POST data from PayPal as descirbed under IPN above. Note the data you received may have already been processed by PDT. Code:</p>
<pre name="code" class="html:collapse">
<input type="hidden" name="notify_url" value="your_ipn_url_here"></pre>
<p>Auto Return = Enabled in account profile </p>
<p>PDT = Enabled in account profile </p>
<p>IPN = Enabled in account profile</p>
<p><strong>I also recommend this approach if you are able to deal with the duplicates</strong> coming from different channels. You get the best of both worlds.</p>
<p><strong>Where are the Profile settings for all these?</strong></p>
<p>Auto Return and default return URL are in <strong>Profile</strong> -&gt; <strong>Website Payment Preferences</strong></p>
<p>PDT and your Identity Token (<strong>at</strong> variable) are in <strong>Profile</strong> -&gt; <strong>Website Payment Preferences</strong></p>
<p>IPN and the default notify_url are in <strong>Profile</strong> -&gt; <strong>Instant Payment Notification Preferences</strong></p>
<p>I welcome your questions, comments and corrections however please do not post questions or problems specific to your scripts. You should be able to resolve most of the problems by double checking what you have against the approaches outlined above. If not, please create a separate thread for your specific problem. Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.2816.com.cn/archives/paypal-auto-return-pdt-and-ipn/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu下启动/重启/停止apache服务器</title>
		<link>http://www.2816.com.cn/archives/ubuntu-apache-service</link>
		<comments>http://www.2816.com.cn/archives/ubuntu-apache-service#comments</comments>
		<pubDate>Thu, 29 Apr 2010 17:04:08 +0000</pubDate>
		<dc:creator>Leon</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.2816.com.cn/?p=55</guid>
		<description><![CDATA[Task: Start Apache 2 Server /启动apache服务 # /etc/init.d/apache2 start or $ sudo /etc/init.d/apache2 start Task: Restart Apache 2 Server /重启apache服务 # /etc/init.d/apache2 restart or $ sudo /etc/init.d/apache2 restart Task: Stop Apache 2 Server /停止apache服务 # /etc/init.d/apache2 stop or $ sudo &#8230; <a href="http://www.2816.com.cn/archives/ubuntu-apache-service">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Task: Start Apache 2 Server /启动apache服务</p>
<p># /etc/init.d/apache2 start<br />
or<br />
$ sudo /etc/init.d/apache2 start</p>
<p>Task: Restart Apache 2 Server /重启apache服务</p>
<p># /etc/init.d/apache2 restart<br />
or<br />
$ sudo /etc/init.d/apache2 restart</p>
<p>Task: Stop Apache 2 Server /停止apache服务</p>
<p># /etc/init.d/apache2 stop<br />
or<br />
$ sudo /etc/init.d/apache2 stop</p>
]]></content:encoded>
			<wfw:commentRss>http://www.2816.com.cn/archives/ubuntu-apache-service/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
