Beispiel #1
0
        /// <summary>
        /// Preenche um User com os seus dados
        /// </summary>
        public override void fillUser( User user )
        {
            NpgsqlConnection conn = new NpgsqlConnection(OrionGlobals.getConnectionString("connectionStringPG"));
            NpgsqlCommand cmd = new NpgsqlCommand("OrionsBelt_UsersGetUser", conn);
            cmd.CommandType=CommandType.StoredProcedure;
            cmd.CommandTimeout = 0;

            cmd.Parameters.Add("@user_mail",user.Mail);

            try {
                conn.Open();

                reader = cmd.ExecuteReader();

                if( reader.HasRows ) {
                    reader.Read();

                    user.Nick = (string) getField("user_nick");
                    user.UserId = (int) getField("user_id");

                    if ( getField("user_ruler_id") != DBNull.Value )
                        user.RulerId = (int) getField("user_ruler_id");

                    user.EloRanking = (int) getField("user_rank");

                    user.RegistDate = (DateTime) getField("user_registDate");
                    user.LastLogin = (DateTime) getField("user_lastLogin");

                    user.Skin = (int) getField("user_skin");
                    user.Lang = (string) getField("user_lang");
                    user.ImagesDir = (string) getField("user_imagesDir");

                    user.Website = (string) getField("user_website");
                    user.Avatar = (string) getField("user_avatar");

                    user.Msn = (string) getField("user_msn");
                    user.Icq = (string) getField("user_icq");
                    user.Jabber = (string) getField("user_jabber");
                    user.Aim = (string) getField("user_aim");
                    user.Yahoo = (string) getField("user_yahoo");

                    user.AllianceId = (int) reader["user_alliance_id"];
                    user.AllianceRank = AllianceInfo.ToAllianceRank( reader["user_alliance_rank"].ToString() );

                    user.Wins = (int) reader["user_wins"];
                    user.Losses = (int) reader["user_losses"];

                }else {
                    ExceptionLog.log("User não encontrado", "Mail: " + user.Mail==null?"null":user.Mail );

                }
                reader = null;
            } catch( NpgsqlException e ) {
                throw new AlnitakException("Erro ao executar o procedimento 'OrionsBelt_UsersGetUser' @ NpgsqlServerUserutility::fillUser ",e);
            } finally {
                conn.Close();
            }
        }
Beispiel #2
0
        private Ranking[] GetMatchResult( User current, User user, BattleResult result )
        {
            Ranking one = new Ranking();
            one.EloRanking = current.EloRanking;
            Ranking two = new Ranking();
            two.EloRanking = user.EloRanking;

            Ranking.Update(one, two, result);

            return new Ranking[] { one, two };
        }
