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