private static List <ApiKey> getKeyRing()
        {
            List <ApiKey> keyRing = new List <ApiKey>();

            log.Debug("Getting keyring.");
            string html = "";

            try {
                html = new System.Net.WebClient().DownloadString(keyringURL);
            } catch (System.Exception ex) {
                log.Error("Failed to retrieve data: " + ex.Message);
            }
            if (!string.IsNullOrEmpty(html))
            {
                html = html.Replace("\n", "");
                MatchCollection keyRecords = findText(html, @"<table><thead>.*?<tbody>(<tr>.*?</tr>)</tbody></table>");
                if (keyRecords.Count == 0)
                {
                    log.Warn("Could not find table of keys.");
                    return(keyRing);
                }
                foreach (String record in keyRecords[0].Captures[0].Value.Split(new string[] { "<tr>" }, StringSplitOptions.None).Skip(2))
                {
                    MatchCollection keyAttributes = findText(record, @"<td.*?>(.*?)</td>");
                    if (keyAttributes.Count > 0)
                    {
                        try {
                            keyRing.Add(new ApiKey(keyAttributes));
                        } catch { }
                    }
                }
            }
            log.Debug("There are " + keyRing.Count + " keys.");
            return(keyRing);
        }
Exemple #2
0
        public static string DownloadGallery(string Domain, string GalleryFilesUrlNoDomain, int ID)
        {
            string GalleryFiles = "";

            using (System.Net.WebClient client = new System.Net.WebClient())
            {
                GalleryFiles = new System.Net.WebClient().DownloadString("http://" + Domain + "/Images/GetGallery?title=gallery_" + ID);
            }

            string GalleryPath = LS.CurrentHttpContext.Server.MapPath("/Content/UserFiles/" + GalleryFilesUrlNoDomain);

            if (!System.IO.Directory.Exists(GalleryPath))
            {
                System.IO.Directory.CreateDirectory(GalleryPath);
            }

            if (string.IsNullOrEmpty(GalleryFiles))
            {
                return(GalleryFilesUrlNoDomain);
            }
            GalleryFiles = GalleryFiles.Replace("<br />", "^");

            foreach (string item in GalleryFiles.Split('^'))
            {
                if (string.IsNullOrEmpty(item))
                {
                    continue;
                }
                DownloadPic(Domain, item);
            }

            return(GalleryFilesUrlNoDomain);
        }
Exemple #3
0
        private void tHotkeys_Tick(object sender, EventArgs e)
        {
            if (GetAsyncKeyState(Keys.Scroll) == -32767)
            {
                string src = new System.Net.WebClient().DownloadString(
                    "http://zip.4chan.org/a/imgboard.html");
                src = src
                      .Replace("¤", "")
                      .Replace("\" class=\"quotejs\">No.</a><a href=\"", "¤");
                string[] pa = src
                              .Substring(src.IndexOf("¤") + 1)
                              .Split('¤');
                for (int a = 0; a < pa.Length; a++)
                {
                    pa[a] = pa[a]
                            .Replace("¤", "")
                            .Replace(".html#q", "¤")
                            .Split('¤')[1];
                    pa[a] = pa[a]
                            .Split('"')[0];
                }
                int iRet = 0;
                for (int a = 0; a < pa.Length; a++)
                {
                    int iTmp = Convert.ToInt32(pa[a]);
                    if (iTmp > iRet)
                    {
                        iRet = iTmp;
                    }
                }
                iRet += 2;

                SendKeys.Send("" + iRet);
            }
        }
Exemple #4
0
 private void cGetname_Click(object sender, EventArgs e)
 {
     try
     {
         string Link = tLink.Text;
         if (Link.Length > Link.IndexOf(ytID_Prefix) + ytID_Prefix.Length + 11)
         {
             Link = Link.Substring(0, Link.IndexOf(ytID_Prefix) + ytID_Prefix.Length + 11);
         }
         string YT_Html  = new System.Net.WebClient().DownloadString(Link);
         string ytPrefix = "<meta name=\"title\" content=\"";
         YT_Html = YT_Html.Substring(YT_Html.IndexOf(ytPrefix) + ytPrefix.Length);
         YT_Html = YT_Html.Substring(0, YT_Html.IndexOf("\">"));
         YT_Html = YT_Html.Replace("/", "_").Replace("\\", "_").Replace(":", "_").Replace("?", "_").Replace
                       ("<", "_").Replace("\"", "_").Replace(">", "_").Replace("|", "_");
         if (YT_Html.Length > 250)
         {
             YT_Html = YT_Html.Substring(0, 250);
         }
         tFile.Text = YT_Html;
     }
     catch (Exception ex)
     {
         System.Media.SystemSounds.Hand.Play();
         MessageBox.Show("Houston, we have a problem.\r\n\r\n" +
                         "Occurred in: cmdIdentifyVoid\r\n" + ex.Message);
     }
 }
