Feeds:
文章
留言

Archive for 四月 4th, 2008

今天嘗試開發 AIR 用的 Flex 元件,結果執行時出現如下的錯誤訊息image

正在納悶時,還好查到[1]文章,該文提到手動加入如下的片段即可修正此錯誤訊息,

var resourceManagerImpl:Object = ApplicationDomain.currentDomain.getDefinition("mx.resources::ResourceManagerImpl");
Singleton.registerClass("mx.resources::IResourceManager", Class(resourceManagerImpl));            

另外該文還提到這應該是….. Bug

參考資料
[1] "http://groups.google.com/group/flex_india/browse_thread/thread/b53a0a828f1346eb"

Read Full Post »

目前尚未解決同時下載問題,不過當一個處於下載狀態時,另一個連結可繼續進行下載~ 如果有人熟悉  "reCAPTCHA Client API" 也許可以填補這個缺點…

下載 mihd.lua

MODULE_NAME = "mihd"
MODULE_VERSION = "0.0.3"
MODULE_REQUIRE_VERSION = "1.2.3.4"
MODULE_AUTHOR = "cwchiu@hotmail.com"
MODULE_LAST_UPDATE = "2008/04/05"
————————————————————————-
–local func
————————————————————————-
local function dumpHTML(msg)
if msg == nil then
  msg = “
end

Compile("(.*)")
local _, html = What()
UpdateLog(msg .. html)
end

http://mihd.net/download:dl_request?fk=nrvfhzl,type=na
local function fetchUrl()

GetHtml(‘http://mihd.net/download:dl_js’)
–dumpHTML(‘dl_js: ‘) 
GetHtml(‘http://mihd.net/dl’)
–dumpHTML(‘dl:’)
 
if not Compile("<a id="dl_link" target="_blank" href="([^"]+)">Download</a>") then
  return false
end

local _, link = What()
 

if link == nil then
  return false
end
–UpdateLog(‘link>>’ .. link)
return GetFile(link)
end

— 無驗證碼
local function modeNA(__file_key)
local request = ‘http://mihd.net/download:dl_request?fk=&#8217;.. __file_key ..’,type=na’
–UpdateLog(request)
GetHtml(request)
–dumpHTML(‘request: ‘)
return fetchUrl()
end

— 簡易驗證碼模式
local function modeSimple(__file_key)
GetCaptcha(‘http://mihd.net/download:captcha?&#8217; ..  math.random()  )
local c = PromptCaptcha(60)
local request = ‘http://mihd.net/download:dl_request?fk=&#8217;.. __file_key ..’,type=simple’ .. ‘,captcha=’ .. c;
GetHtml(request)

return fetchUrl()
end


local function makeRecaptcha(__file_key)
UpdateLog(‘未實作 Recaptcha’)
–,recaptcha_response_field=’ .. escape( recaptcha_response_field )
–,recaptcha_challenge_field=’ .. recaptcha_challenge_field
–local request = ‘http://mihd.net/download:dl_request?fk=&#8217;.. __file_key ..’,type=recaptcha’ .. ‘,captcha=’ .. c;

return false
end

local function DownFile()
local url = GetUrl()
_,__, __file_key=
url:find(‘mihd%.net/(%w+)’)
UpdateLog(‘key>>’ .. __file_key)

if modeNA(__file_key) or modeSimple(__file_key) or makeRecaptcha(__file_key) then
  return true
end

 

if not GetHtml() then return false end
if not Compile("name="form_auth" value="([^"]+)"") then return false end
local _,form_auth = What()
if not form_auth then
  if Find("404 Page Not Found") then
   UpdateLog("網頁顯示 404 Page Not Found,應該是被刪除了")
  else
   UpdateLog("找不到表格,請檢查紀錄檔")
   CreateLogFile("mihd_download_failed.html")
  end
  return false
end

AddFormField("form_auth",form_auth,false)
if not PostForm("http://mihd.net/request_ticket.html") then return false end
if not Compile("download_details_heading.+?href="([^"]+)"") then return false end
local _,url = What()
if not url then
  UpdateLog("找不到真實路徑,請檢查紀錄檔")
  CreateLogFile("mihd_download_failed.html")
  return false
end

return GetFile(url)
end

————————————————————————-
–main
————————————————————————-
function Download()
local url = GetUrl()
if url:find( "mihd%.net/%w+" ) then
  return DownFile()
else
  UpdateLog("網址有誤")
end
end

function Upload()
if not GetHtml("http://mihd.net/") then return false end
if not Compile("<form.+?action="([^"]+)"") then return false end
local _,action = What()
if not action then
  UpdateLog("找不到上傳表格,請檢查紀錄檔")
  CreateLogFile("mihd_upload_failed.html")
  return false
end

AddFormFile("Filedata")
UpdateLog("準備上傳…","info")
if not UploadFile(action:replace("&amp;","&")) then return false end
if not Compile("Your download link.+?value="([^"]+)"(?:.+?Your delete link.+?value="([^"]+)")?") then return false end
local _,u1,u2 = What()
if not u1 then
  UpdateLog("找不到網址1,視為失敗,請檢查紀錄檔")
  CreateLogFile("mihd_upload_failed.html")
  return false
end

if not u2 or u2==" then
  if Find("This file was already uploaded!") then
   UpdateLog("網站顯示此檔案已經上傳過了","info")
  end
  SetUrl(u1)
  UpdateLog("上傳成功,網址1為檔案連結", "info")
else
  SetUrl(u1,u2)
  UpdateLog("上傳成功,網址1為檔案連結,網址2為刪除連結", "info")
end

return true
end

執行結果

00e

Read Full Post »