public int Command(WebSqlCommand sqlCmd) { if (sqlCmd.SqlQuery.StartsWith("SELECT", StringComparison.CurrentCultureIgnoreCase)) { throw new WebDatabaseException("SELECT query is not supported in WebDatabase Command function."); } byte[] buffer; try { _webClient.QueryString.Clear(); buffer = _webClient.UploadValues(_webDatabaseUri, "POST", GetPostValues(sqlCmd)); } catch (Exception ex) { throw new WebDatabaseException(ex.Message, ex, -1); } using (BinaryReader bR = new BinaryReader(new MemoryStream(buffer))) { int errorCode = bR.ReadInt32(); if (errorCode != 0) { string message = Encoding.UTF8.GetString(bR.ReadBytes(bR.ReadInt32())); string remoteStackTrace = Encoding.UTF8.GetString(bR.ReadBytes(bR.ReadInt32())); throw new WebDatabaseException(message, errorCode, remoteStackTrace); } return(bR.ReadInt32()); } }
} // End Function GetFormValues public static void Test() { string projName = RedmineMailService.SecretManager.GetSecret <string>("SAP_Project_Name"); string url = RedmineMailService.SecretManager.GetSecret <string>("URL", projName); string username = RedmineMailService.SecretManager.GetSecret <string>("Username", projName); string password = RedmineMailService.SecretManager.GetSecret <string>("Password", projName); string base64Creds = System.Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(username + ":" + password)); string basicCredentials = "Basic " + base64Creds; using (WebClientEx wc = new WebClientEx()) { wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"); wc.Headers.Add("Authorization", basicCredentials); // Request 1 string redirect = wc.DownloadString(url); RedirectValues rv1 = GetFormValues(redirect); byte[] retValue = wc.UploadValues(rv1.Action, rv1.Method, rv1.PostValues); string resp = System.Text.Encoding.UTF8.GetString(retValue); System.Console.WriteLine(resp); RedirectValues rv2 = GetFormValues(resp); System.Console.WriteLine(rv2); // Request 2 wc.Headers["referer"] = url; rv2.PostValues["j_username"] = username; rv2.PostValues["j_password"] = password; // string url2 = "https://accounts.sap.com" + rv2.Action; System.Uri baseUri = new System.Uri(rv1.Action, System.UriKind.Absolute); string url2 = baseUri.Scheme + "://" + baseUri.Authority + rv2.Action; byte[] loginRetValue = wc.UploadValues(url2, rv2.Method, rv2.PostValues); string strLoginRetValue = System.Text.Encoding.UTF8.GetString(loginRetValue); System.Console.WriteLine(strLoginRetValue); System.Console.WriteLine(wc.CookieContainer); RedirectValues rv3 = GetFormValues(strLoginRetValue); System.Console.WriteLine(rv3); // Request 3 wc.Headers["referer"] = url2; byte[] retValueRedirect = wc.UploadValues(rv3.Action, rv3.Method, rv3.PostValues); string strRedirectResult = System.Text.Encoding.UTF8.GetString(retValueRedirect); System.Console.WriteLine(strRedirectResult); } // End Using wc } // End Sub Test
} // END WebClient Class public static string GetSpaceTrack(string[] noradId, string username, string password) { string uriBase = "https://www.space-track.org"; string requestController = "/basicspacedata"; string requestAction = "/query"; string predicateValues = "/class/tle_latest/ORDINAL/1/NORAD_CAT_ID/" + string.Join(",", noradId) + "/orderby/NORAD_CAT_ID/format/3le"; string request = uriBase + requestController + requestAction + predicateValues; // Create new WebClient object to communicate with the service using (var client = new WebClientEx()) { // Store the user authentication information var data = new NameValueCollection { { "identity", username }, { "password", password }, }; // Generate the URL for the API Query and return the response var response2 = client.UploadValues(uriBase + "/ajaxauth/login", data); var response4 = client.DownloadData(request); return(System.Text.Encoding.Default.GetString(response4)); } }
public static string UploadCollection(string sUrl, out string sErrmsg, NameValueCollection data, int iTimeOut, bool IsErrResponse = false) { string aRet = ""; sErrmsg = null; WebClientEx aClient = new WebClientEx(iTimeOut); try { byte[] byRemoteInfo = aClient.UploadValues(sUrl, "POST", data); aRet = Encoding.UTF8.GetString(byRemoteInfo); } catch (WebException e) { sErrmsg = e.Message; if (IsErrResponse) { if (e.Response != null && e.Response.GetResponseStream().CanRead) { StreamReader myReader = new StreamReader(e.Response.GetResponseStream(), Encoding.GetEncoding("utf-8")); sErrmsg = myReader.ReadToEnd(); myReader.Close(); } } aClient.Dispose(); return(""); } aClient.Dispose(); return(aRet); }
private static string GetToken(int Project_ID) { System.Collections.Specialized.NameValueCollection pD1 = new System.Collections.Specialized.NameValueCollection(); pD1.Add("ref", "bug_report_page.php"); pD1.Add("project_id", Project_ID.ToString().Trim()); pD1.Add("make_default", string.Empty); WebClientEx httpToken = new WebClientEx(); cJar = new System.Net.CookieContainer(); httpToken.KeepAlive = false; httpToken.CookieJar = cJar; httpToken.SendHeaders = new System.Net.WebHeaderCollection(); httpToken.SendHeaders.Add(System.Net.HttpRequestHeader.Referer, "http://bugs.realityripple.com/login_select_proj_page.php?bug_report_page.php"); string sTok = httpToken.UploadValues("http://bugs.realityripple.com/set_project.php", "POST", pD1); if (sTok.StartsWith("Error: ")) { return(null); } if (sTok.Contains("bug_report_token")) { sTok = sTok.Substring(sTok.IndexOf("bug_report_token") + 25); sTok = sTok.Substring(0, sTok.IndexOf("\"/")); return(sTok); } else { return(null); } }
private void SendData() { if (!isLoggedIn) { MessageBox.Show("Must be logged in to submit the bug. Enter login information."); return; } try { WebClientEx webClient = new WebClientEx(); webClient.Cookies = cookieContainer; webClient.Headers.Add("user-agent", userAgent); webClient.Method = "POST"; // Get data to send. BuildPost(webClient.QueryString); //webClient.UploadValuesCompleted += new UploadValuesCompletedEventHandler(SendData_Completed); webClient.UploadValues(new Uri(issueTrackerUrl + "?do=newtask&project=1"), webClient.QueryString); } catch (WebException) { ConnectionError(); } }
} // END WebClient Class // Get the TLEs based of an array of NORAD CAT IDs, start date, and end date public string GetSpaceTrack(string[] norad, DateTime dtstart, DateTime dtend) { string uriBase = "https://www.space-track.org"; string requestController = "/basicspacedata"; string requestAction = "/query"; // URL to retrieve all the latest tle's for the provided NORAD CAT // IDs for the provided Dates //string predicateValues = "/class/tle_latest/ORDINAL/1/NORAD_CAT_ID/" + string.Join(",", norad) + "/orderby/NORAD_CAT_ID%20ASC/format/tle"; // URL to retrieve all the latest 3le's for the provided NORAD CAT // IDs for the provided Dates string predicateValues = "/class/tle/EPOCH/" + dtstart.ToString("yyyy-MM-dd--") + dtend.ToString("yyyy-MM-dd") + "/NORAD_CAT_ID/" + string.Join(",", norad) + "/orderby/NORAD_CAT_ID%20ASC/format/3le"; string request = uriBase + requestController + requestAction + predicateValues; // Create new WebClient object to communicate with the service using (var client = new WebClientEx()) { // Store the user authentication information var data = new NameValueCollection { { "identity", "myUserName" }, { "password", "myPassword" }, }; // Generate the URL for the API Query and return the response var response2 = client.UploadValues(uriBase + "/ajaxauth/login", data); var response4 = client.DownloadData(request); return(System.Text.Encoding.Default.GetString(response4)); } } // END GetSpaceTrack()
public void DownloadFile(string page, string filepath, params string[] data) { if (Offline) { return; } lock (cookie) { if (!page.Contains("/")) { page = "sw/" + page; } var values = PrepareParams(data); using (var wb = new WebClientEx(cookie)) { var res_b = wb.UploadValues(server + page, "POST", values); if (res_b.Length < 1500) { var res = Encoding.UTF8.GetString(res_b); if (res.StartsWith("err:")) { throw new Exception("Error in server: " + res); } } File.WriteAllBytes(filepath, res_b); } } }
public string SendData(string page, params string[] data) { if (Offline) { return(""); } lock (cookie) { try { if (!page.Contains("/")) { page = "sw/" + page; } var values = PrepareParams(data); using (var wb = new WebClientEx(cookie)) { var res = Encoding.UTF8.GetString(wb.UploadValues(server + page, "POST", values)); if (res.StartsWith("err:")) { throw new Exception("۟۷ۧ ۯ۱ ۳۱Ù۱: \r\n" + res.Replace("err:", "")); } return(res); } } catch (Exception ex) { throw ex;// new Exception(server + page, ex); } } }
public static string GetSpaceTrack(string[] noradId, string username, string password) { string uriBase = "https://www.space-track.org"; string requestController = "/basicspacedata"; string requestAction = "/query"; string predicateValues = "/class/tle_latest/ORDINAL/1/NORAD_CAT_ID/" + string.Join(",", noradId) + "/orderby/NORAD_CAT_ID/format/3le"; string request = uriBase + requestController + requestAction + predicateValues; // Create new WebClient object to communicate with the service using (var client = new WebClientEx()) { // Store the user authentication information var data = new NameValueCollection { { "identity", username }, { "password", password }, }; // Generate the URL for the API Query and return the response var response2 = client.UploadValues(uriBase + "/ajaxauth/login", data); var response4 = client.DownloadData(request); return (System.Text.Encoding.Default.GetString(response4)); } }
static void Main(string[] args) { //HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://linksvip.net/GetLinkFs"); //request.AllowAutoRedirect = true; //request.CookieContainer = cookies; //HttpWebResponse response = (HttpWebResponse)request.GetResponse(); using (var client = new WebClientEx()) { //var response1 = client.DownloadString("https://linksvip.net/GetLinkFs"); //System.Diagnostics.Debug.WriteLine(response1); var data = new NameValueCollection { { "link", "https://www.fshare.vn/file/NCDJDZKJPRC8?token=1545546551" }, { "pass", "undefined" }, { "hash", "0yoHgvl4CsyS8tIu49oEknnEYjvvenuJ13Rljnt0ony4CVuMMq28riOnvqoMk42eMtv1.2522heijy9TD4ur" }, { "captcha", "" }, }; client.Headers["X-Requested-With"] = "XMLHttpRequest"; //client.Headers["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8"; client.Headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763"; var response2 = client.UploadValues("https://linksvip.net/GetLinkFs", data); System.Diagnostics.Debug.WriteLine("ra lua mi"); System.Diagnostics.Debug.WriteLine(response2); Object bytes = response2.GetValue(1); Console.WriteLine(Encoding.Default.GetString(response2)); } Console.ReadKey(); }
public void AddFriend(int PlayerID) { using (WebClientEx WC = new WebClientEx(Cookies)) { NameValueCollection Arguments = new NameValueCollection(1); Arguments.Add("accountId", PlayerID.ToString()); WC.Headers["X-App-Key"] = CSRFToken; WC.Headers["User-Agent"] = SKore.ChromeAgent; WC.UploadValues(Hotel.ToURL() + "/myhabbo/friends/add", Arguments); } }
void MQOEvents_onRequestCharacterLogin(object obj) { if (!LoginWebClient.IsBusy) { MQOEvents.TestEvent("Attempting to login..."); var values = new NameValueCollection { { "CharId", (string)obj.ToString() }, }; // Upload the values string tempUri = "http://midenquest.com/Game.aspx"; LoginWebClient.UploadValues(tempUri, values); MQOEvents.Connected(true); } else { MQOEvents.TestEvent("Login Client is busy"); } }
public void RemoveFriend(int PlayerID) { using (WebClientEx WC = new WebClientEx(Cookies)) { NameValueCollection Arguments = new NameValueCollection(2); Arguments.Add("friendId", PlayerID.ToString()); Arguments.Add("pageSize", "30"); WC.Headers["X-App-Key"] = CSRFToken; WC.Headers["User-Agent"] = SKore.ChromeAgent; WC.UploadValues(Hotel.ToURL(true) + "/friendmanagement/ajax/deletefriends", Arguments); } }
static string GetSourceForMyShowsPage() { using (var client = new WebClientEx()) { var values = new NameValueCollection { { "login_name", "xxx" }, { "login_pass", "xxxx" }, }; // Authenticate client.UploadValues("http://www.tvrage.com/login.php", values); // Download desired page return(client.DownloadString("http://www.tvrage.com/mytvrage.php?page=myshows")); } }
static void Main() { using (var client = new WebClientEx()) { var response1 = client.DownloadString("https://myJazzServer.com:9092/jazz/authenticated/identity"); var data = new NameValueCollection { { "j_username", "myUser" }, { "j_password", "MyPass" }, }; var response2 = client.UploadValues("https://myJazzServer.com:9092/jazz/authenticated/j_security_check", data); Console.WriteLine(Encoding.Default.GetString(response2)); } }
private static string GetSourceForMyShowsPage(string usr, string psw) { using (var client = new WebClientEx()) { var values = new NameValueCollection { { "login_name", usr }, { "login_pass", psw }, }; // Authenticate client.UploadValues("http://admin.anahit.fr/Account/Login", values); // Download desired page return(client.DownloadString("http://admin.anahit.fr/")); } }
private static string ReportBug(string Token, int Project_ID, Mantis_Category Category, Mantis_Reproducibility Reproducable, Mantis_Severity Severity, Mantis_Priority Priority, string Platform, string OS, string OS_Build, string Product_Version, string Summary, string Description, string Steps, string Info, bool Public) { System.Collections.Specialized.NameValueCollection pData = new System.Collections.Specialized.NameValueCollection(); pData.Add("bug_report_token", Token); pData.Add("m_id", "0"); pData.Add("project_id", Project_ID.ToString()); pData.Add("category_id", Category.ToString("d")); pData.Add("reproducibility", Reproducable.ToString("d")); pData.Add("severity", Severity.ToString("d")); pData.Add("priority", Priority.ToString("d")); pData.Add("platform", Platform); pData.Add("os", OS); pData.Add("os_build", OS_Build); pData.Add("product_version", Product_Version); pData.Add("summary", Summary); pData.Add("description", Description); pData.Add("steps_to_reproduce", Steps); pData.Add("additional_info", Info); if (Public) { pData.Add("view_state", "10"); } else { pData.Add("view_state", "50"); } pData.Add("report_stay", string.Empty); string sRet; WebClientEx httpReport = new WebClientEx(); httpReport.KeepAlive = false; httpReport.CookieJar = cJar; sRet = httpReport.UploadValues("http://bugs.realityripple.com/bug_report.php", "POST", pData); if (sRet.StartsWith("Error: ")) { return(null); } if (sRet.Contains("Operation successful.")) { return("OK"); } else { sRet = sRet.Substring(sRet.IndexOf("width50") - 14); sRet = sRet.Substring(0, sRet.IndexOf("</table>") + 8); return(sRet); } }
public static UpdateInfo Check(Uri uri, string version) { NameValueCollection data = new NameValueCollection(); data.Add(osField, Environment.OSVersion.VersionString); data.Add(versionField, version); byte[] output = null; try { WebClientEx webClient = new WebClientEx(); output = webClient.UploadValues(uri, data); } catch (WebException e) { Trace.TraceWarning(e.ToString()); return null; } return UpdateInfo.TryParse(output); }
public static UpdateInfo Check(Uri uri, string version) { NameValueCollection data = new NameValueCollection(); data.Add(osField, Environment.OSVersion.VersionString); data.Add(versionField, version); byte[] output = null; try { WebClientEx webClient = new WebClientEx(); output = webClient.UploadValues(uri, data); } catch (WebException e) { Trace.TraceWarning(e.ToString()); return(null); } return(UpdateInfo.TryParse(output)); }
private void DoXMLRequest(NameValueCollection formData, string address) { using (var webClientEx = new WebClientEx(Cookies)) { webClientEx.Headers["X-App-Key"] = CsrfToken; webClientEx.Headers["User-Agent"] = SKore.ChromeAgent; webClientEx.Headers["Referer"] = Hotel.ToUrl(true) + "/client"; if (formData != null) { webClientEx.UploadValues(address, "POST", formData); } else { webClientEx.DownloadString(address); } } }
public void UpdateProfile(string Motto, bool HomepageVisible, bool FriendRequestAllowed, bool ShowOnlineStatus, bool OfflineMessaging, bool FriendsCanFollow) { using (WebClientEx WC = new WebClientEx(Cookies)) { NameValueCollection Arguments = new NameValueCollection(9); Arguments.Add("__app_key", CSRFToken); Arguments.Add("urlToken", URLToken); Arguments.Add("tab", "2"); Arguments.Add("motto", Motto); Arguments.Add("visibility", HomepageVisible ? "EVERYONE" : "NOBODY"); Arguments.Add("friendRequestsAllowed", FriendRequestAllowed.ToString().ToLower()); Arguments.Add("showOnlineStatus", ShowOnlineStatus.ToString().ToLower()); Arguments.Add("persistentMessagingAllowed", OfflineMessaging.ToString().ToLower()); Arguments.Add("followFriendMode", Convert.ToByte(FriendsCanFollow).ToString()); WC.Headers["X-App-Key"] = CSRFToken; WC.Headers["User-Agent"] = SKore.ChromeAgent; WC.UploadValues(Hotel.ToURL(true) + "/profile/profileupdate", Arguments); } }
public byte[] StartHistoricScrap(string sat_ID, uint dataset_lim) { try { System.Net.WebClient wc = new WebClient(); wc.Encoding = Encoding.UTF8; wc.UseDefaultCredentials = true; wc.Credentials = CredentialCache.DefaultCredentials; wc.Credentials = new NetworkCredential(@"*****@*****.**", "buroso89startrack"); wc.Headers[HttpRequestHeader.UserAgent] = @"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2"; string uriBase = "https://www.space-track.org"; string request = string.Format("https://www.space-track.org/basicspacedata/query/class/tle/NORAD_CAT_ID/{0}/orderby/EPOCH desc/limit/{1}/format/tle", sat_ID, dataset_lim); // Create new WebClient object to communicate with the service using (var client = new WebClientEx()) { // Store the user authentication information var data = new NameValueCollection { { "identity", @"*****@*****.**" }, { "password", "buroso89startrack" }, }; // Generate the URL for the API Query and return the response var response2 = client.UploadValues(uriBase + "/ajaxauth/login", data); var response4 = client.DownloadData(request); wc.Dispose(); return(response4); } } catch (Exception ex) { Debug.WriteLine(ex.ToString()); return(null); } }
} // END WebClient Class public static void GetConjunctionsForCreateDate(string workingPath, string createDate, string userName, string password) { //https://www.space-track.org/expandedspacedata/query/class/cdm/CONSTELLATION/agi/limit/100/creation_date/%3E2015-03-27T00:00:00/orderby/creation_date%20desc/format/kvn ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; string uriBase = "https://www.space-track.org"; string requestController = "/expandedspacedata"; string requestAction = "/query"; // URL to retrieve all the latest tle's for the provided NORAD CAT // IDs for the provided Dates //string predicateValues = "/class/tle_latest/ORDINAL/1/NORAD_CAT_ID/" + string.Join(",", norad) + "/orderby/NORAD_CAT_ID%20ASC/format/tle"; // URL to retrieve all the latest 3le's for the provided NORAD CAT // IDs for the provided Dates string predicateValues = "/class/cdm/CONSTELLATION/agi/limit/100/creation_date/%3E" + createDate + @"/orderby/creation_date%20desc/format/kvn"; string request = uriBase + requestController + requestAction + predicateValues; string[] test; using (var client = new WebClientEx()) { // Store the user authentication information var data = new NameValueCollection { { "identity", userName }, { "password", password }, }; // Generate the URL for the API Query and return the response var response2 = client.UploadValues("https://www.space-track.org/ajaxauth/login", data); var response4 = client.DownloadData(request); test = Regex.Split((System.Text.Encoding.Default.GetString(response4)), "\r\n"); } List <string> cdmFile = null; string fileName = null; foreach (string item in test) { if (item.Contains("CCSDS_CDM_VERS")) { if (cdmFile != null && cdmFile.Count > 0 && !string.IsNullOrWhiteSpace(fileName)) { File.WriteAllLines(Path.Combine(workingPath, fileName), cdmFile.ToArray()); } cdmFile = new List <string>(); cdmFile.Add(item); } else { if (item.Contains("MESSAGE_ID")) { fileName = item.Split('=').LastOrDefault().Trim() + ".cfe"; } cdmFile.Add(item); } } if (cdmFile != null && cdmFile.Count > 0 && !string.IsNullOrWhiteSpace(fileName)) { File.WriteAllLines(Path.Combine(workingPath, fileName), cdmFile.ToArray()); } ////string createDate = "2015-03-27T00:00:00"; //string requestLink = @"https://www.space-track.org/expandedspacedata/[email protected]&password=*SpaceBook2015*your_password&query/class/cdm/CONSTELLATION/agi/limit/100/creation_date/%3E" + createDate + @"/orderby/creation_date%20desc/format/kvn"; //string cdmsFilePath = Downloader.DownloadLinkToFile(requestLink, workingPath); }
public void event_btnUpload_Activated(object sender, EventArgs e) { if (string.IsNullOrEmpty (txtUserName.StringValue) || string.IsNullOrEmpty (txtPassWord.StringValue)) { var alert = new NSAlert { MessageText = "Username or password empty.", AlertStyle = NSAlertStyle.Informational }; alert.AddButton ("Ok"); alert.RunModal(); return; } FileInfo fInfo = new FileInfo(txtFullSceneName.StringValue); long numBytes = fInfo.Length; FileStream fStream = new FileStream(txtFullSceneName.StringValue, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fStream); FormUpload.FileParameter fp = new FormUpload.FileParameter (br.ReadBytes((int)numBytes), Path.GetFileName (txtFullSceneName.StringValue), "application/octet-stream"); br.Close(); fStream.Close(); string releaseType = string.Empty; if (cmbType.StringValue == "App") releaseType = "1"; if (cmbType.StringValue == "Game") releaseType = "2"; var client = new WebClientEx (); var values = new NameValueCollection { { "username", txtUserName.StringValue }, { "password", txtPassWord.StringValue }, }; // Authenticate client.UploadValues("https://mac-torrents.me/login.php", values); string tempResponse = client.DownloadString ("https://mac-torrents.me/upload.php"); string searchFor = "<input type=\"hidden\" name=\"auth\" value=\""; int indexSearchFor = tempResponse.IndexOf (searchFor) + searchFor.Length; string authString = tempResponse.Substring (indexSearchFor, 32); // Upload torrent Dictionary<string, object> paramsDic = new Dictionary<string, object> (); paramsDic.Add ("submit", "true"); paramsDic.Add ("auth", authString); paramsDic.Add ("type", releaseType); paramsDic.Add ("title", txtTitleCode.StringValue); paramsDic.Add ("tags", txtTagsCode.StringValue); paramsDic.Add ("image", txtImageCode.StringValue); paramsDic.Add ("desc", txtDescriptionCode.Value); paramsDic.Add ("file_input", fp); if (cmbComp.StringValue == "10.6") { paramsDic.Add ("macos[]", new string[] {"1", "2", "3", "4"}); } if (cmbComp.StringValue == "10.7") { paramsDic.Add ("macos[]", new string[] {"2", "3", "4"}); } if (cmbComp.StringValue == "10.8") { paramsDic.Add ("macos[]", new string[] {"3", "4"}); } if (cmbComp.StringValue == "10.9") { paramsDic.Add ("macos[]", "4"); } //Upload torrent FormUpload.MultipartFormDataPost ( "https://mac-torrents.me/upload.php", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) " + "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.149 Safari/537.36", paramsDic, client.CookieContainer); try { tempResponse = client.DownloadString ("https://mac-torrents.me/logout.php?auth=" + authString); } catch { } txtNfoFilename.StringValue = ""; txtDescription.Value = ""; txtDescriptionCode.Value = ""; txtTagsCode.StringValue = ""; txtImageCode.StringValue = ""; var alertEnd = new NSAlert { MessageText = "Done!", AlertStyle = NSAlertStyle.Informational }; alertEnd.AddButton ("Ok"); alertEnd.RunModal(); }
public void authenticate() { using (var client = new WebClientEx(_cookies)) { var data = new NameValueCollection { { "identity", _username }, { "password", _password }, }; var response = client.UploadValues(uriBase + "/ajaxauth/login", data); } }
private void Run() { while (true) { var unix = new DateTime(1970, 1, 1); var now = DateTime.Now; var totalSeconds = now.Subtract(unix).TotalSeconds; for (var i = 0; i < _form.Tasks.Count; i++) { if (_form.Tasks[i].state == PwState.Idle && _form.Tasks[i].timestamp <= totalSeconds) { _form.Tasks[i].state = PwState.Processing; UpdateForm(); var wc = new WebClientEx(); wc.Headers.Add("user-agent", MainForm.UserAgent); var url = new Uri($"https://dpm.mini.pw.edu.pl/node/{_form.Tasks[i].id}/register"); // Add session cookie wc.CookieContainer.Add(url, _form.SessionCookie); // Execute try { // Get form_token var get = wc.DownloadString(url); var match = Regex.Match(get, @"name=\""form_token\"" value=\""(.*?)\"""); if (!match.Success) { throw new Exception("form_token not found"); } var post = new NameValueCollection { { "count", _form.Tasks[i].count }, { "form_token", match.Groups[1].Value }, { "form_id", "registration_form" }, }; var result = wc.UploadValues(url, post); var result_str = Encoding.UTF8.GetString(result); if (result_str.Contains("Rejestracja zostaĆa zapisana")) { // Success :) _form.Tasks[i].state = PwState.Success; UpdateForm(); continue; } } catch (WebException ex) { // Timeout? Network error? Try again! } catch (Exception ex) { Debugger.Break(); } _form.Tasks[i].state = PwState.Idle; UpdateForm(); } } // Sleep for 500ms Thread.Sleep(500); } }