2009年12月23日 星期三

XSL 中 checkbox 如何設定 checked

設定方式如下:
<input type="checkbox" name="test" value="checked" checked="y"/>

XSL 中的空白字元

XSL 中使用 &nbsp; 新增空白字元會出現錯誤,可以改用 &#160; 取代。

XSL 中使用一組不固定資料來判斷另一組資料的輸出值

XML 如下
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="key_sample.xsl" ?>
</document>
<test id="1" name="a">
<test id="2" name="b">
<test id="3" name="c">
<test id="4" name="d">

<data>
<item>
<id>1</id>
<value>value1</value>
<testid>1</testid>
</item>
<item>
<id>2</id>
<value>value2</value>
<testid>1</testid>
</item>
<item>
<id>3</id>
<value>value3</value>
<testid>3</testid>
</item>
<item>
<id>4</id>
<value>value4</value>
<testid>2</testid>
</item>
</data>
</document>


XSL 如下
<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:key name="test-search" match="test" use="@id"/>
<xsl:template match="document">
<HTML>
<BODY>
<xsl:for-each select="data/item">
<div>
id=<xsl:value-of select="id" />
value=<xsl:value-of select="value" />
<xsl:for-each select="key('test-search', testid)">
test name=<xsl:value-of select="@name"/>
</xsl:for-each>
</div>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>

輸出結果如下
id=1 value=value1 test name=a
id=2 value=value2 test name=a
id=3 value=value3 test name=c
id=4 value=value4 test name=b

2009年12月18日 星期五

PHP 時間週相關函式

// 傳回指定年份有多少週
function year_week_num($year){
$days = (checkdate(2, 29, $year) ? 366 : 365) + date("w", mktime(0,0,0,1,1 ,$year));
$mod = $days % 7;
return ($days-$mod) / 7 + ($mod>0 ? 1 : 0);
}

// 傳回指定年份第幾週開始及結束的日期
function year_week($year, $weekno){
if($year<1972) t =" (6-date(" t1 = "$year-01-01" t2 =" date("> year_week_num($year)) $weekno = year_week_num($year);

$t = (($weekno-2)*7 + (7-date("w", mktime(0,0,0,1,1, $year)))) * 86400;

$t1 = date("Y-m-d", mktime(0,0,0,1,1, $year) + $t);
$t2 = date("Y-m-d", mktime(0,0,0,1,1, $year) + $t+86400*6);
return array($t1, $t2);
}

2009年11月25日 星期三

CISCO WS-C3560 IP Source Guard 設定摘要

1.建立 IP Source Guard 使用埠的巨集
建立巨集指令為 switch(config)#macro name macro-name
內容如下:
# macro:oa-clinet
# connect oa network's PC
switchport mode access

# Enable port security limiting port to a single
# MAC address -- that of desktop
switchport port-security
switchport port-security maximum 5

# Ensure port-security age is greater than one minute
# and use inactivity timer
switchport port-security violation restrict
switchport port-security aging time 2
switchport port-security aging type inactivity

# ip source guard
# 確認該介面下MAC所對應的IP位置,是由DHCP所配發,防止用戶隨意更改IP位置
ip verify source port-security

2.建立連接DHCP 伺服器使用埠的巨集
建立巨集指令為 switch(config)#macro name macro-name
內容如下:
# macro:oa-switch
# connect backbone switch
ip arp inspection trust
ip arp inspection limit rate 500 burst interval 3
ip dhcp snooping limit rate 500 // 防止DHCP DOS攻擊,限制Switch轉送DHCP request的速率
ip dhcp snooping trust

3.整體的設定如下:
switch(config)#ip dhcp snooping vlan 1
switch(config)#ip dhcp snooping
switch(config)#ip arp inspection validate src-mac dst-mac
switch(config)#errdisable recovery cause arp-inspection
switch(config)#errdisable recovery interval 3600

4.將交換器上各埠分別套用 1,2 所建立的巨集
switch(config-if)#macro apply macro-name

其他
取消 oa-clinet 巨集的巨集
內容如下
# macro:no-oa-clinet
# remove macro oa-client
# Enable port security limiting port to a single
# MAC address -- that of desktop
no switchport port-security maximum 5

# Ensure port-security age is greater than one minute
# and use inactivity timer
no switchport port-security violation restrict
no switchport port-security aging time 2
no switchport port-security aging type inactivity
no switchport port-security
no switchport mode access
# ip source guard
no ip verify source port-security
no macro description

取消 oa-switch 巨集的巨集
內容如下
# macro:no-oa-switch
# disable oa-switch macro
no ip arp inspection trust
no ip arp inspection limit rate 500 burst interval 3
no ip dhcp snooping limit rate 500
no ip dhcp snooping trust


相關的查詢指令:
show ip dhcp snooping
show ip dhcp snooping binding
show cdp neighbors
show arp-list
show ip arp inspection interfaces
show port-security

CISCO WS-C3560G 忘記密碼,恢復預設值方法

以下方法會失去所有的設定內容
1.拔去電源重新開機。
2.開機完成後,長按前方面板 mode,燈號會開始閃爍,進入重置,自動重新開機。
3.完成開機後即恢復預設。

CISCO WS-C3560G 交換器 NTP 校時設定


1.設定 log 及 debug 訊息的時間戳記
service timestamps debug datetime localtime
service timestamps log datetime localtime

2.設定時區為台灣時區
clock timezone TW +8

3.設定NTP來源的介面來源為 vlan 1
ntp vlan 1

4.指定NTP Server位址,可設定多部伺服器
ntp server 220.130.158.52


顯示 NTP 狀態指令
show ntp status
show ntp associations


其他相關指令
ntp peer // 設定內部NTP設備的IP位址
clock set // 設定時間
show clock // 檢視目前時間


參考資料
http://www.cisco.com/en/US/docs/ios/12_0/configfun/configuration/guide/fcgenral.html#wp4036