コード例 #1
0
 private void web_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
 {
     if (!e.Cancelled && e.Error == null)
     {
         instantiateWebPage(e.Result);
     }
     else
     {
         instantiateWebPage(FileSanitiser.purifyStringForDisplay(Utils.readEntireFile("Content/Web/404Page.html")));
     }
 }
コード例 #2
0
        public override void initFiles()
        {
            root = new Folder("web");
            if (BaseWebpageData == null)
            {
                BaseWebpageData = FileSanitiser.purifyStringForDisplay(Utils.readEntireFile(webPageFileLocation));
            }
            var fileEntry = new FileEntry(BaseWebpageData, "index.html");

            root.files.Add(fileEntry);
            lastLoadedFile = fileEntry;
            comp.files.root.folders.Add(root);
        }
コード例 #3
0
ファイル: FileSanitiser.cs プロジェクト: hochladen/Hacknet
        public static void purifyVehicleFile(string path)
        {
            string data = Utils.readEntireFile(path).Replace('\t', '#').Replace("\r", "");

            for (int index = 0; index < data.Length; ++index)
            {
                if (!GuiData.font.Characters.Contains(data[index]) && (int)data[index] != 10)
                {
                    data = FileSanitiser.replaceChar(data, index, '_');
                }
            }
            Utils.writeToFile(data, "SanitisedFile.txt");
        }
コード例 #4
0
        private void instantiateWebPage(string body)
        {
            var str1      = FileSanitiser.purifyStringForDisplay(body);
            var str2      = lastRequestedURL;
            var fileEntry = root.searchForFile(str2);

            if (fileEntry == null)
            {
                fileEntry = root.searchForFile("index.html");
                str2      = "index.html";
            }
            if (fileEntry != null)
            {
                fileEntry.data = str1;
            }
            base.LoadWebPage(str2);
        }
コード例 #5
0
        public static bool CanCreateAccountForName(string username)
        {
            string str = FileSanitiser.purifyStringForDisplay(username).Replace("_", "-").Trim();

            if (str.Length <= 0)
            {
                return(false);
            }
            for (int index = 0; index < OldSystemSaveFileManifest.Accounts.Count; ++index)
            {
                if (OldSystemSaveFileManifest.Accounts[index].FileUsername == str || OldSystemSaveFileManifest.Accounts[index].Username == username)
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #6
0
        public static bool CanCreateAccountForName(string username)
        {
            var str = FileSanitiser.purifyStringForDisplay(username).Replace("_", "-").Trim();

            if (str.Length <= 0)
            {
                return(false);
            }
            for (var index = 0; index < Accounts.Count; ++index)
            {
                if (Accounts[index].FileUsername == str || Accounts[index].Username == username)
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #7
0
ファイル: WebServerDaemon.cs プロジェクト: hochladen/Hacknet
        public void generateBaseCorporateSite(string companyName, string targetBaseFile = "Content/Web/BaseCorporatePage.html")
        {
            if (WebServerDaemon.BaseComnayPageData == null || targetBaseFile != "Content/Web/BaseCorporatePage.html")
            {
                WebServerDaemon.BaseComnayPageData = FileSanitiser.purifyStringForDisplay(Utils.readEntireFile(targetBaseFile));
            }
            string    dataEntry = WebServerDaemon.BaseComnayPageData.Replace("#$#COMPANYNAME#$#", companyName).Replace("#$#LC_COMPANYNAME#$#", companyName.Replace(' ', '_'));
            FileEntry fileEntry = this.root.searchForFile("index.html");

            if (fileEntry == null)
            {
                fileEntry = new FileEntry(dataEntry, "index.html");
            }
            else
            {
                fileEntry.data = dataEntry;
            }
            this.comp.files.root.searchForFolder("home").files.Add(new FileEntry(fileEntry.data, "index_BACKUP.html"));
        }
コード例 #8
0
        public static Folder GetAppFolder()
        {
            var strArray   = GenerateNames();
            var str        = strArray[0];
            var foldername = strArray[1].ToLower().Replace(" ", "_").Trim();
            var data       = str.Replace(" ", "_").Trim();
            var folder     = new Folder(foldername);

            folder.files.Add(new FileEntry(Computer.generateBinaryString(1024), "app.pkg"));
            var stringBuilder = new StringBuilder("----- [" + str + "] Save Data -----\n\n");
            var num           = 8 + Utils.random.Next(8);

            for (var index = 0; index < num; ++index)
            {
                stringBuilder.Append(GenerateAppSaveLine());
                stringBuilder.Append("\n\n");
            }
            folder.files.Add(new FileEntry(stringBuilder.ToString(), FileSanitiser.purifyStringForDisplay(data) + ".sav"));
            return(folder);
        }
コード例 #9
0
ファイル: WebServerDaemon.cs プロジェクト: hochladen/Hacknet
        public override void initFiles()
        {
            this.root = this.comp.files.root.searchForFolder("web");
            if (this.root == null)
            {
                this.root = new Folder("web");
                this.comp.files.root.folders.Add(this.root);
            }
            if (WebServerDaemon.BaseWebpageData == null)
            {
                if (Settings.IsInExtensionMode)
                {
                    this.webPageFileLocation = Utils.GetFileLoadPrefix() + this.webPageFileLocation;
                }
                string data = Utils.readEntireFile(this.webPageFileLocation);
                WebServerDaemon.BaseWebpageData = Settings.ActiveLocale == "en-us" ? FileSanitiser.purifyStringForDisplay(data) : data;
            }
            FileEntry fileEntry = new FileEntry(WebServerDaemon.BaseWebpageData, "index.html");

            this.root.files.Add(fileEntry);
            this.lastLoadedFile = fileEntry;
        }
コード例 #10
0
ファイル: Utils.cs プロジェクト: strangea/OpenHacknet
        public static string GenerateReportFromException(Exception ex)
        {
            var data1 = ex.GetType() + "\r\n\r\n" + ex.Message + "\r\n\r\nSource : " + ex.Source + "\r\n\r\n" +
                        ex.StackTrace + ex + "\r\n\r\n";

            if (ex.InnerException != null)
            {
                data1 = data1 + "Inner : ---------------\r\n\r\n" +
                        GenerateReportFromException(ex.InnerException)
                        .Replace("\t", "\0")
                        .Replace("\r\n", "\r\n\t")
                        .Replace("\0", "\t") + "\r\n\r\n";
            }
            var data2 = FileSanitiser.purifyStringForDisplay(data1);

            try
            {
                data2 = SuperSmartTwimForWidth(data2, 800, GuiData.smallfont);
            }
            catch (Exception ex1)
            {
            }
            return(data2);
        }