Esempio n. 1
0
        public LicenseManager()
        {
            //IniParser ini = new IniParser(@"chocobot.ini");
            IniParserLegacy.IniFile ini = new IniParserLegacy.IniFile(System.Windows.Forms.Application.StartupPath + "\\chocobot.ini");

            string user = "";
            string password = "";

            try
            {
                user = ini.IniReadValue("Credentials", "UserName");
                password = ini.IniReadValue("Credentials", "Password");
            }
            catch (Exception)
            {
            }

            if(user == "" || password == "")
            {

                clsCredentials userinput = new clsCredentials();
                clsCredentials.Credentials credentials = userinput.Show();

                try
                {
                    user = credentials.User;
                    password = GetMd5Hash(CleanPassword(credentials.Password));
                }catch (Exception)
                {
                    user = "";
                    password = "";
                }

            }

            _user = user;
            _pass = password;
        }
Esempio n. 2
0
        public LicenseResult VerifyLicense()
        {
            Random rnd = new Random();
            Assembly assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
            LicenseResult licenseResult = new LicenseResult();

            if (_user.Length < 3 || _pass.Length < 3)
            {
                licenseResult.Valid = false;
                licenseResult.Error = "ERR101";
            }

            int randInt = rnd.Next(124, 18724);
            string randIntHash = GetMd5Hash("S!k@l" + (randInt + 1563).ToString(CultureInfo.InvariantCulture));
            string htmlResult = new System.Net.WebClient().DownloadString("http://www.chocobotxiv.com/forum/licensing/action.php?user="******"&pass="******"&action=1&session=" + randInt + "&version=" + fvi.FileMajorPart + "." + fvi.FileMinorPart);

            bool result = htmlResult == randIntHash;

            if(result)
            {
                //IniParser ini = new IniParser(@"chocobot.ini");
                IniParserLegacy.IniFile ini = new IniParserLegacy.IniFile(System.Windows.Forms.Application.StartupPath + "\\chocobot.ini");

                ini.IniWriteValue("Credentials", "UserName", _user);
                ini.IniWriteValue("Credentials", "Password", _pass);
                //ini.SaveSettings();
            } else
            {
                licenseResult.Error = htmlResult.Trim();
            }

            licenseResult.Valid = result;

            return licenseResult;
        }
Esempio n. 3
0
        private void btn_SaveRecipe_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();
            dlg.Filter = "Crafting Recipe (*.crft)|*.crft";
            if (dlg.ShowDialog() == false)
                return;

            IniParserLegacy.IniFile ini = new IniParserLegacy.IniFile(dlg.FileName);

            ini.IniWriteValue("Main", "KeyCount", _keyConditions.Count.ToString());

            int currkey = 1;

            foreach (CraftingKey keyCondition in _keyConditions)
            {
                ini.IniWriteValue("Key" + currkey, "key", keyCondition.KeyString);
                ini.IniWriteValue("Key" + currkey, "cp", keyCondition.CP.ToString());
                ini.IniWriteValue("Key" + currkey, "cpcondition", keyCondition.CPCondition.ToString());
                ini.IniWriteValue("Key" + currkey, "durability", keyCondition.Durability.ToString());
                ini.IniWriteValue("Key" + currkey, "durabilitycondition", keyCondition.DurabilityCondition.ToString());
                ini.IniWriteValue("Key" + currkey, "progress", keyCondition.Progress.ToString());
                ini.IniWriteValue("Key" + currkey, "progresscondition", keyCondition.ProgressCondition.ToString());
                ini.IniWriteValue("Key" + currkey, "condition", keyCondition.Condition.ToString());
                ini.IniWriteValue("Key" + currkey, "conditioncondition", keyCondition.ConditionCondition.ToString());
                ini.IniWriteValue("Key" + currkey, "controlkey", keyCondition.ControlKey.ToString());
                currkey++;
            }
        }
Esempio n. 4
0
        private void btn_LoadRecipe_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "Crafting Recipe (*.crft)|*.crft";
            if (dlg.ShowDialog() == false)
                return;

            IniParserLegacy.IniFile ini = new IniParserLegacy.IniFile(dlg.FileName);

            int keycount = int.Parse(ini.IniReadValue("Main", "KeyCount"));

            _keyConditions.Clear();

            for(int i = 0 ; i < keycount ; i++)
            {
                CraftingKey newkey = new CraftingKey();
                newkey.Key = (Keys)Enum.Parse(typeof(Keys), ini.IniReadValue("Key" + (i + 1), "key"), true);
                newkey.CP = short.Parse(ini.IniReadValue("Key" + (i + 1), "cp"));
                newkey.CPCondition = bool.Parse(ini.IniReadValue("Key" + (i + 1), "cpcondition"));

                newkey.Durability = short.Parse(ini.IniReadValue("Key" + (i + 1), "durability"));
                newkey.DurabilityCondition = bool.Parse(ini.IniReadValue("Key" + (i + 1), "durabilitycondition"));

                try
                {
                    newkey.ControlKey = bool.Parse(ini.IniReadValue("Key" + (i + 1), "controlkey"));
                } catch (Exception ex)
                {
                    newkey.ControlKey = false;
                }

                newkey.Condition = ini.IniReadValue("Key" + (i + 1), "condition");
                try
                {
                    newkey.ConditionCondition = bool.Parse(ini.IniReadValue("Key" + (i + 1), "conditioncondition"));
                } catch (Exception ex)
                {
                    newkey.ConditionCondition = false;
                }

                newkey.Progress = short.Parse(ini.IniReadValue("Key" + (i + 1), "progress"));
                newkey.ProgressCondition = bool.Parse(ini.IniReadValue("Key" + (i + 1), "progresscondition"));

                _keyConditions.Add(newkey);
            }
        }