Recent Posts

 
02

svn命令行使用说明(转)

转来的,方便自己学习,懒得到处找,放到这里!

0、查看帮助
命令: svn help
1、同步(checkout)服务器数据到本地
命令: svn checkout [directory]
svn co [directory]
例:把 https://svn.test.cn/book/network/ 目录同步到本地的 /usr/local/svn/book/network 目录
# cd /usr/local/svn/book
# svn checkout https://svn.test.cn/book/network/…
(R)eject, accept (t)emporarily or accept (p)ermanently? t

Password for ‘wandering’: <回车> # wandering是我当前登录系统的帐号
Authentication realm: book Subversion Repository
Username: jack
Password for ‘jack’:

2、提交(commit)本地文档到服务器
命令: svn commit -m “” [directory|file]
svn ci -m “” [directory|file]
例:把 /usr/local/svn/book/network/tcpip.txt 提交到服务器,前提是服务器上已经有此文件。
# cd /usr/local/svn/book/network/
# svn commit -m “” # -m是记录的log信息,可以为空

一般情况下,只要在需要更新的数据文件所在的目录执行 svn ci -m “” 即可。

3、更新(update)服务器数据到本地
命令: svn update [directory|file]
svn up [directory|file]
例:把 https://svn.test.cn/book/network/ 目录中的内容更新到本地
# cd /usr/local/svn/book/network
# cd update

4、查看日志
命令: svn log [directory|file]
例:查看 /usr/local/svn/book/network 目录的修改日志
方法一:
# cd /usr/local/svn/book/network
# svn log
方法二:
# svn log /usr/local/svn/book/network

5、增加(add)本地数据到服务器
命令: svn add

开发人员常用命令

(1) 导入项目

$ cd ~/project
$ mkdir -p svntest/{trunk,branches,tags}
$ svn import svntest https://localhost/test/svntest –message “Start project”

$ rm -rf svntest

我们新建一个项目svntest,在该项目下新建三个子目录:trunk,开发主干;branches,开发分支;tags,开发阶段性标签。然后导入到版本库test下,然后把svntest拿掉。

(2) 导出项目

$ svn checkout https://localhost/test/svntest/trunk

修订版本号的指定方式是每个开发人员必须了解的,以下是几个参考例子,说明可参考svn推荐书。

$ svn diff –revision PREV:COMMITTED foo.c
# shows the last change committed to foo.c

$ svn log –revision HEAD
# shows log message for the latest repository commit

$ svn diff –revision HEAD
# compares your working file (with local changes) to the latest version
# in the repository

$ svn diff –revision BASE:HEAD foo.c
# compares your “pristine” foo.c (no local changes) with the
# latest version in the repository

$ svn log –revision BASE:HEAD
# shows all commit logs since you last updated

$ svn update –revision PREV foo.c
# rewinds the last change on foo.c
# (foo.c’s working revision is decreased)

$ svn checkout –revision 3
# specified with revision number

$ svn checkout –revision {2002-02-17}
$ svn checkout –revision {15:30}
$ svn checkout –revision {15:30:00.200000}
$ svn checkout –revision {”2002-02-17 15:30″}
$ svn checkout –revision {”2002-02-17 15:30 +0230″}
$ svn checkout –revision {2002-02-17T15:30}
$ svn checkout –revision {2002-02-17T15:30Z}
$ svn checkout –revision {2002-02-17T15:30-04:00}
$ svn checkout –revision {20020217T1530}
$ svn checkout –revision {20020217T1530Z}
$ svn checkout –revision {20020217T1530-0500}

(3) 日常指令

$ svn update

$ svn add foo.file
$ svn add foo1.dir
$ svn add foo2.dir –non-recursive
$ svn delete README
$ svn copy foo bar
$ svn move foo1 bar1

$ svn status
$ svn status –verbose
$ svn status –verbose –show-updates
$ svn status stuff/fox.c

$ svn diff
$ svn diff > patchfile

$ svn revert README
$ svn revert

修改冲突发生时,会生成三个文件:.mine, .rOLDREV, .rNEWREV。比如:

$ ls -l
sandwich.txt
sandwich.txt.mine
sandwich.txt.r1
sandwich.txt.r2

解决修改冲突方式之一:修改冲突的文件sandwich.txt,然后运行命令:

