diff --git a/Sunfish/Sunfish/FShared.Designer.cs b/Sunfish/Sunfish/FShared.Designer.cs index a40fc3f..d621e3d 100644 --- a/Sunfish/Sunfish/FShared.Designer.cs +++ b/Sunfish/Sunfish/FShared.Designer.cs @@ -41,6 +41,7 @@ this.cbExec = new System.Windows.Forms.CheckBox(); this.btOpen = new System.Windows.Forms.Button(); this.cbMkDir = new System.Windows.Forms.CheckBox(); + this.cbThumbnails = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // label1 @@ -114,7 +115,7 @@ // btOk // this.btOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btOk.Location = new System.Drawing.Point(316, 140); + this.btOk.Location = new System.Drawing.Point(316, 162); this.btOk.Name = "btOk"; this.btOk.Size = new System.Drawing.Size(75, 23); this.btOk.TabIndex = 7; @@ -155,7 +156,7 @@ // btOpen // this.btOpen.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btOpen.Location = new System.Drawing.Point(207, 140); + this.btOpen.Location = new System.Drawing.Point(207, 162); this.btOpen.Name = "btOpen"; this.btOpen.Size = new System.Drawing.Size(103, 23); this.btOpen.TabIndex = 11; @@ -173,12 +174,23 @@ this.cbMkDir.Text = "Allow create folders"; this.cbMkDir.UseVisualStyleBackColor = true; // + // cbThumbnails + // + this.cbThumbnails.AutoSize = true; + this.cbThumbnails.Location = new System.Drawing.Point(170, 137); + this.cbThumbnails.Name = "cbThumbnails"; + this.cbThumbnails.Size = new System.Drawing.Size(200, 17); + this.cbThumbnails.TabIndex = 13; + this.cbThumbnails.Text = "Send image previews on icons (slow)"; + this.cbThumbnails.UseVisualStyleBackColor = true; + // // FShared // this.AcceptButton = this.btOk; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(403, 175); + this.ClientSize = new System.Drawing.Size(403, 197); + this.Controls.Add(this.cbThumbnails); this.Controls.Add(this.cbMkDir); this.Controls.Add(this.btOpen); this.Controls.Add(this.cbExec); @@ -217,5 +229,6 @@ private System.Windows.Forms.CheckBox cbExec; private System.Windows.Forms.Button btOpen; private System.Windows.Forms.CheckBox cbMkDir; + private System.Windows.Forms.CheckBox cbThumbnails; } } \ No newline at end of file diff --git a/Sunfish/Sunfish/FShared.cs b/Sunfish/Sunfish/FShared.cs index e2486e2..9df5787 100644 --- a/Sunfish/Sunfish/FShared.cs +++ b/Sunfish/Sunfish/FShared.cs @@ -31,6 +31,7 @@ f.cbRena.DataBindings.Add("Checked", sh, "AllowRename"); f.cbExec.DataBindings.Add("Checked", sh, "AllowExecution"); f.cbMkDir.DataBindings.Add("Checked", sh, "AllowNewFolder"); + f.cbThumbnails.DataBindings.Add("Checked", sh, "SendThumbnails"); f.formerName = sh.Name; f.btOpen.Visible=WebXplorer.Contains(sh); return f.ShowDialog() == DialogResult.OK; diff --git a/Sunfish/Sunfish/Form1.Designer.cs b/Sunfish/Sunfish/Form1.Designer.cs index a40868a..18be0fa 100644 --- a/Sunfish/Sunfish/Form1.Designer.cs +++ b/Sunfish/Sunfish/Form1.Designer.cs @@ -37,10 +37,17 @@ this.il16 = new System.Windows.Forms.ImageList(this.components); this.btSub = new System.Windows.Forms.Button(); this.lbPaths = new System.Windows.Forms.ListBox(); + this.cmsItem = new System.Windows.Forms.ContextMenuStrip(this.components); + this.editarToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.btShowIp = new System.Windows.Forms.Button(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.btGeneralOptions = new System.Windows.Forms.Button(); + this.cmsGOptions = new System.Windows.Forms.ContextMenuStrip(this.components); + this.shareScreenToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.tstbPassword = new System.Windows.Forms.ToolStripTextBox(); ((System.ComponentModel.ISupportInitialize)(this.nudPort)).BeginInit(); + this.cmsItem.SuspendLayout(); + this.cmsGOptions.SuspendLayout(); this.SuspendLayout(); // // button1 @@ -129,6 +136,7 @@ this.lbPaths.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.lbPaths.ContextMenuStrip = this.cmsItem; this.lbPaths.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed; this.lbPaths.FormattingEnabled = true; this.lbPaths.IntegralHeight = false; @@ -141,6 +149,21 @@ this.lbPaths.SelectedIndexChanged += new System.EventHandler(this.lbPaths_SelectedIndexChanged); this.lbPaths.DoubleClick += new System.EventHandler(this.clbPaths_DoubleClick); // + // cmsItem + // + this.cmsItem.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.editarToolStripMenuItem}); + this.cmsItem.Name = "cmsItem"; + this.cmsItem.Size = new System.Drawing.Size(107, 26); + 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.Text = "Editar"; + // // btShowIp // this.btShowIp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); @@ -165,6 +188,31 @@ this.btGeneralOptions.TabIndex = 9; this.toolTip1.SetToolTip(this.btGeneralOptions, "General Options"); this.btGeneralOptions.UseVisualStyleBackColor = true; + this.btGeneralOptions.Click += new System.EventHandler(this.btGeneralOptions_Click); + // + // cmsGOptions + // + this.cmsGOptions.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.shareScreenToolStripMenuItem}); + this.cmsGOptions.Name = "cmsGOptions"; + this.cmsGOptions.Size = new System.Drawing.Size(153, 48); + // + // 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.Text = "Share Screen"; + this.shareScreenToolStripMenuItem.Click += new System.EventHandler(this.shareScreenToolStripMenuItem_Click); + // + // tstbPassword + // + this.tstbPassword.Name = "tstbPassword"; + this.tstbPassword.Size = new System.Drawing.Size(100, 23); + this.tstbPassword.ToolTipText = "Password"; + this.tstbPassword.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tstbPassword_KeyPress); + this.tstbPassword.TextChanged += new System.EventHandler(this.tstbPassword_TextChanged); // // Form1 // @@ -184,6 +232,8 @@ this.Text = "Sunfish"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed); ((System.ComponentModel.ISupportInitialize)(this.nudPort)).EndInit(); + this.cmsItem.ResumeLayout(false); + this.cmsGOptions.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -201,6 +251,11 @@ private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ImageList il16; private System.Windows.Forms.Button btGeneralOptions; + private System.Windows.Forms.ContextMenuStrip cmsItem; + private System.Windows.Forms.ToolStripMenuItem editarToolStripMenuItem; + private System.Windows.Forms.ContextMenuStrip cmsGOptions; + private System.Windows.Forms.ToolStripMenuItem shareScreenToolStripMenuItem; + private System.Windows.Forms.ToolStripTextBox tstbPassword; } } diff --git a/Sunfish/Sunfish/Form1.cs b/Sunfish/Sunfish/Form1.cs index 632fb32..ebdaa54 100644 --- a/Sunfish/Sunfish/Form1.cs +++ b/Sunfish/Sunfish/Form1.cs @@ -36,12 +36,25 @@ Enabled = false; nudPort.Value = WebXplorer.Port; cbActive.Checked=WebXplorer.Active; + shareScreenToolStripMenuItem.Checked = WebXplorer.SharedScreen; + tstbPassword.Text = WebXplorer.SharedScreenPassword; lbPaths.Items.Clear(); foreach (WShared sh in WebXplorer.Shares) lbPaths.Items.Add(sh); Enabled = true; } + private List ListInterfacesIPs() + { + List result = new List(); + foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces()) + if (item.NetworkInterfaceType != NetworkInterfaceType.Loopback && item.OperationalStatus == OperationalStatus.Up) + foreach (UnicastIPAddressInformation ip in item.GetIPProperties().UnicastAddresses) + if (ip.Address.AddressFamily == AddressFamily.InterNetwork) + result.Add(new IpInfo(item, ip.Address.ToString())); + return result; + } + private void button1_Click(object sender, EventArgs e) { WindowState = FormWindowState.Minimized; @@ -134,27 +147,63 @@ { StringBuilder sb = new StringBuilder(WebXplorer.Active?"A":"ina"); sb.Append("ctive.\r\n"); - foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces()) + foreach (IpInfo ip in ListInterfacesIPs()) { - if (item.NetworkInterfaceType != NetworkInterfaceType.Loopback && item.OperationalStatus == OperationalStatus.Up) - { - foreach (UnicastIPAddressInformation ip in item.GetIPProperties().UnicastAddresses) - { - if (ip.Address.AddressFamily == AddressFamily.InterNetwork) - { - sb.Append(item.Name); - sb.Append(" ("); - sb.Append(item.NetworkInterfaceType); - sb.Append("): "); - sb.Append(ip.Address.ToString()); - sb.Append(":"); - sb.Append(WebXplorer.Port); - sb.Append("\r\n"); - } - } - } + sb.Append(ip.InterfaceName); + sb.Append(" ("); + sb.Append(ip.InterfaceType); + sb.Append("): "); + sb.Append(ip.Address); + sb.Append(":"); + sb.Append(WebXplorer.Port); + sb.Append("\r\n"); } MessageBox.Show(sb.ToString(),"Network 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) + cmsItem.Items.RemoveAt(cmsItem.Items.Count - 1); + if (sh == null) + return; + foreach (IpInfo ip in ListInterfacesIPs()) + { + ToolStripItem tsi = cmsItem.Items.Add("Copy url for " + ip.Address + " (" + ip.InterfaceName + ", " + ip.InterfaceType + ")"); + tsi.Tag = "http://" + ip.Address + ":" + WebXplorer.Port + "/" + sh.Name + "/"; + tsi.Click += tsi_Click; + } + } + + void tsi_Click(object sender, EventArgs e) + { + ToolStripItem tsi = sender as ToolStripItem; + if (tsi == null) + return; + Clipboard.SetText(tsi.Tag.ToString()); + } + + private void btGeneralOptions_Click(object sender, EventArgs e) + { + cmsGOptions.Show(btGeneralOptions, new Point(0, btGeneralOptions.Height)); + } + + private void shareScreenToolStripMenuItem_Click(object sender, EventArgs e) + { + WebXplorer.SharedScreen = !WebXplorer.SharedScreen; + shareScreenToolStripMenuItem.Checked = WebXplorer.SharedScreen; + } + + private void tstbPassword_TextChanged(object sender, EventArgs e) + { + WebXplorer.SharedScreenPassword = tstbPassword.Text; + } + + private void tstbPassword_KeyPress(object sender, KeyPressEventArgs e) + { + e.KeyChar = char.ToLower(e.KeyChar); + } } } diff --git a/Sunfish/Sunfish/Form1.resx b/Sunfish/Sunfish/Form1.resx index 3a8b7aa..9a298c8 100644 --- a/Sunfish/Sunfish/Form1.resx +++ b/Sunfish/Sunfish/Form1.resx @@ -128,7 +128,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAq - AQAAAk1TRnQBSQFMAgEBAgEAARABAAEQAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA + AQAAAk1TRnQBSQFMAgEBAgEAASABAAEgAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA AwABEAMAAQEBAAEEBgABAhgAAYACAAGAAwACgAEAAYADAAGAAQABgAEAAoACAAPAAQADgAMAAf8CAAH/ AwAC/wEAAf8DAAH/AQAB/wEAAv8CAAP//wD/AAMAAUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEB BQABgBcAA/8BAAT/BAAE/wQABP8EAAH8AT8C/wQAAfwBPwL/BAAB/AE/Av8EAAHgAQcB4AEHBAAB4AEH @@ -136,4 +136,13 @@ BAAL + + 17, 17 + + + 185, 17 + + + 283, 17 + \ No newline at end of file diff --git a/Sunfish/Sunfish/HttpServer.cs b/Sunfish/Sunfish/HttpServer.cs index 23795ea..b569b18 100644 --- a/Sunfish/Sunfish/HttpServer.cs +++ b/Sunfish/Sunfish/HttpServer.cs @@ -145,6 +145,7 @@ swout = new StreamWriter(Response.OutputStream, utf8EncoderNoBOM); Response.Headers[HttpResponseHeader.ContentType] = "text/html"; Response.Headers[HttpResponseHeader.ContentEncoding] = "UTF-8"; + GetHeaders(); Process(); Out.Close(); diff --git a/Sunfish/Sunfish/IpInfo.cs b/Sunfish/Sunfish/IpInfo.cs new file mode 100644 index 0000000..f468d71 --- /dev/null +++ b/Sunfish/Sunfish/IpInfo.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.NetworkInformation; +using System.Text; + +namespace DolphinWebXplorer2 +{ + class IpInfo + { + private NetworkInterface iface; + private string ip; + + public IpInfo(NetworkInterface iface, string ip) + { + this.iface = iface; + this.ip = ip; + } + + public string InterfaceName { get { return iface.Name; } } + public NetworkInterfaceType InterfaceType { get { return iface.NetworkInterfaceType; } } + public string Address { get { return ip; } } + } +} diff --git a/Sunfish/Sunfish/Program.cs b/Sunfish/Sunfish/Program.cs index cc63df2..6c8f675 100644 --- a/Sunfish/Sunfish/Program.cs +++ b/Sunfish/Sunfish/Program.cs @@ -8,7 +8,7 @@ { static class Program { - public static string VERSION = "0.7c"; + public static string VERSION = "0.8"; /// /// 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 9d481ac..2f70b7b 100644 --- a/Sunfish/Sunfish/Properties/Resources.Designer.cs +++ b/Sunfish/Sunfish/Properties/Resources.Designer.cs @@ -141,6 +141,15 @@ } /// + /// Looks up a localized string similar to . + /// + internal static string ShScreen { + get { + return ResourceManager.GetString("ShScreen", resourceCulture); + } + } + + /// /// Looks up a localized string similar to html{ /// background:#BBBBBB; ///} @@ -179,6 +188,39 @@ } /// + /// Looks up a localized string similar to html{ + /// background: #222; + /// height: 100%; + ///} + /// + ///body{ + /// display: table; + /// margin: 0 auto; + /// height: 100%; + ///} + /// + ///div#ctt { + /// display: table-cell; + /// vertical-align: middle; + /// height: 100%; + ///} + /// + ///div#main { + /// background: #FFF; + /// box-shadow: 0 2px 5px #555; + /// border: 1px solid #000; + /// font-family:verdana; + /// font-size:12px; + /// padding:0; + ///}. + /// + internal static string siteblack { + get { + return ResourceManager.GetString("siteblack", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Icon similar to (Icon). /// internal static System.Drawing.Icon sunfishWebServer { diff --git a/Sunfish/Sunfish/Properties/Resources.resx b/Sunfish/Sunfish/Properties/Resources.resx index 783f4e4..cc1723a 100644 --- a/Sunfish/Sunfish/Properties/Resources.resx +++ b/Sunfish/Sunfish/Properties/Resources.resx @@ -119,7 +119,7 @@ - ..\resources\site.css;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + ..\resources\site.css;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;iso-8859-1 ..\Resources\sunfishWebServer.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -157,4 +157,10 @@ ..\Resources\share.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\site1.css;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + + + ..\Resources\ShScreen.js;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 + \ No newline at end of file diff --git a/Sunfish/Sunfish/Resources/ShScreen.js b/Sunfish/Sunfish/Resources/ShScreen.js new file mode 100644 index 0000000..9e8e7a0 --- /dev/null +++ b/Sunfish/Sunfish/Resources/ShScreen.js @@ -0,0 +1,15 @@ +var shs = new (function () { + var byId = function (name) { + return document.getElementById(name); + } + var frm; + var scr; + var code; + this.start = function () { + frm = byId("frm"); + scr = byId("scr"); + code = byId("scpwd").value; + frm.style.display = "none"; + scr.src = "/$screencap?code=" + code; + } +})(); \ No newline at end of file diff --git a/Sunfish/Sunfish/Resources/site1.css b/Sunfish/Sunfish/Resources/site1.css new file mode 100644 index 0000000..51c5a9e --- /dev/null +++ b/Sunfish/Sunfish/Resources/site1.css @@ -0,0 +1,35 @@ +html{ + background: #222; + height: 100%; +} + +body{ + display: table; + margin: 0 auto; + height: 100%; +} + +div#ctt { + display: table-cell; + vertical-align: middle; + height: 100%; +} + +div#main { + background: #FFF; + box-shadow: 0 2px 5px #777; + border: 0px; + border-radius:4px; + font-family:verdana; + font-size:12px; + padding:0; +} + +div#frm { + padding:10px; +} + +img#scr { + max-width:100%; + max-height:100%; +} \ No newline at end of file diff --git a/Sunfish/Sunfish/Sunfish.csproj b/Sunfish/Sunfish/Sunfish.csproj index 490000a..f06fba5 100644 --- a/Sunfish/Sunfish/Sunfish.csproj +++ b/Sunfish/Sunfish/Sunfish.csproj @@ -77,6 +77,7 @@ FShared.cs + @@ -150,9 +151,12 @@ + + + diff --git a/Sunfish/Sunfish/wx/WShared.cs b/Sunfish/Sunfish/wx/WShared.cs index a4d5b7a..1dd7020 100644 --- a/Sunfish/Sunfish/wx/WShared.cs +++ b/Sunfish/Sunfish/wx/WShared.cs @@ -16,6 +16,7 @@ private bool allowRename; private bool allowExecution; private bool allowNewFolder; + private bool sendThumbnails; public WShared() { @@ -37,6 +38,29 @@ 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 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 { @@ -55,5 +79,6 @@ 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 e8ea722..9f5441b 100644 --- a/Sunfish/Sunfish/wx/WebXplorer.cs +++ b/Sunfish/Sunfish/wx/WebXplorer.cs @@ -26,6 +26,8 @@ public static byte[] res_screen; public static byte[] res_folder; 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(); @@ -44,6 +46,11 @@ res_screen = GetImageData(Resources.screen, ImageFormat.Png); res_folder = GetImageData(Resources.foldericon, 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) @@ -115,14 +122,24 @@ YN[true] = "Y"; YN[false] = "N"; List data = new List(); - data.Add("#Sunfish WebXplorer V" + Program.VERSION + " (The new Dolphin WebXplorer) (C) XWolf 2014"); - data.Add(""); - data.Add("#Each line is: ||||||||"); - data.Add(""); + data.Add("#Sunfish WebXplorer V" + Program.VERSION + " (The new Dolphin WebXplorer) (C) XWolf 2014-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] + "|" + YN[s.AllowSubfolders] + "|" + YN[s.AllowUpload] + "|" + YN[s.AllowDeletion] + "|" + YN[s.AllowRename] + "|" + YN[s.AllowExecution] + "|" + YN[s.AllowNewFolder]); + data.Add("Shared: " + s.Name + "|" + s.Path + "|" + YN[s.Enabled] + "|" + s.GetFlags()); File.WriteAllLines(filename, data.ToArray()); } @@ -130,11 +147,12 @@ { string[] data = File.ReadAllLines(filename); bool setactive = false; + sharedScreen = false; shares.Clear(); Stop(); foreach (string l in data) { - if (l.StartsWith("#")) + if (l.StartsWith("#") || l.Length==0) continue; int dp = l.IndexOf(':'); if (dp < 0) @@ -149,6 +167,12 @@ 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('|'); @@ -158,12 +182,7 @@ { WShared sh = new WShared(sname, spath); sh.Enabled = "Y".Equals(s.Length > 2 ? s[2] : null); - sh.AllowSubfolders = "Y".Equals(s.Length > 3 ? s[3] : null); - sh.AllowUpload = "Y".Equals(s.Length > 4 ? s[4] : null); - sh.AllowDeletion = "Y".Equals(s.Length > 5 ? s[5] : null); - sh.AllowRename = "Y".Equals(s.Length > 6 ? s[6] : null); - sh.AllowExecution = "Y".Equals(s.Length > 7 ? s[7] : null); - sh.AllowNewFolder = "Y".Equals(s.Length > 8 ? s[8] : null); + sh.SetFlags(s.Length > 3 ? s[3] : ""); Add(sh); } } @@ -209,6 +228,8 @@ 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 @@ -218,6 +239,8 @@ 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; @@ -299,25 +322,34 @@ } } + private void Special(string path) + { + if (path=="screen"){ + BlackHeader("Shared Screen", global::DolphinWebXplorer2.Properties.Resources.ShScreen); + Out.Write("
Password:
"); + Out.Write(""); + BlackFooter(); + } + } + private void GetIcon(WShared sh, string path) { path = sh.GetLocalPath(path); try { - //FileInfo fi = new FileInfo(path); - //if (fi.Length < 1024 * 1024) - //{ - // try{ - // using (Image i = Image.FromFile(path)) - // { - // using (Image t = i.GetThumbnailImage(32, 32, null, IntPtr.Zero)) - // { - // BinaryOut((Bitmap)t); - // return; - // } - // } - // }catch{}; - //} + 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); } @@ -609,6 +641,27 @@ Footer(); } + 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 Header(string title, WShared sh, string[] path) { Out.Write("Sunfish ["); @@ -647,8 +700,8 @@ Out.Write("<div id='headtoolbox'>"); if (sh != null && sh.AllowNewFolder) Out.Write("<button class='htool' title='New Folder' onclick='location.href+=\"?Action=MKD\"'><img src='/·folder' width='16' height='16'></button>"); - if (true) - Out.Write("<button class='htool' title='Simple remote control' onclick='location.href+=\"/screen\"'><img src='/·screen' width='16' height='16'></button>"); + if (WebXplorer.SharedScreen) + Out.Write("<button class='htool' title='Simple remote control' onclick='location.href=\"/$screen\"'><img src='/·screen' width='16' height='16'></button>"); Out.Write("</div>"); Out.Write("</div><div id='main'>"); }