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