viewgit/index.php:465 Only variables should be passed by reference [2048]
viewgit/index.php:466 Non-static method GeSHi::get_language_name_from_extension() should not be called statically [2048]
using System; using Tamir.SharpSsh; using System.Collections; using System.IO; namespace Dizzy { public class SFTPConnection { public Sftp sftp; string user; public delegate void SFTPEvent (string src, string dest, int transferredBytes, int totalBytes, string message); public event SFTPEvent TransferStarted; public event SFTPEvent TransferProgress; public event SFTPEvent TransferStopped; public delegate void Del (string src, string dest, int transferredBytes, int totalBytes, string message); public SFTPConnection (string user, string password) { // Inizializziamo il protocollo this.user = user; this.sftp.Password = password; } public void Abort () { this.sftp.Cancel (); } private void TransferStartedHandler(string src, string dest, int transferredBytes, int totalBytes, string message) { if(TransferStarted != null) TransferStarted(src, dest, transferredBytes, totalBytes, message); } private void TransferProgressHandler(string src, string dest, int transferredBytes, int totalBytes, string message) { if (TransferProgress != null) TransferProgress(src, dest, transferredBytes, totalBytes, message); } private void TransferStoppedHandler(string src, string dest, int transferredBytes, int totalBytes, string message) { if (TransferStopped != null) TransferStopped(src, dest, transferredBytes, totalBytes, message); } public void Connect() { sftp.Connect (22); } public ArrayList SearchFiles() { Console.WriteLine(" => Scan della nobackup"); // ArrayList users = sftp.GetFileList ("/nobackup/"); users.Add("robol"); users.Add("bianchi"); foreach(string folder in users) { if (folder == ".") continue; else if (folder == "..") continue; Console.WriteLine(" => Scan di {0}", folder); try { matches.AddRange (GetFolderContent(folder)); } catch(Exception e) { Console.WriteLine (e.Message); } } Console.WriteLine(" => Scan terminato"); return matches; } protected ArrayList GetFolderContent(string folder) { ArrayList matches, files; File f; string user; files = sftp.GetFileList("/nobackup/" + folder + "/"); foreach(string entry in files) { // Controllo che non sia una cartella. Evidentemente // questo metodo non è affidabile, ma per ora è il meglio // che SFTP ci permetta di fare. if(entry.IndexOf(".") == -1) matches.AddRange(GetFolderContent(folder + "/" + entry)); else if(!entry.StartsWith(".")) { user = folder; if(user.Contains("/")) user = user.Substring(0, user.IndexOf("/")); matches.Add(f); } } return matches; } public void Download(File f, string downloadFolder) { this.sftp.Get (f.path, downloadFolder + Path.DirectorySeparatorChar + f.name); } public void Upload(string filename) { this.sftp.Put(filename, "/nobackup/" + this.user + "/"); } public void Disconnect () { sftp.Close (); } } }