Beispiel #3
0
        /// <summary>Responde ao pedido de autenticação</summary>
        protected void Application_AuthenticateRequest( object src, EventArgs e )
        {
            Log.log("Authenticate Request.... ");
            string request =  HttpContext.Current.Request.FilePath;
            bool isAspx = request.IndexOf(".aspx") != -1;

            if( Request.IsAuthenticated ) {
                if( Context.User is User ) {
                    Log.log("Context is user!");
                    return;
                }
                string name = Context.User.Identity.Name;

                object o = HttpContext.Current.Cache[name];
                if( o == null ) {
                    User user = new User( Context.User.Identity, UserUtility.bd.getRoles(name) );
                    HttpContext.Current.Cache.Add(name, user, null, DateTime.Now.AddMinutes(9), Cache.NoSlidingExpiration, CacheItemPriority.Default, new CacheItemRemovedCallback(this.UserOffline));
                    HttpContext.Current.Cache.Add("Ruler-"+user.UserId, user, null, DateTime.Now.AddMinutes(9), Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
                    Context.User = user;
                    RegisterOnlineUser(user);
                    UserUtility.bd.updateLastLogin(name);
                } else {
                    User user = (User) o;
                    Context.User = user;
                    string userId = "Ruler-"+user.UserId;
                    if(HttpContext.Current.Cache[name] == null || HttpContext.Current.Cache[userId] == null) {
                        HttpContext.Current.Cache.Add(name, user, null, DateTime.Now.AddMinutes(9), Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
                        HttpContext.Current.Cache.Add(userId, user, null, DateTime.Now.AddMinutes(9), Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
                    }
                }
                setUserSkin( (User)Context.User );
            } else {
                Context.User = defaultPrincipal;
            }

            if( CheckWiki(Context.User) ) {
                Log.log("... Done!");
                return;
            }

            if( !canView() && isAspx ) {
                OrionGlobals.forceLogin();
            }

            Log.log("... Done!");
        }
Beispiel #4
0
        private void RenderRanks( HtmlTextWriter writer, User[] users )
        {
            writer.WriteLine("<table class='planetFrame'>");
            writer.WriteLine("<tr class='resourceTitle'>");
            writer.WriteLine("<td class='resourceTitle'>#</td>");
            writer.WriteLine("<td class='resourceTitle'>{0}</td>", info.getContent("stats_rulers"));
            writer.WriteLine("<td class='resourceTitle'>{0}</td>", info.getContent("battle_rank"));
            writer.WriteLine("<td class='resourceTitle'>{0}</td>", info.getContent("batalhas"));
            writer.WriteLine("<td class='resourceTitle'>{0}</td>", info.getContent("score"));
            writer.WriteLine("</tr>");

            for( int i = 0; i < users.Length; ++i ) {
                if( users[i] == null ) {
                    continue;
                }

                writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
                writer.WriteLine("<td class='resourceCell'>{0}&ordm;</td>", i +1 );

                bool rulerViewing = false;

                // mostrar o nome do ruler
                writer.WriteLine("<td class='resource'>");
                if( rulerViewing ) {
                    writer.WriteLine("<u><b>{0}</b></u>", OrionGlobals.getLink(users[i]));
                } else {
                    writer.WriteLine(OrionGlobals.getLink(users[i]));
                }

                writer.WriteLine("</td>");

                writer.WriteLine("<td class='resourceCell'>{0}</td>", users[i].EloRankDescription.ToString() );
                writer.WriteLine("<td class='resourceCell'><span class='green'>{0}</span> / <span class='red'>{1}</span></td>", users[i].Wins, users[i].Losses );
                writer.WriteLine("<td class='resourceCell'>{0}</td>", users[i].EloRanking );

                writer.WriteLine("</tr>");
            }
            writer.WriteLine("</table>");
        }
Beispiel #5
0
        /// <summary>Regista um utilizador</summary>
        public void Register( User user )
        {
            if( HasRegisteredUsers ) {
                foreach(User registered in list.Values) {
                    if( registered.UserId == user.UserId ) {
                        return;
                    }
                }
            }

            lock(this) {
                DateTime date = DateTime.Now;

                while( list[date] != null ) {
                    date = date.AddMilliseconds(5);
                }

                list.Add(date, user);
                if( list.Count == Limit ) {
                    list.RemoveAt(0);
                }
            }
        }
        /// <summary>
        /// Guarda um User com os seus dados na Base de Dados
        /// </summary>
        public override void saveUser( User user, string password )
        {
            Hashtable param = new Hashtable();

            param.Add("@user_id",user.UserId);
            if( password != string.Empty )
                param.Add("@user_pass",hashPassword(password) );

            param.Add("@user_ruler_id",user.RulerId);
            param.Add("@user_nick",user.Nick);
            param.Add("@user_skin",user.Skin);
            param.Add("@user_lang",user.Lang);
            param.Add("@user_website",user.Website);
            param.Add("@user_avatar",user.Avatar);
            param.Add("@user_msn",user.Msn);
            param.Add("@user_icq",user.Icq);
            param.Add("@user_jabber",user.Jabber);
            param.Add("@user_aim",user.Aim);
            param.Add("@user_yahoo",user.Yahoo);
            param.Add("@user_signature",user.Signature);
            param.Add("@user_imagesDir",user.ImagesDir);
            param.Add("@user_rank",user.EloRanking);

            SqlServerUtility.executeNonQuery("OrionsBelt_UsersUpdateUser",param);
        }
        /// <summary>Obtém um User dado o seu id</summary>
        public override User getUser( int id )
        {
            SqlConnection conn = new SqlConnection(OrionGlobals.getConnectionString("connectionString"));
            SqlCommand cmd = new SqlCommand("OrionsBelt_UsersGetUserById", conn);
            cmd.CommandType=CommandType.StoredProcedure;
            cmd.CommandTimeout = 0;

            cmd.Parameters.Add("@id",id);

            try {
                conn.Open();

                reader = cmd.ExecuteReader();
                if( reader.Read() ) {
                    User user = new User();

                    user.Nick = (string) reader["user_nick"];
                    user.UserId = (int) reader["user_id"];
                    user.RulerId = (int) reader["user_ruler_id"];
                    user.EloRanking = (int) reader["user_rank"];

                    user.RegistDate = (DateTime) getField("user_registDate");
                    user.LastLogin = (DateTime) getField("user_lastLogin");

                    user.Skin = (int) reader["user_skin"];
                    user.Lang = (string) reader["user_lang"];
                    user.ImagesDir = (string) reader["user_imagesDir"];

                    user.Website = (string) reader["user_website"];
                    user.Avatar = (string) reader["user_avatar"];

                    user.Msn = (string) reader["user_msn"];
                    user.Icq = (string) reader["user_icq"];
                    user.Jabber = (string) reader["user_jabber"];
                    user.Aim = (string) reader["user_aim"];
                    user.Yahoo = (string) reader["user_yahoo"];

                    return user;

                }else
                    return null;

            } catch( Exception e ) {
                throw new AlnitakException("Erro ao executar o procedimento 'OrionsBelt_UsersGetUserById' @ SqlServerUserutility::getUser : " + e.Message,e);
            } finally {
                conn.Close();
            }
        }
Beispiel #8
0
 /// <summary>Altera a skin currente para a skin do utilizador</summary>
 private void setUserSkin( User user )
 {
     MasterSkinInfo masterSkinInfo = MasterSkinUtility.getMasterSkinInfoFromId( user.Skin );
     Context.Items[ "MasterSkinInfo" ] = masterSkinInfo;
 }
Beispiel #9
0
        /// <summary>Regista a entrada de um utilizador online</summary>
        private void RegisterOnlineUser( User user )
        {
            UserWatcher users = (UserWatcher) Application["AlnitakOnlineUsers"];
            users.Register(user);
            UserOnline();

            Log.log("User " + user.Nick + "("+user.UserId+") has entered the game");
        }
Beispiel #10
0
        private IList PopulateInativeUsers(DataSet ds)
        {
            ArrayList users = new ArrayList();
            foreach( DataRow row in ds.Tables[0].Rows ) {
                User user = new User();

                user.UserId = (int) row[0];
                user.RulerId = (int) row[1];
                user.Nick = (string) row[6];

                users.Add( user );
            }
            return users;
        }
Beispiel #11
0
        public bool HasMember( User asker )
        {
            if( asker == null ) {
                return false;
            }

            foreach( User user in Members ) {
                if( user.UserId == asker.UserId )  {
                    return true;
                }
            }

            return false;
        }
Beispiel #12
0
 /// <summary>Preenche um User com os seus dados</summary>
 public override void fillUser( User user )
 {
     string query = string.Format("SELECT * FROM Users WHERE `user_mail` LIKE '{0}'",user.Mail);
     fillUserInformation(user, query);
 }
Beispiel #13
0
 /// <summary>Guarda um User com os seus dados na Base de Dados</summary>
 public abstract void saveUser( User user, string password );
Beispiel #14
0
        /// <summary>Mostra a documentação</summary>
        private void showInfo( HtmlTextWriter writer, User user )
        {
            showUserRole(writer, user);

            writer.WriteLine("<div class='planetInfoZoneTitle'>{0} - <b>{1}</b></div>",
                    info.getContent("information"), user.Nick
                );

            string avatar = user.Avatar!=string.Empty?user.Avatar:Alnitak.User.DefaultAvatar;

            writer.WriteLine("<table cellpadding='0' cellspacing='0' class='planetFrame' >");
            writer.WriteLine("<tr><td>");
            writer.WriteLine("<table width='100%'>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource' width='50%'>{0}</td>", info.getContent("name"));
            writer.WriteLine("<td class='resourceCell' width='50%'>{0}</td>", OrionGlobals.getLink(user));
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("online"));
            writer.WriteLine("<td class='resourceCell'>");
            if(  OrionGlobals.isUserOnline(user.UserId) ) {
                writer.WriteLine("<img src='{0}' />", OrionGlobals.getCommonImagePath("online.gif"));
            } else {
                writer.WriteLine("<img src='{0}' />", OrionGlobals.getCommonImagePath("offline.gif"));
            }
            writer.WriteLine("</td>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("profile_website"));
            writer.WriteLine("<td class='resourceCell'><a href='{0}'>{0}</a></td>", user.Website==string.Empty?"-":user.Website);
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("section_contact"));
            writer.WriteLine("<td class='resourceCell'><a href='{0}forum/default.aspx?g=pmessage&u={1}'>{2}</a></td>", OrionGlobals.AppPath, user.UserId, info.getContent("pmsg_send"));
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("profile_signature"));
            writer.WriteLine("<td class='resourceCell'>{0}</td>", user.Signature==string.Empty?"-":user.Signature);
            writer.WriteLine("</tr>");
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("profile_regist"));
            writer.WriteLine("<td class='resourceCell'>{0}</td>", OrionGlobals.FormatDateTime(user.RegistDate));
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("profile_lastLogin"));
            writer.WriteLine("<td class='resourceCell'>{0}</td>", OrionGlobals.FormatDateTime(user.LastLogin));
            writer.WriteLine("</tr>");
            writer.WriteLine("</tr>");

            writer.WriteLine("</table>");

            writer.WriteLine("</td>");

            writer.WriteLine("<td class='resource' align='center'><fieldset><legend><b>{1}</b></legend><img class='avatar' src='{0}'/></fieldset></td></tr>",avatar,info.getContent("profile_avatarText"));

            writer.WriteLine("</table>");

            writer.WriteLine("<div class='planetInfoZoneTitle'>{0} - <b>{1}</b></div>",
                    info.getContent("elo_battle_rank"), user.Nick
                );

            writer.WriteLine("<table class='planetFrame'>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("score"));
            writer.WriteLine("<td class='resourceCell'>{0}</td>", user.EloRanking);
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("elo_battle_rank"));
            writer.WriteLine("<td class='resourceCell'>{0}</td>", user.EloRankDescription);
            writer.WriteLine("</tr>");

            User current = Context.User as User;
            if( current != null ) {
                Ranking[] ranks = GetMatchResult(current, user, BattleResult.NumberOneVictory);
                int ifWinPoints = ranks[0].EloRanking - current.EloRanking;
                writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
                writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("IfWin"));
                writer.WriteLine("<td class='resourceCell'>{0} (<span class='green'>+{1}</span>)</td>", ranks[0].EloRanking, ifWinPoints);
                writer.WriteLine("</tr>");

                ranks = GetMatchResult(current, user, BattleResult.NumberTwoVictory);
                int ifLoosePoints = ranks[0].EloRanking - current.EloRanking;
                writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
                writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("IfLoose"));
                writer.WriteLine("<td class='resourceCell'>{0} (<span class='red'>{1}</span>)</td>", ranks[0].EloRanking, ifLoosePoints);
                writer.WriteLine("</tr>");
            }
            writer.WriteLine("</table>");

            if ( user.RulerId == -1 ) {
                return;
            }

            Ruler ruler = Universe.instance.getRuler(user.RulerId);

            writer.WriteLine("<div class='planetInfoZoneTitle'>{0} - <b>{1}</b></div>",
                    info.getContent("information"), user.Nick
                );

            writer.WriteLine("<table class='planetFrame'>");
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("battle_rank"));
            writer.WriteLine("<td class='resourceCell'><b>{0}</b>º</td>", (ruler.Rank==-1?"~":ruler.Rank.ToString()));
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("stats_alliances"));
            string allianceText = null;
            if ( Universe.instance.isDefaultAlliance(ruler) || ruler.AllianceId < 0 ) {
                allianceText = "<i>"+info.getContent("no_alliance")+"</i>";
            } else {
                allianceText = AllianceUtility.Persistance.Get( ruler.AllianceId ).Name;
            }
            writer.WriteLine("<td class='resourceCell'>{0}</td>", allianceText  );
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("planetas"));
            writer.WriteLine("<td class='resourceCell'>{0}</td>", ruler.Planets.Length);
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("victories"));
            writer.WriteLine("<td class='resourceCell'>{0}</td>", ruler.Victories);
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("defeats"));
            writer.WriteLine("<td class='resourceCell'>{0}</td>", ruler.Defeats);
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("score"));
            writer.WriteLine("<td class='resourceCell'>{0}</td>", ruler.getResourceCount("score"));
            writer.WriteLine("</tr>");
            writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
            writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("battle_rank"));
            writer.WriteLine("<td class='resourceCell'>{0}</td>", info.getContent(ruler.Ranking));
            writer.WriteLine("</tr>");

            if( current!= null ) {
                if( user.RulerId != current.RulerId ) {
                    writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
                    writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("battleAdminUser_friendly"));
                    writer.WriteLine("<td class='resourceCell'><a href='ruler/battle/friendlybattle/default.aspx?user={0}'>{1}</a></td>",user.Nick, info.getContent("battle_create"));
                    writer.WriteLine("</tr>");
                }

                if( current.IsInRole("admin") ) {
                    writer.WriteLine("<tr onmouseover='overResource(this);' onmouseout='outResource(this);'>");
                    writer.WriteLine("<td class='resource'>{0}</td>", info.getContent("batalhas"));
                    writer.WriteLine("<td class='resourceCell'><a href='admin/battleadmin/default.aspx?id={0}'>{1}</a></td>", ruler.Id, info.getContent("battleAdminUser_view") );
                    writer.WriteLine("</tr>");
                }
            }

            writer.WriteLine("</table>");

            if( ruler.Prizes == null || ruler.Prizes.Count == 0 ) {
                return;
            }

            writer.WriteLine("<div class='planetInfoZoneTitle'><b>{0}</b></div>",
                    info.getContent("section_prizes")
                );

            writer.WriteLine("<table class='planetFrame'>");
            writer.WriteLine("<tr class='resourceTitle'>");
            writer.WriteLine("<td class='resourceTitle'>{0}</td>", info.getContent("Medal"));
            writer.WriteLine("<td class='resourceTitle'>{0}</td>", info.getContent("prize"));
            writer.WriteLine("<td class='resourceTitle'>{0}</td>", info.getContent("turn_current"));
            writer.WriteLine("</tr>");

            foreach( Winner winner in ruler.Prizes ) {
                writer.WriteLine("<tr  onmouseover='overResource(this);' onmouseout='outResource(this);'>");
                writer.WriteLine("<td class='resourceCell'><img src='{0}prizes/{1}{2}.gif' /></td>", OrionGlobals.getCommonImagePath(), OrionGlobals.getPrizeCategory(winner), winner.Medal.ToString() );
                writer.WriteLine("<td class='resource'>{0}</td>", info.getContent(winner.Prize));
                writer.WriteLine("<td class='resourceCell'>{0}</td>", winner.Turn);
                writer.WriteLine("</tr>");
            }

            writer.WriteLine("</table>");
        }
