http://www.fixdown.com/english/Programming/9203_download.htm
本文包含以下内容:
1、 得到目前的日期和时间-我们有多少种方式?
2、 改变日期显示的方式-日期和时间的显示形式
3、 转换现在的日期为Unix的时间戳值
4、 改变日期
a. 增加时间
b. 减去时间
c. 找出两日期之间的间隔
5、 为PHP添加DateAdd函数
6、 为PHP添加DateDiff函数
**得到目前的日期和时间
在Unix中,时间的表示方式为计算从1970年1月1日零时起所过去的秒数,这称为UNIX 时间戳(Unix Epoch)。
如果我们有这样一段的代码:
?
echo time();
?
将返回值958905820
阅读全文
1、 得到目前的日期和时间-我们有多少种方式?
2、 改变日期显示的方式-日期和时间的显示形式
3、 转换现在的日期为Unix的时间戳值
4、 改变日期
a. 增加时间
b. 减去时间
c. 找出两日期之间的间隔
5、 为PHP添加DateAdd函数
6、 为PHP添加DateDiff函数
**得到目前的日期和时间
在Unix中,时间的表示方式为计算从1970年1月1日零时起所过去的秒数,这称为UNIX 时间戳(Unix Epoch)。
如果我们有这样一段的代码:
?
echo time();
?
将返回值958905820

http://tech.ddvip.com/2007-02/117049614319269.html
http://hi.baidu.com/suchshow/blog/item/8aeb9523c6a26a579822edc8.html
在原创那边写了几个php+ajax的应用例子,今天和新手谈谈smarty+xjax,希望对新手有帮助,xajax是用PHP写的ajax开发框架,可以生成JS代码,这样使用起ajax就比较简单了,今天结合模板引擎smarty,来实现一个检测用户名合法性的小程序,大家有兴趣的话还可以扩展这个程序到自己的应用中,嗯,这里写出核心代码,里面注释很详细,不过建议大家看之前还是看看这个http://blog.csdn.net/fhiesc/archive/2006/07/04/873441.aspx,相信你会很快明白xajax是什么东东,及如何使用,最后依然是效果图和源代码下载。好的,看代码吧:
阅读全文
http://hi.baidu.com/suchshow/blog/item/8aeb9523c6a26a579822edc8.html
在原创那边写了几个php+ajax的应用例子,今天和新手谈谈smarty+xjax,希望对新手有帮助,xajax是用PHP写的ajax开发框架,可以生成JS代码,这样使用起ajax就比较简单了,今天结合模板引擎smarty,来实现一个检测用户名合法性的小程序,大家有兴趣的话还可以扩展这个程序到自己的应用中,嗯,这里写出核心代码,里面注释很详细,不过建议大家看之前还是看看这个http://blog.csdn.net/fhiesc/archive/2006/07/04/873441.aspx,相信你会很快明白xajax是什么东东,及如何使用,最后依然是效果图和源代码下载。好的,看代码吧:

一般使用Vim都是三个窗口,,,一般包含以下一些东西,,,
大家可以试试看,,,觉着好用,,,不妨装上!!!呵呵
第一个:
Tag List
下载地址:?http://www.vim.org/scripts/script.php?script_id=273
官方描述: The “Tag List” plugin is a source code browser plugin for Vim and provides an overview of the structure of source code files and allows you to efficiently browse through source code files for different programming languages.
这是一个非常非常非常非常重要的插件, 有了它, 我们才能够在 VIM 中查看一个文件中包含的函数列表, 或是一个类包含的方法列表, 为编程人员提供了极大方便。推荐大家一定要安装!
安装注意事项: 有的系统内置的 ctags 功能太弱, 推荐大家安装 EXUBERANT CTAGS, 这个东西功能比较强大, 居然连 HTML 里面内嵌的 Java Script 都能够支持, 实在是匪疑所思!
把方法列表放在屏幕的右侧, 在 .vimrc 中设置
let Tlist_Use_Right_Window=1
让当前不被编辑的文件的方法列表自动折叠起来, 这样可以节约一些屏幕空间,可在 .vimrc 中设置了
let Tlist_File_Fold_Auto_Close=1。
------------------------------------------------------------------->
阅读全文
大家可以试试看,,,觉着好用,,,不妨装上!!!呵呵
第一个:
Tag List
下载地址:?http://www.vim.org/scripts/script.php?script_id=273
官方描述: The “Tag List” plugin is a source code browser plugin for Vim and provides an overview of the structure of source code files and allows you to efficiently browse through source code files for different programming languages.
这是一个非常非常非常非常重要的插件, 有了它, 我们才能够在 VIM 中查看一个文件中包含的函数列表, 或是一个类包含的方法列表, 为编程人员提供了极大方便。推荐大家一定要安装!
安装注意事项: 有的系统内置的 ctags 功能太弱, 推荐大家安装 EXUBERANT CTAGS, 这个东西功能比较强大, 居然连 HTML 里面内嵌的 Java Script 都能够支持, 实在是匪疑所思!
把方法列表放在屏幕的右侧, 在 .vimrc 中设置
let Tlist_Use_Right_Window=1
让当前不被编辑的文件的方法列表自动折叠起来, 这样可以节约一些屏幕空间,可在 .vimrc 中设置了
let Tlist_File_Fold_Auto_Close=1。
------------------------------------------------------------------->