$ svn resolved sandwich.txt

方式之二:用库里的新版本覆盖你的修改:

$ cp sandwich.txt.r2 sandwich.txt
$ svn resolved sandwich.txt

方式之三:撤销你的修改,这种方式不需要运行resolved子命令:

$ svn revert sandwich.txt
Reverted ’sandwich.txt’
$ ls sandwich.*
sandwich.txt

确保没问题后,就可以提交了。

$ svn commit –message “Correct some fatal problems”
$ svn commit –file logmsg
$ svn commit

(4) 检验版本历史

$ svn log
$ svn log –revision 5:19
$ svn log foo.c
$ svn log -r 8 -v

$ svn diff
$ svn diff –revision 3 rules.txt
$ svn diff –revision 2:3 rules.txt
$ svn diff –revision 4:5 http://svn.red-bean.com/repos/example/trunk/text/rules.txt

$ svn cat –revision 2 rules.txt
$ svn cat –revision 2 rules.txt > rules.txt.v2

$ svn list http://svn.collab.net/repos/svn
$ svn list –verbose http://svn.collab.net/repos/svn

$ svn checkout –revision 1729 # Checks out a new working copy at r1729

$ svn update –revision 1729 # Updates an existing working copy to r1729

(5) 其他有用的命令

svn cleanup

为失败的事务清场。

(6) 分支和合并

建立分支方法一:先checkout然后做拷贝,最后提交拷贝。

$ svn checkout http://svn.example.com/repos/calc bigwc
A bigwc/trunk/
A bigwc/trunk/Makefile
A bigwc/trunk/integer.c
A bigwc/trunk/button.c
A bigwc/branches/
Checked out revision 340.

$ cd bigwc
$ svn copy trunk branches/my-calc-branch
$ svn status
A + branches/my-calc-branch

$ svn commit -m “Creating a private branch of /calc/trunk.”
Adding branches/my-calc-branch
Committed revision 341.

建立分支方法二:直接远程拷贝。

$ svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/branches/my-calc-branch \
-m “Creating a private branch of /calc/trunk.”

Committed revision 341.

建立分支后,你可以把分支checkout并继续你的开发。

$ svn checkout http://svn.example.com/repos/calc/branches/my-calc-branch

假设你已经checkout了主干,现在想切换到某个分支开发,可做如下的操作:

$ cd calc
$ svn info | grep URL
URL: http://svn.example.com/repos/calc/trunk
$ svn switch http://svn.example.com/repos/calc/branches/my-calc-branch
U integer.c
U button.c
U Makefile
Updated to revision 341.
$ svn info | grep URL
URL: http://svn.example.com/repos/calc/branches/my-calc-branch

合并文件的命令参考:

$ svn diff -r 343:344 http://svn.example.com/repos/calc/trunk
$ svn merge -r 343:344 http://svn.example.com/repos/calc/trunk
$ svn commit -m “integer.c: ported r344 (spelling fixes) from trunk.”
$ svn merge -r 343:344 http://svn.example.com/repos/calc/trunk my-calc-branch
$ svn merge http://svn.example.com/repos/branch1@150 \
http://svn.example.com/repos/branch2@212 \
my-working-copy
$ svn merge -r 100:200 http://svn.example.com/repos/trunk my-working-copy
$ svn merge -r 100:200 http://svn.example.com/repos/trunk
$ svn merge –dry-run -r 343:344 http://svn.example.com/repos/calc/trunk

最后一条命令仅仅做合并测试,并不执行合并操作。

建立标签和建立分支没什么区别,不过是拷贝到不同的目录而已。

$ svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/tags/release-1.0 \
-m “Tagging the 1.0 release of the ‘calc’ project.”

$ ls
my-working-copy/
$ svn copy my-working-copy http://svn.example.com/repos/calc/tags/mytag
Committed revision 352.

后一种方式直接把本地的工作拷贝复制为标签。

此外,你还可以删除某个分支。

$ svn delete http://svn.example.com/repos/calc/branches/my-calc-branch \
-m “Removing obsolete branch of calc project.”

管理人员常用命令

(7) 版本库管理

$ svnadmin help

$ svnadmin help create

$ svnadmin create –fs-type bdb /usr/local/repository/svn/test
$ chown -R svn.svn /usr/local/repository/svn/test

