从做一个发变更通知的模块中学到的

1. 了解了使用程序创建jira提案的方法
2. jQuery中查找表单中所有可以提交的元素(input select checkbox textarea)的方法: $("#formid").find(":input")
3.  有如下svn命令:
    svn log –limit 1 –username xxx –password xxx https://xxx.xx.xx/xxxx

由于该svn没有购买https证书,而且自制的证书的domain都不匹配,于是就会出现提示信息如下:

如果使用(p)选择永远接受,则下次不再有该提示信息,因为他可以将你的输入信息保存的你的家目录下的文件中;但是不行的是,该命令需要通过webserver执行,而执行web的用户是nologin的,没地方保存该信息,于是这里可以通过(t)暂时接受的方式来解决该问题,PHP脚本如下:

 
  1. <?php
  2. $cmd = "echo t|/usr/bin/svn log -v –limit 1 –username {$username} –password {$password} {$svn} 2>/dev/null";
  3. $fp = popen($cmd"r");
  4. while(!feof($fp)) {
  5.         $line .= fgets($fp);
  6. }
  7. echo $line

注意:这里的错误重定向也是不能忽视的。

php 编译的一点问题

首先,我编译PHP时使用如下命令:
./configure –prefix=/usr/local/php-5.3.3 && make

完成之后,发现默认的php.ini 为: /usr/local/php-5.3.3/lib/php.ini ; 于是我改变了注意,想修改prefix为 /usr/local , 如果不执行make clean的话,则
./configure –prefix=/usr/local && make

发现默认的php.ini 仍为: /usr/local/php-5.3.3/lib/php.ini

看来必须make clean了, 似乎configure之后生成的头文件: ./main/build-defs.h 是不被依赖的

ssl 协议之 Cipher Suite

通过wireshark抓包分析ssl协议,其中,发现client提供给server的可选的sipher suites如下:

定义: openssl\ssl\ssl.h

相关参考:
http://msdn.microsoft.com/en-us/library/aa380513%28v=vs.85%29.aspx
http://www.ietf.org/rfc/rfc2246.txt
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzas.doc/sy10700_.htm

http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzas.doc/sy10700_.htm

http://lamp.linux.gov.cn/Apache/ApacheMenu/mod/mod_ssl.htmlhttp://seaknight.bokee.com/6897206.html

PHP 文件包含分析

测试脚本a.php:

  1. <?php
  2. include_once("b.php");
  3. echo "=====\n";
  4. include_once("b.php");
  5. echo "=====\n";
  6. include_once("c.php");

目录结构:
a.php
b.php

include_path 的 = .;/usr/local/lib/php

strace -e file php a.php
——————————
open("a.php", O_RDONLY)                 = 3     // 打开a.php
getcwd("/usr/home/junjie2", 4096)       = 18
lstat64("/usr/home/junjie2/a.php", {st_mode=S_IFREG|0644, st_size=108, …}) = 0
lstat64("/usr/home/junjie2", {st_mode=S_IFDIR|0777, st_size=36864, …}) = 0
lstat64("/usr/home", {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
lstat64("/usr", {st_mode=S_IFDIR|0755, st_size=4096, …}) = 0
getcwd("/usr/home/junjie2", 4096)       = 18     // get current working directory (这个就是include_path 中的 "." )
lstat64("/usr/home/junjie2/./b.php", {st_mode=S_IFREG|0644, st_size=7, …}) = 0   // 找见了
lstat64("/usr/home/junjie2/b.php", {st_mode=S_IFREG|0644, st_size=7, …}) = 0
open("/usr/home/junjie2/b.php", O_RDONLY) = 3
=====
getcwd("/usr/home/junjie2", 4096)       = 18  // 这次包含没有真实的文件操作,因为包含过了的文件PHP自己都知道,可以使用get_included_files()来查看,所以就不需要再lstats和open了
=====
getcwd("/usr/home/junjie2", 4096)       = 18      // get current working directory (这个就是include_path 中的 "." )
lstat64("/usr/home/junjie2/./c.php", 0xbf904350) = -1 ENOENT (No such file or directory)  // 没找见
lstat64("/usr/local/lib/php/c.php", 0xbf904350) = -1 ENOENT (No such file or directory)     // 去include_path 中的 "/usr/local/lib/php" 下面找还没找见
lstat64("/usr/home/junjie2/c.php", 0xbf904350) = -1 ENOENT (No such file or directory)    // 去脚本所在的目录下面找此次查找和include_path 无关
getcwd("/usr/home/junjie2", 4096)       = 18  // 这里又查一次,why?
lstat64("/usr/home/junjie2/./c.php", 0xbf9042a0) = -1 ENOENT (No such file or directory)
lstat64("/usr/local/lib/php/c.php", 0xbf9042a0) = -1 ENOENT (No such file or directory)
lstat64("/usr/home/junjie2/c.php", 0xbf9042a0) = -1 ENOENT (No such file or directory)
getcwd("/usr/home/junjie2", 4096)       = 18
lstat64("/usr/home/junjie2/c.php", 0xbf906390) = -1 ENOENT (No such file or directory) // 这次查找可能是报错的时候查的
open("/usr/home/junjie2/c.php", O_RDONLY) = -1 ENOENT (No such file or directory)

结论:
1. 先查找 include_path 设置的目录; 其中的 "." 代表的不是脚本所在目录,而是脚本运行时的cwd(当前工作目录),这个目录是可以通过chdir修改的
2. 如果include_path 中查不到,则再查找脚本所在目录,这个和是否设置了include_path 无关
3. ini_set("include_path", ""); 第二个参数不能为空,为空的话就没有任何作用

PHP中的foreach和list、each

关于PHP的一个小题目:

 
  1. <?php
  2. $arr = array(1,2,3);
  3. foreach($arr as $num) { 
  4.     if ($num == 2) $arr[] = 4;
  5.     echo $num;
  6. }

输出结果: 1234 还是 123 ?
答案: 123

如果才能达到 1234 的效果呢?

使用list、each, 代码如下:

 
  1. <?php
  2. $arr = array(1,0,null,2,3);
  3. while(list($key$num) = each($arr)) {
  4.     if ($num == 2) $arr[] = 4;
  5.     echo $num;
  6. }

  7.     

关于sar的一个问题: Invalid system activity file

问题:
# sar -q
Invalid system activity file: /var/log/sa/sa04 (0x5)

分析过程:
1. google之: 得到如下信息:

来自: http://sebastien.godard.pagesperso-orange.fr/faq.html

2. 怀疑是生成sa数据文件的sar和解析sa数据文件的sar命令的版本不同
# which sar
/usr/local/bin/sar     # 这个是我读取sa数据文件的命令,版本号 8.0.0
# sar -V
sysstat version 8.0.0
(C) Sebastien Godard (sysstat <at> orange.fr)

3. 如何知道生成sa数据文件使用的是那个版本的sar呢?
一般这些文件都是写在cron里面的,所以grep一下cron的配置文件:(注意: grep sa 不是grep sar)
# grep sa -r /etc/cron*     
/etc/cron.d/sysstat:*/10 * * * * root /usr/lib/sa/sa1 1 1
/etc/cron.d/sysstat:53 23 * * * root /usr/lib/sa/sa2 -A

# /usr/lib/sa/sa1 -V
sysstat version 7.0.2
(C) Sebastien Godard

4. 为什么会出现这种情况呢?
7.0.2 版本的sar是在 /usr/bin/ 目录下的, 而我的执行环境中的$PATH 变量如下:
# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin

先找到了 /usr/local/bin 下的sar了

解决办法: (写sar的全路径呗)
#/usr/bin/sar -q