Example #1
0
        public string getCookieDestinet(string sUrl)
        {
            string destinet = "";
            var httpDownload = new HttpSession();

            var sPost = "dnn$ctr$Signin$Signin_textboxUsername=host" +
                        "&dnn$ctr$Signin$Signin_textboxPassword=guidedes10no" +
                        "&dnn$ctr$Signin$cmdLogin=Logg%20inn";

            var sContent = httpDownload.GetMethodDownload(sUrl, true, false, false, true);

            // step 2
            var _cookies = httpDownload.Cookies;

            string strRegex = "<input\\s+type=.{1}hidden.{1}\\s+name=.{1}__VIEWSTATE.{1}\\s+id=.{1}__VIEWSTATE.{1}\\s+value=.{1}([^.\"]+)";

            Regex rxGetViewState = new Regex(strRegex);
            Match mViewState = rxGetViewState.Match(sContent);

            string sViewState = mViewState.Groups[1].Value;//.Replace("/", "%2F").Replace("=", "%3D");
            sPost += "&__VIEWSTATE=" + sViewState;
            httpDownload.PostMethodDownload(sUrl, sPost, true, false, false, true);
            destinet = httpDownload.Cookies[".DESTINET"].Value;
            return destinet;
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var httpDownload = new HttpSession();

            var sPost = "{\"key\": \"64a5889c-e31d-4dc4-8fd0-edcc0f45f37d\"}";// "key=64a5889c-e31d-4dc4-8fd0-edcc0f45f37d";

            string sUrl1 = "https://mandrillapp.com/api/1.0/tags/all-time-series.json";
            string sUrl2 = "https://mandrillapp.com/api/1.0/users/info.json";
            httpDownload.sContentType = "application/json";
            httpDownload._iTimeOut = 3000;
            httpDownload.sAccept = "application/json";
             //   WebHeaderCollection.KeysCollection test = new System.Collections.Specialized.NameObjectCollectionBase.KeysCollection();

            //httpDownload.Headers.Add("Accept", "application/json");
            //httpDownload.Headers["Content-Type"] = "application/json";

            httpDownload.PostMethodDownload(sUrl2, sPost, true, false, true, true);
        }
Example #3
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     var httpDownload = new HttpSession();
     var sUrl = txtURLPost.Text;// "http://www.hnammobile.com/api/vote?item_id=79";
     var sPost = "";
     /////
     //sUrl = txtUrl.Text;
     sPost = "";
     httpDownload.PostMethodDownload(sUrl, sPost, true, false, false, false);
     count++;
     lbCount.Text = count.ToString();
 }
Example #4
0
 private void button7_Click(object sender, EventArgs e)
 {
     var httpDownload = new HttpSession();
     var sUrl = "http://www.viavia.no/admin";
     getCookieDestinet(sUrl);
 }
Example #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            var httpDownload = new HttpSession();
            var sUrl = "";
            var sPost = "";
            /////
            sUrl = txtUrl.Text;
            sPost = "";
            CookieCollection Cookie = new CookieCollection();

            var sContent = httpDownload.PostMethodDownload(sUrl, sPost, false, false, false, false);

            txtContent.Text = sContent;
        }
