Esempio n. 1
0
 public async Task <IActionResult> UploadFile(List <IFormFile> postedFiles)
 {
     if (_signInManager.IsSignedIn(User))
     {
         wwFileAccess.wwFileAccess wwfi = new wwFileAccess.wwFileAccess();
         foreach (var postedFile in postedFiles)
         {
             if (postedFile == null)
             {
                 continue;
             }
             string path = wwfi.MapPath("~/wwwroot/Content/resources/");
             if (!Directory.Exists(path))
             {
                 Directory.CreateDirectory(path);
             }
             if (postedFile.Length > 0)
             {
                 var filePath = Path.Combine(path, postedFile.FileName);
                 using (var fileStream = new FileStream(filePath, FileMode.Create))
                 {
                     await postedFile.CopyToAsync(fileStream);
                 }
             }
         }
         return(RedirectToAction("ManageFiles"));
     }
     else
     {
         return(RedirectToAction("ViewPage", "Page"));
     }
 }
Esempio n. 2
0
        public async Task <IActionResult> UploadFavicon(IFormFile postedFile)
        {
            if (_signInManager.IsSignedIn(User))
            {
                wwFileAccess.wwFileAccess wwfi = new wwFileAccess.wwFileAccess();
                if (postedFile != null)
                {
                    string path = wwfi.MapPath("~/wwwroot/");
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    if (postedFile.Length > 0)
                    {
                        var filePath = Path.Combine(path, "favicon.ico");
                        using (var fileStream = new FileStream(filePath, FileMode.Create))
                        {
                            await postedFile.CopyToAsync(fileStream);
                        }
                    }
                }
                return(RedirectToAction("ControlPanel"));
            }
            else
            {
                return(RedirectToAction("ViewPage", "Page"));
            }
        }
Esempio n. 3
0
 public ActionResult GarbageFile(string filePath)
 {
     if (_signInManager.IsSignedIn(User))
     {
         wwFileAccess.wwFileAccess wwfi = new wwFileAccess.wwFileAccess();
         wwfi.GarbageFile(filePath);
         return(RedirectToAction("ManageFiles", new { garbage = "yes" }));
     }
     else
     {
         return(RedirectToAction("ViewPage", "Page"));
     }
 }
Esempio n. 4
0
 public ActionResult MoveFile(string oldFileName, string newFileName)
 {
     if (_signInManager.IsSignedIn(User))
     {
         wwFileAccess.wwFileAccess wwfi = new wwFileAccess.wwFileAccess();
         wwfi.MoveFile(oldFileName, newFileName);
         return(RedirectToAction("ManageFiles"));
     }
     else
     {
         return(RedirectToAction("ViewPage", "Page"));
     }
 }
Esempio n. 5
0
 public IActionResult EditAppSettings(string newValue)
 {
     if (_signInManager.IsSignedIn(User))
     {
         wwFileAccess.wwFileAccess wwfi = new wwFileAccess.wwFileAccess();
         // Edit the config file
         using (StreamWriter sw = System.IO.File.CreateText(wwfi.MapPath("~/appsettings.json")))
         {
             sw.Write(newValue);
         }
         // Stop the app, systemd will restart it
         Task.Delay(5000).ContinueWith(t => _applicationLifetime.StopApplication()); // Wait a bit so that the IActionResult can be returned before the application stops itself
         return(RedirectToAction("ControlPanel", new { restart = "yes" }));
     }
     else
     {
         return(RedirectToAction("ViewPage", "Page"));
     }
 }
Esempio n. 6
0
 public IActionResult ControlPanel(string restart)
 {
     wwBuildInfo.wwBuildInfo   wwbi = new wwBuildInfo.wwBuildInfo();
     wwFileAccess.wwFileAccess wwfi = new wwFileAccess.wwFileAccess();
     ViewData["SoftwareName"]    = wwbi.GetName();
     ViewData["VersionNumber"]   = wwbi.GetVersion();
     ViewData["ProjectUrl"]      = wwbi.GetUrl();
     ViewData["SiteName"]        = wwbi.getSiteSettings()["SiteName"];
     ViewData["RestartShow"]     = (restart == "yes");
     ViewData["AppSettingsJson"] = System.IO.File.ReadAllText(wwfi.MapPath("~/appsettings.json"));
     //ViewData["AppSettingsJson"] = wwfi.MapPath("~/appsettings.json");
     if (_signInManager.IsSignedIn(User))
     {
         return(View());
     }
     else
     {
         return(RedirectToAction("ViewPage", "Page"));
     }
 }
