Beispiel #1
0
        public static MemoryStream ParseLoot(string toon, string server, float minutes)
        {
            float m = minutes / 2;

            if (m < 1)
            {
                m = 1;        // 1 meg min
            }
            float c;

            if (float.TryParse(Cfg.get("LogFileScanSize"), out c))
            {
                if (m > c)
                {
                    m = c;        //logfilescansize limit
                }
            }
            else
            {
                if (m > 20)
                {
                    m = 20;         // 20 meg limit
                }
            }

            return(ParseLoot(toon, server, minutes, DateTime.Now, m));
        }
Beispiel #2
0
        public string UploadLog(string filePath)
        {
            if (!m_Authorized)
            {
                return("Bad username/password");
            }

            string fileName = Path.GetFileName(filePath);

            string[] bits = fileName.Split('_');

            if (bits.Length != 4)
            {
                return("Something did not compute");
            }

            Dictionary <string, string> d = new Dictionary <string, string>
            {
                ["sid"]    = m_WebClient.SID,
                ["toon"]   = bits[2],
                ["type"]   = bits[0],
                ["server"] = bits[1],
                ["file"]   = File.ReadAllText(filePath, Encoding.UTF8)
            };


            try
            {
                String url = Cfg.get("HttpUploadUrl");
                //m_WebClient.DownloadData(u);
                PreparePost(url);

                byte[] toSend = FormBytes(d);

                byte[] respB    = m_WebClient.UploadData(url, "POST", toSend);
                string response = Encoding.UTF8.GetString(respB);
                // check the response for success
                if (response.ToLower().Contains("success"))
                {
                    return("success");
                }

                return(response);
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Beispiel #3
0
        private void LoadConfig()
        {
            cmbToons.Items.Clear();
            cmbToons.Items.AddRange(FuEQ.GetToons().ToArray());

            if (cmbToons.Items.Count > 0)
            {
                cmbToons.Enabled = true;
                if (m_currentToon.Length > 0 && m_currentServer.Length > 0)
                {
                    int i = cmbToons.Items.IndexOf(String.Format("{0} - {1}", m_currentServer, m_currentToon));
                    if (i > -1)
                    {
                        cmbToons.SelectedIndex = i;
                    }
                }
                else if (cmbToons.Items.Count > 0)
                {
                    cmbToons.SelectedIndex = 0;
                }
                string[] toonBits = cmbToons.Items[cmbToons.SelectedIndex].ToString().Split(new string[] { " - " }, StringSplitOptions.None);
                if (toonBits.Length == 2)
                {
                    m_currentToon   = toonBits[1];
                    m_currentServer = toonBits[0];
                    EnableRestOfUI();
                }
            }
            else
            {
                cmbToons.Enabled = false;
                // force them to add a toon
                DisableRestOfUI();
            }

            txtEqFolder.Text = FuEQ.GetEQFolderForToon(m_currentToon, m_currentServer);
//            txtEqFolder.Text = Cfg.get("EqFolder");
            txtLootMinutes.Text       = Cfg.get("LootMinutes");
            txtLootLookupMinutes.Text = Cfg.get("LootLookupMinutes");
            txtEqCharacter.Text       = "";
            txtEqServer.Text          = "bristle";
            txtFuUsername.Text        = Cfg.getEncrypted("HttpUsername");
            txtFuPassword.Text        = Cfg.getEncrypted("HttpPassword");
        }
Beispiel #4
0
        private void UpgradeOld()
        {
            string toon = Cfg.get("EqToon");

            if (toon.Length > 0)
            {
                string server = Cfg.get("EqServerShortName");
                string folder = Cfg.get("EqFolder");
                FuEQ.SetToons(new List <string> {
                    String.Format("{0} - {1}", server, toon)
                });
                FuEQ.SetEQFolderForToon(toon, server, folder);

                Cfg.delete("EqToon");
                Cfg.delete("EqServerShortName");
                Cfg.delete("EqFolder");
                Cfg.delete("EqLogFolder");
            }
        }
Beispiel #5
0
        public bool Login(string username, string password)
        {
            Dictionary <string, string> d = new Dictionary <string, string>
            {
                ["username"] = username,
                ["password"] = password,
                ["redirect"] = "../index.php",
                ["login"]    = "******"
            };

            byte[] result;

            PreparePost(Cfg.get("HttpLoginUrl"));

            try
            {
                result = m_WebClient.UploadData(Cfg.get("HttpLoginUrl"), FormBytes(d));
            }
            catch (WebException e)
            {
                MessageBox.Show(e.Message, "Error connecting to FU Website");
                m_Authorized = false;
                return(false);
            }

            string html = Encoding.UTF8.GetString(result).ToLower();

            if (html.Contains(String.Format("welcome, {0}!", username.ToLower())))
            {
                m_Authorized = true;
                return(true);
            }

            MessageBox.Show("Invalid FU Website Username/Password");
            m_Authorized = false;
            return(false);
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            bool debug = false;

            if (IsInstalled() || debug)
            {
                if (!HasConfig() && !debug)
                {
                    // make an empty config file
                    BuildEmptyConfigFile();
                    command = "config";
                }
            }
            else
            {
                // install and create config file
                if (MessageBox.Show("About to install", "FuRaidTool", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    Install();
                }
                return; // probably wont get hit because install kills this process
            }

            appFolder = Path.GetDirectoryName(Application.ExecutablePath);

            float minutes = -1;

            if (command == "config" || args.Length == 0)
            {
                command = "config";
                //command = "loot";
            }
            else if (args.Length == 1)
            {
                command = args[0];
            }
            else
            {
                command = args[0].ToLower();
                toon    = args[1];

                if (args.Length > 2)
                {
                    server = args[2];
                }
                else
                {
                    server = "bristle";
                }
            }

            switch (command)
            {
            case "config":
                FuHttp     f  = new FuHttp();
                ConfigForm cf = new ConfigForm();
                cf.AppPath = Application.ExecutablePath;
                cf.ShowDialog();
                break;

            case "loot":
                if (minutes == -1)
                {
                    if (!float.TryParse(Cfg.get("LootMinutes"), out minutes))
                    {
                        minutes = 10;
                    }
                }
                if (UpdateLoot(toon, server, minutes))
                {
                    SendLogsToServer();
                    Process.Start("http://fuworldorder.net/admin/loot/loot_assignments.php");
                }
                break;

            case "lootlookup":
                if (minutes == -1)
                {
                    if (!float.TryParse(Cfg.get("LootLookupMinutes"), out minutes))
                    {
                        minutes = 3;
                    }
                }
                DoLootLookup(toon, server, minutes);
                break;

            case "attendance":
                if (UpdateRaidAttendance(toon, server))
                {
                    SendLogsToServer();
                    Process.Start("http://fuworldorder.net/admin/raid/attendance.php");
                }
                break;

            case "guildroster":
                if (UpdateGuildRoster(toon, server))
                {
                    SendLogsToServer();
                    Process.Start("http://fuworldorder.net/admin/raid/attendance.php");
                }
                break;

            case "sendlogs":
                SendLogsToServer();
                break;
            }
        }
Beispiel #7
0
        public static MemoryStream ParseRoster(string toon, string server)
        {
            // get the guild dump
            // looking for last file of format fu world order-<datetime>.txt in eq\Fu World Order-20161226-090424.txt

            MemoryStream ms           = new MemoryStream();
            StreamWriter sw           = new StreamWriter(ms, Encoding.ASCII);
            string       lastdumpfile = GetLastFile(FuEQ.GetEQFolderForToon(toon, server), String.Format("{0}_{1}-*.txt", Cfg.get("EqGuildName"), server));

            if (String.IsNullOrEmpty(lastdumpfile))
            {
                return(ms);
            }

            try
            {
                sw.Write(File.ReadAllText(lastdumpfile));
            }
            catch (Exception e)
            {
                return(ms); // failure reading file
            }
            sw.Flush();

            ms.Position = 0;
            return(ms);
        }
Beispiel #8
0
 public static List <string> GetToons()
 {
     return(Cfg.get("_toons").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList());
 }