Beispiel #15
0
 /// <summary>Indica um mail dado um user</summary>
 public static string GetFormattedMail( User user )
 {
     return string.Format("{0} <{1}>", user.Nick, user.Mail);
 }
Beispiel #16
0
        /// <summary>Preenche um User com os seus dados</summary>
        private bool fillUserInformation( User user, string query )
        {
            HttpContext.Current.Trace.Write("MySQL","Query String: " + query);

            try {
                conn.Open();
                MySqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = query;

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

                HttpContext.Current.Trace.Write("MySQL","Has Rows: " + reader.HasRows.ToString());

                user.Nick = (string) reader["user_nick"];
                user.Mail = (string) reader["user_mail"];
                user.UserId = (int) reader["IDUsers"];
                user.RulerId = (int) reader["user_ruler_id"];
                user.EloRanking = (int) reader["user_rank"];
                user.AllianceId = (int) reader["user_alliance_id"];
                user.AllianceRank = AllianceInfo.ToAllianceRank((string) reader["user_alliance_rank"]);

                if( reader["user_regist"] != DBNull.Value ) {
                    user.RegistDate = (DateTime) reader["user_regist"];
                } else {
                    user.RegistDate = DateTime.Now;
                }

                if( reader["user_lastLogin"] != DBNull.Value ) {
                    user.LastLogin = (DateTime) reader["user_lastLogin"];
                } else {
                    user.LastLogin = DateTime.Now;
                }

                user.Skin = (int) reader["user_skin"];
                user.Lang = (string) reader["user_lang"];
                user.ImagesDir = (string) reader["user_imagesDir"];

                user.Website = (string) reader["user_website"];
                user.Avatar = (string) reader["user_avatar"];

                user.Msn = (string) reader["user_msn"];
                user.Icq = (string) reader["user_icq"];
                user.Jabber = (string) reader["user_jabber"];
                user.Aim = (string) reader["user_aim"];
                user.Yahoo = (string) reader["user_yahoo"];

                user.SetRoles( getRoles(user.UserId) );

                return true;

            } catch( Exception e ) {
                HttpContext.Current.Trace.Warn("MySQL",e.Message);
                Console.WriteLine("EXCEPTION: " + e);
                return false;
            } finally {
                conn.Close();
            }
        }
