internal static string VideoDefaultIndex(string rootdir, string prefx, string port_) { string[] files; int count = 0; try { files = System.IO.Directory.GetFiles(rootdir + "Video"); string doc = string.Format("<body background=\"bg.jpg\"><a href 'http://{0}:{1}'> Refresh page </a><br />", prefx, port_); doc += "<h2>Enjoy watching !! Rykon Videos </h2><center>\r\n"; foreach (string f in files) { if (!WebServer.isMediaFile(f)) { continue; } count++; string filmn = AppHelper.LastPeice(f, "\\"); doc += "<video width=\"220\" height=\"140\" controls>"; doc += " <source src=\"" + filmn + "\" type=\"video/mp4\">"; doc += "</video>"; } if (count < 1) { doc += WebDesigner.NoMediaFoundTelladmin; } return(Htmlbeg + doc + "</center> </body><b><p style=\"color:red\">This page was created on " + AppHelper.ReturnAllTime() + "</p></b>" + WebDesigner.HtmlEnd); } catch { return("no media found "); } }
internal static string ListenDefaultIndex(string rootdir, string prefx, string port_) { string[] files; int count = 0; try { files = System.IO.Directory.GetFiles(rootdir + "Listen"); string doc = string.Format("<body background=\"bg.jpg\"><a href 'http://{0}:{1}'> Refresh page </a><br />", prefx, port_); doc += "<h2>Enjoy Listening !! Rykon Listen </h2><center>\r\n"; foreach (string f in files) { if (!WebServer.isMediaFile(f)) { continue; } count++; string filmn = AppHelper.LastPeice(f, "\\"); doc += "<h2>" + filmn + "</h2><div class='header' ><br /><audio controls>\r\n"; doc += " <source src=\"" + filmn + "\" type=\"audio/mpeg\">\r\n</audio>\r\n"; doc += "<hr /><br />\r\n\r\n</div><style>#header { background-color:black; color:white; text-align:center; padding:5px;}#nav { line-height:30px; background-color:#eeeeee; height:300px; width:100px; float:left; padding:5px; }#section { width:350px; float:left; padding:10px; }#footer { background-color:black; color:white; clear:both; text-align:center; padding:5px; }</style>"; } if (count < 1) { doc += WebDesigner.NoMediaFoundTelladmin; } return(Htmlbeg + doc + "</center> </body><b><p style=\"color:red\">This page was created on " + AppHelper.ReturnAllTime() + "</p></b>" + WebDesigner.HtmlEnd); } catch { return("no media found "); } }
internal static bool IsBinFile(string RequestPage) { string ext = AppHelper.LastPeice(RequestPage, "."); if (WebServer.BinExts.Contains(ext)) { return(true); } return(false); }
internal void SETLocalPath(string p) { this.LocalPath = p; if (p == "/") { lastfilename = lastdirName = "Main"; } else { this.lastfilename = AppHelper.LastPeice(p, "/"); this.lastdirName = AppHelper.LastPeice(p, "/", 2); if (this.lastfilename == null) { this.lastfilename = ""; } if (this.lastdirName == null) { this.lastdirName = ""; } } }
internal static RykonFile[] ListDir(string RequestFile, string rootDir, string HostName, string port, bool ReplaceHost = true) { List <RykonFile> lstr = new List <RykonFile>(); string[] lstar = System.IO.Directory.GetFiles(RequestFile); string[] lstdar = System.IO.Directory.GetDirectories(RequestFile); bool rootDirRequested = (RequestFile == rootDir); string host_et_port = HostName + ":" + port + "/"; rootDir = rootDir.Replace("\\", "/"); ///// parent if (!rootDirRequested) { string fx = AppHelper.GoUpAsDirectory(RequestFile); string fx2 = fx.Replace("\\", "/"); string fx3 = fx2.Replace(rootDir, ""); string fx4 = WebServer.EncodeUrlChars(fx3); string fx5 = "http://" + host_et_port + fx4; string fx6 = fx5.Replace("%2F", "/"); RykonFile r = new RykonFile(); r.IsDir = false; r.Fullpath = fx; r.Webpath = fx6; r.Name = AppHelper.LastPeice(fx6, "/"); lstr.Add(r); } else { lstr.Add(null); } foreach (string f in lstar) //files { string f2 = f.Replace("\\", "/"); string f3 = f2.Replace(rootDir, ""); string f4 = WebServer.EncodeUrlChars(f3); string f5 = "http://" + host_et_port + f4; string f6 = f5.Replace("%2F", "/"); RykonFile r = new RykonFile(); r.IsDir = false; r.Fullpath = f; r.Webpath = f6; r.Name = AppHelper.LastPeice(f6, "/"); lstr.Add(r); } foreach (string f in lstdar) // dirs { string f2 = f.Replace("\\", "/"); string f3 = f2.Replace(rootDir, ""); string f4 = WebServer.EncodeUrlChars(f3); string f5 = "http://" + host_et_port + f4; string f6 = f5.Replace("%2F", "/"); RykonFile r = new RykonFile(); r.IsDir = true; r.Fullpath = f; r.Webpath = f6 + "/"; r.Name = AppHelper.LastPeice(f6, "/"); lstr.Add(r); } return(lstr.ToArray()); }
internal static string ListDirectory(string Dir, string[] f, ServerConfig Config) { int i = 0; string doc = "<h2>\r\n"; doc += " Index of \r\n"; doc += " </h2><h4>\r\n"; doc += WebServer.EncodeHtmlChars(Dir) + "\r\n"; doc += "</h4>\r\n"; doc += "<hr/><table>\r\n"; if (f == null || f.Length < 1) // empty { return("Empty Dir"); } string fic = (Config.ShowDirIcon?WebDesigner.FolderIcoTag:""); foreach (string p in f) { string tr = "<span style=\"text-decoration:underline\">"; tr += "<tr>\r\n"; tr += "<td>" + fic + "\r\n"; tr += "<a style='text-decoration: underline;' draggable='true' href ='" + (p) + "/' >\r\n"; string name = WebServer.EncodeHtmlChars(" ") + WebServer.EncodeHtmlChars(AppHelper.LastPeice(p, "/")); tr += ((i == 0)?"Parent Directory":(i.ToString() + name)); tr += "</a>\r\n"; tr += "</td>\r\n"; tr += "</tr></span>\r\n"; i++; if (p == "") { continue; } doc += tr; } //} doc += "</table><hr />" + WebDesigner.PoweredBy(Config) + " "; return(doc); }