Exemplo n.º 1
0
 public void GetTranslationFromSQL()
 {
     string[] keywords = langDic.Keys.ToArray();
     string keywordString = null;
     foreach (string keyword in keywords)
     {
         keyword.Replace("|", "\\|");
         if (keywordString == null)
         {
             keywordString = keyword;
         }
         else
         {
             keywordString = keywordString + "|" + keyword;
         }
     }
     SqlStoredProcedures sqlSP = new SqlStoredProcedures();
     string contextString = sqlSP.LangGetTranslation(langID, "SL_MVC", keywordString);
     contextString = contextString.Replace("\\|", "\\"); //TODO: Add FULL support for \| escape
     string[] context = contextString.Split('|');
     for (int i = 0; i < keywords.Length; i++)
     {
         langDic[keywords[i]] = context[i];
     }
     taskAddKeyword.SetResult(true);
 }
Exemplo n.º 2
0
        public static int CreateUser(string username, string displayName, string password, string emailAddress, string langName, string ip, string reCapResponse)
        {
            ValidateUsername(username);
            ValidateDisplayName(displayName);
            ValidatePassword(password);
            ValidateEmail(emailAddress);
            ValidateLangName(langName);
            ValidateIP(ip);
            ValidateReCapResponse(reCapResponse, ip);

            string passwordSalt = Hash.GenerateSalt(64);
            string passwordHash = Hash.HashString(password, passwordSalt, new SHA3.SHA3Managed(512));
            SqlStoredProcedures sqlSP = new SqlStoredProcedures();
            try
            {
                int userID = sqlSP.UserCreateUser(username, displayName, passwordSalt, passwordHash, emailAddress, langName, ip);
                string verifyString = sqlSP.UserGetEmailVerifyString(emailAddress);
                Email.SendVerifyEmail(emailAddress, verifyString, langName);
                return userID;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return -1;
            }
        }
Exemplo n.º 3
0
 public string GetLangCode()
 {
     if (langCode == null)
     {
         SqlStoredProcedures sqlSP = new SqlStoredProcedures();
         this.langCode = sqlSP.LangGetLangCode(this.langID);
     }
     return langCode;
 }
Exemplo n.º 4
0
 public void AddTicket()
 {
     TicketTitleCheck();
     TicketCategoryIDCheck();
     TicketRatingCheck();
     TicketCommentCheck();
     TicketNameCheck();
     TicketPhoneNumberCheck();
     TicketEmailCheck();
     SqlStoredProcedures sp = new SqlStoredProcedures();
     sp.SupportAddTicket(this.ticketTitle, this.ticketCategoryID, this.rating, this.comment, this.email, this.phoneNumber, this.name);
 }
Exemplo n.º 5
0
 public SLUser(int userID, string username, string password, string ip, string sessionToken)
 {
     if (username != null)
     {
         ValidateUsername(username);
         SqlStoredProcedures sqlSP = new SqlStoredProcedures();
         this.userID = sqlSP.UserGetUserID(username);
         if (this.userID < 0)
         {
             return;
         }
     }
     else
     {
         ValidateUserID(userID);
         this.userID = userID;
     }
     this.sessionToken = Login(this.userID, password, ip, sessionToken);
     this.displayName = GetDisplayName(this.userID);
 }
Exemplo n.º 6
0
 public int GetLangID()
 {
     SqlStoredProcedures sqlSP = new SqlStoredProcedures();
     return sqlSP.UserGetMainLang(this.userID);
 }
Exemplo n.º 7
0
 public static Dictionary<int, string> GetAllTicketCategoryies()
 {
     SqlStoredProcedures sp = new SqlStoredProcedures();
     return sp.SupportSelectTicketCategories();
 }
Exemplo n.º 8
0
 public static string Login(int userID, string password, string ip, string sessionToken)
 {
     ValidateUserID(userID);
     SqlStoredProcedures sqlSP = new SqlStoredProcedures();
     string outputSessionToken;
     if (sessionToken != null)
     {
         ValidateSessionToken(sessionToken);
         try
         {
             outputSessionToken = sqlSP.UserLogin(userID, null, ip, sessionToken);
         }
         catch
         {
             return null;
         }
     }
     else
     {
         ValidatePassword(password);
         string passwordSalt = sqlSP.UserGetPasswordSalt(userID);
         string passwordHash = Hash.HashString(password, passwordSalt, new SHA3.SHA3Managed(512));
         try
         {
             outputSessionToken = sqlSP.UserLogin(userID, passwordHash, ip, null);
         }
         catch
         {
             return null;
         }
     }
     return outputSessionToken;
 }
Exemplo n.º 9
0
 public static bool VerifyEmail(string emailAddress, string verifyString)
 {
     SqlStoredProcedures sqlSP = new SqlStoredProcedures();
     return sqlSP.UserVerifyEmail(emailAddress, verifyString);
 }
Exemplo n.º 10
0
        public ActionResult VerifyEmail()
        {
            string title = "VerifyEmail";
            Load(title);
            if (ids != null)
            {
                    SqlStoredProcedures sqlSP = new SqlStoredProcedures();
                    ViewBag.verified = sqlSP.UserVerifyEmail(ids["emailAddress"], ids["verifyString"]);
                    return View(title);

            }
            return RedirectToAction("SignUp");
        }
