private void submission_ForumSubmission(object sender, DoWorkEventArgs e) { string textSubject; if (beatmaps[0].Artist.Length == 0) { textSubject = beatmaps[0].Title; } else { textSubject = beatmaps[0].SortTitle; } List <PlayModes> modes = new List <PlayModes>(); foreach (Beatmap b in beatmaps) { if (!modes.Contains(b.PlayMode)) { modes.Add(b.PlayMode); } } if (modes.Count > 1 || modes[0] != PlayModes.Osu) { string modeString = string.Empty; foreach (PlayModes p in modes) { modeString = modeString + p + "|"; } modeString = modeString.TrimEnd('|'); textSubject += " [" + modeString + "]"; } UpdateStatus(LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_PostingToForums)); activeWebRequest = new pWebRequest(Urls.OSZ2_SUBMIT_FORUM); activeWebRequest.Timeout *= 2; activeWebRequest.AddParameter("u", ConfigManager.sUsername); activeWebRequest.AddParameter("p", ConfigManager.sPassword); activeWebRequest.AddParameter("b", newBeatmapSetID.ToString()); activeWebRequest.AddParameter("subject", textSubject); activeWebRequest.AddParameter("message", newMessage + textMessage.Text.Replace("\r", "")); activeWebRequest.AddParameter("complete", (radioButtonPending.Checked ? "1" : "0")); if (checkNotify.Checked) { activeWebRequest.AddParameter("notify", "1"); } activeWebRequest.BlockingPerform(); threadId = Int32.Parse(activeWebRequest.ResponseString); }
private void RequestComments() { if (commentsRequested) { return; } commentsRequested = true; pWebRequest fnr = new pWebRequest(General.WEB_ROOT + "/web/osu-comment.php"); fnr.AddParameter("u", ConfigManager.sUsername); fnr.AddParameter("p", ConfigManager.sPassword); fnr.AddParameter("b", BeatmapManager.Current.BeatmapId.ToString()); fnr.AddParameter("s", BeatmapManager.Current.BeatmapSetId.ToString()); fnr.AddParameter("r", InputManager.ReplayScore.OnlineId.ToString(GameBase.nfi)); fnr.AddParameter("m", ((int)InputManager.ReplayScore.PlayMode).ToString(GameBase.nfi)); fnr.AddParameter("a", "get"); fnr.Finished += comment_IncomingCommentInfo; fnr.Perform(); }
private static void UploadScreenshot(string filename, bool deleteAfterUpload) { if (filename == null) { return; } if (!GameBase.HasLogin) { NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.Screenshot_LoginRequired)); return; } GameBase.RunBackgroundThread(delegate { try { if (lastUpload > 0 && GameBase.Time - lastUpload < 30000) { NotificationManager.ShowMessage("You are trying to upload screenshots too fast!"); return; } lastUpload = GameBase.Time; NotificationManager.ShowMessage("Uploading screenshot...", Color.Yellow, 3000); pWebRequest fileUpload = new pWebRequest(General.WEB_ROOT + "/web/osu-screenshot.php"); fileUpload.AddParameter("u", ConfigManager.sUsername); fileUpload.AddParameter("p", ConfigManager.sPassword); fileUpload.AddParameter("v", "1"); fileUpload.AddFile("ss", File.ReadAllBytes(filename)); fileUpload.BlockingPerform(); string returned = fileUpload.ResponseString; if (returned.Contains("http")) { GameBase.ProcessStart(returned); } else { GameBase.ProcessStart(General.WEB_ROOT + "/ss/" + returned); } NotificationManager.ShowMessage("Screenshot has been uploaded! Opening in browser window..." + filename, Color.YellowGreen, 6000); } catch { } finally { try { if (deleteAfterUpload) { File.Delete(filename); } } catch { } } }); }
internal static void Submit(OsuError err) { if (lastSubmission > 0 && GameBase.Time - lastSubmission < 10000) { return; } lastSubmission = GameBase.Time; try { Logger.Log($@"ERROR (hard crash): {err.Feedback}", LoggingTarget.Runtime, LogLevel.Error); Logger.Log($@"ERROR (hard crash): {err.Exception}", LoggingTarget.Runtime, LogLevel.Error); } catch { } try { pWebRequest r = new pWebRequest(General.WEB_ROOT + "/web/osu-error.php"); r.AddParameter("u", ConfigManager.sUsername); if (GameBase.User != null) { r.AddParameter("i", GameBase.User.Id.ToString()); } r.AddParameter("osumode", ((int)GameBase.Mode).ToString()); r.AddParameter("gamemode", ((int)Player.Mode).ToString()); r.AddParameter("gametime", GameBase.Time.ToString()); r.AddParameter("audiotime", AudioEngine.Time.ToString()); r.AddParameter("culture", Thread.CurrentThread.CurrentCulture.Name); r.AddParameter("b", BeatmapManager.Current != null ? BeatmapManager.Current.BeatmapId.ToString() : ""); r.AddParameter("bc", BeatmapManager.Current != null ? BeatmapManager.Current.BeatmapChecksum : ""); r.AddParameter("exception", err.Exception); r.AddParameter("feedback", err.Feedback); r.AddParameter("stacktrace", err.StackTrace); r.AddParameter("iltrace", err.ILTrace); r.AddParameter("version", General.BUILD_NAME); r.AddParameter("exehash", GameBase.ExeHash(Path.GetFileName(OsuMain.FullPath))); r.AddParameter("config", File.ReadAllText(Path.Combine(OsuMain.UserPath, ConfigManager.UserConfigFilename))); if (err.Screenshot != null) { r.AddFile(@"ss", err.Screenshot); } r.Timeout = 6000; r.BlockingPerform(); } catch { } }
private void submission_PackageAndUpload(object sender, DoWorkEventArgs e) { bool workDone = false; UpdateStatus(LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_SynchronisingMaps)); //Run this on main thread to avoid threading issues (the editor is still being displayed in the background). GameBase.Scheduler.Add(delegate { using (HitObjectManager hitObjectManager = new HitObjectManagerEditor()) { Beatmap current = BeatmapManager.Current; bool requiresReload = false; try { //overwrite beatmap id's from the webservice and save them to disk. for (int i = 0; i < beatmaps.Count; i++) { Beatmap b = beatmaps[i]; if (b.BeatmapSetId != newBeatmapSetID || b.BeatmapId != newBeatmapIDs[i]) { AudioEngine.LoadedBeatmap = BeatmapManager.Current = b; hitObjectManager.SetBeatmap(b, Mods.None); hitObjectManager.LoadWithEvents(); b.BeatmapSetId = newBeatmapSetID; b.BeatmapId = newBeatmapIDs[i]; hitObjectManager.Save(false, false, false); requiresReload = true; } b.ComputeAndSetDifficultiesTomStars(b.PlayMode); } } catch { } if (requiresReload) { AudioEngine.LoadedBeatmap = BeatmapManager.Current = current; editor.LoadFile(current, false, false); } workDone = true; } }); if (checkCancel(e)) { return; } //get beatmap topic contents string url = String.Format(Urls.FORUM_GET_BEATMAP_TOPIC_INFO, ConfigManager.sUsername, ConfigManager.sPassword, newBeatmapSetID); activeWebRequest = new pWebRequest(url); string result = string.Empty; try { activeWebRequest.BlockingPerform(); result = activeWebRequest.ResponseString; if (!string.IsNullOrEmpty(result) && result[0] == '0') { string[] results = result.Split((char)3); threadId = int.Parse(results[1]); Invoke(() => oldMessage = results[3]); } } catch { } while (!workDone) { Thread.Sleep(100); } if (checkCancel(e)) { return; } UpdateStatus(LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_CreatingPackage)); //create a new Osz2 file string osz2Temp = GeneralHelper.GetTempPath(newBeatmapSetID + @".osz2"); //todo: add to progress bar packageCurrentUpload = BeatmapManager.Current.ConvertToOsz2(osz2Temp, false); if (packageCurrentUpload == null) { error = LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_CouldntCreatePackage) + LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_ExtraDiskSpace); submission_PackageAndUpload_Complete(null, null); return; } string osz2NewHash = (BitConverter.ToString(packageCurrentUpload.hash_body) + BitConverter.ToString(packageCurrentUpload.hash_meta)).Replace("-", ""); beatmapFilesize = new System.IO.FileInfo(packageCurrentUpload.Filename).Length; if (checkCancel(e)) { return; } Invoke(delegate { panelMain.Enabled = true; if (beatmaps.Count > 1) { radioButtonWorkInProgress.Checked = approved != 0; radioButtonPending.Checked = approved == 0; } else { radioButtonWorkInProgress.Checked = true; radioButtonPending.Checked = false; } newMessage = "[size=85]This beatmap was submitted using in-game submission on " + DateTime.Now.ToLongDateString() + " at " + DateTime.Now.ToLongTimeString() + "[/size]\n"; newMessage += "\n[b]Artist:[/b] " + beatmaps[0].Artist; newMessage += "\n[b]Title:[/b] " + beatmaps[0].Title; if (beatmaps[0].Source.Length > 0) { newMessage += "\n[b]Source:[/b] " + beatmaps[0].Source; } if (beatmaps[0].Tags.Length > 0) { newMessage += "\n[b]Tags:[/b] " + beatmaps[0].Tags; } newMessage += "\n[b]BPM:[/b] " + Math.Round(1000 / beatmaps[0].ControlPoints[0].BeatLength * 60, 2); newMessage += "\n[b]Filesize:[/b] " + (beatmapFilesize / 1024).ToString(GameBase.nfi) + "kb"; newMessage += String.Format("\n[b]Play Time:[/b] {0:00}:{1:00}", beatmaps[0].TotalLength / 60000, (beatmaps[0].TotalLength % 60000) / 1000); newMessage += "\n[b]Difficulties Available:[/b]\n[list]"; foreach (Beatmap b in beatmaps) { newMessage += string.Format("[*][url={0}]{1}{2}[/url] ({3} stars, {4} notes)\n", Urls.PATH_MAPS + GeneralHelper.UrlEncode(Path.GetFileName(b.Filename)), (b.Version.Length > 0 ? b.Version : "Normal"), (b.PlayMode == PlayModes.OsuMania ? " - " + (int)Math.Round(b.DifficultyCircleSize) + "Key" : ""), Math.Round(b.DifficultyTomStars(b.PlayMode), 2), b.ObjectCount); } newMessage += "[/list]\n"; newMessage += string.Format("\n[size=150][b]Download: [url={0}]{1}[/url][/b][/size]", string.Format(Urls.BEATMAP_SET_DOWNLOAD, newBeatmapSetID), beatmaps[0].SortTitle); if (hasVideo) { newMessage += string.Format("\n[size=120][b]Download: [url={0}]{1}[/url][/b][/size]", string.Format(Urls.BEATMAP_SET_DOWNLOAD_NO_VIDEO, newBeatmapSetID), beatmaps[0].SortTitle + " (no video)"); } newMessage += string.Format("\n[b]Information:[/b] [url={0}]Scores/Beatmap Listing[/url]", string.Format(Urls.BEATMAP_SET_LISTING, newBeatmapSetID)); newMessage += "\n---------------\n"; textMessage.Text = LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_CreatorsWords); if (!string.IsNullOrEmpty(oldMessage)) { if (oldMessage.IndexOf("---------------\n") > 0) { textMessage.Text = oldMessage.Remove(0, oldMessage.IndexOf("---------------") + 16).Trim('\n', '\r').Replace("\n", "\r\n"); } else { textMessage.Text = oldMessage.Replace("\n", "\r\n"); } } textMessage.Focus(); textMessage.SelectAll(); }); bool marathonException = beatmaps[0].Version.Contains("Marathon"); if (beatmapFilesize > 32 * 1024 * 1024 && !marathonException) //special marathon exception { error = LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_UploadFailed) + LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_BeatmapTooLarge); submission_PackageAndUpload_Complete(null, null); return; } if (beatmaps.Count < 2 && !marathonException) { Invoke(delegate { //don't allow submission to pending radioButtonPending.Enabled = false; radioButtonPending.Text = LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_PendingBeatmaps); }); } byte[] uploadBytes; if (!fullSubmit) { UpdateStatus(LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_PreparingChanges)); progressStartTime = DateTime.Now; BSDiffer patchCreator = new BSDiffer(); patchCreator.OnProgress += (object s, long current, long total) => { UpdateProgress(current, total); }; using (MemoryStream ms = new MemoryStream()) { patchCreator.Diff(packagePreviousUpload.Filename, osz2Temp, ms, Compression.GZip); uploadBytes = ms.ToArray(); } } else { uploadBytes = File.ReadAllBytes(osz2Temp); } if (checkCancel(e)) { return; } UpdateStatus(!isNewSubmission ? LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_SendingChanges) : LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_Uploading)); //Start the main upload process... activeWebRequest = new pWebRequest(Urls.OSZ2_SUBMIT_UPLOAD); activeWebRequest.Timeout = 3 * 60 * 1000; activeWebRequest.RetryCount = 0; activeWebRequest.AddParameter("u", ConfigManager.sUsername); activeWebRequest.AddParameter("h", ConfigManager.sPassword); activeWebRequest.AddParameter("t", fullSubmit ? "1" : "2"); activeWebRequest.AddParameter("z", string.Empty); activeWebRequest.AddParameter("s", newBeatmapSetID.ToString()); activeWebRequest.AddFile("osz2", uploadBytes); activeWebRequest.UploadProgress += delegate(pWebRequest r, long current, long total) { if (total == 0) { return; } if (current == total) { UpdateStatus(LocalisationManager.GetString(OsuString.BeatmapSubmissionSystem_Distributing)); } else { UpdateProgress(current, total); } }; activeWebRequest.Finished += submission_PackageAndUpload_Complete; activeWebRequest.Perform(); progressStartTime = DateTime.Now; }
void textBox_OnCommit(pTextBox sender, bool newText) { if (commentTarget == CommentTargets.None && newText) { NotificationManager.ShowMessageMassive("Select a target for your comment first!", 1500); commentInputTextbox.Select(); return; } if (newText && commentInputTextbox.Text.Length > 0) { pWebRequest fnr = new pWebRequest(General.WEB_ROOT + "/web/osu-comment.php"); fnr.AddParameter("u", ConfigManager.sUsername); fnr.AddParameter("p", ConfigManager.sPassword); fnr.AddParameter("s", BeatmapManager.Current.BeatmapSetId.ToString()); fnr.AddParameter("b", BeatmapManager.Current.BeatmapId.ToString(GameBase.nfi)); fnr.AddParameter("m", ((int)InputManager.ReplayScore.PlayMode).ToString(GameBase.nfi)); fnr.AddParameter("r", InputManager.ReplayScore.OnlineId.ToString(GameBase.nfi)); fnr.AddParameter("target", commentTarget.ToString().ToLower()); //append colour here if (commentColourPicker.InitialColour != Color.White && commentColourPicker.InitialColour != Color.TransparentWhite) { string colour = ColourHelper.Color2Hex(commentColourPicker.InitialColour); fnr.AddParameter("f", colour); } fnr.AddParameter("a", "post"); fnr.AddParameter("starttime", commitStartTime.ToString()); fnr.AddParameter("comment", commentInputTextbox.Text); fnr.Finished += delegate { GameBase.Scheduler.Add(delegate { increaseCount(commentTarget); updateCounts(); commentInputTextbox.Text = "Please wait before commenting again..."; NotificationManager.ShowMessage("Your comment has been submitted!", Color.Orange, 3000); }); }; fnr.Perform(); commentInputTextbox.Enabled = false; commentInputTextbox.Text = "Sending..."; } if (commentInputTextbox.Text.Length == 0) { commentInputTextbox.Text = DEFAULT_MESSAGE; } UpdateCommentWindowSizing(); if (Player.Paused) { AudioEngine.TogglePause(); Player.Paused = false; } }
private void submit(object sender, DoWorkEventArgs e) { #if ARCADE //Don't submit scores yet, no matter what. return; #endif #if NO_SCORE_SUBMIT NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.Score_SubmissionDisabled)); return; #endif GameBase.User.spriteInfo.Text = LocalisationManager.GetString(OsuString.Score_SubmittingScore); try { byte[] zipped = new byte[0]; if (Pass) { if (BeatmapManager.Current.onlinePersonalScore != null && TotalScore > BeatmapManager.Current.onlinePersonalScore.TotalScore) { BeatmapManager.Current.Scores.Clear(); } //We should re-retrieve online scores no matter what, otherwise when clicking 'retry' the personal score won't be updated. ReplayCompressed = SevenZipHelper.Compress(new ASCIIEncoding().GetBytes(ReplayString)); #if DEBUG if (ReplayCompressed.Length < 100) { LoadLocalData(); } #endif zipped = ReplayCompressed; } pWebRequest req = new pWebRequest(General.WEB_ROOT + @"/web/osu-submit-modular.php"); req.AddFile(@"score", zipped); string iv = null; #if SUBMISSION_DEBUG File.AppendAllText(@"DEBUG.txt", @"Debug at " + DateTime.Now + @"\n"); #endif if (Pass) { Process[] procs = GameBase.Processes; GameBase.Processes = null; if (procs == null || procs.Length == 0) { procs = Process.GetProcesses(); } StringBuilder b = new StringBuilder(); foreach (Process p in procs) { string filename = string.Empty; try { filename = p.MainModule.FileName; FileInfo fi = new FileInfo(filename); if (fi != null) { filename = CryptoHelper.GetMd5String(fi.Length.ToString()) + @" " + filename; } } catch { } b.AppendLine(filename + @" | " + p.ProcessName + @" (" + p.MainWindowTitle + @")"); } #if SUBMISSION_DEBUG File.AppendAllText(@"DEBUG.txt", @"Running Processes:\n" + b + @"\n\n"); #endif req.AddParameter(@"pl", CryptoHelper.EncryptString(b.ToString(), Secrets.GetScoreSubmissionKey(), ref iv)); } else { req.AddParameter(@"x", Exit ? @"1" : @"0"); req.AddParameter(@"ft", FailTime.ToString()); } #if SUBMISSION_DEBUG File.AppendAllText(@"DEBUG.txt", @"\n1:" + onlineFormatted + @"\n"); File.AppendAllText(@"DEBUG.txt", @"\n2:" + GameBase.clientHash + @"\n"); File.AppendAllText(@"DEBUG.txt", @"\n3:" + iv + @"\n"); #endif req.AddParameter(@"score", CryptoHelper.EncryptString(onlineFormatted, Secrets.GetScoreSubmissionKey(), ref iv)); req.AddParameter(@"fs", CryptoHelper.EncryptString(visualSettingsString, Secrets.GetScoreSubmissionKey(), ref iv)); req.AddParameter(@"c1", GameBase.CreateUniqueId()); req.AddParameter(@"pass", ConfigManager.sPassword); req.AddParameter(@"osuver", General.VERSION.ToString()); req.AddParameter(@"s", CryptoHelper.EncryptString(GameBase.ClientHash, Secrets.GetScoreSubmissionKey(), ref iv)); try { if (Pass && ExtraData != null) { req.AddFile(@"i", ExtraData.ToArray()); } else { req.AddParameter(@"i", string.Empty); } } catch { } GameBase.ChangeAllowance++; ExtraData = null; req.AddParameter(@"iv", iv); int retryCount = Pass ? 10 : 2; int retryDelay = 7500; bool didError = false; while (retryCount-- > 0) { try { req.BlockingPerform(); SubmissionResponseString = req.ResponseString; #if SUBMISSION_DEBUG Debug.Print(SubmissionResponseString); File.AppendAllText(@"DEBUG.txt", @"\nres:" + SubmissionResponseString + @"\n\n\n\n\n-------------------\n\n\n\n"); #endif if (SubmissionResponseString.Contains(@"error:")) { switch (SubmissionResponseString.Replace(@"error: ", string.Empty)) { case @"reset": BanchoClient.HandlePasswordReset(); break; case @"verify": BanchoClient.RequireVerification(); break; case @"nouser": NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.Score_ErrorNoUser)); break; case @"pass": NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.Score_ErrorPassword)); break; case @"inactive": case @"ban": NotificationManager.ShowMessage("ERROR: Your account is no longer active. Please send an email to [email protected] if you think this is a mistake."); break; case @"beatmap": if (Beatmap != null && Beatmap.SubmissionStatus > osu_common.SubmissionStatus.Pending) { NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.Score_ErrorBeatmap)); Beatmap.SubmissionStatus = osu_common.SubmissionStatus.Unknown; } break; case @"disabled": NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.Score_ErrorDisabled)); break; case @"oldver": NotificationManager.ShowMessage(LocalisationManager.GetString(OsuString.Score_ErrorVersion)); GameBase.CheckForUpdates(true); break; case @"no": break; } didError = true; } break; } catch { } if (retryDelay >= 60000) { NotificationManager.ShowMessage(string.Format(LocalisationManager.GetString(OsuString.Score_SubmissionFailed), (retryDelay / 60000))); } Thread.Sleep(retryDelay); retryDelay *= 2; } if (didError) { SubmissionStatus = ScoreSubmissionStatus.Complete; return; } } catch (Exception ex) { } if (SubmissionComplete != null) { SubmissionComplete(this); } SubmissionStatus = ScoreSubmissionStatus.Complete; if (!Pass) { GameBase.User.Refresh(); } }