diff --git a/Sunfish/Sunfish/FShared.Designer.cs b/Sunfish/Sunfish/FShared.Designer.cs index d621e3d..c702123 100644 --- a/Sunfish/Sunfish/FShared.Designer.cs +++ b/Sunfish/Sunfish/FShared.Designer.cs @@ -104,7 +104,6 @@ // cbUpl // this.cbUpl.AutoSize = true; - this.cbUpl.Enabled = false; this.cbUpl.Location = new System.Drawing.Point(15, 114); this.cbUpl.Name = "cbUpl"; this.cbUpl.Size = new System.Drawing.Size(91, 17); diff --git a/Sunfish/Sunfish/Form1.Designer.cs b/Sunfish/Sunfish/Form1.Designer.cs index 2cc8edd..e2388c7 100644 --- a/Sunfish/Sunfish/Form1.Designer.cs +++ b/Sunfish/Sunfish/Form1.Designer.cs @@ -45,6 +45,9 @@ this.cmsGOptions = new System.Windows.Forms.ContextMenuStrip(this.components); this.shareScreenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.tstbPassword = new System.Windows.Forms.ToolStripTextBox(); + this.añadirToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.borrarToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); ((System.ComponentModel.ISupportInitialize)(this.nudPort)).BeginInit(); this.cmsItem.SuspendLayout(); this.cmsGOptions.SuspendLayout(); @@ -152,16 +155,19 @@ // cmsItem // this.cmsItem.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.editarToolStripMenuItem}); + this.añadirToolStripMenuItem, + this.editarToolStripMenuItem, + this.borrarToolStripMenuItem, + this.toolStripSeparator1}); this.cmsItem.Name = "cmsItem"; - this.cmsItem.Size = new System.Drawing.Size(107, 26); + this.cmsItem.Size = new System.Drawing.Size(153, 98); this.cmsItem.Opening += new System.ComponentModel.CancelEventHandler(this.cmsItem_Opening); // // editarToolStripMenuItem // this.editarToolStripMenuItem.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold); this.editarToolStripMenuItem.Name = "editarToolStripMenuItem"; - this.editarToolStripMenuItem.Size = new System.Drawing.Size(106, 22); + this.editarToolStripMenuItem.Size = new System.Drawing.Size(152, 22); this.editarToolStripMenuItem.Text = "Editar"; // // btShowIp @@ -195,14 +201,14 @@ this.cmsGOptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.shareScreenToolStripMenuItem}); this.cmsGOptions.Name = "cmsGOptions"; - this.cmsGOptions.Size = new System.Drawing.Size(153, 48); + this.cmsGOptions.Size = new System.Drawing.Size(142, 26); // // shareScreenToolStripMenuItem // this.shareScreenToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.tstbPassword}); this.shareScreenToolStripMenuItem.Name = "shareScreenToolStripMenuItem"; - this.shareScreenToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.shareScreenToolStripMenuItem.Size = new System.Drawing.Size(141, 22); this.shareScreenToolStripMenuItem.Text = "Share Screen"; this.shareScreenToolStripMenuItem.Click += new System.EventHandler(this.shareScreenToolStripMenuItem_Click); // @@ -214,6 +220,27 @@ this.tstbPassword.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tstbPassword_KeyPress); this.tstbPassword.TextChanged += new System.EventHandler(this.tstbPassword_TextChanged); // + // añadirToolStripMenuItem + // + this.añadirToolStripMenuItem.Name = "añadirToolStripMenuItem"; + this.añadirToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Insert; + this.añadirToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.añadirToolStripMenuItem.Text = "Añadir"; + this.añadirToolStripMenuItem.Click += new System.EventHandler(this.btAdd_Click); + // + // borrarToolStripMenuItem + // + this.borrarToolStripMenuItem.Name = "borrarToolStripMenuItem"; + this.borrarToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Delete; + this.borrarToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.borrarToolStripMenuItem.Text = "Borrar"; + this.borrarToolStripMenuItem.Click += new System.EventHandler(this.btSub_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(149, 6); + // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -259,6 +286,9 @@ private System.Windows.Forms.ContextMenuStrip cmsGOptions; private System.Windows.Forms.ToolStripMenuItem shareScreenToolStripMenuItem; private System.Windows.Forms.ToolStripTextBox tstbPassword; + private System.Windows.Forms.ToolStripMenuItem añadirToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem borrarToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; } } diff --git a/Sunfish/Sunfish/Form1.cs b/Sunfish/Sunfish/Form1.cs index 325716a..36c531d 100644 --- a/Sunfish/Sunfish/Form1.cs +++ b/Sunfish/Sunfish/Form1.cs @@ -91,7 +91,17 @@ private void btAdd_Click(object sender, EventArgs e) { - WShared sh = new WShared("NewShared",@"C:\"); + WShared sh; + string clip = Clipboard.GetText(); + if ((Path.DirectorySeparatorChar == '/' ? clip.Length > 0 && clip[0] == '/' : clip.Length > 2 && clip[1] == ':' && clip[2] == '\\') + && (Directory.Exists(clip) || File.Exists(clip))) + { + if (File.Exists(clip)) + clip = Path.GetDirectoryName(clip); + sh = new WShared(Path.GetFileName(clip), clip); + } + else + sh = new WShared("NewShared", @"C:\"); sh.Enabled = true; if (FShared.Execute(sh)) { @@ -162,14 +172,19 @@ sb.Append(WebXplorer.Port); sb.Append("\r\n"); } - MessageBox.Show(sb.ToString(),"Network information",MessageBoxButtons.OK,MessageBoxIcon.Information); + sb.Append("\r\nSunfish "); + sb.Append(Program.VERSION); + sb.Append(" (C) XWolfOverride@gmail.com 2007-2015\r\nEasy folder shares"); + MessageBox.Show(sb.ToString(),"Sunfish information",MessageBoxButtons.OK,MessageBoxIcon.Information); } private void cmsItem_Opening(object sender, CancelEventArgs e) { WShared sh = lbPaths.SelectedItem as WShared; editarToolStripMenuItem.Enabled = sh != null; - while (cmsItem.Items.Count > 1) + borrarToolStripMenuItem.Enabled = sh != null; + toolStripSeparator1.Visible = sh != null; + while (cmsItem.Items.Count > 4) cmsItem.Items.RemoveAt(cmsItem.Items.Count - 1); if (sh == null) return; diff --git a/Sunfish/Sunfish/Form1.resx b/Sunfish/Sunfish/Form1.resx index 97ae20d..d533893 100644 --- a/Sunfish/Sunfish/Form1.resx +++ b/Sunfish/Sunfish/Form1.resx @@ -128,7 +128,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAq - AQAAAk1TRnQBSQFMAgEBAgEAAUABAAFAAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA + AQAAAk1TRnQBSQFMAgEBAgEAAUgBAAFIAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA AwABEAMAAQEBAAEEBgABAhgAAYACAAGAAwACgAEAAYADAAGAAQABgAEAAoACAAPAAQADgAMAAf8CAAH/ AwAC/wEAAf8DAAH/AQAB/wEAAv8CAAP//wD/AAMAAUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEB BQABgBcAA/8BAAT/BAAE/wQABP8EAAH8AT8C/wQAAfwBPwL/BAAB/AE/Av8EAAHgAQcB4AEHBAAB4AEH @@ -136,6 +136,9 @@ BAAL + + 17, 17 + 185, 17 diff --git a/Sunfish/Sunfish/HttpServer.cs b/Sunfish/Sunfish/HttpServer.cs index 4d5e3b2..00de905 100644 --- a/Sunfish/Sunfish/HttpServer.cs +++ b/Sunfish/Sunfish/HttpServer.cs @@ -459,16 +459,7 @@ return result; } - //private void ReadToEnd(Stream input) - //{ - // byte[] buf = new byte[10240]; - // int readed = 0; - // using (FileStream output = new FileStream("Test POST", FileMode.Create, FileAccess.Write)) - // { - // while ((readed = input.Read(buf, 0, buf.Length)) > 0) - // output.Write(buf, 0, readed); - // } - //} + public Dictionary File { get { return files; } } } public class HttpPostFile diff --git a/Sunfish/Sunfish/Program.cs b/Sunfish/Sunfish/Program.cs index 49bb8e2..80754dc 100644 --- a/Sunfish/Sunfish/Program.cs +++ b/Sunfish/Sunfish/Program.cs @@ -8,7 +8,7 @@ { static class Program { - public static string VERSION = "0.9c"; + public static string VERSION = "0.9e"; private static Form1 mainform; /// /// Punto de entrada principal para la aplicación. diff --git a/Sunfish/Sunfish/Properties/Resources.Designer.cs b/Sunfish/Sunfish/Properties/Resources.Designer.cs index 2f70b7b..3795ac1 100644 --- a/Sunfish/Sunfish/Properties/Resources.Designer.cs +++ b/Sunfish/Sunfish/Properties/Resources.Designer.cs @@ -141,7 +141,24 @@ } /// - /// Looks up a localized string similar to . + /// Looks up a localized string similar to var shs = new (function () { + /// var xmlhttp = new XMLHttpRequest(); + /// var byId = function (name) { + /// return document.getElementById(name); + /// } + /// var sfifo = []; + /// var sending = false; + /// var send = function (code, cmd, important) { + /// if (sending) { + /// if (important) + /// sfifo.push(cmd); + /// return; + /// } + /// sending = true; + /// if (cmd == null) { + /// cmd = sfifo.shift(); + /// } + /// xmlhttp.open("GET", "$screencmd? [rest of string was truncated]";. /// internal static string ShScreen { get { @@ -207,11 +224,24 @@ /// ///div#main { /// background: #FFF; - /// box-shadow: 0 2px 5px #555; - /// border: 1px solid #000; + /// box-shadow: 0 2px 7px #999; + /// border: 0px; + /// border-radius:4px; /// font-family:verdana; /// font-size:12px; /// padding:0; + /// overflow:hidden; + ///} + /// + ///div#frm { + /// padding:10px; + ///} + /// + ///img#scr { + ////* + /// max-width:100%; + /// max-height:100%; + ///*/ ///}. /// internal static string siteblack { @@ -259,5 +289,15 @@ return ((System.Drawing.Bitmap)(obj)); } } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap upload { + get { + object obj = ResourceManager.GetObject("upload", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } } } diff --git a/Sunfish/Sunfish/Properties/Resources.resx b/Sunfish/Sunfish/Properties/Resources.resx index cc1723a..94b3f21 100644 --- a/Sunfish/Sunfish/Properties/Resources.resx +++ b/Sunfish/Sunfish/Properties/Resources.resx @@ -163,4 +163,7 @@ ..\Resources\ShScreen.js;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + ..\Resources\upload.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/Sunfish/Sunfish/Resources/upload.png b/Sunfish/Sunfish/Resources/upload.png new file mode 100644 index 0000000..5b34e06 --- /dev/null +++ b/Sunfish/Sunfish/Resources/upload.png Binary files differ diff --git a/Sunfish/Sunfish/Sunfish.csproj b/Sunfish/Sunfish/Sunfish.csproj index 352b74f..3401ffc 100644 --- a/Sunfish/Sunfish/Sunfish.csproj +++ b/Sunfish/Sunfish/Sunfish.csproj @@ -160,6 +160,7 @@ + diff --git a/Sunfish/Sunfish/wx/WebXplorer.cs b/Sunfish/Sunfish/wx/WebXplorer.cs index 34b4e7d..a8a41a3 100644 --- a/Sunfish/Sunfish/wx/WebXplorer.cs +++ b/Sunfish/Sunfish/wx/WebXplorer.cs @@ -27,6 +27,7 @@ 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; @@ -47,6 +48,7 @@ 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(); @@ -124,7 +126,7 @@ YN[true] = "Y"; YN[false] = "N"; List data = new List(); - data.Add("#Sunfish WebXplorer V" + Program.VERSION + " (The new Dolphin WebXplorer) (C) XWolf 2014-2015"); + 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]); @@ -283,6 +285,12 @@ case "MKDDO": PageCreateFolderDo(sh, rpath); break; + case "UPL": + PageUpload(sh, rpath); + break; + case "UPLDO": + PageUploadDo(sh, rpath); + break; } } else @@ -318,6 +326,9 @@ 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; @@ -514,6 +525,7 @@ { 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) @@ -595,6 +607,8 @@ } } + private const string RESETURL=""; + private void PageRename(WShared sh, string path) { Header(sh.Name, sh, path.Split('/')); @@ -625,7 +639,7 @@ if (!sh.AllowRename) Error("Forbidden", "Renaming is not allowed on this site"); else if (!WebXplorer.CheckACode("R" + path,GET["acode"])) - Error("Auth code error", ""); + Error("Auth code error", RESETURL); else { string dir = System.IO.Path.GetDirectoryName(path); @@ -640,7 +654,7 @@ try { File.Move(path, dir + nname); - Out.WriteLine(""); + Out.WriteLine(RESETURL); } catch (Exception e) { @@ -660,7 +674,7 @@ try { System.Diagnostics.Process.Start(path); - Out.WriteLine(""); + Out.WriteLine(RESETURL); } catch (Exception e) { @@ -698,13 +712,13 @@ if (!sh.AllowDeletion) Error("Forbidden", "Deletion is not allowed on this site"); else if (!WebXplorer.CheckACode("D" + path, GET["acode"])) - Error("Auth code error", ""); + Error("Auth code error", RESETURL); else { try { File.Delete(sh.GetLocalPath(path)); - Out.WriteLine(""); + Out.WriteLine(RESETURL); } catch (Exception e) { @@ -743,7 +757,7 @@ 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", ""); + Error("Auth code error", RESETURL); else { string dname = GET["dirname"]; @@ -755,7 +769,7 @@ try { Directory.CreateDirectory(sh.GetLocalPath(dir + dname)); - Out.WriteLine(""); + Out.WriteLine(RESETURL); } catch (Exception e) { @@ -765,6 +779,56 @@ 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(); + } + private void BlackHeader(string title, string script) { Out.Write("Sunfish ["); @@ -822,6 +886,8 @@ } Out.Write(""); Out.Write(""); + if (sh != null && sh.AllowUpload) + Out.Write(""); if (sh != null && sh.AllowNewFolder) Out.Write(""); if (WebXplorer.SharedScreen)