Beispiel #17
0
        /// <summary>Guarda um User com os seus dados na Base de Dados</summary>
        public override void saveUser( User user, string password )
        {
            /*
                UPDATE Users
                user_mail='', user_pass='',
                user_msn='', user_icq='', user_jabber='', user_aim='', user_yahoo='', user_signature='', user_imagesDir=''
                WHERE user_id=
            */

            //

            StringWriter writer = new StringWriter();
            writer.Write("UPDATE Users SET ");
            writer.Write("user_ruler_id={0}, ", user.RulerId);

            writer.Write("user_nick='{0}', ", user.Nick);
            writer.Write("user_skin={0}, ", user.Skin);
            writer.Write("user_lang='{0}', ", user.Lang);

            writer.Write("user_website='{0}', ", user.Website);
            writer.Write("user_avatar='{0}', ", user.Avatar);
            writer.Write("user_rank='{0}', ", user.EloRanking);
            writer.Write("user_alliance_id='{0}', ", user.AllianceId);
            writer.Write("user_alliance_rank='{0}', ", AllianceInfo.FromAllianceRole(user.AllianceRank));

            writer.Write("user_msn='{0}', ", user.Msn);
            writer.Write("user_icq='{0}', ", user.Icq);
            writer.Write("user_jabber='{0}', ", user.Jabber);
            writer.Write("user_aim='{0}', ", user.Aim);
            writer.Write("user_yahoo='{0}', ", user.Yahoo);
            writer.Write("user_signature='{0}', ", user.Signature);
            writer.Write("user_imagesDir='{0}' ", user.ImagesDir);

            writer.Write("WHERE IDUsers={0}", user.UserId);

            string query = writer.ToString();
            HttpContext.Current.Trace.Write("MySQL","Query String: " + query);

            try {
                conn.Open();
                MySqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = query;

                cmd.ExecuteNonQuery();

            } catch( Exception e ) {
                HttpContext.Current.Trace.Warn("MySQL",e.Message);
                Console.WriteLine("Update exception: " + e.Message);
            } finally {
                conn.Close();
            }
        }