建立版本库,库类型为bdb(使用Berkeley DB做仓库),库名称为test。
svn版本库有两种存储方式:基于Berkeley DB(bdb)或者基于文件系统(fsfs),通过 –fs-type可指定存储方式。

(8) 查询版本库信息

$ svnlook help

$ svnlook help tree

$ svnlook tree /usr/local/repository/svn/test –show-ids

02

类百度知道多组头衔角色插件FOR DISCUZ7(UTF-8,GBK)

欢迎反馈意见,欢迎提交bug,欢迎批评,欢迎指教,欢迎使用并传播,请注明版权,谢谢!
去年发布了6.X系列的,基本无人问津,帖子地址http://www.discuz.net/viewthread.php?tid=1122418
看截图,文件在附件里!
screenshot1
screenshot2
screenshot3
rankgroup_for_discuz7

19

xoops调取Discuz最新主题,最新回复程序(block版)

使用方法:
1,下载附件,解压缩到modules目录下…
2,打开discuz/include/functions.php,修改discuz的表前缀,记得加上数据库名(例子:xoops.cdb,其中xoops为数据库名),
修改Discuz论坛的URL,网址最后不要加/,使其格式为 http://…/discuz 类似!
3,登录后台,安装模块…
4,将模块的排序设置为0,使其不在首页显示该链接…
5,到区块管理里修改其显示区块
6,删除缓存,即可

注:如发现后台区块管理中没有Discuz的两个区块,那请到群组管理中,修改权限,添加上这两个区块的权限即可!

  1. <?php
  2. /*
  3.     Date:2009-5-18
  4.     $Id: xoops_version.php   cfc4n $
  5. */
  6. $modversion['name'] = _MI_DISCUZ_NAME;
  7. $modversion['version'] = 0.1;
  8. $modversion['description'] = _MI_DISCUZ_DESC;
  9. $modversion['credits'] = "The Xoops Project, The Xoops China Community, Taiwen Jiang (phppp)";
  10. $modversion['author'] = "CFC4N(cfc4nphp@gmail.com)";
  11. $modversion['license'] = "GNU General Public License (GPL) see LICENSE";
  12. $modversion['image'] = "images/discuz_logo.gif";
  13. $modversion['dirname'] = "discuz";
  14. $modversion['hasMain'] = 1;
  15. $modversion['blocks'][0] = array(
  16.     'file' => "discuz_block.php",
  17.     'name' => _MI_DISCUZ_BLOCK_NEWPOST,
  18.     'description' => "Shows new posts",
  19.     'show_func' => "b_discuz_newpost_show",
  20.     'options' => "",
  21.     'template' => 'discuz_block_newpost.html');
  22.  
  23. $modversion['blocks'][1] = array(
  24.     'file' => "discuz_block.php",
  25.     'name' => _MI_DISCUZ_BLOCK_NEWREPLY,
  26.     'description' => "Shows new replied topics",
  27.     'show_func' => "b_discuz_newreply_show",
  28.     'options' => "",
  29.     'template' => 'discuz_block_newreply.html');
  30. ?>

xoops调取Discuz最新主题,最新回复程序(bloack版)

03

关于正则表达式的贪婪与非贪婪模式(转)