Exemple #5
0
        //Program.WorkingFilesDirectory

        public static void Initialise()
        {
            String cloudCredsURL = "https://raw.githubusercontent.com/phw198/OutlookGoogleCalendarSync/master/docs/keyring.md";
            String html          = null;
            String line          = null;
            String placeHolder   = "###";
            String cloudID       = null;
            String cloudKey      = null;

            log.Debug("Getting credential attributes");
            try {
                try {
                    html = new System.Net.WebClient().DownloadString(cloudCredsURL);
                    html = html.Replace("\n", "");
                } catch (System.Exception ex) {
                    log.Error("Failed to retrieve data: " + ex.Message);
                }

                if (string.IsNullOrEmpty(html))
                {
                    throw new ApplicationException("Not able to retrieve error reporting credentials.");
                }

                Regex           rgx        = new Regex(@"### Error Reporting.*\|ID\|(.*)\|\|Key\|(.*?)\|", RegexOptions.IgnoreCase);
                MatchCollection keyRecords = rgx.Matches(html);
                if (keyRecords.Count == 1)
                {
                    cloudID  = keyRecords[0].Groups[1].ToString();
                    cloudKey = keyRecords[0].Groups[2].ToString();
                }
                else
                {
                    throw new ApplicationException("Unexpected parse of error reporting credentials.");
                }

                List <String> newLines = new List <string>();
                StreamReader  sr       = new StreamReader(templateCredFile);
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.IndexOf(placeHolder) > 0)
                    {
                        if (line.IndexOf("private_key_id") > 0)
                        {
                            line = line.Replace(placeHolder, cloudID);
                        }
                        else if (line.IndexOf("private_key") > 0)
                        {
                            line = line.Replace(placeHolder, cloudKey);
                        }
                    }
                    newLines.Add(line);
                }
                File.WriteAllLines(credFile, newLines.ToArray());
                Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", credFile);
            } catch (ApplicationException ex) {
                log.Warn(ex.Message);
                Enabled = false;
            }
        }
        static void Main(string[] args)
        {
            bool running = true;

            while (running)
            {
                int      invalid, valid;
                string[] inputList;
                invalid = 0;
                valid   = 0;

                Console.Write("Patient ID(s):");
                string input = Console.ReadLine();


                if (input == "url")
                {
                    input     = new System.Net.WebClient().DownloadString("https://s3.amazonaws.com/cognisant-interview-resources/identifiers.json");
                    input     = input.Trim('[', ']');
                    input     = input.Replace("\"", string.Empty);
                    inputList = input.Split(",");
                }
                else if (input == "exit")
                {
                    running = false;
                    break;
                }
                else
                {
                    inputList = new string[] { input };
                }

                foreach (string id in inputList)
                {
                    if (VerifyID(id))
                    {
                        valid++;
                    }
                    else
                    {
                        invalid++;
                    }
                }

                Console.WriteLine("Valid Results [" + valid + "]");
                Console.WriteLine("Inavlid Results [" + invalid + "]");
                Console.WriteLine("Total IDs: [" + (valid + invalid) + "]\n");
                Console.WriteLine("Press any key to input another ID(s)");
                Console.ReadKey();
                Console.Clear();
            }
        }
        public static void Initialise()
        {
            if (Program.StartedWithSquirrelArgs && !(Environment.GetCommandLineArgs()[1].ToLower().Equals("--squirrel-firstrun")))
            {
                return;
            }
            if (Program.InDeveloperMode)
            {
                return;
            }

            //Note, logging isn't actually initialised yet, so log4net won't log any lines within this function

            String cloudCredsURL = "https://raw.githubusercontent.com/phw198/OutlookGoogleCalendarSync/master/docs/keyring.md";
            String html          = null;
            String line          = null;
            String placeHolder   = "###";
            String cloudID       = null;
            String cloudKey      = null;

            log.Debug("Getting credential attributes");
            try {
                try {
                    html = new System.Net.WebClient().DownloadString(cloudCredsURL);
                    html = html.Replace("\n", "");
                } catch (System.Exception ex) {
                    log.Error("Failed to retrieve data: " + ex.Message);
                }

                if (string.IsNullOrEmpty(html))
                {
                    throw new ApplicationException("Not able to retrieve error reporting credentials.");
                }

                Regex           rgx        = new Regex(@"### Error Reporting.*\|ID\|(.*)\|\|Key\|(.*?)\|", RegexOptions.IgnoreCase);
                MatchCollection keyRecords = rgx.Matches(html);
                if (keyRecords.Count == 1)
                {
                    cloudID  = keyRecords[0].Groups[1].ToString();
                    cloudKey = keyRecords[0].Groups[2].ToString();
                }
                else
                {
                    throw new ApplicationException("Unexpected parse of error reporting credentials.");
                }

                List <String> newLines = new List <string>();
                StreamReader  sr       = new StreamReader(templateCredFile);
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.IndexOf(placeHolder) > 0)
                    {
                        if (line.IndexOf("private_key_id") > 0)
                        {
                            line = line.Replace(placeHolder, cloudID);
                        }
                        else if (line.IndexOf("private_key") > 0)
                        {
                            line = line.Replace(placeHolder, cloudKey);
                        }
                    }
                    newLines.Add(line);
                }
                File.WriteAllLines(credFile, newLines.ToArray());
                Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", credFile);
            } catch (ApplicationException ex) {
                log.Warn(ex.Message);
                Initialised = false;

                //} catch (System.Exception ex) {
                //Logging isn't initialised yet, so don't catch this error - let it crash out so user is aware and hopefully reports it!
                //System.Windows.Forms.MessageBox.Show(ex.Message);
                //log.Debug("Failed to initialise error reporting.");
                //OGCSexception.Analyse(ex);
            }
        }
