2011年6月30日 星期四

允許後台的排序與前台不同(Order By)

今天要分享的是, 讓資料在後台的排序欄位與前台不同,
解決方法有2:

───────────────────────────────────
 ■ 方案1: 用 DND
───────────────────────────────────
 ※ 缺點: 之後欄位資料調整, 要改2個(以上) 的 xml.
 ※ 優點: 現行程式不需調整.


───────────────────────────────────
 ■ 方案2: 在 xml 裡增加新的 tag
───────────────────────────────────
 ※ 缺點: 要改寫程式.
 ※ 優點: 多個節點, 都用共同一個 DSD 的情況下, 只需要使用同一支 xml.

step 1: 修改 xml 檔, 增加新的tag.


step 2: 更新 asp 程式及 select box 在使用 xsl 版型.

step 3: 大功告成了, 執行畫面如下:

2011年6月28日 星期二

Flash廣告輪播,增加 "另開視窗" 的判斷

Flash廣告輪播,增加 "另開視窗" 的判斷

Step 1:
在 flash12345.asp 增加一個 newWindow 的 tag, 讓 flash 做判斷.


Step 2:
在 flash 的 action 裡, 判斷目前的 item 的 newWindow=="N" 就設成 同視窗開啟 (_self)
反之就另開視窗 (_blank)


 ※ 附註: 這年頭, 愈來愈少人用 flash 了, 因為 jQuery 做出來的效果很棒, 也比較好維護跟修改.

2011年6月20日 星期一

[Asp].無組件上傳 (hyUpload)

先透過 .isFile 屬性來判斷要處理的欄位是檔案, 還是一般的字串.

由於是使用 iis 內建的元件, 因此在 x64 (64bit) 和 x86 (32bit) 都可以work.



● 畫面1: 選取檔案 (form.asp).
================================



● 畫面2: 上傳成功 (upload.asp).
================================
(用藍字來顯示 File 的部份, 綠色用來顯示一般的 string 資料.



● 檔案清單:
================================
\form.asp
\upload.asp
\inc\hyFileUpload.inc


● form.asp (source code):
================================
<form method="post" ENCTYPE="multipart/form-data" action="upload.asp">
<br/>userName:<input type="text" name="userName">
<br/>file:<input type="file" name="uploadFile">
<br/><input type="submit" name="submit" value="Upload">
</form>


● upload.asp (source code):
================================
dim apath
apath = server.mapPath(".") & "\"

dim xup
set xup=New HyFileUpload

'// 定義最大值, 單位Byte, 0: 不設限
xup.MaxBytesToAbort = 0
'// 定義預設上傳路徑
xup.Start apath

for each x in xup.Form
response.write "<br/> filed(" & x & ") ==>" & xup.Form(x).IsFile & vbcrlf
if xup.Form(x).IsFile then
response.write "<font color='blue'>"
response.write "<br/>+------Name:" & xup.Form(x).Name & vbcrlf
response.write "<br/>+------FileSize:" & xup.Form(x).FileSize & vbcrlf
response.write "<br/>+------FileName:" & xup.Form(x).FileName & vbcrlf
response.write "<br/>+------FileType:" & xup.Form(x).FileType & vbcrlf
response.write "<br/>+------sDefaultPath:" & xup.Form(x).sDefaultPath & vbcrlf
response.write "</font>"
else
response.write "<font color='green'>"
response.write "<br/>+------Name:" & xup.Form(x).Name & vbcrlf
response.write "<br/>+------Value:" & xup.Form(x).value & vbcrlf
response.write "</font>"
end if
next

set xup=nothing




================================
附註1: 更多相關文章 google 關鍵字下: ASP 無組件上傳
附註2: 特別感謝 e部門, 還有ken, 還有提供我這個 source code 的人.

在x64 的 iis 下執行 32-bit Applications 的方法2

這次是不透過允許 32bit 應用程式(Enable 32-bit Applications) 的情況下, 來執行 32 bit 的 com+ object, 設定方試很簡單, 在元件裡按 "內容" -> "進階" -> "允許IIS內建內容" 打勾

Component Services -> Computers -> My Computer -> COM+ Applications
Open a COM+ Application object.
Open Components.
Right-click on a class and select Properties.
Under "Advanced" there is a check box for "Allow IIS intrinsic properties".

附註1: 經測試, 在同一個畫面, 同一時間執行 32bit 和 64bit 的 object.
附註2: 我用的 TABS 是 2.1版, 1.6版或 3.0版可能也ok.


執行畫面如下:

2011年6月9日 星期四

在x64 的 iis 下執行 32-bit Applications

在x64 的 iis 下執行 32-bit Applications 的方法, 就是在應用程式集區(Application pools) 裡允許 32bit 應用程式(Enable 32-bit Applications)




測試結果: overpower(縮圖元件) 和 tabs(檔案上傳元件) 可以正常地被 create, tabs 可以上傳檔案.


相關文章: google 關鍵字下: vb6 x64 server.CreateObject

分享 x64 環境下的縮圖元件--imageMagick

step 1: 先到 URL: http://www.imagemagick.org/script/binary-releases.php#windows
下載 windows-x64-dll.exe (Win64 dynamic at 16 bits-per-pixel)

step 2: 點2下 exe 檔, 安裝.

step 3: 執行 regsvr32:
C:\Program Files\ImageMagick-6.7.0-Q16> regsvr32 ImageMagickObject.dll

step 4: 測試縮圖 asp:

dim imObject
set imObject = createobject("ImageMagickObject.MagickImage.1")

dim myInputFile
dim myOutputFile

myInputFile = server.mapPath(".") & "\demo.jpg"
myOutputFile = server.mapPath(".") & "\demo_new.jpg"
imObjectReturn = imObject.Convert(myInputFile, "-resize=200x", myOutputFile)


response.write "Now:" & now()
response.write "轉檔完成囉!"


step 5: 大功告成.

2011年6月2日 星期四

身份驗證缺陷 (Broken Authentication)

今天在研究一份資料報告,有一個身份驗證缺陷 (Broken Authentication)的弱點. 我花了1小時, trace 程式, 和看報告, 終於找到原因, 我覺得當初寫程式的人真是豬頭, 居然會犯下醬子的錯. @_@;

程式1: member_edit.asp
他在 show form 時, 是從 session 裡去取得 user 當初 login 時的帳號(userid), 並把 userid 放到 form 裡的一個 hidden 欄位.


程式2: member_edit_act.asp
直接 request hidden 的欄位裡的值, 拿來做 SQL 的運算,
結果 user 把帳號值置換成別人的帳號, 就把別人的資料 overwrite 過去, 然後就可以用別人的帳號來 login.


為什麼當初寫的人, 會沒有想到這個問題?
需不需要做教育訓練?
如果一開始就可以寫出沒有弱點的程式, 該有多好. 呵呵呵.

Facebook 留言板