这个是转载的,放这里,是方便自己阅读!

  1. 以前看正则表达式,但没有注意到正则表达式的贪婪与非贪婪模式,今天在经典上看到了这么段代码:
  2. <script>
  3. try{
  4. str="<p>abcdefg</p><p>abcdefghijkl</p>";
  5.  
  6. re1=str.match(/<p>[\W\w]+?<\/p>/ig);
  7. alert("非贪婪模式:\r\n\r\n1:"+re1[0]+"\r\n2:"+re1[1]);
  8.  
  9. re1=str.match(/<p>[\W\w]+<\/p>/ig);
  10. alert("贪婪模式:\r\n\r\n"+re1);
  11.  
  12. re1=str.match(/<p>(.+?)<\/p>/i);
  13. alert("非贪婪模式,且不要标记:\r\n\r\n1:"+re1[1]);
  14.  
  15. re1=str.match(/<p>(.+)<\/p>/i);
  16. alert("贪婪模式,且不要标记:\r\n\r\n"+re1[1]);
  17. }catch(e){alert(e.description)}
  18. </script>
  19.  
  20. 匹配次数中的贪婪与非贪婪
  21.  
  22.     在使用修饰匹配次数的特殊符号时,有几种表示方法可以使同一个表达式能够匹配不同的次数,比如:"{m,n}", "{m,}", "?", "*", "+",具体匹配的次数随被匹配的字符串而定。这种重复匹配不定次数的表达式在匹配过程中,总是尽可能多的匹配。比如,针对文本 "dxxxdxxxd",举例如下:
  23.  
  24. 表达式
  25.    
  26.  
  27. 匹配结果
  28.  
  29. (d)(\w+)
  30.    
  31.  
  32. "\w+" 将匹配第一个 "d" 之后的所有字符 "xxxdxxxd"
  33.  
  34. (d)(\w+)(d)
  35.    
  36.  
  37. "\w+" 将匹配第一个 "d" 和最后一个 "d" 之间的所有字符 "xxxdxxx"。虽然 "\w+" 也能够匹配上最后一个 "d",但是为了使整个表达式匹配成功,"\w+" 可以 "让出" 它本来能够匹配的最后一个 "d"
  38.  
  39.     由此可见,"\w+" 在匹配的时候,总是尽可能多的匹配符合它规则的字符。虽然第二个举例中,它没有匹配最后一个 "d",但那也是为了让整个表达式能够匹配成功。同理,带 "*" 和 "{m,n}" 的表达式都是尽可能地多匹配,带 "?" 的表达式在可匹配可不匹配的时候,也是尽可能的 "要匹配"。这 种匹配原则就叫作 "贪婪" 模式 。
  40.  
  41.     非贪婪模式:
  42.  
  43.     在修饰匹配次数的特殊符号后再加上一个 "?" 号,则可以使匹配次数不定的表达式尽可能少的匹配,使可匹配可不匹配的表达式,尽可能的 "不匹配"。这种匹配原则叫作 "非贪婪" 模式,也叫作 "勉强" 模式。如果少匹配就会导致整个表达式匹配失败的时候,与贪婪模式类似,非贪婪模式会最小限度的再匹配一些,以使整个表达式匹配成功。举例如下,针对文本 "dxxxdxxxd" 举例:
  44.  
  45. 表达式
  46.    
  47.  
  48. 匹配结果
  49.  
  50. (d)(\w+?)
  51.    
  52.  
  53. "\w+?" 将尽可能少的匹配第一个 "d" 之后的字符,结果是:"\w+?" 只匹配了一个 "x"
  54.  
  55. (d)(\w+?)(d)
  56.    
  57.  
  58. 为了让整个表达式匹配成功,"\w+?" 不得不匹配 "xxx" 才可以让后边的 "d" 匹配,从而使整个表达式匹配成功。因此,结果是:"\w+?" 匹配 "xxx"
  59.  
  60.     更多的情况,举例如下:
  61.  
  62.     举例1:表达式 "<td>(.*)</td>" 与字符串 "<td><p>aa</p></td> <td><p>bb</p></td>" 匹配时,匹配的结果是:成功;匹配到的内容是 "<td><p>aa</p></td> <td><p>bb</p></td>" 整个字符串, 表达式中的 "</td>" 将与字符串中最后一个 "</td>" 匹配。
  63.  
  64.     举例2:相比之下,表达式 "<td>(.*?)</td>" 匹配举例1中同样的字符串时,将只得到 "<td><p>aa</p></td>", 再次匹配下一个时,可以得到第二个 "<td><p>bb</p></td>"。
17

URL REwrite fox xoops

只写了news,tag,newbb,profile,extgallery这几个模块!
需要apache 的 Rewrite module 的支持!

1,将.htaccess,rewrite_url.php 两个文件复制到xoops主目录下.
2,如果你的xoops不是您网站的根目录,请按照一下操作,否则,请跳过此条,直接进行第3条!
如果您的网站类似这个url http://www.xxx.com/xoops 的话,请打开.htaccess ,找到
#RewriteBase ,去掉前面的# ,后面加上 /xoops, 使之成为RewriteBase /xoops ,保存
3,打开mainfile.php,找到
define(”XOOPS_CHECK_PATH”, 0);
在其下面添加 include “rewrite_url.php”;
4,清除缓存,刷新即可!