读本文之前请注意:
1. 本文的目标是提供一些vim的使用技巧,利用这些技巧可以提高vim的操作效率。部分技巧在vi上也可以使用,但是现在基本上都是用vim了。
2. 本文是整理和总结使用技巧,而非讲解vim入门,因此不会涉及最基本的使用,例如如何上移或下移光标,对此类操作请参阅任何一本vim或者vi教程。
3. 本文阅读对象是了解了vim的基本操作,而希望高效地利用vim进行工作的人。熟练使用vim的人自然不必细读,如果能留下您的宝贵意见,本人将感激不尽。
4. 本文由本人搜集整理,转载请注明出处
本文一般情况下用(里边的字母一般大小写无所谓,除非特别注明)表示按住ctrl同时按下相关字母,命令前加一个i表示在插入模式下用这个命令
1. 选定文字 / 拷贝粘贴
v为可视模式,可以选定多行。选定多行之后,可以用yy或者dd等等进行拷贝和剪切。
p 是粘贴
y 和d 可以直接拷贝或者剪切选定的内容
yw是拷贝一个单词
如果要复制整行的最简单办法就是V,y,p 就行了
v是可以选定一行任意个字符的,V是行选定的,一次一整行,然后通过向下或向上移动光标而选定多行。
对于v选定的,拷贝后就是这么多,选多少就拷贝多少,而V选定的,粘贴的话会自动换到下一行
命令模式下,也是块选定,不过是列块选定
阅读全文
1. 本文的目标是提供一些vim的使用技巧,利用这些技巧可以提高vim的操作效率。部分技巧在vi上也可以使用,但是现在基本上都是用vim了。
2. 本文是整理和总结使用技巧,而非讲解vim入门,因此不会涉及最基本的使用,例如如何上移或下移光标,对此类操作请参阅任何一本vim或者vi教程。
3. 本文阅读对象是了解了vim的基本操作,而希望高效地利用vim进行工作的人。熟练使用vim的人自然不必细读,如果能留下您的宝贵意见,本人将感激不尽。
4. 本文由本人搜集整理,转载请注明出处
本文一般情况下用
1. 选定文字 / 拷贝粘贴
v为可视模式,可以选定多行。选定多行之后,可以用yy或者dd等等进行拷贝和剪切。
p 是粘贴
y 和d 可以直接拷贝或者剪切选定的内容
yw是拷贝一个单词
如果要复制整行的最简单办法就是V,y,p 就行了
v是可以选定一行任意个字符的,V是行选定的,一次一整行,然后通过向下或向上移动光标而选定多行。
对于v选定的,拷贝后就是这么多,选多少就拷贝多少,而V选定的,粘贴的话会自动换到下一行