Exemple #8
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            wb.Navigate("about:blank"); Application.DoEvents();
            itKrim = T2A(0); itPress = T2A(0); itGTA = T2A(0); itFC = T2A(0);

            Form SplashForm = new frmSplash(); SplashForm.Show();

            sUser = FileRead("user.txt");
            string sUData = sUser.ToLower();

            if (sUData != "")
            {
                sUData = sUData.Replace("æ", "(ae)").Replace("ø", "(oo)").Replace("å", "(aa)");
                sUData = "" + new Crc32().S(sUData);
            }
            else
            {
                sUData = "xxxxxxxx";
            }

            string vRaw = new System.Net.WebClient().DownloadString(
                "http://tox.awardspace.us/div/pNMC_version.php?" +
                "id=" + sUData + "&" +
                "cv=" + Application.ProductVersion);

            vRaw = vRaw.Replace("\r", "");
            if (!vRaw.Contains("<VERSION>" + Application.ProductVersion + "</VERSION>"))
            {
                if (DialogResult.Yes == MessageBox.Show(
                        "En ny versjon av pNMC er tilgjengelig. Oppdatere?",
                        "Oppdatere pNMC", MessageBoxButtons.YesNo))
                {
                    string Link = new System.Net.WebClient().DownloadString(
                        "http://www.praetox.com/inf/pNMC_link.html").Split('%')[1];
                    Link += "?id=" + sUData + "&cv=" + Application.ProductVersion;
                    System.Diagnostics.Process.Start(Link); AppExit();
                }
            }

            while (SplashForm.Enabled)
            {
                Application.DoEvents(); System.Threading.Thread.Sleep(10);
            }
            this.Show(); Application.DoEvents(); SplashForm.Dispose();

            string tmpPW = "";

            wb.Navigate("http://www.nordicmafia.net/"); w8();
            if (sUser != null)
            {
                wb.Document.GetElementById("brukernavn").SetAttribute("value", sUser);
            }
            MessageBox.Show("Vennligst logg inn.");
            while (!wb.IsBusy)
            {
                System.Threading.Thread.Sleep(10); Application.DoEvents();
                sUser     = wb.Document.GetElementById("brukernavn").GetAttribute("value");
                tmpPW     = wb.Document.GetElementById("passoord").GetAttribute("value");
                this.Text = "pNMC (" + sUser + ")  |  v" + Application.ProductVersion + "  |  www.Praetox.com";
            }
            sPass = tmpPW; FileWrite("user.txt", sUser);
        }