Esempio n. 7
0
        #pragma warning disable 1998
        public async override global::System.Threading.Tasks.Task ExecuteAsync()
        {
#line 1 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"

            Layout = null;

#line default
#line hidden
            BeginContext(24, 29, true);
            WriteLiteral("\n<!DOCTYPE html>\n\n<html>\n    ");
            EndContext();
            BeginContext(53, 1027, false);
            __tagHelperExecutionContext = __tagHelperScopeManager.Begin("head", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "a9837e9dceef5f03c89f88eb213f7400f3b263586860", async() => {
                BeginContext(59, 31, true);
                WriteLiteral("\n        <title>Manage Files | ");
                EndContext();
                BeginContext(91, 20, false);
#line 9 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                Write(ViewData["SiteName"]);

#line default
#line hidden
                EndContext();
                BeginContext(111, 962, true);
                WriteLiteral(@"</title>
        <script src=""https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js""></script>
        <link rel=""stylesheet"" type=""text/css"" href=""https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css"">
        <script src=""https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.js""></script>
        <style>
            body {
                margin: 14px;
                /*margin-right: 14px;*/
            }
            .ui.file.input {
                display: none;
            }
        </style>
        <script>
            function decodeHtml(html) {
                var txt = document.createElement(""textarea"");
                txt.innerHTML = html;
                return txt.value;
            }
            $( document ).ready(function() {
                $('.dropdown').dropdown();
                $('.popuptrigger').popup({
                    on: 'click'
                });
            });
        </script>
    ");
                EndContext();
            }
                                                                        );
            __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.HeadTagHelper>();
            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_HeadTagHelper);
            await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

            if (!__tagHelperExecutionContext.Output.IsContentModified)
            {
                await __tagHelperExecutionContext.SetOutputContentAsync();
            }
            Write(__tagHelperExecutionContext.Output);
            __tagHelperExecutionContext = __tagHelperScopeManager.End();
            EndContext();
            BeginContext(1080, 5, true);
            WriteLiteral("\n    ");
            EndContext();
            BeginContext(1085, 4904, false);
            __tagHelperExecutionContext = __tagHelperScopeManager.Begin("body", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "a9837e9dceef5f03c89f88eb213f7400f3b263589370", async() => {
                BeginContext(1091, 1342, true);
                WriteLiteral(@"
        <!--
        <div class=""ui inverted menu"">
            <a href=""/"" class=""item"">
                Home
            </a>
            <form class=""right item"" id=""navigateForm"" action=""/Page/NavigateForm"" method=""post"">
                <div class=""ui inverted transparent input"">
                    <input type=""text"" name=""pageName"" placeholder=""Navigate to..."">
                </div>
                <button type=""submit"" class=""ui black button"">Go</button>
            </form>
            <div class=""ui inverted dropdown icon item"">
                <i class=""wrench icon""></i>
                <div class=""menu"">
                    <a class=""item"" href=""/ViewPage/Special|List of pages"">
                        Special|List of pages
                    </a>
                    <a class=""item"" href=""/NewPage"">
                        New Page
                    </a>
                    <a class=""item"" href=""/ManageTemplates"">
                        Manage Templates
                    </a>
              ");
                WriteLiteral(@"      <a class=""item"" href=""/ManageFiles"">
                        Manage Files
                    </a>
                    <a class=""item"" href=""/Admin/ControlPanel"">
                        Control Panel
                    </a>
                    <a class=""item"" href=""/Docs/About"">
                        About ");
                EndContext();
                BeginContext(2434, 24, false);
#line 67 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                Write(ViewData["SoftwareName"]);

#line default
#line hidden
                EndContext();
                BeginContext(2458, 213, true);
                WriteLiteral("\n                    </a>\n                    <a class=\"item\" href=\"/Docs/Syntax\">\n                        Syntax Guide\n                    </a>\n                </div>\n            </div>\n        </div>-->\n        ");
                EndContext();
                BeginContext(2671, 26, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("partial", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.SelfClosing, "a9837e9dceef5f03c89f88eb213f7400f3b2635811755", async() => {
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_PartialTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.PartialTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_PartialTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_PartialTagHelper.Name = (string)__tagHelperAttribute_0.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(2697, 118, true);
                WriteLiteral("\n        <div id=\"customContent\">\n            <div class=\"ui header\">\n                Manage Files\n            </div>\n");
                EndContext();
#line 80 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                if ((bool)ViewData["GarbageShow"])
                {
#line default
#line hidden
                    BeginContext(2864, 346, true);
                    WriteLiteral(@"            <div class=""ui message"">
                <div class=""header"">
                    File moved to garbage
                </div>
                <p>Your file has been moved to /Content/garbage/, to fully delete it go to your control panel and click ""Empty garbage."" To restore your file, click ""Restore garbage"".</p>
            </div>
");
                    EndContext();
#line 87 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                }

#line default
#line hidden
                BeginContext(3224, 205, true);
                WriteLiteral("            <table class=\"ui celled table\">\n                <thead><tr>\n                        <th>Path</th>\n                        <th>Actions</th>\n                </tr></thead>\n                <tbody>\n");
                EndContext();
#line 94 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"

                wwFileAccess.wwFileAccess fa = new wwFileAccess.wwFileAccess();
                string[] allFiles            = fa.GetAllFiles();


#line default
#line hidden
                BeginContext(3616, 20, true);
                WriteLiteral("                    ");
                EndContext();
#line 98 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                foreach (string oneFile in allFiles)
                {
#line default
#line hidden
                    BeginContext(3696, 53, true);
                    WriteLiteral("                    <tr>\n                        <td>");
                    EndContext();
                    BeginContext(3750, 7, false);
#line 101 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                    Write(oneFile);

#line default
#line hidden
                    EndContext();
                    BeginContext(3757, 497, true);
                    WriteLiteral(@"</td>
                        <td>
                            <div class=""popuptrigger ui animated yellow icon button"">
                                <div class=""visible content"">
                                    <i class=""angle right icon""></i>
                                </div>
                                <div class=""hidden content"">
                                    Rename
                                </div>
                            </div>
                            ");
                    EndContext();
                    BeginContext(4254, 486, false);
                    __tagHelperExecutionContext = __tagHelperScopeManager.Begin("form", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "a9837e9dceef5f03c89f88eb213f7400f3b2635815856", async() => {
                        BeginContext(4315, 138, true);
                        WriteLiteral("\n                                <div class=\"ui action input\">\n                                    <input type=\"hidden\" name=\"oldFileName\"");
                        EndContext();
                        BeginWriteAttribute("value", " value=\"", 4453, "\"", 4469, 1);
#line 113 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                        WriteAttributeValue("", 4461, oneFile, 4461, 8, false);

#line default
#line hidden
                        EndWriteAttribute();
                        BeginContext(4470, 263, true);
                        WriteLiteral(@">
                                    <input type=""text"" name=""newFileName"" placeholder=""New filename"">
                                    <button type=""submit"" class=""ui button"">Rename</button>
                                </div>
                            ");
                        EndContext();
                    }
                                                                                );
                    __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper>();
                    __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper>();
                    __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper);
                    __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1);
                    __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_2);
                    __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Method = (string)__tagHelperAttribute_3.Value;
                    __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_3);
                    await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                    if (!__tagHelperExecutionContext.Output.IsContentModified)
                    {
                        await __tagHelperExecutionContext.SetOutputContentAsync();
                    }
                    Write(__tagHelperExecutionContext.Output);
                    __tagHelperExecutionContext = __tagHelperScopeManager.End();
                    EndContext();
                    BeginContext(4740, 59, true);
                    WriteLiteral("\n                            <a class=\"ui blue icon button\"");
                    EndContext();
                    BeginWriteAttribute("href", " href=\"", 4799, "\"", 4814, 1);
#line 118 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                    WriteAttributeValue("", 4806, oneFile, 4806, 8, false);

#line default
#line hidden
                    EndWriteAttribute();
                    BeginContext(4815, 92, true);
                    WriteLiteral("><i class=\"download icon\"></i></a>\n                            <a class=\"ui red icon button\"");
                    EndContext();
                    BeginWriteAttribute("onclick", " onclick=\"", 4907, "\"", 4979, 4);
                    WriteAttributeValue("", 4917, "$(\'#filePath\').val(\'", 4917, 20, true);
#line 119 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                    WriteAttributeValue("", 4937, oneFile, 4937, 8, false);

#line default
#line hidden
                    WriteAttributeValue("", 4945, "\');", 4945, 3, true);
                    WriteAttributeValue(" ", 4948, "$(\'#deleteFileSubmit\').click()", 4949, 31, true);
                    EndWriteAttribute();
                    BeginContext(4980, 89, true);
                    WriteLiteral("><i class=\"trash icon\"></i></a>\n                        </td>\n                    </tr> \n");
                    EndContext();
#line 122 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                }

#line default
#line hidden
                BeginContext(5091, 58, true);
                WriteLiteral("                </tbody>\n            </table>\n            ");
                EndContext();
                BeginContext(5149, 410, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("form", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "a9837e9dceef5f03c89f88eb213f7400f3b2635820158", async() => {
                    BeginContext(5245, 307, true);
                    WriteLiteral(@"
                <label for=""postedFile"" class=""ui labeled icon button"">
                    <i class=""file icon""></i>
                    Upload a file
                </label>
                <input type=""file"" id=""postedFile"" name=""postedFile"" class=""ui file input"" onchange=""form.submit()"">
            ");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_4);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_5);
                __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Method = (string)__tagHelperAttribute_3.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_3);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_6);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(5559, 120, true);
                WriteLiteral("\n        </div>\n        <div class=\"ui divider\"></div>\n        <span id=\"version\" class=\"ui small grey text\">Powered by ");
                EndContext();
                BeginContext(5680, 24, false);
#line 134 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                Write(ViewData["SoftwareName"]);

#line default
#line hidden
                EndContext();
                BeginContext(5704, 1, true);
                WriteLiteral(" ");
                EndContext();
                BeginContext(5706, 25, false);
#line 134 "/home/benjamin/webweb-core/webweb/Views/Page/ManageFiles.cshtml"
                Write(ViewData["VersionNumber"]);

#line default
#line hidden
                EndContext();
                BeginContext(5731, 16, true);
                WriteLiteral("</span>\n        ");
                EndContext();
                BeginContext(5747, 230, false);
                __tagHelperExecutionContext = __tagHelperScopeManager.Begin("form", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "a9837e9dceef5f03c89f88eb213f7400f3b2635823399", async() => {
                    BeginContext(5810, 160, true);
                    WriteLiteral("\n            <input type=\"hidden\" name=\"filePath\" id=\"filePath\">\n            <button type=\"submit\" style=\"display:none\" id=\"deleteFileSubmit\"></button>\n        ");
                    EndContext();
                }
                                                                            );
                __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.FormTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper);
                __Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.RenderAtEndOfFormTagHelper>();
                __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_RenderAtEndOfFormTagHelper);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_7);
                __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_8);
                __Microsoft_AspNetCore_Mvc_TagHelpers_FormTagHelper.Method = (string)__tagHelperAttribute_3.Value;
                __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_3);
                await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                if (!__tagHelperExecutionContext.Output.IsContentModified)
                {
                    await __tagHelperExecutionContext.SetOutputContentAsync();
                }
                Write(__tagHelperExecutionContext.Output);
                __tagHelperExecutionContext = __tagHelperScopeManager.End();
                EndContext();
                BeginContext(5977, 5, true);
                WriteLiteral("\n    ");
                EndContext();
            }
                                                                        );
            __Microsoft_AspNetCore_Mvc_Razor_TagHelpers_BodyTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.Razor.TagHelpers.BodyTagHelper>();
            __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_Razor_TagHelpers_BodyTagHelper);
            await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);

            if (!__tagHelperExecutionContext.Output.IsContentModified)
            {
                await __tagHelperExecutionContext.SetOutputContentAsync();
            }
            Write(__tagHelperExecutionContext.Output);
            __tagHelperExecutionContext = __tagHelperScopeManager.End();
            EndContext();
            BeginContext(5989, 13, true);
            WriteLiteral("\n</html>\n\n\n\n\n");
            EndContext();
        }
Esempio n. 8
0
 public ActionResult ClearGarbageForm()
 {
     wwFileAccess.wwFileAccess wwfi = new wwFileAccess.wwFileAccess();
     Array.ForEach(Directory.GetFiles(wwfi.MapPath("~/wwwroot/Content/garbage")), System.IO.File.Delete);
     return(RedirectToAction("ControlPanel"));
 }