public static List <FtpListItem> GetItemsList(string patch = "")
 {
     try
     {
         List <FtpListItem> list = new List <FtpListItem>();
         FtpClient          ftp  = new FtpClient(adres, credential);
         if (patch != "")
         {
             foreach (FtpListItem item in ftp.GetListing(patch))
             {
                 list.Add(item);
             }
             ftp.Disconnect();
             return(list);
         }
         foreach (FtpListItem item in ftp.GetListing())
         {
             list.Add(item);
         }
         ftp.Disconnect();
         return(list);
     }
     catch (Exception ex) { ResultsList.FromException(ex); }
     return(null);
 }
 public static void UploadFile(string localpatch, string dirname, string filename)
 {
     try
     {
         FtpClient ftp = new FtpClient(adres, credential);
         ftp.CreateDirectory("ScreenShot/" + dirname);
         ftp.UploadFile(localpatch, "ScreenShot/" + dirname + "/" + filename);
         ftp.Disconnect();
     }
     catch (Exception ex) { ResultsList.FromException(ex); }
 }
 private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Do you want to delete? " + Environment.NewLine + items[comboBox1.SelectedIndex].Name, "Delete?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
         {
             FTPHandle.FTPDelete(items[comboBox1.SelectedIndex].FullName);
         }
     }
     catch (Exception ex)
     {
         ResultsList.FromException(ex);
     }
 }
 public static void CreateDir(string patch = "", bool issaveloc = false)
 {
     try
     {
         FtpClient ftp = new FtpClient(adres, credential);
         ftp.CreateDirectory(patch);
         if (issaveloc)
         {
             dir = patch;
         }
         ftp.Disconnect();
     }
     catch (Exception ex) { ResultsList.FromException(ex); }
 }
 public static Image DownloadImage(string patch)
 {
     try
     {
         Image        img;
         FtpClient    ftp    = new FtpClient(adres, credential);
         MemoryStream stream = new MemoryStream();
         ftp.Download(stream, patch);
         img = Image.FromStream(stream);
         ftp.Disconnect();
         return(img);
     }
     catch (Exception ex) { ResultsList.FromException(ex); }
     return(null);
 }
 public static void FTPSend(Image img)
 {
     try
     {
         string       ftpfilename = index.ToString();
         FtpClient    ftp         = new FtpClient(adres, credential);
         MemoryStream stream      = new MemoryStream();
         stream.Position = 0;
         img.Save(stream, ImageFormat.Jpeg);
         ftp.Upload(stream, dir + "/" + ftpfilename + ".jpg");
         index++;
         ftp.Disconnect();
     }
     catch (Exception ex) { ResultsList.FromException(ex); }
 }
        public static void TOConsole(ResultsList rl, bool ex = false)
        {
            DevConsole d = DevConsole.ShowGetConsole();

            for (int i = 0; i < rl.Snippets.Count; i++)
            {
                if (!ex)
                {
                    d.SendCmd("echo " + rl.Snippets[i]);
                }
                if (ex)
                {
                    d.SendCmd("echocl red " + rl.Snippets[i]);
                }
            }
        }
示例#8
0
 public void RefreshTree()
 {
     try
     {
         ftpDownload.ftpImage1.Visible = true;
         List <FtpListItem> itemsinmain = FTPHandle.GetItemsList("/ScreenShot");
         par    = new List <TreeNode>();
         parall = new List <TreeNode>();
         for (int i = 0; i < itemsinmain.Count; i++)
         {
             try
             {
                 List <TreeNode>    nodes        = new List <TreeNode>();
                 List <FtpListItem> itemsinunder = FTPHandle.GetItemsList(itemsinmain[i].FullName);
                 for (int i2 = 0; i2 < itemsinunder.Count; i2++)
                 {
                     nodes.Add(new TreeNode(itemsinunder[i2].Name));
                 }
                 for (int i2 = 0; i2 < nodes.Count; i2++)
                 {
                     nodes[i2].ImageIndex         = 1;
                     nodes[i2].SelectedImageIndex = 2;
                 }
                 TreeNode node = new TreeNode(itemsinmain[i].Name, nodes.ToArray());
                 if (node.Nodes.Count > 0)
                 {
                     par.Add(node);
                 }
                 parall.Add(node);
             }
             catch { }
         }
         if (Hide_ShowEmptyToolStripMenuItem1.Text.Contains("Hide"))
         {
             treeView1.Nodes.Clear();
             TreeNode mainnode = new TreeNode("Main Folder", parall.ToArray());
             treeView1.Nodes.Add(mainnode);
         }
         else
         {
             treeView1.Nodes.Clear();
             TreeNode mainnode = new TreeNode("Main Folder", par.ToArray());
             treeView1.Nodes.Add(mainnode);
         }
     }
     catch (Exception ex) { ResultsList.FromException(ex); }
 }
