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 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. lock (this)
  44. {
  45.  
  46. SQLiteCommand sqlCmd;
  47.  
  48. this.conn.Open ();
  49. sqlCmd = this.conn.CreateCommand ();
  50.  
  51. sqlCmd.CommandText = "INSERT OR REPLACE INTO config VALUES ('" + field + "', '" + val + "');";
  52. sqlCmd.ExecuteNonQuery ();
  53. this.conn.Close ();
  54. }
  55. }
  56.  
  57. protected void Init ()
  58. {
  59.  
  60. SQLiteCommand sqlCmd;
  61. this.conn.Open ();
  62. sqlCmd = this.conn.CreateCommand ();
  63.  
  64. sqlCmd.CommandText = "SELECT * FROM sqlite_master WHERE type='table';";
  65. SQLiteDataReader reader = sqlCmd.ExecuteReader ();
  66.  
  67. if(!reader.HasRows)
  68. {
  69. this.conn.Close ();
  70. InitialSetup ();
  71. }
  72. else
  73. this.conn.Close ();
  74.  
  75. }
  76.  
  77. protected void InitialSetup ()
  78. {
  79. lock (this)
  80. {
  81. // Dobbiamo creare la struttura del database
  82. SQLiteCommand sqlCmd;
  83. this.conn.Open ();
  84.  
  85. // Tabelle delle configurazioni
  86. sqlCmd = this.conn.CreateCommand ();
  87. sqlCmd.CommandText = "CREATE TABLE config (field TEXT PRIMARY KEY, value TEXT);";
  88. sqlCmd.ExecuteNonQuery ();
  89.  
  90. // Tabella della lista
  91. sqlCmd = this.conn.CreateCommand ();
  92. sqlCmd.CommandText = "CREATE TABLE list (path TEXT PRIMARY KEY, user TEXT);";
  93. sqlCmd.ExecuteNonQuery ();
  94.  
  95. this.conn.Close ();
  96. }
  97. }
  98.  
  99. protected string DataBaseName ()
  100. {
  101. string dir = "";
  102. if (System.Environment.OSVersion.ToString ().Contains("Windows"))
  103. {
  104.  
  105. System.Reflection.Assembly a = System.Reflection.Assembly.GetEntryAssembly ();
  106. dir = System.IO.Path.GetDirectoryName (a.Location);
  107.  
  108. }
  109. else // Assumiamo qualcosa di Unix-like
  110. {
  111. dir = System.Environment.GetEnvironmentVariable("HOME");
  112. dir += System.IO.Path.DirectorySeparatorChar + ".dizzy";
  113. }
  114. if (!System.IO.Directory.Exists(dir))
  115. System.IO.Directory.CreateDirectory (dir);
  116.  
  117. string db = dir + System.IO.Path.DirectorySeparatorChar + "config.sqlite";
  118. if (!System.IO.File.Exists (db))
  119. System.IO.File.Create (db);
  120. return db;
  121. }
  122. }
  123.  
  124. }