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