流行的 IDE 的编辑器,诸如 Eclipse,都提供了括号自动补全的功能,相当的方便。可惜 Vim 默认情况下并没有提供这样的功能,那就只有自己来写了。
将下面的代码加入到 ~/.vimrc 中,重启 Vim,即可:
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap < <><ESC>i
:inoremap > <c-r>=ClosePair('>')<CR>
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
这样,写代码的时候不再担心会丢掉右边的括号了,尤其是函数嵌套的时候 。
英文单词自动补全:
安装:
拷贝文件到[你的gvim的安装目录]\vimfiles\plugin\中即可!
下载:
http://www.vim.org/scripts/script.php?script_id=1338
将下面的代码加入到 ~/.vimrc 中,重启 Vim,即可:
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {}<ESC>i
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap < <><ESC>i
:inoremap > <c-r>=ClosePair('>')<CR>
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
这样,写代码的时候不再担心会丢掉右边的括号了,尤其是函数嵌套的时候 。
英文单词自动补全:
安装:
拷贝文件到[你的gvim的安装目录]\vimfiles\plugin\中即可!
下载:
http://www.vim.org/scripts/script.php?script_id=1338
最近,zend for eclipse除了6.0.1版本,但是我整合apata(有两种方法整合)后发现在D盘建立php工程后它不建立函数跳转和一些tag索引,为此,我安装卸载多次方发现是由于它在D盘,我在D盘以前建立过php工程,建立了一个Config.Msi目录,它是隐藏起来的,你需要打开工具栏的隐藏选项即可看到,然后del掉,一切ok了。。。哈哈哈,这个文件是由于eclipse换工作目录时候(file-->witch work space ),生成的。如果你想换目录到D盘,最好把:C:\Documents and Settings\Administrator\Zend\workspaces\DefaultWorkspace 下的.metadata拷贝到d盘,你然后在D下面建立工程:aaa bbb ccc等工程即可。.metadata好像是个配置文件,其可以进行函数提示等都是在里面配置的,至于其他的我也不太明白,呵呵
由于SourceForge网站被封,导致很多程序员常用的开发框架都无法下载了,工作和学习非常不方便,下面教大家一个简单的下载sourceforge上面开源软件的办法:
http://mirror.optus.net/sourceforge/
访问如上URL地址,这是一个sourceforge的下载镜像站点,按照字母顺序分目录列出来sourceforge上面所有的软件下载了,我们可以按目录一级一级找到自己要下载的软件,例如:
我要下载Hibernate,那么寻找 /h/hi/hibernate 目录就找到了,该目录下面是所有Hibernate相关软件各个版本的下载地址:
http://mirror.optus.net/sourceforge/h/hi/hibernate/
再例如我要下载Spring也一样,寻找 /s/sp/springframework 目录,即:
http://mirror.optus.net/sourceforge/s/sp/springframework/
如果你想下载JBoss Seam和JBoss应用服务器的话,是下面这个目录:
http://mirror.optus.net/sourceforge/j/jb/jboss/
这个镜像的下载速度不错噢,经过测试每秒有60KB的稳定下载速度。
http://mirror.optus.net/sourceforge/
访问如上URL地址,这是一个sourceforge的下载镜像站点,按照字母顺序分目录列出来sourceforge上面所有的软件下载了,我们可以按目录一级一级找到自己要下载的软件,例如:
我要下载Hibernate,那么寻找 /h/hi/hibernate 目录就找到了,该目录下面是所有Hibernate相关软件各个版本的下载地址:
http://mirror.optus.net/sourceforge/h/hi/hibernate/
再例如我要下载Spring也一样,寻找 /s/sp/springframework 目录,即:
http://mirror.optus.net/sourceforge/s/sp/springframework/
如果你想下载JBoss Seam和JBoss应用服务器的话,是下面这个目录:
http://mirror.optus.net/sourceforge/j/jb/jboss/
这个镜像的下载速度不错噢,经过测试每秒有60KB的稳定下载速度。
姜源 说:
http://www.scribd.com/doc/263139/VIM-for-PHP-Programmers
姜源 说:
这个slide介绍了一些用vim写php的技艺。
姜源 说:
技巧
姜源 说:
但如果你希望用那些auto complete比较好的功能还是别用vi了。
向东 xiangdong.org 说:
hao ..
姜源 说:
vi是一个超级editor不是一个ide
姜源 说:
以前写php的时候我只用editplus
姜源 说:
基本是开着手册。
姜源 说:
很少用自动完成功能。
向东 xiangdong.org 说:
懒人啊,呵呵,我用zend咯。。
http://www.scribd.com/doc/263139/VIM-for-PHP-Programmers
姜源 说:
这个slide介绍了一些用vim写php的技艺。
姜源 说:
技巧
姜源 说:
但如果你希望用那些auto complete比较好的功能还是别用vi了。
向东 xiangdong.org 说:
hao ..
姜源 说:
vi是一个超级editor不是一个ide
姜源 说:
以前写php的时候我只用editplus
姜源 说:
基本是开着手册。
姜源 说:
很少用自动完成功能。
向东 xiangdong.org 说:
懒人啊,呵呵,我用zend咯。。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" src="template.js"></script>
<script language="javascript">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js测试</title>
</head>
<body>
<textarea name="template_jst" id="template_jst" cols="44" rows="22">
Hello ${customer.first} ${customer.last}.<br/>
Your shopping cart has ${products.length} item(s):
<table>
<tr><td>Name</td>
<td>Description</td>
<td>Price</td>
<td>Quantity & Alert</td>
</tr>
{for p in products}
<tr><td>${p.name|capitalize}</td><td>${p.desc}</td>
<td>$${p.price}</td><td>${p.quantity} :
${p.alert|default:""|capitalize}</td>
</tr>
{forelse}
<tr><td colspan="4">No products in your cart.</tr>
{/for}
</table>
{if customer.level == "gold"}
We love you! Please check out our Gold Customer specials!
{else}
Become a Gold Customer by buying more stuff here.
{/if}
</textarea>
<div>
<textarea name="jsData" id="jsData" cols="44" rows="21">
var data = {
products : [ { name: "Linu", desc: "computer",
price: 1000, quantity: 100, alert:null },
{ name: "ipod", desc: "music player",
price: 200, quantity: 200, alert:"on sale now!" },
{ name: "cinema display", desc: "screen",
price: 800, quantity: 300, alert:"best deal!" } ],
customer : { first: "John", last: "Public", level: "gold" }
};
</textarea>
</div>
<hr/>
Output:
<div id="output" name="dfjdk">test</div>
</body>
<script language="javascript">
var dataTextarea = document.getElementById("jsData");
var outputEl = document.getElementById("output");
eval(dataTextarea.value);
//outputEl.innerHTML = TrimPath.processDOMTemplate("template_jst", data);
outputEl.innerHTML =TrimPath.parseTemplate(document.getElementById("template_jst").value, "template_jst").process(data);
</script>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" src="template.js"></script>
<script language="javascript">
</script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js测试</title>
</head>
<body>
<textarea name="template_jst" id="template_jst" cols="44" rows="22">
Hello ${customer.first} ${customer.last}.<br/>
Your shopping cart has ${products.length} item(s):
<table>
<tr><td>Name</td>
<td>Description</td>
<td>Price</td>
<td>Quantity & Alert</td>
</tr>
{for p in products}
<tr><td>${p.name|capitalize}</td><td>${p.desc}</td>
<td>$${p.price}</td><td>${p.quantity} :
${p.alert|default:""|capitalize}</td>
</tr>
{forelse}
<tr><td colspan="4">No products in your cart.</tr>
{/for}
</table>
{if customer.level == "gold"}
We love you! Please check out our Gold Customer specials!
{else}
Become a Gold Customer by buying more stuff here.
{/if}
</textarea>
<div>
<textarea name="jsData" id="jsData" cols="44" rows="21">
var data = {
products : [ { name: "Linu", desc: "computer",
price: 1000, quantity: 100, alert:null },
{ name: "ipod", desc: "music player",
price: 200, quantity: 200, alert:"on sale now!" },
{ name: "cinema display", desc: "screen",
price: 800, quantity: 300, alert:"best deal!" } ],
customer : { first: "John", last: "Public", level: "gold" }
};
</textarea>
</div>
<hr/>
Output:
<div id="output" name="dfjdk">test</div>
</body>
<script language="javascript">
var dataTextarea = document.getElementById("jsData");
var outputEl = document.getElementById("output");
eval(dataTextarea.value);
//outputEl.innerHTML = TrimPath.processDOMTemplate("template_jst", data);
outputEl.innerHTML =TrimPath.parseTemplate(document.getElementById("template_jst").value, "template_jst").process(data);
</script>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>一个使用到for...in循环的Javascript示例</title>
</head>
<body>
<script type="text/javascript">
var data = {
products : [ { name: "Linu", desc: "computer",
price: 1000, quantity: 100, alert:null },
{ name: "ipod", desc: "music player",
price: 200, quantity: 200, alert:"on sale now!" },
{ name: "cinema display", desc: "screen",
price: 800, quantity: 300, alert:"best deal!" } ],
customer : { first: "John", last: "Public", level: "gold" }
};
function isArray(a) {
if(typeof a =="undefined"||null==a)
{
return false;
}
else
{
return a.sort ? true : false;
}
}
function printObj(obj,depth,Attr)
{
if(typeof depth=="undefined"){depth=0;}
if(typeof Attr=="undefined"){Attr="";}
/*
var space="";
for(var i=0;i<=depth;i++)
{
space+=" "
}
if(""!=Attr)
{
document.write(space+Attr+":<br />");
}
*/
if(isArray(obj))
{
for(var i=0;i<obj.length;i++)
{
printObj(obj[i],depth++,i);
}
}
else{
if(typeof obj=="undefined")
{
}else if(typeof obj=="string"||typeof obj=="number" ||typeof obj=="boolean")
{
//document.write(space+" "+obj+"<br />");
document.write(" "+obj+"<br />");
}else
{
for(var p in obj)
{
var eachValue=obj[p];
printObj(eachValue,depth++,p);
}
}
}
}
printObj(data);
</script>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>一个使用到for...in循环的Javascript示例</title>
</head>
<body>
<script type="text/javascript">
var data = {
products : [ { name: "Linu", desc: "computer",
price: 1000, quantity: 100, alert:null },
{ name: "ipod", desc: "music player",
price: 200, quantity: 200, alert:"on sale now!" },
{ name: "cinema display", desc: "screen",
price: 800, quantity: 300, alert:"best deal!" } ],
customer : { first: "John", last: "Public", level: "gold" }
};
function isArray(a) {
if(typeof a =="undefined"||null==a)
{
return false;
}
else
{
return a.sort ? true : false;
}
}
function printObj(obj,depth,Attr)
{
if(typeof depth=="undefined"){depth=0;}
if(typeof Attr=="undefined"){Attr="";}
/*
var space="";
for(var i=0;i<=depth;i++)
{
space+=" "
}
if(""!=Attr)
{
document.write(space+Attr+":<br />");
}
*/
if(isArray(obj))
{
for(var i=0;i<obj.length;i++)
{
printObj(obj[i],depth++,i);
}
}
else{
if(typeof obj=="undefined")
{
}else if(typeof obj=="string"||typeof obj=="number" ||typeof obj=="boolean")
{
//document.write(space+" "+obj+"<br />");
document.write(" "+obj+"<br />");
}else
{
for(var p in obj)
{
var eachValue=obj[p];
printObj(eachValue,depth++,p);
}
}
}
}
printObj(data);
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<div id = "contentdiv">111</div>
</body>
<script language="javascript">
var htmls="hello the world";
alert(document.getElementById('contentdiv').innerHTML);//HTML大写,否则调试不通过啊,必须让div加载后调用该函数
document.getElementById('contentdiv').innerHTML=htmls;
</script>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<div id = "contentdiv">111</div>
</body>
<script language="javascript">
var htmls="hello the world";
alert(document.getElementById('contentdiv').innerHTML);//HTML大写,否则调试不通过啊,必须让div加载后调用该函数
document.getElementById('contentdiv').innerHTML=htmls;
</script>
</html>
PHP作为一种服务器端的脚本语言,象编写简单,或者是复杂的动态网页这样的任务,它完全能够胜任。但事情不总是如此,有时为了实现某个功能,必须借助于操作系统的外部程序(或者称之为命令),这样可以做到事半功倍。
那么,是否可以在PHP脚本中调用外部命令呢?如果能,如何去做呢?有些什么方面的顾虑呢?相信你看了本文后,肯定能够回答这些问题了。
是否可以?
答案是肯定的。PHP和其它的程序设计语言一样,完全可以在程序内调用外部命令,并且是很简单的:只要用一个或几个函数即可。
阅读全文
那么,是否可以在PHP脚本中调用外部命令呢?如果能,如何去做呢?有些什么方面的顾虑呢?相信你看了本文后,肯定能够回答这些问题了。
是否可以?
答案是肯定的。PHP和其它的程序设计语言一样,完全可以在程序内调用外部命令,并且是很简单的:只要用一个或几个函数即可。