附帖子地址:http://xoops.org.cn/modules/newbb/viewtopic.php?topic_id=20353

.htaccess

  1. RewriteEngine On
  2.  
  3. #如果你的xoops不是在网站根目录,请填写目录名,比如:
  4. #http://xx.com/xoops ,那么请将#RewriteBase前的#去掉,并且,改为 RewriteBase /xoops ,如果是根目录,请保持不变
  5.  
  6. #RewriteBase
  7.  
  8. #RewriteCond %{REQUEST_FILENAME}   !-f
  9.  
  10. #all
  11. RewriteRule ^(profile|pm|news|gamaps|extgallery|contact)/index.html$ modules/$1/index.php
  12.  
  13. #profile
  14. RewriteRule ^profile/([a-zA-Z_-]+).html$ modules/profile/$1.php
  15. RewriteRule ^profile/userinfo.php.*$ modules/profile/userinfo.php$1
  16. RewriteRule ^profile/([0-9]+).html$ modules/profile/userinfo.php?uid=$1
  17. RewriteRule ^profile/edit-([0-9]+).html$ modules/profile/edituser.php?uid=$1
  18.  
  19. # newbb
  20. RewriteRule ^newbb/forum-(d+).html$ modules/newbb/viewforum.php?forum=$1
  21. RewriteRule ^newbb/rss-(d+).html$ modules/newbb/rss.php?f=$1
  22. RewriteRule ^newbb/thread-(d+)-(d+).html$ modules/newbb/viewtopic.php?topic_id=$1&forum=$2
  23. RewriteRule ^newbb/thread-(d+)-(d+)-(w*)-(ASC|DESC)-(next|prev).html$ modules/newbb/viewtopic.php?viewmode=$3&order=$4&topic_id=$1&forum=$2&move=$5
  24. RewriteRule ^newbb/index-(d+).html$ modules/newbb/index.php?cat=$1
  25. RewriteRule ^newbb/(w+).php.*$ modules/newbb/$1.php$2
  26.  
  27. #news
  28. RewriteRule ^news/(d+).html$ modules/news/article.php?storyid=$1
  29. RewriteRule ^news/index-(d+).html$ modules/news/index.php?storytopic=$1
  30. RewriteRule ^news/index-(d+)-(d+).html$ modules/news/index.php?storytopic=$1&start=$2
  31. RewriteRule ^news/ratenews-(d+).html$ modules/news/ratenews.php?storyid=$1
  32. RewriteRule ^news/comment-(w*)-(d+)-(d+).html$ modules/news/comment_new.php?com_itemid=$2&com_order=$3&com_mode=$1
  33.  
  34. #extgallery
  35. RewriteRule ^extgallery/index-(d+).html$ modules/extgallery/public_album.php?id=$1
  36. RewriteRule ^extgallery/index-(d+)-(d+).html$ modules/extgallery/public_album.php?id=$1&start=$2
  37. RewriteRule ^extgallery/photo-(d+).html(#?[a-zA-Z0-9]*)$ modules/extgallery/public_photo.php?photoId=$1$2
  38. RewriteRule ^extgallery/userphoto-(d+).html(#?[a-zA-Z0-9]*)$ modules/extgallery/public_userphoto.php?photoId=$1$2
  39. RewriteRule ^extgallery/rate-(d+)-(d+).html$ modules/extgallery/public_rating.php?id=$1&rate=$2
  40. RewriteRule ^extgallery/useralbum-(d+).html$ modules/extgallery/public_useralbum.php?id=$1
  41. RewriteRule ^extgallery/download-(d+).html$ modules/extgallery/public_download.php?id=$1
  42. RewriteRule ^extgallery/sendecard-(d+).html$ modules/extgallery/public_sendecard.php?id=$1

rewrite_url.php

  1. <?php
  2. // $Id: rewrite_url.php,v 1.0 2009-3-16 cfc4n $
  3. // <http://www.xoops.org.cn>
  4. //
  5. if (!defined("XOOPS_ROOT_PATH") || !defined("XOOPS_URL") ) {
  6.     exit();
  7. }
  8. ######################################
  9. #正则表达式里好多代码都被高亮插件执行了,大家还是下载附件吧#
  10. ######################################

附件:xoops-rewrite-url