diff --git a/Sunfish/Sunfish/SunfishServerProcessor.cs b/Sunfish/Sunfish/SunfishServerProcessor.cs index 5ce5c7b..f458ec0 100644 --- a/Sunfish/Sunfish/SunfishServerProcessor.cs +++ b/Sunfish/Sunfish/SunfishServerProcessor.cs @@ -19,10 +19,9 @@ } private void Process() { - //SunfishService s = Sunfish.GetServiceForPath(Request.Url.LocalPath); + SunfishService s = Sunfish.GetServiceForPath(call.Request.Url.LocalPath); //Response.Headers[HttpResponseHeader.ContentType] = "text/plain"; //call.OpenOutput(); - call.Out.WriteLine("Sunfish here"); return; //if (s == null) // if (Sunfish.RootMenu) diff --git a/Sunfish/Sunfish/wx/WShared.cs b/Sunfish/Sunfish/wx/WShared.cs index aba0d27..2d5d67d 100644 --- a/Sunfish/Sunfish/wx/WShared.cs +++ b/Sunfish/Sunfish/wx/WShared.cs @@ -1,82 +1,82 @@ -using System.Linq; -using System.Text; +//using System.Linq; +//using System.Text; -namespace DolphinWebXplorer2.wx -{ - public class WShared - { - private string name; - private string path; - private bool enabled; - private bool allowSubfolders; - private bool allowUpload; - private bool allowDeletion; - private bool allowRename; - private bool allowExecution; - private bool allowNewFolder; - private bool sendThumbnails; +//namespace DolphinWebXplorer2.wx +//{ +// public class WShared +// { +// private string name; +// private string path; +// private bool enabled; +// private bool allowSubfolders; +// private bool allowUpload; +// private bool allowDeletion; +// private bool allowRename; +// private bool allowExecution; +// private bool allowNewFolder; +// private bool sendThumbnails; - public WShared() - { - } +// public WShared() +// { +// } - public WShared(string name, string path) - { - this.name = name; - Path = path; - } +// public WShared(string name, string path) +// { +// this.name = name; +// Path = path; +// } - public string GetLocalPath(string path) - { - return this.path + path.Replace('/', System.IO.Path.DirectorySeparatorChar); - } +// public string GetLocalPath(string path) +// { +// return this.path + path.Replace('/', System.IO.Path.DirectorySeparatorChar); +// } - public string GetRemotePath(string path) - { - return '/' + name + '/' + path; - } +// public string GetRemotePath(string path) +// { +// return '/' + name + '/' + path; +// } - public string GetFlags() - { - StringBuilder sb = new StringBuilder(""); - sb.Append(allowSubfolders ? 'S' : '-'); - sb.Append(allowUpload ? 'U' : '-'); - sb.Append(allowDeletion ? 'D' : '-'); - sb.Append(allowRename ? 'R' : '-'); - sb.Append(allowExecution ? 'X' : '-'); - sb.Append(allowNewFolder ? 'F' : '-'); - sb.Append(sendThumbnails ? 'T' : '-'); - return sb.ToString(); - } +// public string GetFlags() +// { +// StringBuilder sb = new StringBuilder(""); +// sb.Append(allowSubfolders ? 'S' : '-'); +// sb.Append(allowUpload ? 'U' : '-'); +// sb.Append(allowDeletion ? 'D' : '-'); +// sb.Append(allowRename ? 'R' : '-'); +// sb.Append(allowExecution ? 'X' : '-'); +// sb.Append(allowNewFolder ? 'F' : '-'); +// sb.Append(sendThumbnails ? 'T' : '-'); +// return sb.ToString(); +// } - public void SetFlags(string flags) - { - allowSubfolders = flags.Contains('S'); - allowUpload = flags.Contains('U'); - allowDeletion = flags.Contains('D'); - allowRename = flags.Contains('R'); - allowExecution = flags.Contains('X'); - allowNewFolder = flags.Contains('F'); - sendThumbnails = flags.Contains('T'); - } - public string Name { get { return name; } set { name = value; } } - public string Path - { - get { return path; } - set - { - path = value; - if (!path.EndsWith("\\")) - path += '\\'; - } - } - public bool Enabled { get { return enabled; } set { enabled = value; } } - public bool AllowSubfolders { get { return allowSubfolders; } set { allowSubfolders = value; } } - public bool AllowUpload { get { return allowUpload; } set { allowUpload = value; } } - public bool AllowDeletion { get { return allowDeletion; } set { allowDeletion = value; } } - public bool AllowRename { get { return allowRename; } set { allowRename = value; } } - public bool AllowExecution { get { return allowExecution; } set { allowExecution = value; } } - public bool AllowNewFolder { get { return allowNewFolder; } set { allowNewFolder = value; } } - public bool SendThumbnails { get { return sendThumbnails; } set { sendThumbnails = value; } } - } -} +// public void SetFlags(string flags) +// { +// allowSubfolders = flags.Contains('S'); +// allowUpload = flags.Contains('U'); +// allowDeletion = flags.Contains('D'); +// allowRename = flags.Contains('R'); +// allowExecution = flags.Contains('X'); +// allowNewFolder = flags.Contains('F'); +// sendThumbnails = flags.Contains('T'); +// } +// public string Name { get { return name; } set { name = value; } } +// public string Path +// { +// get { return path; } +// set +// { +// path = value; +// if (!path.EndsWith("\\")) +// path += '\\'; +// } +// } +// public bool Enabled { get { return enabled; } set { enabled = value; } } +// public bool AllowSubfolders { get { return allowSubfolders; } set { allowSubfolders = value; } } +// public bool AllowUpload { get { return allowUpload; } set { allowUpload = value; } } +// public bool AllowDeletion { get { return allowDeletion; } set { allowDeletion = value; } } +// public bool AllowRename { get { return allowRename; } set { allowRename = value; } } +// public bool AllowExecution { get { return allowExecution; } set { allowExecution = value; } } +// public bool AllowNewFolder { get { return allowNewFolder; } set { allowNewFolder = value; } } +// public bool SendThumbnails { get { return sendThumbnails; } set { sendThumbnails = value; } } +// } +//} diff --git a/Sunfish/Sunfish/wx/WebXplorer.cs b/Sunfish/Sunfish/wx/WebXplorer.cs index ddf6299..5309634 100644 --- a/Sunfish/Sunfish/wx/WebXplorer.cs +++ b/Sunfish/Sunfish/wx/WebXplorer.cs @@ -1,902 +1,902 @@ -using DolphinWebXplorer2.Middleware; -using DolphinWebXplorer2.Properties; -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Imaging; -using System.IO; -using System.Linq; -using System.Net; -using System.Reflection; -using System.Text; -using System.Windows.Forms; +//using DolphinWebXplorer2.Middleware; +//using DolphinWebXplorer2.Properties; +//using System; +//using System.Collections.Generic; +//using System.Drawing; +//using System.Drawing.Imaging; +//using System.IO; +//using System.Linq; +//using System.Net; +//using System.Reflection; +//using System.Text; +//using System.Windows.Forms; -namespace DolphinWebXplorer2.wx -{ - static class WebXplorer - { - private static List shares = new List(); - private static HttpServer server; - public static byte[] res_logo; - public static byte[] res_favicon; - public static byte[] res_tdelete; - public static byte[] res_texecute; - public static byte[] res_rename; - public static byte[] res_screen; - public static byte[] res_folder; - public static byte[] res_upload; - private static int port = 90; - private static bool sharedScreen = false; - private static string sharedScreenPwd; - public static Random rnd = new Random(); - private static Dictionary acodes = new Dictionary(); +//namespace DolphinWebXplorer2.wx +//{ +// static class WebXplorer +// { +// private static List shares = new List(); +// private static HttpServer server; +// public static byte[] res_logo; +// public static byte[] res_favicon; +// public static byte[] res_tdelete; +// public static byte[] res_texecute; +// public static byte[] res_rename; +// public static byte[] res_screen; +// public static byte[] res_folder; +// public static byte[] res_upload; +// private static int port = 90; +// private static bool sharedScreen = false; +// private static string sharedScreenPwd; +// public static Random rnd = new Random(); +// private static Dictionary acodes = new Dictionary(); - static WebXplorer() - { - using (MemoryStream ms = new MemoryStream()) - { - Resources.sunfishWebServer.Save(ms); - ms.Position = 0; - res_favicon = ms.ToArray(); - } - res_logo = GetImageData(Resources.sws, ImageFormat.Png); - res_tdelete = GetImageData(Resources.t_delete, ImageFormat.Png); - res_texecute = GetImageData(Resources.t_execute, ImageFormat.Png); - res_rename = GetImageData(Resources.rename, ImageFormat.Png); - res_screen = GetImageData(Resources.screen, ImageFormat.Png); - res_folder = GetImageData(Resources.foldericon, ImageFormat.Png); - res_upload = GetImageData(Resources.upload, ImageFormat.Png); - Win32.DestroyIcon(Win32.GetIcon(".").hIcon); - string letters = "abcdefghikjlmnopqrstuvwxyz1234567890"; - Random rnd = new Random(); - sharedScreenPwd = ""; - while (sharedScreenPwd.Length < 10) - sharedScreenPwd += letters[rnd.Next(letters.Length)]; - } +// static WebXplorer() +// { +// using (MemoryStream ms = new MemoryStream()) +// { +// Resources.sunfishWebServer.Save(ms); +// ms.Position = 0; +// res_favicon = ms.ToArray(); +// } +// res_logo = GetImageData(Resources.sws, ImageFormat.Png); +// res_tdelete = GetImageData(Resources.t_delete, ImageFormat.Png); +// res_texecute = GetImageData(Resources.t_execute, ImageFormat.Png); +// res_rename = GetImageData(Resources.rename, ImageFormat.Png); +// res_screen = GetImageData(Resources.screen, ImageFormat.Png); +// res_folder = GetImageData(Resources.foldericon, ImageFormat.Png); +// res_upload = GetImageData(Resources.upload, ImageFormat.Png); +// Win32.DestroyIcon(Win32.GetIcon(".").hIcon); +// string letters = "abcdefghikjlmnopqrstuvwxyz1234567890"; +// Random rnd = new Random(); +// sharedScreenPwd = ""; +// while (sharedScreenPwd.Length < 10) +// sharedScreenPwd += letters[rnd.Next(letters.Length)]; +// } - private static byte[] GetImageData(Image i, ImageFormat format) - { - using (MemoryStream ms = new MemoryStream()) - { - i.Save(ms, format); - ms.Position = 0; - return ms.ToArray(); - } - } +// private static byte[] GetImageData(Image i, ImageFormat format) +// { +// using (MemoryStream ms = new MemoryStream()) +// { +// i.Save(ms, format); +// ms.Position = 0; +// return ms.ToArray(); +// } +// } - public static void Add(WShared sh) - { - shares.Add(sh); - } +// public static void Add(WShared sh) +// { +// shares.Add(sh); +// } - public static WShared Get(string index) - { - foreach (WShared w in shares) - if (w.Name.Equals(index, StringComparison.CurrentCultureIgnoreCase)) - return w; - return null; - } +// public static WShared Get(string index) +// { +// foreach (WShared w in shares) +// if (w.Name.Equals(index, StringComparison.CurrentCultureIgnoreCase)) +// return w; +// return null; +// } - public static void Delete(string index) - { - shares.Remove(Get(index)); - } +// public static void Delete(string index) +// { +// shares.Remove(Get(index)); +// } - public static void Delete(WShared ws) - { - shares.Remove(ws); - } +// public static void Delete(WShared ws) +// { +// shares.Remove(ws); +// } - public static void Start() - { - if (server != null) - Stop(); - server = new HttpServer(port); - server.CreateProcessor += new HttpServer.CreateProcessorHandler(server_CreateProcessor); - server.Error += new HttpServer.ErrorEventHandler(server_Error); - server.Start(); - } +// public static void Start() +// { +// if (server != null) +// Stop(); +// server = new HttpServer(port); +// server.CreateProcessor += new HttpServer.CreateProcessorHandler(server_CreateProcessor); +// server.Error += new HttpServer.ErrorEventHandler(server_Error); +// server.Start(); +// } - static void server_Error(HttpServer server, Exception e) - { - if (!(e is ObjectDisposedException) && !(e is HttpListenerException)) - MessageBox.Show(e.Message + "\r\n" + e.StackTrace, e.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); - } +// static void server_Error(HttpServer server, Exception e) +// { +// if (!(e is ObjectDisposedException) && !(e is HttpListenerException)) +// MessageBox.Show(e.Message + "\r\n" + e.StackTrace, e.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); +// } - static HttpServerProcessor server_CreateProcessor(HttpServer server) - { - return new XplorerProcessor(); - } +// static HttpServerProcessor server_CreateProcessor(HttpServer server) +// { +// return new XplorerProcessor(); +// } - public static void Stop() - { - if (server == null) - return; - server.Stop(); - server = null; - } +// public static void Stop() +// { +// if (server == null) +// return; +// server.Stop(); +// server = null; +// } - public static void Save(string filename) - { - Dictionary YN = new Dictionary(); - YN[true] = "Y"; - YN[false] = "N"; - List data = new List(); - data.Add("#Sunfish WebXplorer V" + Program.VERSION + " (The new Dolphin WebXplorer) (C) XWolfOverride@gmail.com 2007-2015"); - data.Add("Active: " + YN[Active]); - data.Add("Port: " + port); - data.Add("SharedScreen:" + YN[sharedScreen]); - data.Add("SharedScreen.Password:" + sharedScreenPwd.ToLower()); - data.Add(""); - data.Add("#Each shared line is: Shared:|||"); - data.Add("# Where flags stands for"); - data.Add("# ·S Allow sub folder navigation"); - data.Add("# ·U Allow upload files"); - data.Add("# ·D Allow file deletion"); - data.Add("# ·R Allow rile rename"); - data.Add("# ·X Allow remote execution (execute on server side)"); - data.Add("# ·F Allow create folders"); - data.Add("# ·T Send thumbnails icons"); - data.Add(""); - foreach (WShared s in shares) - data.Add("Shared: " + s.Name + "|" + s.Path + "|" + YN[s.Enabled] + "|" + s.GetFlags()); - File.WriteAllLines(filename, data.ToArray()); - } +// public static void Save(string filename) +// { +// Dictionary YN = new Dictionary(); +// YN[true] = "Y"; +// YN[false] = "N"; +// List data = new List(); +// data.Add("#Sunfish WebXplorer V" + Program.VERSION + " (The new Dolphin WebXplorer) (C) XWolfOverride@gmail.com 2007-2015"); +// data.Add("Active: " + YN[Active]); +// data.Add("Port: " + port); +// data.Add("SharedScreen:" + YN[sharedScreen]); +// data.Add("SharedScreen.Password:" + sharedScreenPwd.ToLower()); +// data.Add(""); +// data.Add("#Each shared line is: Shared:|||"); +// data.Add("# Where flags stands for"); +// data.Add("# ·S Allow sub folder navigation"); +// data.Add("# ·U Allow upload files"); +// data.Add("# ·D Allow file deletion"); +// data.Add("# ·R Allow rile rename"); +// data.Add("# ·X Allow remote execution (execute on server side)"); +// data.Add("# ·F Allow create folders"); +// data.Add("# ·T Send thumbnails icons"); +// data.Add(""); +// foreach (WShared s in shares) +// data.Add("Shared: " + s.Name + "|" + s.Path + "|" + YN[s.Enabled] + "|" + s.GetFlags()); +// File.WriteAllLines(filename, data.ToArray()); +// } - public static void Load(string filename) - { - string[] data = File.ReadAllLines(filename); - bool setactive = false; - sharedScreen = false; - shares.Clear(); - Stop(); - foreach (string l in data) - { - if (l.StartsWith("#") || l.Length == 0) - continue; - int dp = l.IndexOf(':'); - if (dp < 0) - continue; - string cmd = l.Substring(0, dp); - string par = l.Substring(dp + 1).Trim(); - switch (cmd.ToLower()) - { - case "active": - setactive = "Y".Equals(par); - break; - case "port": - int.TryParse(par, out port); - break; - case "sharedscreen": - sharedScreen = "Y".Equals(par); - break; - case "sharedscreen.password": - sharedScreenPwd = par; - break; - case "shared": - { - string[] s = par.Split('|'); - string sname = s.Length > 0 ? s[0] : null; - string spath = s.Length > 1 ? s[1] : null; - if (sname != null && spath != null) - { - WShared sh = new WShared(sname, spath); - sh.Enabled = "Y".Equals(s.Length > 2 ? s[2] : null); - sh.SetFlags(s.Length > 3 ? s[3] : ""); - Add(sh); - } - } - break; - } - } - if (setactive) - Start(); - } +// public static void Load(string filename) +// { +// string[] data = File.ReadAllLines(filename); +// bool setactive = false; +// sharedScreen = false; +// shares.Clear(); +// Stop(); +// foreach (string l in data) +// { +// if (l.StartsWith("#") || l.Length == 0) +// continue; +// int dp = l.IndexOf(':'); +// if (dp < 0) +// continue; +// string cmd = l.Substring(0, dp); +// string par = l.Substring(dp + 1).Trim(); +// switch (cmd.ToLower()) +// { +// case "active": +// setactive = "Y".Equals(par); +// break; +// case "port": +// int.TryParse(par, out port); +// break; +// case "sharedscreen": +// sharedScreen = "Y".Equals(par); +// break; +// case "sharedscreen.password": +// sharedScreenPwd = par; +// break; +// case "shared": +// { +// string[] s = par.Split('|'); +// string sname = s.Length > 0 ? s[0] : null; +// string spath = s.Length > 1 ? s[1] : null; +// if (sname != null && spath != null) +// { +// WShared sh = new WShared(sname, spath); +// sh.Enabled = "Y".Equals(s.Length > 2 ? s[2] : null); +// sh.SetFlags(s.Length > 3 ? s[3] : ""); +// Add(sh); +// } +// } +// break; +// } +// } +// if (setactive) +// Start(); +// } - public static bool Contains(WShared sh) - { - return shares.Contains(sh); - } +// public static bool Contains(WShared sh) +// { +// return shares.Contains(sh); +// } - public static string CreateACode(string key) - { - string result = GenACode(); - acodes[key] = result; - return result; - } +// public static string CreateACode(string key) +// { +// string result = GenACode(); +// acodes[key] = result; +// return result; +// } - public static bool CheckACode(string key, string acode) - { - if (acodes.ContainsKey(key)) - { - bool result = acode == acodes[key]; - acodes.Remove(key); - return result; - } - return false; - } +// public static bool CheckACode(string key, string acode) +// { +// if (acodes.ContainsKey(key)) +// { +// bool result = acode == acodes[key]; +// acodes.Remove(key); +// return result; +// } +// return false; +// } - private static string GenACode() - { - string allowed = "_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - StringBuilder result = new StringBuilder(16); - while (result.Length < 16) - result.Append(allowed[rnd.Next(allowed.Length)]); - return result.ToString(); - } +// private static string GenACode() +// { +// string allowed = "_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +// StringBuilder result = new StringBuilder(16); +// while (result.Length < 16) +// result.Append(allowed[rnd.Next(allowed.Length)]); +// return result.ToString(); +// } - public static WShared[] Shares { get { return shares.ToArray(); } } - public static bool Active { get { return server != null; } } - public static int Port { get { return port; } set { if (Active) throw new Exception("Can't change port while running"); else port = value; } } - public static bool SharedScreen { get { return sharedScreen; } set { sharedScreen = value; } } - public static string SharedScreenPassword { get { return sharedScreenPwd; } set { sharedScreenPwd = value; } } - } +// public static WShared[] Shares { get { return shares.ToArray(); } } +// public static bool Active { get { return server != null; } } +// public static int Port { get { return port; } set { if (Active) throw new Exception("Can't change port while running"); else port = value; } } +// public static bool SharedScreen { get { return sharedScreen; } set { sharedScreen = value; } } +// public static string SharedScreenPassword { get { return sharedScreenPwd; } set { sharedScreenPwd = value; } } +// } - class XplorerProcessor : HttpServerProcessor - { - protected override void Process() - { - string path = Path.Substring(1); - if (path.StartsWith("·") || path == "favicon.ico") - Resource(path.Substring(1)); - if (path.StartsWith("$")) - Special(path.Substring(1)); - else - { - string shpath = path.Contains('/') ? path.Substring(0, path.IndexOf('/')) : null; - string rpath = shpath == null ? null : path.Substring(shpath.Length + 1); - string action = GET.ContainsKey("Action") ? GET["Action"] : null; - rpath = UDec(rpath); - WShared sh = WebXplorer.Get(shpath); - if (sh == null) - Menu(); - else if (action != null) - { - switch (action) - { - case "ICO": - GetIcon(sh, rpath); - break; - case "GET": - Download(sh, rpath); - break; - case "REN": - PageRename(sh, rpath); - break; - case "RENDO": - PageRenameDo(sh, rpath); - break; - case "RUN": - PageExecute(sh, rpath); - break; - case "DEL": - PageDelete(sh, rpath); - break; - case "DELDO": - PageDeleteDo(sh, rpath); - break; - case "MKD": - PageCreateFolder(sh, rpath); - break; - case "MKDDO": - PageCreateFolderDo(sh, rpath); - break; - case "UPL": - PageUpload(sh, rpath); - break; - case "UPLDO": - PageUploadDo(sh, rpath); - break; - } - } - else - if (sh.Enabled) - Shared(sh, rpath); - else - Menu(); - } - } +// class XplorerProcessor : HttpServerProcessor +// { +// protected override void Process() +// { +// //string path = Path.Substring(1); +// //if (path.StartsWith("·") || path == "favicon.ico") +// // Resource(path.Substring(1)); +// //if (path.StartsWith("$")) +// // Special(path.Substring(1)); +// //else +// //{ +// // string shpath = path.Contains('/') ? path.Substring(0, path.IndexOf('/')) : null; +// // string rpath = shpath == null ? null : path.Substring(shpath.Length + 1); +// // string action = GET.ContainsKey("Action") ? GET["Action"] : null; +// // rpath = UDec(rpath); +// // WShared sh = WebXplorer.Get(shpath); +// // if (sh == null) +// // Menu(); +// // else if (action != null) +// // { +// // switch (action) +// // { +// // case "ICO": +// // GetIcon(sh, rpath); +// // break; +// // case "GET": +// // Download(sh, rpath); +// // break; +// // case "REN": +// // PageRename(sh, rpath); +// // break; +// // case "RENDO": +// // PageRenameDo(sh, rpath); +// // break; +// // case "RUN": +// // PageExecute(sh, rpath); +// // break; +// // case "DEL": +// // PageDelete(sh, rpath); +// // break; +// // case "DELDO": +// // PageDeleteDo(sh, rpath); +// // break; +// // case "MKD": +// // PageCreateFolder(sh, rpath); +// // break; +// // case "MKDDO": +// // PageCreateFolderDo(sh, rpath); +// // break; +// // case "UPL": +// // PageUpload(sh, rpath); +// // break; +// // case "UPLDO": +// // PageUploadDo(sh, rpath); +// // break; +// // } +// // } +// // else +// // if (sh.Enabled) +// // Shared(sh, rpath); +// // else +// // Menu(); +// //} +// } - private void Resource(string res) - { - switch (res) - { - case "logo": - BinaryOut(WebXplorer.res_logo, "image/png"); - break; - case "avicon.ico": - BinaryOut(WebXplorer.res_favicon, "image/vnd.microsoft.icon"); - break; - case "t_delete": - BinaryOut(WebXplorer.res_tdelete, "image/png"); - break; - case "t_execute": - BinaryOut(WebXplorer.res_texecute, "image/png"); - break; - case "rename": - BinaryOut(WebXplorer.res_rename, "image/png"); - break; - case "screen": - BinaryOut(WebXplorer.res_screen, "image/png"); - break; - case "folder": - BinaryOut(WebXplorer.res_folder, "image/png"); - break; - case "upload": - BinaryOut(WebXplorer.res_upload, "image/png"); - break; - case "/Sunfish.exe": - BinaryOut(GetMyself(), "application/x-msdownload"); - break; - } - } +// private void Resource(string res) +// { +// switch (res) +// { +// case "logo": +// BinaryOut(WebXplorer.res_logo, "image/png"); +// break; +// case "avicon.ico": +// BinaryOut(WebXplorer.res_favicon, "image/vnd.microsoft.icon"); +// break; +// case "t_delete": +// BinaryOut(WebXplorer.res_tdelete, "image/png"); +// break; +// case "t_execute": +// BinaryOut(WebXplorer.res_texecute, "image/png"); +// break; +// case "rename": +// BinaryOut(WebXplorer.res_rename, "image/png"); +// break; +// case "screen": +// BinaryOut(WebXplorer.res_screen, "image/png"); +// break; +// case "folder": +// BinaryOut(WebXplorer.res_folder, "image/png"); +// break; +// case "upload": +// BinaryOut(WebXplorer.res_upload, "image/png"); +// break; +// case "/Sunfish.exe": +// BinaryOut(GetMyself(), "application/x-msdownload"); +// break; +// } +// } - private void Special(string path) - { - if (path == "screen") - { - BlackHeader("Shared Screen", global::DolphinWebXplorer2.Properties.Resources.ShScreen); - Out.Write("
Password:  
"); - Out.Write("
"); - BlackFooter(); - return; - } - if (path == "screencap") - { - if (GET["code"] != WebXplorer.SharedScreenPassword) - return; - BinaryOut(RemoteScreen.GetScreen(), "image/jpeg"); - return; - } - if (path == "screencmd") - { - if (GET["code"] != WebXplorer.SharedScreenPassword) - return; - RemoteScreen.InputCommand(GET["cmd"]); - Out.Write("Ok"); - return; - } - } +// private void Special(string path) +// { +// if (path == "screen") +// { +// BlackHeader("Shared Screen", global::DolphinWebXplorer2.Properties.Resources.ShScreen); +// Out.Write("
Password:  
"); +// Out.Write("
"); +// BlackFooter(); +// return; +// } +// if (path == "screencap") +// { +// if (GET["code"] != WebXplorer.SharedScreenPassword) +// return; +// BinaryOut(RemoteScreen.GetScreen(), "image/jpeg"); +// return; +// } +// if (path == "screencmd") +// { +// if (GET["code"] != WebXplorer.SharedScreenPassword) +// return; +// RemoteScreen.InputCommand(GET["cmd"]); +// Out.Write("Ok"); +// return; +// } +// } - private void GetIcon(WShared sh, string path) - { - path = sh.GetLocalPath(path); - try - { - if (sh.SendThumbnails) - try - { - FileInfo fi = new FileInfo(path); - if (fi.Length < 10485760) //10Mb - using (Image i = Image.FromFile(path)) - using (Image t = i.GetThumbnailImage(32, 32, null, IntPtr.Zero)) - { - BinaryOut((Bitmap)t); - return; - } - } - catch { }; - using (ShellIcon i = new ShellIcon(path)) - BinaryOut(i.Image); - } - catch (Exception e) - { - Out.WriteLine(e.GetType().Name); - Out.WriteLine(e.Message); - } - } +// private void GetIcon(WShared sh, string path) +// { +// path = sh.GetLocalPath(path); +// try +// { +// if (sh.SendThumbnails) +// try +// { +// FileInfo fi = new FileInfo(path); +// if (fi.Length < 10485760) //10Mb +// using (Image i = Image.FromFile(path)) +// using (Image t = i.GetThumbnailImage(32, 32, null, IntPtr.Zero)) +// { +// BinaryOut((Bitmap)t); +// return; +// } +// } +// catch { }; +// using (ShellIcon i = new ShellIcon(path)) +// BinaryOut(i.Image); +// } +// catch (Exception e) +// { +// Out.WriteLine(e.GetType().Name); +// Out.WriteLine(e.Message); +// } +// } - private void BinaryOut(Bitmap image) - { - using (MemoryStream ms = new MemoryStream()) - { - image.Save(ms, ImageFormat.Png); - ms.Position = 0; - BinaryOut(ms, "image/png"); - } - } +// private void BinaryOut(Bitmap image) +// { +// using (MemoryStream ms = new MemoryStream()) +// { +// image.Save(ms, ImageFormat.Png); +// ms.Position = 0; +// BinaryOut(ms, "image/png"); +// } +// } - private void BinaryOut(Icon image) - { - using (MemoryStream ms = new MemoryStream()) - { - image.Save(ms); - ms.Position = 0; - BinaryOut(ms, "image/vnd.microsoft.icon"); - } - } +// private void BinaryOut(Icon image) +// { +// using (MemoryStream ms = new MemoryStream()) +// { +// image.Save(ms); +// ms.Position = 0; +// BinaryOut(ms, "image/vnd.microsoft.icon"); +// } +// } - private void BinaryOut(MemoryStream ms, string mimetype) - { - BinaryOut(ms.ToArray(), mimetype); - } +// private void BinaryOut(MemoryStream ms, string mimetype) +// { +// BinaryOut(ms.ToArray(), mimetype); +// } - private void BinaryOut(FileStream fs, string mimetype) - { - if (mimetype != null) - Response.Headers[HttpResponseHeader.ContentType] = mimetype; - Response.ContentLength64 = fs.Length; - byte[] buffer = new byte[1024 * 64]; - int readed = buffer.Length; - while (readed == buffer.Length) - { - readed = fs.Read(buffer, 0, buffer.Length); - Write(buffer, 0, readed); - } - } +// private void BinaryOut(FileStream fs, string mimetype) +// { +// if (mimetype != null) +// Response.Headers[HttpResponseHeader.ContentType] = mimetype; +// Response.ContentLength64 = fs.Length; +// byte[] buffer = new byte[1024 * 64]; +// int readed = buffer.Length; +// while (readed == buffer.Length) +// { +// readed = fs.Read(buffer, 0, buffer.Length); +// Write(buffer, 0, readed); +// } +// } - private void BinaryOut(byte[] data, string mimetype) - { - Response.Headers[HttpResponseHeader.ContentType] = mimetype; - Response.ContentLength64 = data.Length; - Write(data); - } +// private void BinaryOut(byte[] data, string mimetype) +// { +// Response.Headers[HttpResponseHeader.ContentType] = mimetype; +// Response.ContentLength64 = data.Length; +// Write(data); +// } - private byte[] GetMyself() - { - return File.ReadAllBytes(Assembly.GetExecutingAssembly().Location); - } +// private byte[] GetMyself() +// { +// return File.ReadAllBytes(Assembly.GetExecutingAssembly().Location); +// } - private void Menu() - { - Header("Home", null, null); - foreach (WShared s in WebXplorer.Shares) - { - if (!s.Enabled) - continue; - ItemDirectory(null, s.Name, '/' + s.Name + '/'); - } - Footer(); - } +// private void Menu() +// { +// Header("Home", null, null); +// foreach (WShared s in WebXplorer.Shares) +// { +// if (!s.Enabled) +// continue; +// ItemDirectory(null, s.Name, '/' + s.Name + '/'); +// } +// Footer(); +// } - private void Shared(WShared sh, string path) - { - if (!sh.AllowSubfolders) - path = ""; - Header(sh.Name, sh, path.Split('/')); - string rpath = sh.GetLocalPath(path); - try - { - if (sh.AllowSubfolders) - { - foreach (string dir in Directory.GetDirectories(rpath)) - { - string name = System.IO.Path.GetFileName(dir); - ItemDirectory(sh, name, sh.GetRemotePath(path + name) + '/'); - } - } - foreach (string fil in Directory.GetFiles(rpath)) - { - string name = System.IO.Path.GetFileName(fil); - ItemFile(sh, name, sh.GetRemotePath(path + name), fil); - } - } - catch (Exception e) - { - Error(e); - } - Footer(); - } +// private void Shared(WShared sh, string path) +// { +// if (!sh.AllowSubfolders) +// path = ""; +// Header(sh.Name, sh, path.Split('/')); +// string rpath = sh.GetLocalPath(path); +// try +// { +// if (sh.AllowSubfolders) +// { +// foreach (string dir in Directory.GetDirectories(rpath)) +// { +// string name = System.IO.Path.GetFileName(dir); +// ItemDirectory(sh, name, sh.GetRemotePath(path + name) + '/'); +// } +// } +// foreach (string fil in Directory.GetFiles(rpath)) +// { +// string name = System.IO.Path.GetFileName(fil); +// ItemFile(sh, name, sh.GetRemotePath(path + name), fil); +// } +// } +// catch (Exception e) +// { +// Error(e); +// } +// Footer(); +// } - private void Download(WShared sh, string path) - { - string rpath = sh.GetLocalPath(path); - string name = System.IO.Path.GetFileName(rpath); - try - { - using (FileStream fs = new FileStream(rpath, FileMode.Open, FileAccess.Read)) - { - //Response.Headers["Content-Disposition"] = "attachment; filename=\"" + name + "\""; - BinaryOut(fs, Win32.GetMimeType(name)); - } - } - catch (Exception e) - { - Header(sh.Name, sh, path.Split('/')); - Error(e); - Footer(); - } - } +// private void Download(WShared sh, string path) +// { +// string rpath = sh.GetLocalPath(path); +// string name = System.IO.Path.GetFileName(rpath); +// try +// { +// using (FileStream fs = new FileStream(rpath, FileMode.Open, FileAccess.Read)) +// { +// //Response.Headers["Content-Disposition"] = "attachment; filename=\"" + name + "\""; +// BinaryOut(fs, Win32.GetMimeType(name)); +// } +// } +// catch (Exception e) +// { +// Header(sh.Name, sh, path.Split('/')); +// Error(e); +// Footer(); +// } +// } - #region Action Pages - private const string RESETURL = ""; +// #region Action Pages +// private const string RESETURL = ""; - private void PageRename(WShared sh, string path) - { - Header(sh.Name, sh, path.Split('/')); - if (!sh.AllowRename) - Error("Forbidden", "Renaming is not allowed on this site"); - else - { - string oname = System.IO.Path.GetFileName(path); - string acode = WebXplorer.CreateACode("R" + path); - Out.Write("
"); - Out.Write(""); - Out.Write(""); - Out.Write("Renaming file: "); - Out.Write(oname); - Out.Write("
Enter new name:
"); - Out.Write("
"); - } - Footer(); - } +// private void PageRename(WShared sh, string path) +// { +// Header(sh.Name, sh, path.Split('/')); +// if (!sh.AllowRename) +// Error("Forbidden", "Renaming is not allowed on this site"); +// else +// { +// string oname = System.IO.Path.GetFileName(path); +// string acode = WebXplorer.CreateACode("R" + path); +// Out.Write("
"); +// Out.Write(""); +// Out.Write(""); +// Out.Write("Renaming file: "); +// Out.Write(oname); +// Out.Write("
Enter new name:
"); +// Out.Write("
"); +// } +// Footer(); +// } - private void PageRenameDo(WShared sh, string path) - { - Header(sh.Name, sh, path.Split('/')); - if (!sh.AllowRename) - Error("Forbidden", "Renaming is not allowed on this site"); - else if (!WebXplorer.CheckACode("R" + path, GET["acode"])) - Error("Auth code error", RESETURL); - else - { - string dir = System.IO.Path.GetDirectoryName(path); - if (!dir.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && !(dir.Length == 0)) - dir += System.IO.Path.DirectorySeparatorChar; - string oname = System.IO.Path.GetFileName(path); - string nname = GET["newname"]; - if (oname != nname) - if (nname.Contains("/") || nname.Contains("\\") || nname.Contains(":")) - Error("New File error", "Path separator char not allowed as file name"); - else - try - { - File.Move(path, dir + nname); - Out.WriteLine(RESETURL); - } - catch (Exception e) - { - Error(e); - } - } - Footer(); - } +// private void PageRenameDo(WShared sh, string path) +// { +// Header(sh.Name, sh, path.Split('/')); +// if (!sh.AllowRename) +// Error("Forbidden", "Renaming is not allowed on this site"); +// else if (!WebXplorer.CheckACode("R" + path, GET["acode"])) +// Error("Auth code error", RESETURL); +// else +// { +// string dir = System.IO.Path.GetDirectoryName(path); +// if (!dir.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && !(dir.Length == 0)) +// dir += System.IO.Path.DirectorySeparatorChar; +// string oname = System.IO.Path.GetFileName(path); +// string nname = GET["newname"]; +// if (oname != nname) +// if (nname.Contains("/") || nname.Contains("\\") || nname.Contains(":")) +// Error("New File error", "Path separator char not allowed as file name"); +// else +// try +// { +// File.Move(path, dir + nname); +// Out.WriteLine(RESETURL); +// } +// catch (Exception e) +// { +// Error(e); +// } +// } +// Footer(); +// } - private void PageExecute(WShared sh, string path) - { - Header(sh.Name, sh, path.Split('/')); - if (!sh.AllowExecution) - Error("Forbidden", "Remote execution is not allowed on this site"); - else - { - try - { - System.Diagnostics.Process.Start(path); - Out.WriteLine(RESETURL); - } - catch (Exception e) - { - Error(e); - } - } - Footer(); - } +// private void PageExecute(WShared sh, string path) +// { +// Header(sh.Name, sh, path.Split('/')); +// if (!sh.AllowExecution) +// Error("Forbidden", "Remote execution is not allowed on this site"); +// else +// { +// try +// { +// System.Diagnostics.Process.Start(path); +// Out.WriteLine(RESETURL); +// } +// catch (Exception e) +// { +// Error(e); +// } +// } +// Footer(); +// } - private void PageDelete(WShared sh, string path) - { - Header(sh.Name, sh, path.Split('/')); - if (!sh.AllowDeletion) - Error("Forbidden", "Deletion is not allowed on this site"); - else - { - string oname = System.IO.Path.GetFileName(path); - string acode = WebXplorer.CreateACode("D" + path); - Out.Write("
"); - Out.Write(""); - Out.Write(""); - Out.Write("Delete file "); - Out.Write(oname); - Out.Write("?
"); - Out.Write("
"); - } - Footer(); - } +// private void PageDelete(WShared sh, string path) +// { +// Header(sh.Name, sh, path.Split('/')); +// if (!sh.AllowDeletion) +// Error("Forbidden", "Deletion is not allowed on this site"); +// else +// { +// string oname = System.IO.Path.GetFileName(path); +// string acode = WebXplorer.CreateACode("D" + path); +// Out.Write("
"); +// Out.Write(""); +// Out.Write(""); +// Out.Write("Delete file "); +// Out.Write(oname); +// Out.Write("?
"); +// Out.Write("
"); +// } +// Footer(); +// } - private void PageDeleteDo(WShared sh, string path) - { - Header(sh.Name, sh, path.Split('/')); - if (!sh.AllowDeletion) - Error("Forbidden", "Deletion is not allowed on this site"); - else if (!WebXplorer.CheckACode("D" + path, GET["acode"])) - Error("Auth code error", RESETURL); - else - { - try - { - File.Delete(sh.GetLocalPath(path)); - Out.WriteLine(RESETURL); - } - catch (Exception e) - { - Error(e); - } - } - Footer(); - } +// private void PageDeleteDo(WShared sh, string path) +// { +// Header(sh.Name, sh, path.Split('/')); +// if (!sh.AllowDeletion) +// Error("Forbidden", "Deletion is not allowed on this site"); +// else if (!WebXplorer.CheckACode("D" + path, GET["acode"])) +// Error("Auth code error", RESETURL); +// else +// { +// try +// { +// File.Delete(sh.GetLocalPath(path)); +// Out.WriteLine(RESETURL); +// } +// catch (Exception e) +// { +// Error(e); +// } +// } +// Footer(); +// } - private void PageCreateFolder(WShared sh, string path) - { - Header(sh.Name, sh, path.Split('/')); - if (!sh.AllowNewFolder) - Error("Forbidden", "Folder creation is not allowed on this site"); - else - { - string oname = System.IO.Path.GetFileName(path); - string acode = WebXplorer.CreateACode("C" + path); - Out.Write("
"); - Out.Write(""); - Out.Write(""); - Out.Write("Create Directory: "); - Out.Write("
Enter new name:
"); - Out.Write("
"); - } - Footer(); - } +// private void PageCreateFolder(WShared sh, string path) +// { +// Header(sh.Name, sh, path.Split('/')); +// if (!sh.AllowNewFolder) +// Error("Forbidden", "Folder creation is not allowed on this site"); +// else +// { +// string oname = System.IO.Path.GetFileName(path); +// string acode = WebXplorer.CreateACode("C" + path); +// Out.Write("
"); +// Out.Write(""); +// Out.Write(""); +// Out.Write("Create Directory: "); +// Out.Write("
Enter new name:
"); +// Out.Write("
"); +// } +// Footer(); +// } - private void PageCreateFolderDo(WShared sh, string path) - { - Header(sh.Name, sh, path.Split('/')); - if (!sh.AllowNewFolder) - Error("Forbidden", "Folder creation is not allowed on this site"); - else if (!WebXplorer.CheckACode("C" + path, GET["acode"])) - Error("Auth code error", RESETURL); - else - { - string dname = GET["dirname"]; - if (dname.Contains("/") || dname.Contains("\\") || dname.Contains(":")) - Error("Create directory error", "Path separator char not allowed as file name"); - string dir = path.Replace('/', System.IO.Path.DirectorySeparatorChar); - if (!dir.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && !(dir.Length == 0)) - dir += System.IO.Path.DirectorySeparatorChar; - try - { - Directory.CreateDirectory(sh.GetLocalPath(dir + dname)); - Out.WriteLine(RESETURL); - } - catch (Exception e) - { - Error(e); - } - } - Footer(); - } +// private void PageCreateFolderDo(WShared sh, string path) +// { +// Header(sh.Name, sh, path.Split('/')); +// if (!sh.AllowNewFolder) +// Error("Forbidden", "Folder creation is not allowed on this site"); +// else if (!WebXplorer.CheckACode("C" + path, GET["acode"])) +// Error("Auth code error", RESETURL); +// else +// { +// string dname = GET["dirname"]; +// if (dname.Contains("/") || dname.Contains("\\") || dname.Contains(":")) +// Error("Create directory error", "Path separator char not allowed as file name"); +// string dir = path.Replace('/', System.IO.Path.DirectorySeparatorChar); +// if (!dir.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) && !(dir.Length == 0)) +// dir += System.IO.Path.DirectorySeparatorChar; +// try +// { +// Directory.CreateDirectory(sh.GetLocalPath(dir + dname)); +// Out.WriteLine(RESETURL); +// } +// catch (Exception e) +// { +// Error(e); +// } +// } +// Footer(); +// } - private void PageUpload(WShared sh, string path) - { - Header(sh.Name, sh, path.Split('/')); - if (!sh.AllowUpload) - Error("Forbidden", "File upload is not allowed on this site"); - else - { - string oname = System.IO.Path.GetFileName(path); - string acode = WebXplorer.CreateACode("U" + path); - Out.Write("
"); - Out.Write(""); - Out.Write("Upload file: "); - Out.Write("
"); - Out.Write("
"); - } - Footer(); - } +// private void PageUpload(WShared sh, string path) +// { +// Header(sh.Name, sh, path.Split('/')); +// if (!sh.AllowUpload) +// Error("Forbidden", "File upload is not allowed on this site"); +// else +// { +// string oname = System.IO.Path.GetFileName(path); +// string acode = WebXplorer.CreateACode("U" + path); +// Out.Write("
"); +// Out.Write(""); +// Out.Write("Upload file: "); +// Out.Write("
"); +// Out.Write("
"); +// } +// Footer(); +// } - private void PageUploadDo(WShared sh, string path) - { - Header(sh.Name, sh, path.Split('/')); - if (!sh.AllowUpload) - Error("Forbidden", "File upload is not allowed on this site"); - else if (!WebXplorer.CheckACode("U" + path, GET["acode"])) - Error("Auth code error", RESETURL); - else if (Post == null) - Error("Communication error", "Error uploading file"); - else - { - HttpPostFile file = Post.File["file"]; - string fname = file.Filename; - string dir = path.Replace('/', System.IO.Path.DirectorySeparatorChar); - string dest = sh.GetLocalPath(dir + file.Filename); - if (File.Exists(dest)) - Error("Upload error", "Destination file exists, rename file before upload. Or delete destination if you have rights."); - else try - { - File.WriteAllBytes(dest, file.Data); - Out.WriteLine(RESETURL); - } - catch (Exception e) - { - Error(e); - } - } - Footer(); - } - #endregion +// private void PageUploadDo(WShared sh, string path) +// { +// Header(sh.Name, sh, path.Split('/')); +// if (!sh.AllowUpload) +// Error("Forbidden", "File upload is not allowed on this site"); +// else if (!WebXplorer.CheckACode("U" + path, GET["acode"])) +// Error("Auth code error", RESETURL); +// else if (Post == null) +// Error("Communication error", "Error uploading file"); +// else +// { +// HttpPostFile file = Post.File["file"]; +// string fname = file.Filename; +// string dir = path.Replace('/', System.IO.Path.DirectorySeparatorChar); +// string dest = sh.GetLocalPath(dir + file.Filename); +// if (File.Exists(dest)) +// Error("Upload error", "Destination file exists, rename file before upload. Or delete destination if you have rights."); +// else try +// { +// File.WriteAllBytes(dest, file.Data); +// Out.WriteLine(RESETURL); +// } +// catch (Exception e) +// { +// Error(e); +// } +// } +// Footer(); +// } +// #endregion - private void BlackHeader(string title, string script) - { - Out.Write("Sunfish ["); - Out.Write(title); - Out.Write("]"); - if (script != null) - { - Out.Write(""); - } - Out.Write("
"); - } +// private void BlackHeader(string title, string script) +// { +// Out.Write("Sunfish ["); +// Out.Write(title); +// Out.Write("]"); +// if (script != null) +// { +// Out.Write(""); +// } +// Out.Write("
"); +// } - private void BlackFooter() - { - Out.Write("
"); - } +// private void BlackFooter() +// { +// Out.Write("
"); +// } - private void Header(string title, WShared sh, string[] path) - { - Out.Write("Sunfish ["); - Out.Write(title); - Out.Write("]
"); - } +// private void Header(string title, WShared sh, string[] path) +// { +// Out.Write("Sunfish ["); +// Out.Write(title); +// Out.Write("]
"); +// } - private void Footer() - { - Out.Write("
"); - } +// private void Footer() +// { +// Out.Write("
"); +// } - private string UEnc(string url) - { - return url == null ? null : url.Replace("#", "|1"); - } +// private string UEnc(string url) +// { +// return url == null ? null : url.Replace("#", "|1"); +// } - private string UDec(string url) - { - return url == null ? null : url.Replace("|1", "#"); - } +// private string UDec(string url) +// { +// return url == null ? null : url.Replace("|1", "#"); +// } - private void ItemDirectory(WShared sh, string name, string path) - { - ItemBegin(path, null, name, "Directory"); - if (sh != null) - { - if (sh.AllowExecution) - ItemTool(path, "REN", "Rename folder", "rename"); - if (sh.AllowDeletion) - ItemTool(path, "DEL", "Delete folder", "t_delete"); - } - ItemEnd(); - } +// private void ItemDirectory(WShared sh, string name, string path) +// { +// ItemBegin(path, null, name, "Directory"); +// if (sh != null) +// { +// if (sh.AllowExecution) +// ItemTool(path, "REN", "Rename folder", "rename"); +// if (sh.AllowDeletion) +// ItemTool(path, "DEL", "Delete folder", "t_delete"); +// } +// ItemEnd(); +// } - private void ItemFile(WShared sh, string name, string path, string realpath) - { - FileInfo f = new FileInfo(realpath); - ItemBegin(path, "?Action=GET", name, FBytes(f.Length)); - if (sh != null) - { - if (sh.AllowExecution) - ItemTool(path, "RUN", "Execute on server", "t_execute"); - if (sh.AllowExecution) - ItemTool(path, "REN", "Rename file", "rename"); - if (sh.AllowDeletion) - ItemTool(path, "DEL", "Delete file", "t_delete"); - } - ItemEnd(); - } +// private void ItemFile(WShared sh, string name, string path, string realpath) +// { +// FileInfo f = new FileInfo(realpath); +// ItemBegin(path, "?Action=GET", name, FBytes(f.Length)); +// if (sh != null) +// { +// if (sh.AllowExecution) +// ItemTool(path, "RUN", "Execute on server", "t_execute"); +// if (sh.AllowExecution) +// ItemTool(path, "REN", "Rename file", "rename"); +// if (sh.AllowDeletion) +// ItemTool(path, "DEL", "Delete file", "t_delete"); +// } +// ItemEnd(); +// } - private void ItemBegin(string path, string param, string name, string info) - { - Out.Write("
"); - Out.Write(info); - Out.Write("
"); - Out.Write("
"); - } +// private void ItemBegin(string path, string param, string name, string info) +// { +// Out.Write("
"); +// Out.Write(info); +// Out.Write("
"); +// Out.Write("
"); +// } - private void ItemTool(string path, string action, string title, string icon) - { - Out.Write(""); - } +// private void ItemTool(string path, string action, string title, string icon) +// { +// Out.Write(""); +// } - private void ItemEnd() - { - Out.Write("
"); - Out.Write("
"); - } +// private void ItemEnd() +// { +// Out.Write("
"); +// Out.Write("
"); +// } - private string FBytes(double lng) - { - string[] tail = { " bytes", "Kb", "Mb", "Gb", "Tb", "Pb", "Yb" }; - int taili = 0; - while (lng > 1024) - { - lng /= 1024; - taili++; - } - return lng.ToString("#0.00") + (taili >= tail.Length ? "^b" : tail[taili]); - } +// private string FBytes(double lng) +// { +// string[] tail = { " bytes", "Kb", "Mb", "Gb", "Tb", "Pb", "Yb" }; +// int taili = 0; +// while (lng > 1024) +// { +// lng /= 1024; +// taili++; +// } +// return lng.ToString("#0.00") + (taili >= tail.Length ? "^b" : tail[taili]); +// } - private void Error(Exception e) - { - Error(e.GetType().Name, e.Message.Replace("\n", "
")); - } +// private void Error(Exception e) +// { +// Error(e.GetType().Name, e.Message.Replace("\n", "
")); +// } - private void Error(string title, string message) - { - Out.Write("
"); - Out.Write(title); - Out.Write("
"); - Out.Write(message); - Out.Write("
"); - } - } -} +// private void Error(string title, string message) +// { +// Out.Write("
"); +// Out.Write(title); +// Out.Write("
"); +// Out.Write(message); +// Out.Write("
"); +// } +// } +//}