static public string GetName() { Username = PostRequest("https://hllm.tk/php/upload/confirm", new NameValueCollection() { { "uid", Filedata[0] }, { "utk", Filedata[1] } }); if (Username == "false" || Username == "") { LoggedIn = false; StartupHdr.ShowLogin(); return(""); } try { return(Username); }catch { return(""); } }
static public void Upload(string path, string subdir = "", bool getToken = false) { if (LoggedIn) { Cursor.Current = Cursors.WaitCursor; if (File.Exists(path)) { string dataStr = Convert.ToBase64String(File.ReadAllBytes(path)); string filename = Path.GetFileName(path); Console.WriteLine("Uploading " + filename + (subdir != "" ? " under: " + subdir : "")); string response = PostRequest("https://hllm.tk/php/upload/upload", new NameValueCollection() { { "uid", Filedata[0] }, { "utk", Filedata[1] }, { "data", dataStr }, { "name", filename }, { "dir", subdir } }); if (response != "false") { if (subdir == "" || getToken) { Clipboard.SetText(response); } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("OK"); Console.ForegroundColor = ConsoleColor.White; } else { ConsoleHdr.writeE("ERROR UPLOADING"); //Console.ReadKey(); //System.Threading.Thread.Sleep(2000); } } else if (Directory.Exists(path)) { bool token = false; if (subdir == "" || getToken) { token = true; } Console.WriteLine("Encountered /" + new DirectoryInfo(path).Name + " ..."); subdir = subdir + new DirectoryInfo(path).Name + "/"; string[] paths = Directory.GetFileSystemEntries(path); foreach (string newpath in paths) { Upload(newpath, subdir); } if (token) { string response = PostRequest("https://hllm.tk/php/upload/token", new NameValueCollection() { { "uid", Filedata[0] }, { "utk", Filedata[1] }, { "name", new DirectoryInfo(path).Name }, { "dir", "" } }); Clipboard.SetText(response); } } else { ConsoleHdr.writeE(Path.GetFileName(path) + " not found!"); } } else { StartupHdr.ShowLogin(); } Cursor.Current = Cursors.Default; }
static private bool commandLineStep() { Console.Write(">"); string raw = Console.ReadLine(); int x = 2; string[] rawArray = raw.Split(new char[] { ' ' }, x); string command = rawArray[0]; List <string> args = new List <string>(); if (rawArray.Length > 1) { string pattern = "[\"'](.*?)[\"']|([^ \"'\\s]+)"; Regex rgx = new Regex(pattern); int[] groupNumbers = rgx.GetGroupNumbers(); Match m = rgx.Match(rawArray[1]); while (m.Success) { for (int i = 1; i <= 2; i++) { Group g = m.Groups[i]; CaptureCollection cc = g.Captures; if (cc.Count > 0) { args.Add(cc[0].Value); } } m = m.NextMatch(); } } switch (command) { case "damn": case "bye": case "kys": case "quit": case "close": case "exit": write("Bye!"); System.Threading.Thread.Sleep(500); return(false); //FreeCons(); break; case "upload": if (args.Count == 0) { OpenFileDialog opf = new OpenFileDialog(); DialogResult result = opf.ShowDialog(); if (result == DialogResult.OK) { UploadHdr.Upload(opf.FileName); } else { writeE("There was an problem with:\n" + opf.FileName); } } else { foreach (string path in args) { UploadHdr.Upload(path); } } break; case "logout": UploadHdr.Logout(); Console.WriteLine("Please log back in"); StartupHdr.ShowLogin(); break; case "screenshot": Process proc = Process.Start("snippingtool", "/clip"); proc.WaitForExit(); if (Clipboard.ContainsImage()) { string path = Path.GetTempPath() + "screenshot_" + DateTime.Now.ToString("dd-MM-yy_HH.mm.ss") + ".png"; Image img = Clipboard.GetImage(); img.Save(path, System.Drawing.Imaging.ImageFormat.Png); UploadHdr.Upload(path, "screenshots/", true); File.Delete(path); } else { writeE("Theres no picture!"); } break; case "fullscreenshot": string ImgPath = Path.GetTempPath() + "screenshot_" + DateTime.Now.ToString("dd-MM-yy_HH.mm.ss") + ".png"; Bitmap image = HotKeyHdr.screenshot(); image.Save(ImgPath, System.Drawing.Imaging.ImageFormat.Png); UploadHdr.Upload(ImgPath, "screenshots/", true); File.Delete(ImgPath); break; default: writeE("Unrecognized command: " + command); break; } return(true); }