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 System.Data.SQLite;
  4.  
  5. namespace Dizzy
  6. {
  7.  
  8.  
  9. public class GlobalConfig
  10. {
  11. public string user, password;
  12. private SQLiteConnection conn;
  13.  
  14. public GlobalConfig ()
  15. {
  16. conn = new SQLiteConnection ("Data Source=" + DataBaseName () + ";Version=3;");
  17. // Controlliamo che il database sia correttamente
  18. // inizializzato.
  19. Init ();
  20. }
  21.  
  22. public string GetValue(string field)
  23. {
  24. string val;
  25.  
  26. SQLiteCommand sqlCmd;
  27. this.conn.Open ();
  28. sqlCmd = this.conn.CreateCommand ();
  29.  
  30. sqlCmd.CommandText = "SELECT value FROM config WHERE field = '" + field + "';";
  31. SQLiteDataReader reader = sqlCmd.ExecuteReader ();
  32. if (reader.Read())
  33. val = reader.GetString(0);
  34. else
  35. val = "";
  36. this.conn.Close ();
  37. return val;
  38.  
  39. }
  40.  
  41. public void InsertValue(string field, string val)
  42. {
  43. SQLiteCommand sqlCmd;
  44.  
  45. this.conn.Open ();
  46. sqlCmd = this.conn.CreateCommand ();
  47.  
  48. sqlCmd.CommandText = "INSERT OR REPLACE INTO config VALUES ('" + field + "', '" + val + "');";
  49. sqlCmd.ExecuteNonQuery ();
  50. this.conn.Close ();
  51. }
  52.  
  53. protected void Init ()
  54. {
  55. SQLiteCommand sqlCmd;
  56. this.conn.Open ();
  57. sqlCmd = this.conn.CreateCommand ();
  58.  
  59. sqlCmd.CommandText = "SELECT * FROM sqlite_master WHERE type='table';";
  60. SQLiteDataReader reader = sqlCmd.ExecuteReader ();
  61.  
  62. if(!reader.HasRows)
  63. {
  64. this.conn.Close ();
  65. InitialSetup ();
  66. }
  67. else
  68. this.conn.Close ();
  69. }
  70.  
  71. protected void InitialSetup ()
  72. {
  73. // Dobbiamo creare la struttura del database
  74. SQLiteCommand sqlCmd;
  75. this.conn.Open ();
  76.  
  77. // Tabelle delle configurazioni
  78. sqlCmd = this.conn.CreateCommand ();
  79. sqlCmd.CommandText = "CREATE TABLE config (field TEXT, value TEXT);";
  80. sqlCmd.ExecuteNonQuery ();
  81.  
  82. // Tabella della lista
  83. sqlCmd = this.conn.CreateCommand ();
  84. sqlCmd.CommandText = "CREATE TABLE list (path TEXT, user TEXT);";
  85. sqlCmd.ExecuteNonQuery ();
  86.  
  87. this.conn.Close ();
  88. }
  89.  
  90. protected string DataBaseName ()
  91. {
  92. string dir = "";
  93. if (System.Environment.OSVersion.ToString ().Contains("Windows"))
  94. {
  95.  
  96. System.Reflection.Assembly a = System.Reflection.Assembly.GetEntryAssembly ();
  97. dir = System.IO.Path.GetDirectoryName (a.Location);
  98.  
  99. }
  100. else // Assumiamo qualcosa di Unix-like
  101. {
  102. dir = System.Environment.GetEnvironmentVariable("HOME");
  103. dir += System.IO.Path.DirectorySeparatorChar + ".dizzy";
  104. }
  105. if (!System.IO.Directory.Exists(dir))
  106. System.IO.Directory.CreateDirectory (dir);
  107.  
  108. string db = dir + System.IO.Path.DirectorySeparatorChar + "config.sqlite";
  109. if (!System.IO.File.Exists (db))
  110. System.IO.File.Create (db);
  111. return db;
  112. }
  113. }
  114.  
  115. }