背景:经blockips实践%config(noreplace) /usr/local/nginx/conf/blockips.conf,在安装时有/usr/local/nginx/conf/blockips.conf,不会覆盖原来的,而是新起文件名:/usr/local/nginx/conf/blockips.conf.rpmnew ,在删这个rpm包时,rpm -e blockips 会将原来的没有被覆盖的文件/usr/local/nginx/conf/blockips.conf挪动为:/usr/local/nginx/conf/blockips.conf.rpmsave 。也就是说安装时不覆盖,生成新文件.rpmnew,卸载时那个安装时没有覆盖的文件挪动为.rpmsave。
[实践OK]blockips打包里实践得出来的。还发现如果和即将安装的一样的时候,是不会作上述重命名的,直接就安装上了,也就是说安装前做了比对操作!
实践也证明了上面的一个情况,一是noreplace会比对不一样给生成新的.rpmnew,卸载RPM包时会将原来没覆盖的文件给挪为.rpmsave,如果相同则直接覆盖,不做前面这些操作。
#rpm -ihv blockips-1.0.0-220622153009.el7.x86_64.rpm
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:blockips-1.0.0-220622153009.el7 ################################# [100%]
警告:/usr/local/nginx/conf/blockips.conf 已建立为 /usr/local/nginx/conf/blockips.conf.rpmnew
警告:/usr/local/nginx/conf/vhosts/blockipsvc.conf 已建立为 /usr/local/nginx/conf/vhosts/blockipsvc.conf.rpmnew
rpm -e blockips
警告:/usr/local/nginx/conf/vhosts/blockipsvc.conf 已另存为 /usr/local/nginx/conf/vhosts/blockipsvc.conf.rpmsave
警告:/usr/local/nginx/conf/blockips.conf 已另存为 /usr/local/nginx/conf/blockips.conf.rpmsave
ls -1 /usr/local/nginx/conf/blockips.conf.rpm*
/usr/local/nginx/conf/blockips.conf.rpmnew #rpm包安装时发现同名配置,给安装包里的重新命名为.rpmnew
/usr/local/nginx/conf/blockips.conf.rpmsave #卸载rpm包前因文件名内容不一样没有被覆盖的文件给重新命令为.rpmsave
ls -1 /usr/local/nginx/conf/vhosts/blockipsvc.conf.rpm*
/usr/local/nginx/conf/vhosts/blockipsvc.conf.rpmnew
/usr/local/nginx/conf/vhosts/blockipsvc.conf.rpmsave
上面的实践来源:https://jackxiang.com/post/11406/
In addition to the marked directories, the standard Linux documentation directories, such as /usr/share/man, are automatically assumed to be documentation directories.
Similar to the %doc directive, the %config directive marks a file as configuration. For example:
%files
/sbin/ypbind
%config /etc/rc.d/init.d/*
%config /etc/yp.conf
%doc README NEWS
A special option to the %config directive, noreplace, tells RPM not to overwrite, or replace a configuration file. For example:
%files
/sbin/ypbind
%config /etc/rc.d/init.d/*
%config(noreplace) /etc/yp.conf
%doc README NEWS
Use this option to help protect local modifications. If you use %config(noreplace), the file will not overwrite an existing file that has been modified. If the file has not been modified on disk, the rpm command will overwrite the file. But, if the file has been modified on disk, the rpm command will copy the new file with an extra file-name extension of .rpmnew.
Similarly, %config(missingok) means that the file does not have to exist on disk. You can use this modifier for files or links that are created during the %post scripts but will need to be removed if the package is removed.
Another special modifier, %ghost, tells the rpm command that the file should not be included in the package. You can use this to name the needed attributes for a file that the program, when installed, will create. For example, you may want to ensure that a program’s log file has certain attributes.
From:https://docs.fedoraproject.org/ro/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch09s05s03.html
强制删除所有rpm包:
RPM包常用参数 (备忘用)
1.安装一个包
# rpm -ivh
2.升级一个包
# rpm -Uvh
3.移走一个包
# rpm -e
4.安装参数
--force 即使覆盖属于其它包的文件也强迫安装
--nodeps 如果该RPM包的安装依赖其它包,即使其它包没装,也强迫安装。
5.查询一个包是否被安装
# rpm -q < rpm package name>
6.得到被安装的包的信息
# rpm -qi < rpm package name>
阅读全文
[实践OK]blockips打包里实践得出来的。还发现如果和即将安装的一样的时候,是不会作上述重命名的,直接就安装上了,也就是说安装前做了比对操作!
实践也证明了上面的一个情况,一是noreplace会比对不一样给生成新的.rpmnew,卸载RPM包时会将原来没覆盖的文件给挪为.rpmsave,如果相同则直接覆盖,不做前面这些操作。
#rpm -ihv blockips-1.0.0-220622153009.el7.x86_64.rpm
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:blockips-1.0.0-220622153009.el7 ################################# [100%]
警告:/usr/local/nginx/conf/blockips.conf 已建立为 /usr/local/nginx/conf/blockips.conf.rpmnew
警告:/usr/local/nginx/conf/vhosts/blockipsvc.conf 已建立为 /usr/local/nginx/conf/vhosts/blockipsvc.conf.rpmnew
rpm -e blockips
警告:/usr/local/nginx/conf/vhosts/blockipsvc.conf 已另存为 /usr/local/nginx/conf/vhosts/blockipsvc.conf.rpmsave
警告:/usr/local/nginx/conf/blockips.conf 已另存为 /usr/local/nginx/conf/blockips.conf.rpmsave
ls -1 /usr/local/nginx/conf/blockips.conf.rpm*
/usr/local/nginx/conf/blockips.conf.rpmnew #rpm包安装时发现同名配置,给安装包里的重新命名为.rpmnew
/usr/local/nginx/conf/blockips.conf.rpmsave #卸载rpm包前因文件名内容不一样没有被覆盖的文件给重新命令为.rpmsave
ls -1 /usr/local/nginx/conf/vhosts/blockipsvc.conf.rpm*
/usr/local/nginx/conf/vhosts/blockipsvc.conf.rpmnew
/usr/local/nginx/conf/vhosts/blockipsvc.conf.rpmsave
上面的实践来源:https://jackxiang.com/post/11406/
In addition to the marked directories, the standard Linux documentation directories, such as /usr/share/man, are automatically assumed to be documentation directories.
Similar to the %doc directive, the %config directive marks a file as configuration. For example:
%files
/sbin/ypbind
%config /etc/rc.d/init.d/*
%config /etc/yp.conf
%doc README NEWS
A special option to the %config directive, noreplace, tells RPM not to overwrite, or replace a configuration file. For example:
%files
/sbin/ypbind
%config /etc/rc.d/init.d/*
%config(noreplace) /etc/yp.conf
%doc README NEWS
Use this option to help protect local modifications. If you use %config(noreplace), the file will not overwrite an existing file that has been modified. If the file has not been modified on disk, the rpm command will overwrite the file. But, if the file has been modified on disk, the rpm command will copy the new file with an extra file-name extension of .rpmnew.
Similarly, %config(missingok) means that the file does not have to exist on disk. You can use this modifier for files or links that are created during the %post scripts but will need to be removed if the package is removed.
Another special modifier, %ghost, tells the rpm command that the file should not be included in the package. You can use this to name the needed attributes for a file that the program, when installed, will create. For example, you may want to ensure that a program’s log file has certain attributes.
From:https://docs.fedoraproject.org/ro/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch09s05s03.html
强制删除所有rpm包:
rpm -qa|awk '{print "rpm -e " $0 " --allmatches --nodeps"}'|sh
RPM包常用参数 (备忘用)
1.安装一个包
# rpm -ivh
2.升级一个包
# rpm -Uvh
3.移走一个包
# rpm -e
4.安装参数
--force 即使覆盖属于其它包的文件也强迫安装
--nodeps 如果该RPM包的安装依赖其它包,即使其它包没装,也强迫安装。
5.查询一个包是否被安装
# rpm -q < rpm package name>
6.得到被安装的包的信息
# rpm -qi < rpm package name>

放着备查
* –b 当file存在并且是块文件时返回真
* -c 当file存在并且是字符文件时返回真
* -d 当pathname存在并且是一个目录时返回真
* -e 当pathname指定的文件或目录存在时返回真
* -f 当file存在并且是正规文件时返回真
* -g 当由pathname指定的文件或目录存在并且设置了SGID位时返回为真
* -h 当file存在并且是符号链接文件时返回真,该选项在一些老系统上无效
* -k 当由pathname指定的文件或目录存在并且设置了“粘滞”位时返回真
* -p 当file存在并且是命令管道时返回为真
* -r 当由pathname指定的文件或目录存在并且可读时返回为真
* -s 当file存在文件大小大于0时返回真
* -u 当由pathname指定的文件或目录存在并且设置了SUID位时返回真
* -w 当由pathname指定的文件或目录存在并且可执行时返回真。一个目录为了它的内容被访问必然是可执行的。
* -o 当由pathname指定的文件或目录存在并且被子当前进程的有效用户ID所指定的用户拥有时返回真。
UNIX Shell 里面比较字符写法:
* -eq 等于
* -ne 不等于
* -gt 大于
* -lt 小于
* -le 小于等于
* -ge 大于等于
* -z 空串
* = 两个字符相等
* != 两个字符不等
* -n 非空串
* –b 当file存在并且是块文件时返回真
* -c 当file存在并且是字符文件时返回真
* -d 当pathname存在并且是一个目录时返回真
* -e 当pathname指定的文件或目录存在时返回真
* -f 当file存在并且是正规文件时返回真
* -g 当由pathname指定的文件或目录存在并且设置了SGID位时返回为真
* -h 当file存在并且是符号链接文件时返回真,该选项在一些老系统上无效
* -k 当由pathname指定的文件或目录存在并且设置了“粘滞”位时返回真
* -p 当file存在并且是命令管道时返回为真
* -r 当由pathname指定的文件或目录存在并且可读时返回为真
* -s 当file存在文件大小大于0时返回真
* -u 当由pathname指定的文件或目录存在并且设置了SUID位时返回真
* -w 当由pathname指定的文件或目录存在并且可执行时返回真。一个目录为了它的内容被访问必然是可执行的。
* -o 当由pathname指定的文件或目录存在并且被子当前进程的有效用户ID所指定的用户拥有时返回真。
UNIX Shell 里面比较字符写法:
* -eq 等于
* -ne 不等于
* -gt 大于
* -lt 小于
* -le 小于等于
* -ge 大于等于
* -z 空串
* = 两个字符相等
* != 两个字符不等
* -n 非空串
<?php
function change($num)
{
$num_zero_result=2;
if($num==1)
return 1;
if($num==2)
return 2;
for($i=1;$i<$num-1;$i++)
{
$num_zero_result=$num_zero_result*2;
}
return $num_zero_result;
}
echo change(1);
echo change(2);
echo change(3);
echo change(4);
echo change(5);
echo change(6);
echo change(7);
echo change(8);
echo change(9);
?>
function change($num)
{
$num_zero_result=2;
if($num==1)
return 1;
if($num==2)
return 2;
for($i=1;$i<$num-1;$i++)
{
$num_zero_result=$num_zero_result*2;
}
return $num_zero_result;
}
echo change(1);
echo change(2);
echo change(3);
echo change(4);
echo change(5);
echo change(6);
echo change(7);
echo change(8);
echo change(9);
?>
写了个api,被人调用,coresearch_get_del2.php?type=deluser&uid=1456736567 发现有人用如下方式调用:
coresearch_get_del2.php?type=deluser&uid=
为空,于是本人用isset来判断失败了,最后修改为:
if(!strlen(trim($uid)))
{
echo "trim space has no number";
exit(0);
}
最好修改为:
if(empty($uid))
{
echo "trim space find has no number,is empty?";
exit(0);
}
看看区别url:
http://www.g168.net/html/PHP_006/2007/1216/20076531760459.html
Empty函数:
一)无论是Null还是真的是空:'' 用empty都能正确判断返回1值:
---------- 调试PHP ----------
11
输出完成 (耗时 0 秒) - 正常终止
二)对连接Memcache里没有值的情况其返回为false值,用empty也能判断:
---------- 调试PHP ----------
Get key1 value: This is first value
bool(false)
bool(true)
输出完成 (耗时 0 秒) - 正常终止
总之,empty函数对真的空,Null,及bool的false都能判断正确。
网上:empty:
如果 变量 是非空或非零的值,则 empty() 返回 FALSE。换句话说,""、0、"0"、NULL、FALSE、array()、var $var、未定义; 以及没有任何属性的对象都将被认为是空的,如果 var 为空,则返回 TRUE。
来自:http://www.cnblogs.com/chengmo/archive/2010/10/18/1854258.html
coresearch_get_del2.php?type=deluser&uid=
为空,于是本人用isset来判断失败了,最后修改为:
if(!strlen(trim($uid)))
{
echo "trim space has no number";
exit(0);
}
最好修改为:
if(empty($uid))
{
echo "trim space find has no number,is empty?";
exit(0);
}
看看区别url:
http://www.g168.net/html/PHP_006/2007/1216/20076531760459.html
Empty函数:
一)无论是Null还是真的是空:'' 用empty都能正确判断返回1值:
---------- 调试PHP ----------
11
输出完成 (耗时 0 秒) - 正常终止
二)对连接Memcache里没有值的情况其返回为false值,用empty也能判断:
---------- 调试PHP ----------
Get key1 value: This is first value
bool(false)
bool(true)
输出完成 (耗时 0 秒) - 正常终止
总之,empty函数对真的空,Null,及bool的false都能判断正确。
网上:empty:
如果 变量 是非空或非零的值,则 empty() 返回 FALSE。换句话说,""、0、"0"、NULL、FALSE、array()、var $var、未定义; 以及没有任何属性的对象都将被认为是空的,如果 var 为空,则返回 TRUE。
来自:http://www.cnblogs.com/chengmo/archive/2010/10/18/1854258.html