Exemplo n.º 11
0
 private void EmailSub()
 {
     bool sub = Convert.ToBoolean(postData["sub"]);
     SqlStoredProcedures sqlSP = new SqlStoredProcedures();
     if (sub)
     {
         sqlSP.UserAddEmailSub(user.userID);
     }
     else
     {
         sqlSP.UserDelEmailSub(user.userID);
     }
 }
Exemplo n.º 12
0
        private ActionResult SendMassEmail()
        {
            if (postData.ContainsKey("subject") && postData.ContainsKey("body")) {
                try
                {
                    SqlStoredProcedures sqlSP = new SqlStoredProcedures();
                    string subject = postData["subject"];
                    string body = postData["body"];
                    string logo = "<img src=\"http://unsolvedcrime.ca/Resources/Shared/Images/Logo/Logo.png\" height=\"141\" width=\"141\">";
                    string title = "<font size=\"6\">Unsolved Crime</font>";
                    body = HttpUtility.HtmlDecode(body);
                    body = "<tr><td>"+ title + "</td><td>" + logo + "</td></tr>" + body;
                    body = "<div>" + body.Replace("\n", "</div><div>") + "</div>";
                    body = body.Replace("<div></div>", "<br />");
                    body = "<font size=\"3\">" + body + "</font>";

                    Dictionary<string, string> subs = sqlSP.SupportSelectSubscription();
                    foreach (KeyValuePair<string, string> sub in subs)
                    {
                        string unSub = "<div><a href=\"//unsolvedcrime.ca/Unsubscribe/emailAddress=" + sub.Key + "/\">Unsubscribe</a></div>";
                        Email.SendAdminEmail(sub.Key, subject, body + unSub);
                        System.Diagnostics.Debug.WriteLine("Sent to:" + sub.Key);
                    }
                    return Content("true");
                }
                catch(Exception e)
                {
                    return Content("false");
                }

            }
            else
            {
                return Content("false");
            }
        }
Exemplo n.º 13
0
 public ActionResult SignUpCheck()
 {
     LoadIds();
         string checkName = ids["checkName"];
         switch (checkName)
         {
             case "emailExist":
                 {
                     SqlStoredProcedures sqlSP = new SqlStoredProcedures();
                     return Content(Convert.ToString(sqlSP.UserEmailExist(ids["email"])));
                 }
             case "usernameExist":
                 {
                     SqlStoredProcedures sqlSP = new SqlStoredProcedures();
                     return Content(Convert.ToString(sqlSP.UserUsernameExist(ids["username"])));
                 }
             default:
                 {
                     return Content("null");
                 }
         }
 }
Exemplo n.º 14
0
 public ActionResult Home()
 {
     string title = "Home";
     Load(title);
     if (postData != null && postData.ContainsKey("emailAddress") && postData.ContainsKey("zip"))
     {
         try
         {
             string emailAddress = postData["emailAddress"];
             string zip = postData["zip"];
             zip = zip.Replace(" ", "");
             if(emailAddress.Length < 3 || !emailAddress.Contains("@") || zip.Length != 6){
                 throw new ArgumentException();
             }
             SqlStoredProcedures sqlSP = new SqlStoredProcedures();
             sqlSP.SupportAddSubscription(emailAddress, zip);
             return Content("true");
         }
         catch (Exception)
         {
             return Content("false");
         }
     }
     else
     {
         return View(title);
     }
 }
Exemplo n.º 15
0
 public static string GetLangNameNative(string langName)
 {
     SqlStoredProcedures sqlSP = new SqlStoredProcedures();
     return sqlSP.LangGetLangNameNative(langName);
 }
Exemplo n.º 16
0
 public static Dictionary<string, string> GetLangListNative()
 {
     SqlStoredProcedures sqlSP = new SqlStoredProcedures();
     return sqlSP.LangSelectLangListNative();
 }
Exemplo n.º 17
0
 public Lang(string langName)
 {
     SqlStoredProcedures sqlSP = new SqlStoredProcedures();
     this.langName = langName;
     this.langID = sqlSP.LangGetLangID(this.langName);
 }
Exemplo n.º 18
0
        private Dictionary<string, string> langDic = new Dictionary<string, string>(); //Best property name 2014

        public Lang(int langID)
        {
            SqlStoredProcedures sqlSP = new SqlStoredProcedures();
            this.langID = langID;
            this.langName = sqlSP.LangGetLangName(this.langID);
        }
Exemplo n.º 19
0
 public static string GetDisplayName(int userID)
 {
     SqlStoredProcedures sqlSP = new SqlStoredProcedures();
     string displayName = sqlSP.UserGetDisplayName(userID);
     return displayName;
 }
Exemplo n.º 20
0
 public ActionResult Unsubscribe()
 {
     string title = "Unsubscribe";
     Load(title);
     if (ids != null && ids.ContainsKey("emailAddress"))
     {
         string emailAddress = ids["emailAddress"];
         SqlStoredProcedures sqlSP = new SqlStoredProcedures();
         sqlSP.SupportDelSubscription(emailAddress);
         ViewBag.emailAddress = emailAddress;
         return View(title);
     }
     return RedirectToAction("Home");
 }