Пример #1
0
        public static string GetUsername(long userID)
        {
            var connection = Forums.GetConnection();

            lock (lck)
            {
                if (users == null)
                {
                    users = new Dictionary <long, string> ();
                }

                if (!users.ContainsKey(userID))
                {
                    connection.Open();

                    var cmd = connection.CreateCommand();
                    cmd.CommandText = "SELECT username FROM phpbb_users WHERE (user_id=" + userID + ")";

                    var reader = cmd.ExecuteReader();
                    reader.Read();

                    users.Add(userID, (string)reader["username"]);

                    reader.Close();
                    cmd.Dispose();

                    connection.Close();
                }

                return(users[userID]);
            }
        }
Пример #2
0
        private static void LoadForums()
        {
            var connection = Forums.GetConnection();

            lock (lck)
            {
                connection.Open();

                if (forums == null)
                {
                    forums = new Dictionary <ulong, string> ();

                    var cmd = connection.CreateCommand();
                    cmd.CommandText = "SELECT forum_name,forum_id FROM phpbb_forums WHERE (auth_read = 0)";

                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        forums.Add(Convert.ToUInt64(reader["forum_id"]), (string)reader["forum_name"]);
                    }

                    reader.Close();
                    cmd.Dispose();
                }

                connection.Close();
            }
        }
Пример #3
0
        public static string GetTopicSubject(ulong topicID)
        {
            var connection = Forums.GetConnection();

            lock (lck)
            {
                connection.Open();

                var cmd = connection.CreateCommand();
                cmd.CommandText = "SELECT topic_title FROM phpbb_topics WHERE (topic_id=" + topicID + ")";

                var reader = cmd.ExecuteReader();
                reader.Read();

                string subject = (string)reader["topic_title"];

                reader.Close();
                cmd.Dispose();

                connection.Close();

                return(subject);
            }
        }
Пример #4
0
        public static string GetPostSubject(ulong postID)
        {
            var connection = Forums.GetConnection();

            lock (lck)
            {
                connection.Open();

                var cmd = connection.CreateCommand();
                cmd.CommandText = "SELECT post_subject FROM phpbb_posts_text WHERE (post_id=" + postID + ")";

                var reader = cmd.ExecuteReader();
                reader.Read();

                string subject = (string)reader["post_subject"];

                reader.Close();
                cmd.Dispose();

                connection.Close();

                return(subject);
            }
        }