Beispiel #18
0
 /// <summary>Obtém um User dado o seu id</summary>
 public override User getUser( int id )
 {
     User user = new User();
     string query = string.Format("SELECT * FROM Users WHERE `IDUsers` = {0}", id);
     if( !fillUserInformation(user, query) ) {
         return null;
     }
     return user;
 }
Beispiel #19
0
 /// <summary>Mostra informação de roles</summary>
 private void showUserRole( HtmlTextWriter writer, User user )
 {
     if( OrionGlobals.isAdmin(user) ) {
         writer.WriteLine("<div class='nav'>{0}</div>", string.Format(info.getContent("user_admin"), OrionGlobals.getLink(user)) );
         return;
     }
     if( OrionGlobals.isBetaTester(user) ) {
         writer.WriteLine("<div class='nav'>{0}</div>", string.Format(info.getContent("user_betatester"), OrionGlobals.getLink(user)) );
         return;
     }
     if( OrionGlobals.isArtist(user) ) {
         writer.WriteLine("<div class='nav'>{0}</div>", string.Format(info.getContent("user_artist"), OrionGlobals.getLink(user)) );
         return;
     }
 }
Beispiel #20
0
 /// <summary>Retorna um link completo para um ruler</summary>
 public static string getLink( User user )
 {
     if( user.RulerId == -1 ) {
         StringWriter writer = new StringWriter();
         string css = getUserCss(user.UserId);
         writer.Write("<a href='{2}userinfo.aspx?id={1}' class='{3}'>{0}</a>", user.Nick, user.UserId, AppPath, css);
         getUserText(writer, user.UserId, null);
         return writer.ToString();
     }
     return getLink( Universe.instance.getRuler(user.RulerId) );
 }
