Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BT_Open_Click(object sender, EventArgs e)
        {
            String lURL     = this.TB_URL.Text;
            String lHost    = String.Empty;
            String lHostTmp = String.Empty;

            if (!String.IsNullOrEmpty(lURL))
            {
                if (!lURL.Contains(Uri.SchemeDelimiter))
                {
                    lURL             = string.Concat(Uri.UriSchemeHttp, Uri.SchemeDelimiter, lURL);
                    this.TB_URL.Text = lURL;
                } // if (!lURL....
            }     // if (!stri...


            try
            {
                Uri uri = new Uri(lURL);
                lHost = uri.Host; // will return www.foo.com
            }
            catch (Exception)
            {
            }

            mHeaderData = String.Empty;

            cTask.clearIECache();
            cTask.clearCookies();


            if (CB_Cookies.Checked && TB_Cookies.Text.Length > 0)
            {
                try
                {
                    foreach (String lCookie in TB_Cookies.Text.ToString().Split(';'))
                    {
                        if (lCookie.Length > 0 && lCookie.Contains("="))
                        {
                            Regex    regex      = new Regex("=");
                            String[] substrings = regex.Split(lCookie, 2);

                            InternetSetCookie(lURL, substrings[0], substrings[1]);
                        } // if (lCookie....
                    }     // foreach (s...
                }
                catch (Exception)
                {
                }
            } // if (CB_Cookie...

            mHeaderData = "User-Agent: " + TB_UserAgent.Text + "\r\n";
            mHeaderData = "Host: " + lHost + "\r\n";

            if (CB_Cookies.Checked && TB_Cookies.Text.Length > 0)
            {
                mHeaderData += "Cookie: " + TB_Cookies.Text + "\r\n";
            }



            DeleteUrlCacheEntry(lURL);
            cTask.clearIECache();
            cTask.clearCookies();


            UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, TB_UserAgent.Text, TB_UserAgent.Text.Length, 0);
            WB_MiniBrowser.ScriptErrorsSuppressed = true;
            WB_MiniBrowser.Navigate(lURL, "", null, mHeaderData);
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pURL"></param>
        /// <param name="pCookie"></param>
        /// <param name="pSrcIP"></param>
        /// <param name="pUserAgent"></param>
        public Browser(String pURL, String pCookie, String pSrcIP, String pUserAgent)
        {
            InitializeComponent();

            cTask = TaskFacade.getInstance();
            CMB_UserAgent.DataSource    = mUserAgentSettings;
            CMB_UserAgent.SelectedIndex = 1;


            TB_URL.Text     = pURL;
            TB_Cookies.Text = pCookie;
            mCookies        = pCookie;

            mUserAgentCustom            = pUserAgent;
            CMB_UserAgent.SelectedIndex = 0;
            this.Text = "MiniBrowser 0.3";


            if (!String.IsNullOrEmpty(pURL))
            {
                if (!pURL.ToLower().StartsWith("http"))
                {
                    pURL             = String.Format("http://{0}", pURL);
                    this.TB_URL.Text = pURL;
                } // if (!lURL....
            }     // if (!stri...



            /*
             *
             */
            String lURL = this.TB_URL.Text;

            mHeaderData = String.Empty;

            cTask.clearIECache();
            cTask.clearCookies();


            if (CB_Cookies.Checked && TB_Cookies.Text.Length > 0)
            {
                try
                {
                    foreach (String lCookie in TB_Cookies.Text.ToString().Split(';'))
                    {
                        if (lCookie.Length > 0 && lCookie.Contains("="))
                        {
                            Regex    regex      = new Regex("=");
                            String[] substrings = regex.Split(lCookie, 2);

                            InternetSetCookie(lURL, substrings[0], substrings[1]);
                        } // if (lCookie....
                    }     // foreach (s...
                }
                catch (Exception lEx)
                {
                }
            } // if (CB_Cookie...
              //

            if (CB_UserAgent.Checked && TB_UserAgent.Text.Length > 0)
            {
                mHeaderData = "User-Agent: " + TB_UserAgent.Text + "\r\n";
            }
            else
            {
                mHeaderData = String.Format("User-Agent: {0}\r\n", TB_UserAgent.Text);
            }

            if (CB_Cookies.Checked && TB_Cookies.Text.Length > 0)
            {
                mHeaderData += "Cookie: " + TB_Cookies.Text + "\r\n";
            }


            DeleteUrlCacheEntry(lURL);
            cTask.clearIECache();
            cTask.clearCookies();

            UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, TB_UserAgent.Text, TB_UserAgent.Text.Length, 0);
        }
Exemple #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pURL"></param>
        /// <param name="pCookie"></param>
        /// <param name="pSrcIP"></param>
        /// <param name="pUserAgent"></param>
        public Browser(String pURL, String pCookie, String pSrcIP, String pUserAgent)
        {
            InitializeComponent();

              cTask = TaskFacade.getInstance();
              CMB_UserAgent.DataSource = mUserAgentSettings;
              CMB_UserAgent.SelectedIndex = 1;

              TB_URL.Text = pURL;
              TB_Cookies.Text = pCookie;
              mCookies = pCookie;

              mUserAgentCustom = pUserAgent;
              CMB_UserAgent.SelectedIndex = 0;
              this.Text = "MiniBrowser 0.3";

              if (!String.IsNullOrEmpty(pURL))
              {
            if (!pURL.ToLower().StartsWith("http"))
            {
              pURL = String.Format("http://{0}", pURL);
              this.TB_URL.Text = pURL;
            } // if (!lURL....
              } // if (!stri...

              /*
               *
               */
              String lURL = this.TB_URL.Text;

              mHeaderData = String.Empty;

              cTask.clearIECache();
              cTask.clearCookies();

              if (CB_Cookies.Checked && TB_Cookies.Text.Length > 0)
              {
            try
            {
              foreach (String lCookie in TB_Cookies.Text.ToString().Split(';'))
              {
            if (lCookie.Length > 0 && lCookie.Contains("="))
            {
              Regex regex = new Regex("=");
              String[] substrings = regex.Split(lCookie, 2);

              InternetSetCookie(lURL, substrings[0], substrings[1]);
            } // if (lCookie....
              } // foreach (s...
            }
            catch (Exception lEx)
            {
            }
              } // if (CB_Cookie...
              //

              if (CB_UserAgent.Checked && TB_UserAgent.Text.Length > 0)
            mHeaderData = "User-Agent: " + TB_UserAgent.Text + "\r\n";
              else
            mHeaderData = String.Format("User-Agent: {0}\r\n", TB_UserAgent.Text);

              if (CB_Cookies.Checked && TB_Cookies.Text.Length > 0)
            mHeaderData += "Cookie: " + TB_Cookies.Text + "\r\n";

              DeleteUrlCacheEntry(lURL);
              cTask.clearIECache();
              cTask.clearCookies();

              UrlMkSetSessionOption(URLMON_OPTION_USERAGENT, TB_UserAgent.Text, TB_UserAgent.Text.Length, 0);
        }