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]

  1.  
  2. using System;
  3. using Tamir.SharpSsh;
  4. using System.Collections;
  5. using System.IO;
  6.  
  7. namespace Dizzy
  8. {
  9.  
  10. public class SFTPConnection
  11. {
  12.  
  13. public Sftp sftp;
  14. string user;
  15. public delegate void SFTPEvent (string src, string dest, int transferredBytes,
  16. int totalBytes, string message);
  17.  
  18. public event SFTPEvent TransferStarted;
  19. public event SFTPEvent TransferProgress;
  20. public event SFTPEvent TransferStopped;
  21.  
  22. public delegate void Del (string src, string dest,
  23. int transferredBytes, int totalBytes, string message);
  24.  
  25. public SFTPConnection (string user, string password)
  26. {
  27.  
  28. // Inizializziamo il protocollo
  29. this.user = user;
  30. this.sftp = new Sftp ("poisson.phc.unipi.it", user);
  31. this.sftp.Password = password;
  32.  
  33. this.sftp.OnTransferStart += new FileTransferEvent(this.TransferStartedHandler);
  34. this.sftp.OnTransferProgress += new FileTransferEvent(this.TransferProgressHandler);
  35. this.sftp.OnTransferEnd += new FileTransferEvent(this.TransferStoppedHandler);
  36.  
  37. }
  38.  
  39. public void Abort () {
  40. this.sftp.Cancel ();
  41. }
  42.  
  43. private void TransferStartedHandler(string src, string dest, int transferredBytes,
  44. int totalBytes, string message)
  45. {
  46. if(TransferStarted != null)
  47. TransferStarted(src, dest, transferredBytes, totalBytes, message);
  48. }
  49.  
  50. private void TransferProgressHandler(string src, string dest, int transferredBytes,
  51. int totalBytes, string message)
  52. {
  53. if (TransferProgress != null)
  54. TransferProgress(src, dest, transferredBytes, totalBytes, message);
  55. }
  56.  
  57. private void TransferStoppedHandler(string src, string dest, int transferredBytes,
  58. int totalBytes, string message)
  59. {
  60. if (TransferStopped != null)
  61. TransferStopped(src, dest, transferredBytes, totalBytes, message);
  62. }
  63.  
  64. public void Connect()
  65. {
  66. sftp.Connect (22);
  67. }
  68.  
  69. public ArrayList SearchFiles()
  70. {
  71. ArrayList matches = new ArrayList ();
  72. Console.WriteLine(" => Scan della nobackup");
  73. // ArrayList users = sftp.GetFileList ("/nobackup/");
  74. ArrayList users = new ArrayList();
  75. users.Add("robol");
  76. users.Add("bianchi");
  77. foreach(string folder in users)
  78. {
  79. if (folder == ".")
  80. continue;
  81. else if (folder == "..")
  82. continue;
  83. Console.WriteLine(" => Scan di {0}", folder);
  84. try { matches.AddRange (GetFolderContent(folder)); }
  85. catch(Exception e) { Console.WriteLine (e.Message); }
  86. }
  87. Console.WriteLine(" => Scan terminato");
  88. return matches;
  89. }
  90.  
  91. protected ArrayList GetFolderContent(string folder)
  92. {
  93. ArrayList matches, files;
  94. File f;
  95. string user;
  96. files = sftp.GetFileList("/nobackup/" + folder + "/");
  97. matches = new ArrayList ();
  98. foreach(string entry in files)
  99. {
  100. // Controllo che non sia una cartella. Evidentemente
  101. // questo metodo non è affidabile, ma per ora è il meglio
  102. // che SFTP ci permetta di fare.
  103. if(entry.IndexOf(".") == -1)
  104. matches.AddRange(GetFolderContent(folder + "/" + entry));
  105. else if(!entry.StartsWith("."))
  106. {
  107. user = folder;
  108. if(user.Contains("/"))
  109. user = user.Substring(0, user.IndexOf("/"));
  110. f = new File("/nobackup/" + folder + "/" + entry, user );
  111. matches.Add(f);
  112. }
  113. }
  114. return matches;
  115. }
  116.  
  117. public void Download(File f, string downloadFolder)
  118. {
  119. this.sftp.Get (f.path, downloadFolder + Path.DirectorySeparatorChar + f.name);
  120. }
  121.  
  122. public void Upload(string filename)
  123. {
  124. this.sftp.Put(filename, "/nobackup/" + this.user + "/");
  125. }
  126.  
  127. public void Disconnect ()
  128. {
  129. sftp.Close ();
  130. }
  131. }
  132.  
  133.  
  134. }