Beispiel #1
0
 public RandomPassword() : base(Encrypt.CreateRandomPassword(ro_RandomPasswordLength, CommonLogic.IIF(AppLogic.AppConfig("NewPwdAllowedChars").Length == 0, @"abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ23456789~!@#$%&*()_-={}[]\\|;:\,./?", AppLogic.AppConfig("NewPwdAllowedChars"))), Encrypt.CreateRandomSalt())
 {
 }
Beispiel #2
0
        public string Display(int customerID, bool showPollsLink)
        {
            StringBuilder tmpS = new StringBuilder(4096);

            if (!this.CustomerHasVoted(customerID))
            {
                tmpS.Append("<form method=\"POST\" action=\"pollvote.aspx\" name=\"Poll" + this._pollID.ToString() + "Form\" id=\"Poll" + this._pollID.ToString() + "Form\">");
                tmpS.Append("<input type=\"hidden\" name=\"PollID\" value=\"" + this._pollID.ToString() + "\">");
                tmpS.Append("<span class=\"PollTitle\">" + this._name + CommonLogic.IIF(this.IsExpired(), " " + AppLogic.GetString("poll.cs.1", this._skinID, Thread.CurrentThread.CurrentUICulture.Name), string.Empty) + "</span>");

                using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                {
                    dbconn.Open();
                    using (IDataReader rs = DB.GetRS("select * from PollAnswer   with (NOLOCK)  where deleted=0 and PollID=" + this._pollID.ToString() + " order by DisplayOrder,Name", dbconn))
                    {
                        while (rs.Read())
                        {
                            tmpS.Append("<input class=\"PollRadio\" type=\"radio\" value=\"" + DB.RSFieldInt(rs, "PollAnswerID").ToString() + "\" name=\"Poll_" + this._pollID.ToString() + "\"><span class=\"PollAnswer\">" + DB.RSFieldByLocale(rs, "Name", this._localeSetting) + "</span>");
                        }
                    }
                }

                tmpS.Append("<div align=\"center\"><input class=\"PollSubmit\" type=\"submit\" value=\"Vote\" name=\"B1\"></div>");
                tmpS.Append("</form>");
            }
            else
            {
                tmpS.Append("<span class=\"PollTitle\">" + this._name + CommonLogic.IIF(this.IsExpired(), " (Not Active)", string.Empty) + "</span>");
                tmpS.Append("<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
                string sql = "SELECT TOP 100 PERCENT Poll.PollID, PollAnswer.Name, PollAnswer.PollAnswerID, COUNT(PollVotingRecord.PollAnswerID) AS NumVotes, PollAnswer.DisplayOrder FROM (PollAnswer   with (NOLOCK)  INNER JOIN Poll   with (NOLOCK)  ON PollAnswer.PollID = Poll.PollID) LEFT OUTER JOIN PollVotingRecord   with (NOLOCK)  ON PollAnswer.PollID = PollVotingRecord.PollID AND PollAnswer.PollAnswerID = PollVotingRecord.PollAnswerID GROUP BY Poll.PollID, PollAnswer.Name, PollAnswer.PollAnswerID, PollAnswer.DisplayOrder HAVING (Poll.PollID = " + this._pollID.ToString() + ") ";
                switch (this._sortOrder)
                {
                case 1:
                    // As Written
                    sql = sql + " Order By PollAnswer.PollAnswerID";
                    break;

                case 2:
                    // Ascending
                    sql = sql + " ORDER BY NumVotes ASC, PollAnswer.PollAnswerID";
                    break;

                case 3:
                    // Descending
                    sql = sql + " ORDER BY NumVotes DESC, PollAnswer.PollAnswerID";
                    break;
                }

                int NV = this.NumVotes();

                using (SqlConnection dbconn = new SqlConnection(DB.GetDBConn()))
                {
                    dbconn.Open();
                    using (IDataReader rs = DB.GetRS(sql, dbconn))
                    {
                        while (rs.Read())
                        {
                            int answerNumVotes = DB.RSFieldInt(rs, "NumVotes");
                            int thisPercent    = (int)((decimal)answerNumVotes / (decimal)NV * 100.0M);
                            tmpS.Append("<tr>");
                            tmpS.Append("<td width=\"40%\" align=\"right\" valign=\"middle\"><span class=\"PollAnswer\">" + DB.RSFieldByLocale(rs, "Name", this._localeSetting) + ":&nbsp;</span></td>");
                            tmpS.Append("<td width=\"60%\" align=\"left\" valign=\"middle\"><img src=\"" + AppLogic.LocateImageURL("~/App_Themes/skin_" + this._skinID.ToString() + "/images/pollimage.gif") + "\" align=\"absmiddle\" width=\"" + ((int)(thisPercent * 0.9)).ToString() + "%\" height=\"10\" border=\"0\"><span class=\"PollAnswer\"> (" + thisPercent.ToString() + "%)</span></td>");
                            tmpS.Append("</tr>");
                            tmpS.Append("<tr><td colspan=\"2\"><img src=\"images/spacer.gif\" width=\"100%\" height=\"2\"></td></tr>");
                        }
                    }
                }

                tmpS.Append("</table>");
                tmpS.Append("  <div align=\"center\"><span class=\"PollLink\">" + AppLogic.GetString("poll.cs.2", this._skinID, Thread.CurrentThread.CurrentUICulture.Name) + " " + NV.ToString() + "</span></div>");
                if (showPollsLink)
                {
                    tmpS.Append("  <div align=\"center\"><a class=\"PollLink\" href=\"polls.aspx\">" + AppLogic.GetString("poll.cs.3", this._skinID, Thread.CurrentThread.CurrentUICulture.Name) + "</a></div>");
                }
            }

            return(tmpS.ToString());
        }
Beispiel #3
0
        public static String GetEncryptParam(String ParamName)
        {
            String param = string.Empty;

            if (ParamName == "EncryptKey")
            {
                param = CommonLogic.Application(ParamName);
            }
            else
            {
                param = AppLogic.AppConfig(ParamName);
            }

            // now do validation!
            if (ParamName == "EncryptKey")
            {
                if (param.Length == 0 || param == "WIZARD" ||
                    param == AppLogic.ro_TBD)
                {
                    throw new ArgumentException("You must enter your EncryptKey in the /web.config file!!! Open that file in Notepad, and see the instructions.");
                }
            }

            if (ParamName == "EncryptIterations")
            {
                if (param.Length == 0 && !CommonLogic.IsInteger(param) && Convert.ToInt32(param) >= 1 &&
                    Convert.ToInt32(param) <= 4)
                {
                    throw new ArgumentException("The EncryptIterations parameter must be an integer value between 1 and 4.");
                }
            }

            if (ParamName == "InitializationVector")
            {
                if (param.Length == 0 || param == AppLogic.ro_TBD ||
                    param.Length != 16)
                {
                    throw new ArgumentException("You MUST set your InitializationVector in the AppConfig manager in the admin site! it MUST be exactly 16 characters/digits long. This is required for security reasons.");
                }
            }

            if (ParamName == "KeySize")
            {
                if (param.Length == 0 || param == "0" ||
                    (param != "128" && param != "192" && param != "256"))
                {
                    throw new ArgumentException("You MUST set your KeySize value in the AppConfig manager in the admin site to an allowed valid value! This is required for security reasons.");
                }
            }

            if (ParamName == "HashAlgorithm")
            {
                if (param.Length == 0 ||
                    (param != "MD5" && param != "SHA1"))
                {
                    throw new ArgumentException("You MUST set your HashAlgorithm in the AppConfig manager in the admin site to an allowed valid value! This is required for security reasons.");
                }
            }

            return(param);
        }
Beispiel #4
0
        // ----------------------------------------------------------------
        //
        // SIMPLE Xml FIELD ROUTINES
        //
        // ----------------------------------------------------------------

        public static String GetLocaleEntry(String S, String LocaleSetting, bool fallBack)
        {
            String tmpS = String.Empty;

            if (S.Length == 0)
            {
                return(tmpS);
            }
            if (S.StartsWith("&lt;ml&gt;", StringComparison.InvariantCultureIgnoreCase))
            {
                S = XmlDecode(S);
            }
            if (S.StartsWith("<ml>", StringComparison.InvariantCultureIgnoreCase))
            {
                String WebConfigLocale = Localization.GetDefaultLocale();
                if (AppLogic.AppConfigBool("UseXmlDOMForLocaleExtraction"))
                {
                    try
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(S);
                        XmlNode node = doc.DocumentElement.SelectSingleNode("//locale[@name=\"" + LocaleSetting + "\"]");
                        if (fallBack && (node == null))
                        {
                            node = doc.DocumentElement.SelectSingleNode("//locale[@name=\"" + WebConfigLocale + "\"]");
                        }
                        if (node != null)
                        {
                            tmpS = node.InnerText.Trim();
                        }
                        if (tmpS.Length != 0)
                        {
                            tmpS = XmlCommon.XmlDecode(tmpS);
                        }
                    }
                    catch { }
                }
                else
                {
                    // for speed, we are using lightweight simple string token extraction here, not full Xml DOM for speed
                    // return what is between <locale name=\"en-US\">...</locale>, Xml Decoded properly.
                    // we have a good locale field formatted field, so try to get desired locale:
                    if (S.IndexOf("<locale name=\"" + LocaleSetting + "\">") != -1)
                    {
                        tmpS = CommonLogic.ExtractToken(S, "<locale name=\"" + LocaleSetting + "\">", "</locale>");
                    }
                    else if (fallBack && (S.IndexOf("<locale name=\"" + WebConfigLocale + "\">") != -1))
                    {
                        tmpS = CommonLogic.ExtractToken(S, "<locale name=\"" + WebConfigLocale + "\">", "</locale>");
                    }
                    else
                    {
                        tmpS = String.Empty;
                    }
                    if (tmpS.Length != 0)
                    {
                        tmpS = XmlCommon.XmlDecode(tmpS);
                    }
                }
            }
            else
            {
                tmpS = S; // for backwards compatibility...they have no locale info, so just return the field.
            }
            return(tmpS);
        }