Beispiel #21
0
        protected ArrayList PopulateUsers(DataSet ds, string idstr)
        {
            ArrayList list = new ArrayList();

            foreach( DataRow row in ds.Tables[0].Rows ) {
                User user = new User();

                user.Nick = (string) row["user_nick"];
                user.Mail = (string) row["user_mail"];
                user.UserId = (int) row[idstr];
                user.RulerId = (int) row["user_ruler_id"];
                user.EloRanking = (int) row["user_rank"];

                user.AllianceId = (int) row["user_alliance_id"];
                user.AllianceRank = AllianceInfo.ToAllianceRank((string) row["user_alliance_rank"]);

                user.Wins = (int)row["user_wins"];
                user.Losses = (int)row["user_losses"];

                list.Add(user);
            }

            return list;
        }
Beispiel #22
0
        private string GetSelect( User user )
        {
            StringWriter writer = new StringWriter();

            writer.Write("<select name='updateUser{0}' id='updateUser{0}'>", user.UserId );
            writer.Write("<option >Remove</option>", user.UserId );
            writer.Write("<option {1}>Private</option>", user.UserId, user.AllianceRank == AllianceMember.Role.Private? "selected" : "" );
            writer.Write("<option {1}>Corporal</option>", user.UserId, user.AllianceRank == AllianceMember.Role.Corporal? "selected" : "" );
            writer.Write("<option {1}>ViceAdmiral</option>", user.UserId, user.AllianceRank == AllianceMember.Role.ViceAdmiral? "selected" : "" );
            writer.Write("<option {1}>Admiral</option>", user.UserId, user.AllianceRank == AllianceMember.Role.Admiral? "selected" : "" );
            writer.Write("</select> ");
            writer.Write("<input value='Update' type='button' onclick='update({0})' />", user.UserId);

            return writer.ToString();
        }
