Пример #1
0
 public static void init(ContentManager content)
 {
     FileEntry.filenames = new List <string>(128);
     FileEntry.fileData  = new List <string>(128);
     FileInfo[] files = new DirectoryInfo(Path.Combine(content.RootDirectory, "files")).GetFiles("*.*");
     for (int index = 0; index < files.Length; ++index)
     {
         FileEntry.filenames.Add(Path.GetFileNameWithoutExtension(files[index].Name));
         string filename = "Content/files/" + Path.GetFileName(files[index].Name);
         FileEntry.fileData.Add(Utils.readEntireFile(filename));
     }
     string[] strArray = Utils.readEntireFile(Settings.EducationSafeBuild ? "Content/BashLogs_StudentSafe.txt" : "Content/BashLogs.txt").Split(new string[1] {
         "\n#"
     }, StringSplitOptions.RemoveEmptyEntries);
     for (int index = 0; index < strArray.Length; ++index)
     {
         strArray[index].Trim();
         int num = strArray[index].Length - strArray[index].IndexOf("\r\n");
         FileEntry.filenames.Add("IRC_Log:" + strArray[index].Substring(0, strArray[index].IndexOf("\r\n")).Replace("- [X]", "").Replace(" ", ""));
         string data = strArray[index].Substring(strArray[index].IndexOf("\r\n")).Replace("\n ", "\n");
         if (Settings.ActiveLocale == "en-us")
         {
             data = FileSanitiser.purifyStringForDisplay(data);
         }
         FileEntry.fileData.Add(data + "\n\nArchived Via : http://Bash.org");
     }
 }
        public static string AddUserAndGetFilename(string username, string password)
        {
            var str = FileSanitiser.purifyStringForDisplay(username).Replace("_", "-").Trim();

            if (str.Length <= 0)
            {
                return(null);
            }
            for (var index = 0; index < Accounts.Count; ++index)
            {
                if (Accounts[index].FileUsername == str)
                {
                    return(null);
                }
                if (Accounts[index].Username == username)
                {
                    return(null);
                }
            }
            var saveAccountData = new SaveAccountData
            {
                Username     = username,
                Password     = password,
                FileUsername = str
            };

            Accounts.Add(saveAccountData);
            LastLoggedInUser = saveAccountData;
            Save();
            return(str);
        }
Пример #3
0
        public static string AddUserAndGetFilename(string username, string password)
        {
            string str = FileSanitiser.purifyStringForDisplay(username).Replace("_", "-").Trim();

            if (str.Length <= 0)
            {
                return((string)null);
            }
            for (int index = 0; index < OldSystemSaveFileManifest.Accounts.Count; ++index)
            {
                if (OldSystemSaveFileManifest.Accounts[index].FileUsername == str || OldSystemSaveFileManifest.Accounts[index].Username == username)
                {
                    return((string)null);
                }
            }
            SaveAccountData saveAccountData = new SaveAccountData()
            {
                Username = username, Password = password, FileUsername = str
            };

            OldSystemSaveFileManifest.Accounts.Add(saveAccountData);
            OldSystemSaveFileManifest.LastLoggedInUser = saveAccountData;
            OldSystemSaveFileManifest.Save();
            return(str);
        }
Пример #4
0
        public static void init(ContentManager content)
        {
            filenames = new List <string>(128);
            fileData  = new List <string>(128);
            var files = new DirectoryInfo(content.RootDirectory + "\\files").GetFiles("*.*");

            for (var index = 0; index < files.Length; ++index)
            {
                filenames.Add(Path.GetFileNameWithoutExtension(files[index].Name));
                var streamReader =
                    new StreamReader(TitleContainer.OpenStream("Content/files/" + Path.GetFileName(files[index].Name)));
                fileData.Add(streamReader.ReadToEnd());
                streamReader.Close();
            }
            var strArray =
                new StreamReader(TitleContainer.OpenStream("Content/BashLogs.txt")).ReadToEnd().Split(new string[1]
            {
                "\n#"
            }, StringSplitOptions.RemoveEmptyEntries);

            for (var index = 0; index < strArray.Length; ++index)
            {
                strArray[index].Trim();
                var length = strArray[index].Length;
                strArray[index].IndexOf("\r\n");
                filenames.Add("IRC_Log:" +
                              strArray[index].Substring(0, strArray[index].IndexOf("\r\n"))
                              .Replace("- [X]", "")
                              .Replace(" ", ""));
                fileData.Add(
                    FileSanitiser.purifyStringForDisplay(
                        strArray[index].Substring(strArray[index].IndexOf("\r\n")).Replace("\n ", "\n")) +
                    "\n\nArchived Via : http://Bash.org");
            }
        }
Пример #5
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")));
     }
 }
Пример #6
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);
        }
Пример #7
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);
        }
Пример #8
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);
        }
        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);
        }
Пример #10
0
        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"));
        }
Пример #11
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);
        }
Пример #12
0
        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;
        }
Пример #13
0
        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);
        }