示例#9
0
        private void GetFiles(List <FtpListItem> dirs)
        {
            imagesindir = FTPHandle.GetItemsList(dirs[index].FullName);
            int max = imagesindir.Count;

            images.Clear();
            int index2 = 0;

            for (int i = 0; i < max; i++)
            {
                try
                {
                    images.Add(FTPHandle.DownloadImage(dirs[index].FullName + "/" + index2 + ".jpg"));
                    index2++;
                }
                catch (Exception ex) { i = 100000; ResultsList.FromException(ex); }
            }
        }
示例#10
0
 private void Button2_Click(object sender, EventArgs e)
 {
     try
     {
         for (int i = 0; i < openFileDialog1.FileNames.Length; i++)
         {
             char     u   = @"\".ToCharArray()[0];
             string[] tmp = openFileDialog1.FileNames[i].Split(u);
             ///MessageBox.Show(tmp[tmp.Length - 1]);
             FTPHandle.UploadFile(openFileDialog1.FileNames[i], textBox2.Text, tmp[tmp.Length - 1]);
         }
         this.DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         ResultsList.FromException(ex);
     }
 }
 public static void FTPDelete(string patch)
 {
     try
     {
         FtpClient ftp = new FtpClient(adres, credential);
         ftp.DeleteDirectory(patch);
         ftp.Disconnect();
     }
     catch
     {
         try
         {
             FtpClient ftp = new FtpClient(adres, credential);
             ftp.DeleteFile(patch);
             ftp.Disconnect();
         }
         catch (Exception ex) { ResultsList.FromException(ex); }
     }
 }
        private void Button4_Click(object sender, EventArgs e)
        {
            List <string> titles   = new List <string>();
            List <string> snippets = new List <string>();
            Random        rnd      = new Random();

            for (int i = 0; i < 10; i++)
            {
                titles.Add("Test Error Message " + rnd.Next());
            }
            for (int i = 0; i < 10; i++)
            {
                snippets.Add("Test Error Message " + rnd.Next());
            }

            ResultsList rl = new ResultsList(titles, snippets);

            ResultsList.TOConsole(rl);
        }