Beispiel #23
0
 /// <summary>Indica se determinado user é admin</summary>
 public static bool isAdmin( User user )
 {
     return user.IsInRole("admin");
 }
Beispiel #24
0
        protected User[] PopulateUserRankings(int count, DataSet ds, string idstr)
        {
            User[] users = new User[count];
            int i = -1;

            foreach( DataRow row in ds.Tables[0].Rows ) {
                User user = new User();

                user.Nick = (string) row["user_nick"];
                user.Mail = (string) row["user_mail"];
                user.UserId = (int) row[idstr];
                user.RulerId = (int) row["user_ruler_id"];
                user.EloRanking = (int) row["user_rank"];
                user.Wins = (int)row["user_wins"];
                user.Losses = (int)row["user_losses"];

                users[++i] = user;
            }
            return users;
        }
Beispiel #25
0
 /// <summary>Indica se determinado indice é admin</summary>
 public static bool isArtist( User user )
 {
     return user.IsInRole("artist");
 }
Beispiel #26
0
 /// <summary>Preenche um User com os seus dados</summary>
 public abstract void fillUser( User user );
Beispiel #27
0
 /// <summary>Indica se determinado indice é admin</summary>
 public static bool isBetaTester( User user )
 {
     return user.IsInRole("betaTester");
 }
