# インターフェースのテーブルの幅
TABLEWIDTH = 800
# 画像フォルダの場所を定義
-IMGPATH = "./../lunardial/xml/img"
+IMGPATH = "./../lunardial/xml/img/"
# バージョン情報を示す文字列です
APPVERSION = "- FileManager for Ruby version 2.0.0.0 -<br>Copyright(c) 2009 Kureha.H (<a href=\"http://lunardial.sakura.ne.jp/\" target=\"_blank\">http://lunardial.sakura.ne.jp/</a>) & Yui Naruse (<a href=\"http://airemix.com/\" target=\"_blank\">http://airemix.com/</a>)"
end
end
+# = Dirクラス
+#
+# Dirクラスのオーバーライドを行います
+class Dir
+ def Dir.exist?(path)
+ File.exist?(path) && File.ftype(path) == "directory"
+ end
+end
+
class NilClass
def blank?
nil?
# _template_ :: テンプレートファイル(*.erb)のパス
# _binding_ :: binding変数
def initialize(template, binding)
- @erb = ERB.new(myopen(template, "r") {|f| f.read}, nil, "-")
+ @erb = ERB.new(myopen(template, "r:utf-8") {|f| f.read}, nil, "-")
@binding = binding
end
# _basepath_ :: クラス内で扱う最上位のフォルダ(root)とする実パス
def initialize(basepath)
@basepath = basepath
- @basepath << "/" unless @basepath[-1] == "/"
+ @basepath << "/" unless @basepath[-1..-1] == "/"
@relpath_list = []
- raise "Target dir not found." unless check_dir_exist?(pwd)
+ raise "Target dir not found." unless Dir.exist?(pwd)
end
attr_reader :basepath
if pathname == ".."
@relpath_list.delete_at(-1) unless @relpath_list.length == 0
elsif pathname.match(/([^\w]|\.\.|\/|\.)/) == nil
- if check_dir_exist?(pwd + "/" + File.basename(pathname))
+ if Dir.exist?(pwd + "/" + File.basename(pathname))
@relpath_list << File.basename(pathname)
else
raise "Target dir not found."
end
end
- # 対象ディレクトリが存在するかを確認するメソッド
- def check_dir_exist?(target_dir)
- unless (File.exist?(target_dir) || File.ftype(target_dir) != "directory")
- false
- else
- true
- end
- end
-
end
# = Controllerクラス
filer.relpath_list = db["relpath_list"]
if (cgi["updata"].size <= UPLOADLIMIT)
- filer.upload(cgi["updata"], cgi["updata"].original_filename.gsub(/( | )/, "_"))
+ begin
+ filer.upload(cgi["updata"], cgi["updata"].original_filename.gsub(/( | )/, "_"))
+ rescue => ever
+ db["error"] = "既に同名のファイルが存在します!"
+ end
else
db["error"] = "ファイルの容量が大きすぎます!"
end
filer = WebFiler.new(IMGPATH)
filer.relpath_list = db["relpath_list"]
- filer.mkdir(params["dirname"])
+ begin
+ filer.mkdir(params["dirname"])
+ rescue => ever
+ db["error"] = "既に同名のディレクトリが存在します!"
+ end
db["filelist"] = filer.ls.reverse
db["fileinfo"] = filer.lsinfo
filer = WebFiler.new(IMGPATH)
filer.relpath_list = db["relpath_list"]
- filer.cd(params["arg"])
+ begin
+ filer.cd(params["arg"])
+ rescue => ever
+ db["error"] = "移動先のディレクトリが見つかりません!"
+ end
db["filelist"] = filer.ls.reverse
db["fileinfo"] = filer.lsinfo
rescue => exception
# エラーが発生した場合、それを画面に表示します
htmlwriter = HtmlWriter.new("./erbtemp/exception.html.erb", binding)
- cgi.out{htmlwriter.to_code}
+ cgi.out{ htmlwriter.to_code }
end
end