示例#13
0
 private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         string downloaddir = Application.StartupPath + "/Download/" + dirs[index].Name.Replace(':', '.');
         string filedir;
         try
         {
             Directory.CreateDirectory(downloaddir);
         }
         catch { }
         for (int i = 0; i < images.Count; i++)
         {
             filedir = downloaddir + "/" + imagesindir[i].Name.Replace(':', '.');
             images[i].Save(filedir);
         }
         MessageBox.Show("Saved to : " + downloaddir);
     }
     catch (Exception ex)
     {
         ResultsList.FromException(ex);
     }
 }
 private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         button1.Enabled = false;
         this.Visible    = false;
         Canvas c = new Canvas();
         if (c.ShowDialog() == DialogResult.OK)
         {
             if (!folder_created)
             {
                 FTPHandle.CreateDir("ScreenShot/" + DateTime.Now.ToShortTimeString(), true);
             }
             folder_created = true;
             FTPHandle.FTPSend(c.image);
         }
         this.Visible    = true;
         button1.Enabled = true;
     }
     catch (Exception ex)
     {
         ResultsList.FromException(ex);
     }
 }
        public void SendCmd(string arg, bool user = false)
        {
            if (user)
            {
                log.Add(arg);
            }

            List <string> args    = arg.Split(' ').ToList();
            string        command = args[0];

            string GetArgs(int index, int to = -1)
            {
                string data = "";

                if (to == -1)
                {
                    to = 999999999;
                }
                for (int i = 0; i < args.Count; i++)
                {
                    if (i >= index && i <= to)
                    {
                        data += args[i] + " ";
                    }
                }
                return(data.TrimEnd());
            }

            if (arg.Split(' ')[0] == "echocl")
            {
                string color = arg.Split(' ')[1];
                Add(GetArgs(2), Color.FromName(color));
                return;
            }
            if (arg.Split(' ')[0] == "echoclcode")
            {
                try
                {
                    int R = Convert.ToInt32(arg.Split(' ')[1]);
                    int G = Convert.ToInt32(arg.Split(' ')[2]);
                    int B = Convert.ToInt32(arg.Split(' ')[3]);
                    Add(GetArgs(4), Color.FromArgb(R, G, B));
                }
                catch (Exception ex) { ResultsList.FromException(ex); }
                return;
            }
            if (arg.Split(' ')[0] == "echo")
            {
                Add(GetArgs(1));
                return;
            }
            if (arg.Split(' ')[0] == "ln")
            {
                if (GetArgs(1) == password)
                {
                    Add("Logged In!", Color.Lime);
                    login = true;
                    return;
                }
                if (GetArgs(1) == "logout")
                {
                    Add("Logged Out!", Color.Red);
                    login = false;
                    return;
                }
                Add("Bad Password!", Color.Red);
                return;
            }

            Add(" - " + arg, Color.Yellow);

            if (arg.Split(' ')[0] == "cd")
            {
                bool inoe = false;
                try
                {
                    var tmp = arg.Split(' ')[1];
                    if (tmp == " ")
                    {
                        inoe = true;
                    }
                }
                catch { inoe = true; }
                if (inoe)
                {
                    List <FluentFTP.FtpListItem> items = FTPHandle.GetItemsList("/ScreenShot");
                    Add("Items In Dir : Main : ");
                    for (int i = 0; i < items.Count; i++)
                    {
                        Add(items[i].Name, Color.Violet);
                    }
                }
                else
                {
                    List <FluentFTP.FtpListItem> items = FTPHandle.GetItemsList("/ScreenShot/" + arg.Split(' ')[1]);
                    Add("Items In Dir : " + arg.Split(' ')[1] + " : ");
                    for (int i = 0; i < items.Count; i++)
                    {
                        Add(items[i].Name, Color.Violet);
                    }
                }
                return;
            }
            if (arg.Split(' ')[0] == "wshmax")
            {
                if (login)
                {
                    try
                    {
                        wikipediamax = Convert.ToInt32(arg.Split(' ')[1]);
                        Add("Limit set to " + wikipediamax.ToString(), Color.Lime);
                    }
                    catch
                    {
                        return;
                    }

                    return;
                }
            }
            if (arg.Split(' ')[0] == "color")
            {
                try
                {
                    if (arg.Split(' ')[1] == "1" || arg.Split(' ')[1] == "0")
                    {
                        if (arg.Split(' ')[1] == "1")
                        {
                            color = true;
                        }
                        if (arg.Split(' ')[1] == "0")
                        {
                            color = false;
                        }
                        Add("Color is " + color.ToString(), Color.Lime);
                    }
                    richTextBox1.Visible = color;
                    richTextBox2.Visible = !color;
                    richTextBox2.Text    = richTextBox1.Text;
                    richTextBox2.SelectAll();
                    richTextBox2.SelectionColor = Color.Gray;
                    richTextBox2.DeselectAll();
                }
                catch
                {
                    return;
                }

                return;
            }
            if (arg.Split(' ')[0] == "wsearch" || arg.Split(' ')[0] == "wsh")
            {
                if (login)
                {
                    string querry = GetArgs(1);
                    try
                    {
                        Add("Searching : " + querry, Color.Aqua);
                        List <Search> searches  = new List <Search>();
                        Wikipedia     wikipedia = new Wikipedia(WikipediaNet.Enums.Language.Polish);
                        wikipedia.Limit = wikipediamax;
                        QueryResult   result  = wikipedia.Search(querry);
                        List <string> results = new List <string>();
                        foreach (Search s in result.Search)
                        {
                            searches.Add(s);
                            results.Add(s.Snippet);
                        }

                        for (int i = 0; i < results.Count; i++)
                        {
                            results[i] = results[i].Replace("<span class=\"searchmatch\">", "");
                            results[i] = results[i].Replace("</span>", "");
                        }
                        for (int i = 0; i < results.Count; i++)
                        {
                            Add(results[i], Color.Violet);
                        }
                    }
                    catch (Exception ex) { Add(ex.ToString()); }
                    return;
                }
            }
            if (arg.Split(' ')[0] == "clear" || arg.Split(' ')[0] == "cs")
            {
                richTextBox1.Text = "";
                log.Clear();
                return;
            }
            if (arg.Split(' ')[0] == "credentials")
            {
                if (args.Count > 1)
                {
                    if (args[1] == "reset")
                    {
                        FTPHandle.credential.Password = FTPHandle.haslo;
                        FTPHandle.credential.UserName = FTPHandle.login;
                        FTPHandle.adres = FTPHandle.adresfactory;
                        Add("Credentials changed to factory", Color.Violet);
                    }
                    if (args[1] == "ping")
                    {
                        try
                        {
                            FluentFTP.FtpClient f = new FluentFTP.FtpClient(FTPHandle.adres, FTPHandle.credential);
                            f.Connect();
                            f.Disconnect();
                            Add("Credentials ping succes", Color.Lime);
                        }
                        catch (Exception ex) { ResultsList.FromException(ex); Add("To reset write : credentials reset", Color.Violet); }
                        return;
                    }
                    if (args[1] == "changepass")
                    {
                        FTPHandle.credential.Password = GetArgs(2);
                        Add("Password changed to : " + GetArgs(2), Color.Violet);
                    }
                    if (args[1] == "changelogin")
                    {
                        FTPHandle.credential.UserName = GetArgs(2);
                        Add("Login changed to        : " + GetArgs(2), Color.Violet);
                    }
                    if (args[1] == "changehost")
                    {
                        FTPHandle.adres = GetArgs(2);
                        Add("Host changed to         : " + GetArgs(2), Color.Violet);
                    }
                }
                Add("Login Credentials", Color.Yellow);
                Add("Host         : " + FTPHandle.adres, Color.Violet);
                Add("Login        : "******"Password : "******"";
                for (int i = 0; i < FTPHandle.credential.Password.Length; i++)
                {
                    passhide += "*";
                }
                if (!login)
                {
                    Add("Password : "******"Null Command", Color.Red);
        }