Beispiel #28
0
        public bool HasWannabe( User asker )
        {
            if( asker == null ) {
                return false;
            }

            foreach( User user in Wannabe ) {
                if( user.UserId == asker.UserId )  {
                    return true;
                }
            }

            return false;
        }
Beispiel #29
0
        /// <summary>
        /// Guarda um User com os seus dados na Base de Dados
        /// </summary>
        public override void saveUser( User user, string password )
        {
            PostGreParam[] param = new PostGreParam[20];

            param[0] = new PostGreParam(user.UserId,NpgsqlDbType.Integer);

            if( password != string.Empty ) {
                param[1] = new PostGreParam(hashPassword(password),NpgsqlDbType.Varchar,40);
            }else {
                param[1] = new PostGreParam("",NpgsqlDbType.Varchar,40);
            }

            param[2] = new PostGreParam(user.RulerId,NpgsqlDbType.Integer);
            param[3] = new PostGreParam(user.Nick,NpgsqlDbType.Varchar,30);
            param[4] = new PostGreParam(user.Skin,NpgsqlDbType.Integer);
            param[5] = new PostGreParam(user.Lang,NpgsqlDbType.Varchar,5);
            param[6] = new PostGreParam(user.Website,NpgsqlDbType.Varchar,30);
            param[7] = new PostGreParam(user.Avatar,NpgsqlDbType.Varchar,250);
            param[8] = new PostGreParam(user.Msn,NpgsqlDbType.Varchar,30);
            param[9] = new PostGreParam(user.Icq,NpgsqlDbType.Varchar,30);
            param[10] = new PostGreParam(user.Jabber,NpgsqlDbType.Varchar,30);
            param[11] = new PostGreParam(user.Aim,NpgsqlDbType.Varchar,30);
            param[12] = new PostGreParam(user.Yahoo,NpgsqlDbType.Varchar,30);
            param[13] = new PostGreParam(user.Signature,NpgsqlDbType.Varchar,255);
            param[14] = new PostGreParam(user.ImagesDir,NpgsqlDbType.Varchar,100);
            param[15] = new PostGreParam(user.EloRanking,NpgsqlDbType.Integer);
            param[16] = new PostGreParam(user.AllianceId,NpgsqlDbType.Integer);
            param[17] = new PostGreParam(user.AllianceRank,NpgsqlDbType.Varchar,15);
            param[18] = new PostGreParam(user.Wins,NpgsqlDbType.Integer);
            param[19] = new PostGreParam(user.Losses,NpgsqlDbType.Integer);

            PostGreServerUtility.executeNonQuery2("OrionsBelt_UsersUpdateUser",param);
        }