Example #6
0
        public void downloadFile(ref HttpSession httpDownload, string ckLink)
        {
            var rootXML = httpDownload.GetMethodDownload(ckLink, true, false, false, true);

            if (!rootXML.Contains("<Connector><Error number=\"116\" /></Connector>"))
            {
                try
                {
                    XmlDocument _doc = new XmlDocument();
                    _doc.LoadXml(rootXML);
                    string rootFolderName = _doc.GetElementsByTagName("CurrentFolder")[0].Attributes[0].Value;
                    string fullFolderName = _doc.GetElementsByTagName("CurrentFolder")[0].Attributes[1].Value;
                    XmlNodeList listFile = _doc.GetElementsByTagName("File");
                    StreamWriter sw = new StreamWriter(targetFolder + rootFolderName + rootFolderName.Replace("/", "") + ".txt");

                    for (int _i = 0; _i < listFile.Count; ++_i)
                    {
                        try
                        {
                            if (listFile[_i].Attributes[0] != null)
                            {
                                string filename = listFile[_i].Attributes[0].Value;
                                if (filename.Contains("Cache"))
                                {
                                    int a = 3;
                                }
                                txtStatus.Text = "download file: " + System.Environment.NewLine +
                                  sUrl + fullFolderName + filename + System.Environment.NewLine + txtStatus.Text + System.Environment.NewLine;
                                sw.WriteLine(sUrl + fullFolderName + filename);
                                Application.DoEvents();
                                if (checkOnlyGetLink.Checked == false)
                                {
                                    if (!System.IO.File.Exists(targetFolder + rootFolderName + filename))
                                    {
                                        if (checkUseIDM.Checked == true)
                                        {
                                            if (rootFolderName.Length > 1)
                                            {
                                                downloadByIDM(sUrl + fullFolderName + filename, targetFolder + rootFolderName.Substring(0, rootFolderName.Length - 1));
                                            }
                                            else
                                            {
                                                downloadByIDM(sUrl + fullFolderName + filename, targetFolder);
                                            }
                                            Thread.Sleep(1000);
                                        }
                                        else
                                        {
                                            WebClient webClient = new WebClient();
                                            webClient.DownloadFile(sUrl + fullFolderName + filename, targetFolder + rootFolderName + filename);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            txtStatus.Text = ex.Message + System.Environment.NewLine + txtStatus.Text + System.Environment.NewLine;
                            Application.DoEvents();
                        }
                    }
                    sw.Close();
                }
                catch (Exception ex)
                {
                    string error = ex.Message;
                }
            }
        }
Example #7
0
        private void btDownload_Click(object sender, EventArgs e)
        {
            if (checkUseIDM.Checked == true)
            {
                if (!System.IO.File.Exists(txtIDMLink.Text))
                {
                    MessageBox.Show("IDM errror");
                    return;
                }
            }

            timer1.Start();
            targetFolder = txtFolder.Text;
            if (!System.IO.Directory.Exists(targetFolder))
            {
                System.IO.Directory.CreateDirectory(targetFolder);
            }
            string user = "******";
            string password = "******";
            if (txtUser.Text.Trim() != null) { password = txtUser.Text; }
            if (txtPass.Text.Trim() != null) { user = txtPass.Text; }
            sUrl = txtDomain.Text;
            var httpDownload = new HttpSession();
            CookieCollection _cookies = new CookieCollection();
            getCookieDestinet(sUrl + "/admin", ref _cookies);
            httpDownload.Cookies = _cookies;

            string rootLink = sUrl + ckLoadLink.Replace("[[0]]", "GetFolders").Replace("[[1]]", "Portalens%20rotmappe").Replace("[[2]]", "%2F");// "/ckfinder/core/connector/aspx/connector.aspx?command=GetFolders&type=Portalens%20rotmappe&currentFolder=%2F";
            DownloadRecusive(ref httpDownload, rootLink, "%2F");
        }
Example #8
0
        public string getCookieDestinet(string sUrl1, ref CookieCollection _cookies)
        {
            string destinet = "";
            var httpDownload = new HttpSession();

            var sPost = "dnn$ctr$Signin$Signin_textboxUsername=host" +
                        "&dnn$ctr$Signin$Signin_textboxPassword=guidedes10no" +
                        "&dnn$ctr$Signin$cmdLogin=Logg%20inn";

            var sContent = httpDownload.GetMethodDownload(sUrl1, true, false, false, true);

            // step 2
            _cookies = httpDownload.Cookies;

            string strRegex = "<input\\s+type=.{1}hidden.{1}\\s+name=.{1}__VIEWSTATE.{1}\\s+id=.{1}__VIEWSTATE.{1}\\s+value=.{1}([^.\"]+)";
            Regex rxGetViewState = new Regex(strRegex);
            Match mViewState = rxGetViewState.Match(sContent);

            string sViewState = mViewState.Groups[1].Value;//.Replace("/", "%2F").Replace("=", "%3D");
            sPost += "&__VIEWSTATE=" + sViewState;
            httpDownload.PostMethodDownload(sUrl1, sPost, true, false, false, true);

            if (httpDownload.Cookies[".DESTINET"] != null)
            {
                destinet = httpDownload.Cookies[".DESTINET"].Value;
            }
            else
            {
                if (txtCookie.Text != "")
                {
                    Cookie c1 = new Cookie(".DESTINET", txtCookie.Text);
                    c1.Domain = sUrl.Replace("http://", "");
                    c1.Expired = false;
                    c1.Expires = DateTime.Now.AddMinutes(100);
                    httpDownload.Cookies.Add(c1);
                }
            }

            _cookies = httpDownload.Cookies;
            return destinet;
        }
Example #9
0
        public void DownloadRecusive(ref HttpSession httpDownload, string ckLink, string parentFolder)
        {
            var rootXML = httpDownload.GetMethodDownload(ckLink, true, false, false, true);
            XmlDocument _doc = new XmlDocument();
            _doc.LoadXml(rootXML);
            string rootFolderName = _doc.GetElementsByTagName("CurrentFolder")[0].Attributes[0].Value;
            XmlNodeList listFolder = _doc.GetElementsByTagName("Folder");
            //download file for current folder
            string ckGetFileLink = sUrl + ckLoadLink.Replace("[[0]]", "GetFiles").Replace("[[1]]", "Portalens%20rotmappe").Replace("[[2]]", parentFolder.Replace("&", "%26"));
            downloadFile(ref httpDownload, ckGetFileLink);

            //get folders
            for (int _i = 0; _i < listFolder.Count; ++_i)
            {
                string FolderName = listFolder[_i].Attributes[0].Value;
                WebClient webClient = new WebClient();
                DirectoryInfo dir = new DirectoryInfo(targetFolder + parentFolder.Replace("%2F", "/") + FolderName);
                if (!dir.Exists)
                {
                    dir.Create();
                }
                bool hasChild = false;
                hasChild = bool.Parse(listFolder[_i].Attributes[1].Value);

                if (hasChild)
                {
                    string tempCKForderLink = sUrl + ckLoadLink.Replace("[[0]]", "GetFolders").Replace("[[1]]", "Portalens%20rotmappe").Replace("[[2]]", parentFolder + FolderName.Replace(" ", "%20").Replace("&", "%26") + "%2F");
                    DownloadRecusive(ref httpDownload, tempCKForderLink, parentFolder + FolderName + "%2F");
                }
                else
                {
                    //download file for current forder if it has not child
                    string ckGetFileLink1 = sUrl + ckLoadLink.Replace("[[0]]", "GetFiles").Replace("[[1]]", "Portalens%20rotmappe").Replace("[[2]]", parentFolder + FolderName.Replace("&", "%26") + "%2F");
                    downloadFile(ref httpDownload, ckGetFileLink1);
                }
            }
        }