<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Ginew.Z 的博客

    一切,為了讓生活更簡(jiǎn)單、更自然

      BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
      21 Posts :: 0 Stories :: 14 Comments :: 0 Trackbacks

    2006年11月17日 #

    href="#" vs. href="javascript:void(0)"

    開(kāi)發(fā)的時(shí)候有時(shí)需要用link(<a>)來(lái)觸發(fā)一些javascript事件,所以常常可以看到如下的代碼:

    <a href="javascript:void(0)" onclick="doSomething();returnfalse;">Link</a>

    這是一個(gè)曾經(jīng)被多次討論過(guò)的問(wèn)題,長(zhǎng)期以來(lái),我也一直是這樣寫(xiě)的。讀了 >>a href=”javascript:void(0);” — avoid the void 之后,我認(rèn)同了作者的意見(jiàn)。下面的寫(xiě)法確實(shí)更合理:

    <a href="#" onclick="doSomething();returnfalse;">Link</a>

    或者

    <script type="javascript">
    function doSomething() {
      //doSomething
      returnfalse;
    }
    </script>
    <a href="#" onclick="return doSomething();">Link</a>

    以往大家不使用"#"的問(wèn)題是,這將導(dǎo)致點(diǎn)擊鏈接時(shí)頁(yè)面跳回頁(yè)面頂部,但通過(guò) return false 語(yǔ)句將使得瀏覽器忽略鏈接的默認(rèn)動(dòng)作,從而避免了此問(wèn)題。

    youngpup 更有意思,他在>>How to Create Pop-Up Windows 中言辭激烈的倡導(dǎo)大家永遠(yuǎn)永遠(yuǎn)永遠(yuǎn)不要使用 javascript: 偽協(xié)議:

    Never, ever, ever use the javascript: pseudo-protocol for anything, ever ever ever ever again. Please. Pretty please.

    他的解決方案是:

    <a 
      href="http://google.com/" 
      onclick="window.open(this.href, 'popupwindow', 
      'width=400,height=300,scrollbars,resizable'); 
      returnfalse;">

    這樣的好處就是可以保存到書(shū)簽或者收藏夾,可以左鍵單擊,也可以右鍵使用!

    posted @ 2006-11-17 12:15 無(wú)風(fēng)之雨 閱讀(1107) | 評(píng)論 (2)編輯 收藏

    2006年6月9日 #

    ???? 我們打算為用戶(hù)架設(shè)單獨(dú)的虛擬主機(jī)服務(wù)器,可以讓企業(yè)自主上傳jsp、htm、php等程序。其中resin用來(lái)做jsp的容器。
    ???? 由于是用戶(hù)自主通過(guò)FTP上傳程序,我們必須控制這些程序可以執(zhí)行的權(quán)限,不能讓用戶(hù)隨便瀏覽硬盤(pán)上的文件,但又要能讓resin可以正常運(yùn)行。比如:/data/user_a目錄中的程序,只能在/data/user_a目錄及其子目錄中讀寫(xiě),如果想要訪(fǎng)問(wèn)其他目錄,就沒(méi)有權(quán)限。
    ???? 通過(guò)研究resin的文檔以及JAVA的機(jī)制,我認(rèn)為要實(shí)現(xiàn)以上構(gòu)想,可以通過(guò)使用java權(quán)限管理器來(lái)構(gòu)建一個(gè)resin的沙箱來(lái)對(duì)java的具體操作進(jìn)行授權(quán)。
    參考文檔:http://www.caucho.com/resin-3.0/security/securitymanager.xtphttp://www.jscud.com/srun/news/viewhtml/3_2005_10/148.htm

    ???? 當(dāng)我認(rèn)為勝利在望的時(shí)候,發(fā)現(xiàn)resin好像不支持grant codeBase "file:xxxx 。

    grant codeBase "file:/data/ftpdata/user01.test.com/-" {
    ?permission java.io.FilePermission "/data/ftpdata/user01.test.com/-", "read,write,delete";
    };
    ???? 上面的語(yǔ)句,語(yǔ)法上沒(méi)有問(wèn)題,但就是不起作用。那個(gè)codebase目錄下的文件,對(duì)本目錄沒(méi)有任何權(quán)限。

    ??????? resin的官方論壇里面,有人在2001年,針對(duì)resin1.2.5就提出了和我一摸一樣的疑問(wèn)(http://www.caucho.com/support/resin-interest/0105/0106.html),作者發(fā)現(xiàn)問(wèn)題是由于resin的classloader是非安全的,因此改了resin原文件后解決了問(wèn)題(http://www.caucho.com/support/resin-interest/0105/0112.html),但是我看resin3的源代碼,里面已經(jīng)基于java.security.SecureClassLoader,因此應(yīng)該不是這個(gè)原因了。
    ???? 以下是我的resin.policy文件:

    grant codeBase "file:${java.home}/lib/-" {
    ?permission java.security.AllPermission;
    };

    grant codeBase "file:${java.home}/jre/lib/-" {
    ?permission java.security.AllPermission;
    };

    grant codeBase "file:${resin.home}/lib/-" {
    ?permission java.security.AllPermission;
    };

    grant {
    ?permission java.util.PropertyPermission "*", "read";
    ?permission java.io.SerializablePermission "enableSubstitution";
    ?permission java.lang.reflect.ReflectPermission "suppressAccessChecks";?
    ?permission java.lang.RuntimePermission "accessClassInPackage.*";
    ?permission java.lang.RuntimePermission "getClassLoader";
    ?permission java.lang.RuntimePermission "accessDeclaredMembers";
    ?permission java.lang.RuntimePermission "modifyThreadGroup";
    ?permission java.lang.RuntimePermission "setContextClassLoader";
    ?permission java.lang.RuntimePermission "setIO";
    ?permission java.lang.RuntimePermission "stopThread";
    ?permission java.lang.RuntimePermission "createClassLoader";
    ?permission java.lang.RuntimePermission "getProtectionDomain";
    ?permission java.lang.RuntimePermission "defineClassInPackage";
    ?permission java.security.SecurityPermission "putProviderProperty.SunJCE";
    ?permission java.security.SecurityPermission "insertProvider.SunJCE";
    ?permission java.util.logging.LoggingPermission "control";
    ?permission java.lang.RuntimePermission "getAttribute";
    ?permission java.util.PropertyPermission "jaxp.debug", "read";
    ?permission ognl.OgnlInvokePermission "invoke.*";
    ?permission java.net.SocketPermission "localhost:3306","connect";
    ?permission java.io.FilePermission "${resin.home}/-", "read";
    ?permission java.io.FilePermission "${java.home}/-", "read";
    ?permission java.io.FilePermission "/tmp/-","read,write,delete";
    ?permission java.io.FilePermission "/tmp","read,write,delete";
    ?permission java.io.FilePermission ".","read";
    ?permission java.io.FilePermission "/home/apps/java/jdk/lib/tools.jar","read";
    ?permission java.io.FilePermission "/bin/sh", "read,execute";
    };

    //以下語(yǔ)句沒(méi)有任何作用,/data/ftpdata/user01.test.com/下的jsp對(duì)這個(gè)目錄沒(méi)有讀的權(quán)限
    grant codeBase "file:/data/ftpdata/user01.test.com/-" {
    ?permission java.io.FilePermission "/data/ftpdata/user01.test.com/-", "read,write,delete";
    };

    posted @ 2006-06-09 11:00 無(wú)風(fēng)之雨 閱讀(694) | 評(píng)論 (2)編輯 收藏

    2006年5月16日 #

    要了解GPL,一般地,您沒(méi)有必要耐心閱讀原版的GPL協(xié)議,因?yàn)?GPL 無(wú)非交待了幾個(gè)原則:

    • 確保軟件自始至終都以開(kāi)放源代碼形式發(fā)布,保護(hù)開(kāi)發(fā)成果不被竊取用作商業(yè)發(fā)售。任何一套軟件,只要其中使用了受 GPL 協(xié)議保護(hù)的第三方軟件的源程序,并向非開(kāi)發(fā)人員發(fā)布時(shí),軟件本身也就自動(dòng)成為受 GPL 保護(hù)并且約束的實(shí)體。也就是說(shuō),此時(shí)它必須開(kāi)放源代碼。

    • GPL 大致就是一個(gè)左側(cè)版權(quán)(Copyleft,或譯為“反版權(quán)”、“版權(quán)屬左”、“版權(quán)所無(wú)”、“版責(zé)”等)的體現(xiàn)。你可以去掉所有原作的版權(quán) 信息,只要你保持開(kāi)源,并且隨源代碼、二進(jìn)制版附上 GPL 的許可證就行,讓后人可以很明確地得知此軟件的授權(quán)信息。GPL 精髓就是,只要使軟件在完整開(kāi)源 的情況下,盡可能使使用者得到自由發(fā)揮的空間,使軟件得到更快更好的發(fā)展。

    • 無(wú)論軟件以何種形式發(fā)布,都必須同時(shí)附上源代碼。例如在 Web 上提供下載,就必須在二進(jìn)制版本(如果有的話(huà))下載的同一個(gè)頁(yè)面,清楚地提供源代碼下載的鏈接。如果以光盤(pán)形式發(fā)布,就必須同時(shí)附上源文件的光盤(pán)。

    • 開(kāi)發(fā)或維護(hù)遵循 GPL 協(xié)議開(kāi)發(fā)的軟件的公司或個(gè)人,可以對(duì)使用者收取一定的服務(wù)費(fèi)用。但還是一句老話(huà)——必須無(wú)償提供軟件的完整源代碼,不得將源代碼與服務(wù)做捆綁或任何變相捆綁銷(xiāo)售。
    posted @ 2006-05-16 16:50 無(wú)風(fēng)之雨 閱讀(688) | 評(píng)論 (0)編輯 收藏

    2006年5月14日 #

    ?

    posted @ 2006-05-14 11:28 無(wú)風(fēng)之雨 閱讀(285) | 評(píng)論 (0)編輯 收藏

    2006年4月19日 #

    ??????? 今天新頁(yè)面上線(xiàn),很多同事報(bào)告說(shuō)頁(yè)面打開(kāi)到一半,經(jīng)常跳出無(wú)法打開(kāi)Internet站點(diǎn)的錯(cuò)誤,然后頁(yè)面會(huì)跳轉(zhuǎn)到DNS錯(cuò)誤的頁(yè)面。

    ????? notload.jpg
    ????????
    ??????? 這個(gè)問(wèn)題我以前遇到過(guò),一直沒(méi)有詳細(xì)的去深究原因,只是以為是服務(wù)器關(guān)閉連接太快的原因。今天發(fā)現(xiàn)這個(gè)問(wèn)題出的很頻繁,服務(wù)器方面沒(méi)有改什么,只是上傳了新的頁(yè)面程序而已,應(yīng)該不會(huì)和服務(wù)器有關(guān)。在對(duì)頁(yè)面進(jìn)行分析,并搜索了一下網(wǎng)上,發(fā)現(xiàn)原來(lái)是js在document還沒(méi)完全load完的時(shí)候就試圖改變其值導(dǎo)致。

    ??????? 因此對(duì)js做如下改變:

    原js:

    ???? window.settimeout("go()",500);
    ???? function go(){
    ??? .......
    ???? }

    改成:

    var go_i=window.setInterval("go()",500);
    function go(){
    ???if(document.readyState=="complete"){
    ????? window.clearInterval(go2_i);
    ??? }
    ????else return;
    ??? ........
    }
    目的就是讓他一定要在document完成后才執(zhí)行那個(gè)操作
    posted @ 2006-04-19 18:14 無(wú)風(fēng)之雨 閱讀(6925) | 評(píng)論 (6)編輯 收藏

    2006年4月13日 #

    以前如果要使iframe里面的腳本能訪(fǎng)問(wèn)parent的內(nèi)容,但iframe和parent的二級(jí)域名相同,那一般都會(huì)在兩者都寫(xiě)上document.domain="xxx.com" 以放寬訪(fǎng)問(wèn)權(quán)限。

    今天發(fā)現(xiàn),如果iframe和parent在同一個(gè)三級(jí)域名下,比如都是aa.bb.com,那設(shè)了document.domain反而會(huì)造成訪(fǎng)問(wèn)拒絕。

    查了下MSDN,有如下解釋?zhuān)?br />

    Remarks

    The property initially returns the host name of the server from which the page is served. The property can be assigned the domain suffix to allow sharing of pages across frames. For example, a page in one frame from home.microsoft.com and a page from www.microsoft.com initially would not be able to communicate with each other. However, by setting the domain property of both pages to the suffix "microsoft.com", you ensure that both pages are considered secure and access is available between the pages.

    When you set the domain property, use the domain name determined by the server rather than by the client browser.

    All the pages on different hosts must have the domain property explicitly set to the same value to communicate successfully with each other. For example, the value of the domain property of a page on the host microsoft.com would be "microsoft.com" by default. It might seem logical that if you set the domain property of a page on another host named msdn.microsoft.com to "microsoft.com," that the two pages could communicate with each other. However, this is not the case unless you have also explicitly set the domain property of the page on microsoft.com to "microsoft.com".

    Furthermore, this property cannot be used to allow cross-frame communication among frames with different domain suffixes. For example, a page in one frame from www.microsoft.com and a page in another frame from www.msn.com would not be able to communicate with each other even if the domain property of both pages was set to the suffix "microsoft.com".

    security note Security Alert??Using this property incorrectly can compromise the security of your Web site. Set the domain property only if you must allow cross-domain scripting. Use a value determined on the server. Setting this property to a value determined on the client (like through the location object) could expose your site to attack from another site through Domain Name System (DNS) manipulation. For more information, see Security Considerations: Dynamic HTML.

    For more information on domain security, see About Cross-Frame Scripting and Security.

    posted @ 2006-04-13 11:54 無(wú)風(fēng)之雨 閱讀(9361) | 評(píng)論 (3)編輯 收藏

    2006年4月11日 #

    今天發(fā)現(xiàn),在IE里面,當(dāng)一個(gè)域名包含_的時(shí)候,IE不會(huì)給這個(gè)網(wǎng)站發(fā)送COOKIE,真變態(tài)。同事調(diào)試了半天,才發(fā)現(xiàn)還有這個(gè)問(wèn)題
    posted @ 2006-04-11 17:54 無(wú)風(fēng)之雨 閱讀(278) | 評(píng)論 (0)編輯 收藏

    ??? 要備份MYSQL,很多人用mysqldump,其實(shí)這種方式,導(dǎo)出的文件是最大的,導(dǎo)入的時(shí)間是最久的。命令是方便的,但真正發(fā)生錯(cuò)誤的時(shí)候,恢復(fù)效率很低。
    ??? 我主張,另外找一臺(tái)比較空閑的機(jī)器,來(lái)做數(shù)據(jù)庫(kù)的備份。這臺(tái)機(jī)器作以下用途:

    ?? 它是主數(shù)據(jù)庫(kù)帶的slave數(shù)據(jù)庫(kù)群里面的一臺(tái),每天凌晨定時(shí)啟動(dòng)同步數(shù)據(jù),等追上bin-log并全部執(zhí)行后,停止同步,并用select * into outfile將數(shù)據(jù)全部導(dǎo)出成文件,并且在每周的某一天,清除掉主數(shù)據(jù)庫(kù)上已經(jīng)同步好的bin-log,以確保硬盤(pán)空間不被log占滿(mǎn)。

    ?? 為此,我寫(xiě)了3個(gè)腳本,分別執(zhí)行1、啟動(dòng)mysql,追log,然后停止slave;2、導(dǎo)出全部數(shù)據(jù)庫(kù)全部文件到文件;3、刪除主數(shù)據(jù)庫(kù)的log

    ---------------------------------------------------------------------------------------
    #!/bin/bash
    #readMasterMysql.sh
    CHECK_MYSQL=0
    /home/mysql/bin/mysqld_safe &
    until [ "$CHECK_MYSQL" = "1" ]
    do
    ? sleep 10
    ? CHECK_MYSQL=`/home/mysql/bin/mysql -uroot -e"show slave status"|awk '{if($14==$21)print "1"}'|tail -n1`
    done
    /home/mysql/bin/mysql -uroot -e"slave stop"
    /home/script/backupMysql.sh
    /home/mysql/bin/mysqladmin shutdown
    WEEK=`date "+%w"`
    if [ $WEEK = "5" ]
    then
    ??? /home/script/purgeLog.sh
    fi

    ------------------------------------------------------------------------------
    #!/bin/bash
    #purgeLog.sh
    LOG_FILE=/home/mysql/data/master.info
    DB_SERVER=`sed -n '4p' $LOG_FILE`
    DB_USER=`sed -n '5p' $LOG_FILE`
    DB_PASS=`sed -n '6p' $LOG_FILE`
    DB_LOGFILE=`sed -n '2p' $LOG_FILE`
    /home/mysql/bin/mysql -h$DB_SERVER -u$DB_USER -p"$DB_PASS" -e"purge master logs to '$DB_LOGFILE'"

    ------------------------------------------------------------------------------
    #!/bin/bash
    #backupMysql.sh
    database=$1
    table=$2
    MYSQL_CLIENT="/home/mysql/bin/mysql -uroot --default-character-set=gbk"
    MYSQL_DUMP="/home/mysql/bin/mysqldump -d -uroot --default-character-set=gbk"
    OUTPUT_PATH=/date/backup
    for databases in `$MYSQL_CLIENT -e "show databases"|grep -v Database`
    do
    if [ "$#" = "0" -o "$database" = "$databases" ] ; then
    ??????? mkdir -p -m777 $OUTPUT_PATH/$databases/
    ??????? $MYSQL_DUMP $databases > $OUTPUT_PATH/$databases/$databases.sql
    ??????? for tables in `$MYSQL_CLIENT -e "show tables" $databases|grep -v Tables_in_`
    ??????? do
    ??????? if [ "$#" = "0" -o "$#" = "1" -o "$table" = "$tables" ] ; then
    ??????????????? mv -f $OUTPUT_PATH/$databases/$tables $OUTPUT_PATH/$databases/$tables.old
    ??????????????? $MYSQL_CLIENT -e "select * into outfile '$OUTPUT_PATH/$databases/$tables' from $tables" $databases
    ??????? fi
    ??????? done
    fi
    done
    posted @ 2006-04-11 12:47 無(wú)風(fēng)之雨 閱讀(668) | 評(píng)論 (0)編輯 收藏

    一般情況下,Referer和User-Agent同時(shí)為空的時(shí)候,可以認(rèn)為是其他網(wǎng)站在批量采集本站數(shù)據(jù),我打算deny掉這種請(qǐng)求。不過(guò)apache文檔里面沒(méi)有提到有兩個(gè)環(huán)境變量的與操作。最后chinaunix上有大俠回答了我的問(wèn)題:

    SetEnv?? log_flag=1
    SetEnvIf Referer !"^$"? log_flag=0
    SetEnvIf user-agent !"^$" log_flag=0
    ...

    看字面上,就是如果用兩個(gè)非的或來(lái)代替與
    這樣,只要兩個(gè)條件有一個(gè)不滿(mǎn)足,就log_flag就會(huì)變掉,只要它變掉了,就說(shuō)明不符合我屏蔽的規(guī)則。
    高手就是高手,為什么非要苛求一定要有“與”呢,兩個(gè)“非”的“或”,不一樣達(dá)到要求?

    學(xué)習(xí)了。
    posted @ 2006-04-11 12:25 無(wú)風(fēng)之雨 閱讀(844) | 評(píng)論 (0)編輯 收藏

    to_date(?, 'YYYY-MM-DD HH24:MI:SS')"
    STR_TO_DATE('2003-15-10 00:00:00','%Y-%m-%d %H:%i:%s');???? //格式不對(duì),會(huì)返回NULL

    to_char(create_time,'yyyy-MM-dd')
    DATE_FORMAT(create_time,'%Y-%m-%d')

    sysdate
    now()或者CURRENT_TIMESTAMP?//'1997-12-15 23:50:26',建表的時(shí)候,timestamp類(lèi)型可以指定default CURRENT_TIMESTAMP

    sysdate - 7?? //7天前
    now()-INTERVAL 7 DAY??

    select * from (select .... where rownum<end) where rownum>start
    limit [start,] length

    substr(productInfor,1,20)
    SUBSTRING('Quadratically',5,6)???? //SUBSTRING(str,pos,len)

    instr(str,substr,pos,index)
    instr(str,substr) 或者 locate(substr,str,pos)
    // 沒(méi)有相對(duì)應(yīng)的語(yǔ)法,但一般情況,這個(gè)是和substr結(jié)合起來(lái)用的。
    //如果是str="2005-10-01"取中間的10這樣的需要,oracle是substr(str,instr(str,'-',1,1)+1,instr(str,'-',1,2)-instr(str,'-',1,1)-1)
    那在mysql里面,可以試試這樣SUBSTRING_INDEX(SUBSTRING_INDEX(str,'-',2),'-',-1),意思就是取第二個(gè)-之前的str后(2005-10),再取倒數(shù)第一個(gè)-之后的內(nèi)容

    oracle的nvl(ss,dd)函數(shù)在mysql中怎么實(shí)現(xiàn)?
    答:ifnull(ss,dd)

    posted @ 2006-04-11 12:16 無(wú)風(fēng)之雨 閱讀(856) | 評(píng)論 (0)編輯 收藏

    主站蜘蛛池模板: 黄+色+性+人免费| yy6080亚洲一级理论| 亚洲精品无码专区久久| 久久亚洲高清综合| 99热这里有免费国产精品| 亚洲综合激情五月丁香六月| 中文字幕日韩亚洲| 国产免费丝袜调教视频| 成年网站免费入口在线观看| 亚洲国产成人久久精品影视| 国产精品无码一区二区三区免费 | a级成人毛片免费图片| 亚洲熟妇av一区| 亚洲精品高清在线| 久久久高清免费视频| 精品久久久久久国产免费了| 亚洲人成免费电影| 亚洲精品无码鲁网中文电影| 最近2019中文免费字幕| 免费毛片在线看不用播放器| 亚洲日韩国产二区无码| 久久久影院亚洲精品| 亚洲成av人片天堂网老年人| 午夜宅男在线永久免费观看网| 两性色午夜免费视频| 亚洲AV电影天堂男人的天堂| 久久精品国产亚洲av影院| 亚洲福利精品电影在线观看| 免费无码A片一区二三区| 久久精品成人免费观看| 免费无码午夜福利片 | 久久亚洲国产成人精品无码区| 免费电视剧在线观看| 无码国产精品一区二区免费式芒果| 国产偷国产偷亚洲高清在线| 亚洲欧洲另类春色校园网站| 亚洲日本在线看片| 亚洲精品无码mv在线观看网站| 亚洲AV成人精品日韩一区18p| 久久精品网站免费观看| 1000部羞羞禁止免费观看视频|