Beispiel #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     /*BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
      * categories = db.Categories.OrderBy(x => x.OrderIndex).ToList();
      * banners = db.HomeBanners.ToList();
      * news = db.PressRooms.ToList();
      * content = db.Contents.FirstOrDefault();
      * if (Request.Url.AbsolutePath.Contains("default.aspx"))
      * {
      *  Response.RedirectToRoute("ARHome");
      * }
      * else
      * {
      *  lang = Page.RouteData.Values["lang"].ToString();
      *  student = null;
      *  if (Session["UserId"] != null)
      *  {
      *      int sId = (int)Session["UserId"];
      *      student = db.Students.Where(x => x.id == sId).SingleOrDefault();
      *  }
      * }*/
     if (Session["UserId"] != null)
     {
         BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
         var studentId = (long)Session["UserId"];
         var student   = db.Students.Where(x => x.id == studentId).SingleOrDefault();
         Response.Redirect("/fr/level-" + student.levelId);
     }
     else
     {
         Response.Redirect("/fr/login");
     }
 }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lang = Page.RouteData.Values["lang"].ToString();
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();

            if (IsPostBack)
            {
                string accCode = Request.Form["accesscode"];
                string uname   = Request.Form["uname"];
                var    student = db.Students.Where(x => x.AccessCode == accCode && x.UserName == uname).SingleOrDefault();
                if (student != null)
                {
                    string password = StringCipher.Decrypt(student.Password);
                    if (lang == "en")
                    {
                        msg.Text = "<font color='green'>Your Password is : " + password + "</font>";
                    }
                    else
                    {
                        msg.Text = "<font color='green'>Votre mot de passe est: " + password + "</font>";
                    }
                }
                else
                {
                    if (lang == "en")
                    {
                        msg.Text = "<font color='red'>We didn't find your account. Please request it from your school or try again later.</font>";
                    }
                    else
                    {
                        msg.Text = "<font color='red'>Nous n'avons pas trouvé votre compte. Veuillez le demander à votre école ou réessayer plus tard.</font>";
                    }
                }
            }
        }
Beispiel #3
0
        public static bool Check(int opId, string Section, string action)
        {
            bool                    isAdmin = false;
            HttpContext             context = System.Web.HttpContext.Current;
            BrandsMktgBooksEntities dc      = new BrandsMktgBooksEntities();
            var    user      = dc.cms_user.ToList().Where(x => x.id == opId).SingleOrDefault();
            string groupname = dc.cms_groups.ToList().Where(x => x.id == user.groupId).Single().name.ToLower();

            if (!groupname.ToLower().Contains("admin"))
            {
                var policies = dc.cms_policies.ToList().Where(x => x.groupId == user.groupId && x.cms_permissions.name == Section).ToArray();
                for (int i = 0; i < policies.Length; i++)
                {
                    if (policies[i].event_permitted == action)
                    {
                        isAdmin = true;
                    }
                }
            }
            else
            {
                isAdmin = true;
            }
            return(isAdmin);
        }
Beispiel #4
0
        public static bool IsForman(int opId)
        {
            HttpContext             context = System.Web.HttpContext.Current;
            BrandsMktgBooksEntities dc      = new BrandsMktgBooksEntities();
            var    user      = dc.cms_user.ToList().Where(x => x.id == opId).SingleOrDefault();
            string groupname = dc.cms_groups.ToList().Where(x => x.id == user.groupId).Single().name.ToLower();

            return(groupname.ToLower().Contains("foreman") || groupname.ToLower().Contains("foremen"));
        }
Beispiel #5
0
        public static void UpdateRoutes(RouteCollection routes)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            var books = db.Books.ToList();

            foreach (var book in books)
            {
                try
                {
                    routes.Remove(RouteTable.Routes["ENBook" + book.id.ToString()]);
                    routes.Remove(RouteTable.Routes["FRBook" + book.id.ToString()]);
                }
                catch
                {
                }
                try
                {
                    routes.MapPageRoute("ENBook" + book.id.ToString(), "en/book-" + book.id.ToString(),
                                        "~/product.aspx", true, new RouteValueDictionary {
                        { "id", book.id }, { "lang", "en" }, { "levelId", book.levelId }, { "page", "book-" + book.id }
                    });

                    routes.MapPageRoute("FRBook" + book.id.ToString(), "fr/book-" + book.id.ToString(),
                                        "~/product.aspx", true, new RouteValueDictionary {
                        { "id", book.id }, { "lang", "fr" }, { "levelId", book.levelId }, { "page", "book-" + book.id }
                    });
                }
                catch { }
            }
            var levels = db.BooksLevels.ToList();

            foreach (var level in levels)
            {
                try
                {
                    routes.Remove(RouteTable.Routes["ENLevel" + level.id.ToString()]);
                    routes.Remove(RouteTable.Routes["ARLevel" + level.id.ToString()]);
                }
                catch
                {
                }
                try
                {
                    routes.MapPageRoute("ENLevel" + level.id.ToString(), "en/level-" + level.id.ToString(),
                                        "~/books.aspx", true, new RouteValueDictionary {
                        { "id", level.id }, { "lang", "en" }, { "levelId", level.id }, { "page", "level-" + level.id }
                    });

                    routes.MapPageRoute("FRLevel" + level.id.ToString(), "fr/level-" + level.id.ToString(),
                                        "~/books.aspx", true, new RouteValueDictionary {
                        { "id", level.id }, { "lang", "fr" }, { "levelId", level.id }, { "page", "level-" + level.id }
                    });
                }
                catch { }
            }
        }
Beispiel #6
0
        protected void Unnamed1_Click(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();

            var usr = db.cms_user.ToList().SingleOrDefault(x => x.username == Request["userid"] && x.password == MD5Hash(Request["password"]));

            if (usr != null && usr.status == 1)
            {
                usr.date_login     = DateTime.Now;
                usr.isOnline       = true;
                Session["CMSUser"] = usr;
                db.SaveChanges();
                if (!string.IsNullOrEmpty(Request["red"]))
                {
                    Response.Redirect(Request["red"]);
                }
                else
                {
                    Response.Redirect("~/system");
                }
            }
            else
            {
                Msg.Text = @"<div class=""alert alert-danger alert-dismissable"">
                                        <i class=""fa fa-ban""></i>
                                        <b>Alert!</b> Invalid Username / Password
                                    </div>
<script>
document.addEventListener('DOMContentLoaded', function () {
  if (Notification.permission !== ""granted"")
    Notification.requestPermission();
            });

            function notifyMe() {
                if (Notification.permission !== ""granted"")
                    Notification.requestPermission();
                else
                {
                    var notification = new Notification('Error', {
      icon: 'http://maizonpub.com/images/logo-shrink.png',
      body: ""Invalid username / password please try again"",
    });

                /*notification.onclick = function() {
                    window.open("");
                };*/

            }

        }
notifyMe();
</script>
";
            }
        }
Beispiel #7
0
        public static bool SendEmail(String subject, String body, List <string> cc, List <string> bcc, bool isArabic, List <HttpPostedFile> files)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            Content c           = db.Contents.ToList().FirstOrDefault();
            string  recipient   = c.InfoEmail;
            int     Port        = int.Parse(c.SmtpPort);
            bool    isSSL       = c.IsSSL != null?(bool)c.IsSSL:false;
            string  username    = c.SystemEmail;
            string  password    = c.SystemEmailPassword;
            var     fromAddress = new MailAddress(c.InfoEmail);
            var     toAddress   = new MailAddress(recipient);

            var smtp = new SmtpClient
            {
                Host                  = c.SmtpServer,
                Port                  = Port,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(username, password)
            };

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
            smtp.EnableSsl = isSSL;
            try
            {
                using (var message = new MailMessage(fromAddress, toAddress)
                {
                    Subject = subject,
                    IsBodyHtml = true,
                    Body = body
                }
                       )
                {
                    if (files != null)
                    {
                        foreach (HttpPostedFile file in files)
                        {
                            message.Attachments.Add(new Attachment(file.InputStream, Path.GetFileName(file.FileName), file.ContentType));
                        }
                    }
                    smtp.Send(message);
                }
                return(true);
            }
            catch (System.Net.Mail.SmtpException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["UserId"] == null)
     {
         Response.Redirect("login");
     }
     else
     {
         lang   = Page.RouteData.Values["lang"].ToString();
         bookId = int.Parse(Page.RouteData.Values["bookId"].ToString());
         BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
         long sId = (long)Session["UserId"];
         book    = db.Books.Where(x => x.id == bookId).SingleOrDefault();
         student = db.Students.Where(x => x.id == sId).SingleOrDefault();
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            lang = Page.RouteData.Values["lang"].ToString();
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();

            if (IsPostBack)
            {
                string accCode    = Request.Form["accesscode"];
                string uname      = Request.Form["uname"];
                var    userExists = db.Students.Where(x => x.UserName == uname).Count() > 0;
                if (!userExists)
                {
                    var student = db.Students.Where(x => x.AccessCode == accCode && x.UserName == null).SingleOrDefault();
                    if (student != null)
                    {
                        student.Password = StringCipher.Encrypt(Request.Form["passwd"]);
                        student.UserName = Request.Form["uname"];
                        db.SaveChanges();
                        Session["UserId"] = student.id;
                        Response.Redirect("level-" + student.levelId);
                    }
                    else
                    {
                        if (lang == "en")
                        {
                            msg.Text = "<font color='red'>The Access Code you entered is not correct, please use another one.</font>";
                        }
                        if (lang == "ar")
                        {
                            msg.Text = "<font color='red'>Le code d'accès que vous avez entré n'est pas correct, veuillez en utiliser un autre.</font>";
                        }
                    }
                }
                else
                {
                    if (lang == "en")
                    {
                        msg.Text = "<font color='red'>Username is used. Please choose another one.</font>";
                    }
                    if (lang == "ar")
                    {
                        msg.Text = "<font color='red'>Le nom d'utilisateur est utilisé. Veuillez en choisir un autre.</font>";
                    }
                }
            }
        }
Beispiel #10
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["UserId"] == null)
     {
         Response.Redirect("login");
     }
     else
     {
         lang    = Page.RouteData.Values["lang"].ToString();
         levelId = int.Parse(Page.RouteData.Values["levelId"].ToString());
         BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
         long sId = (long)Session["UserId"];
         results    = db.Books.Where(x => x.lang == lang && x.isAvailable == true && x.levelId == levelId).ToList();
         student    = db.Students.Where(x => x.id == sId).SingleOrDefault();
         categories = db.Categories.ToList();
     }
 }
Beispiel #11
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int bookId = int.Parse(context.Request["bookId"]);
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            string msg = "success";

            try
            {
                int userId = (int)context.Session["UserId"];
                db.StudentLibraries.Remove(db.StudentLibraries.Where(x => x.bookId == bookId && x.studentId == userId).FirstOrDefault());
                db.SaveChanges();
            }
            catch
            {
                msg = "error";
            }
            context.Response.Write(msg);
        }
Beispiel #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["UserId"] == null)
     {
         Response.Redirect("login");
     }
     else
     {
         int bookId = int.Parse(Request["bookId"]);
         BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
         long sId = (long)Session["UserId"];
         student   = db.Students.Where(x => x.id == sId).SingleOrDefault();
         gamesList = db.BookPosters.Where(x => x.bookId == bookId).ToList();
         book      = db.Books.Where(x => x.id == bookId).SingleOrDefault();
         if (student.School.showGame == false)
         {
             Response.Redirect("books");
         }
     }
 }
Beispiel #13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
         cms_user usr = (cms_user)Session["CMSUser"];
         var      u   = db.cms_user.ToList().Where(x => x.id == usr.id).SingleOrDefault();
         u.isOnline = false;
         db.SaveChanges();
         Session["CMSUser"] = null;
         if (Request["logout"] != null)
         {
             Response.Redirect("~/system/login.aspx");
         }
     }
     catch
     {
         if (Request["logout"] != null)
         {
             Response.Redirect("~/system/login.aspx");
         }
     }
 }
Beispiel #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lang = Page.RouteData.Values["lang"].ToString();
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            var sessionUsers           = SessionUser.Get();

            if (sessionUsers == null)
            {
                sessionUsers = new List <SessionUser>();
            }
            if (!string.IsNullOrEmpty(Request.Form["header-email"]))
            {
                string uname   = Request.Form["header-email"].ToLower();
                var    student = db.Students.Where(x => x.UserName.ToLower() == uname).SingleOrDefault();
                if (student != null)
                {
                    string key = student.id.ToString();
                    //var ssu = sessionUsers.Where(x => x.Key == key).SingleOrDefault();
                    //if (ssu == null)
                    //{
                    string decryptedPass = StringCipher.Decrypt(student.Password);
                    if (Request.Form["header-passwd"] == decryptedPass)
                    {
                        SessionUser.Add(key, student.UserName);
                        Session["UserId"] = student.id;
                        Response.Redirect("level-" + student.levelId);
                    }
                    else
                    {
                        if (lang == "en")
                        {
                            msg.Text = "<font color='red'>Invalid Username/Password.</font>";
                        }
                        if (lang == "fr")
                        {
                            msg.Text = "<font color='red'>Nom d'utilisateur / mot de passe invalide.</font>";
                        }
                    }
                    //}
                    //else
                    //{
                    //    msg.Text = lang=="fr"? "<font color='red'>Il y a une autre session utilisant ce compte, veuillez en utiliser une autre.</font>" : "<font color='red'>There is another Session using this account,please use another one.</font>";
                    //}
                }
                else
                {
                    if (lang == "en")
                    {
                        msg.Text = "<font color='red'>Invalid Username/Password.</font>";
                    }
                    if (lang == "fr")
                    {
                        msg.Text = "<font color='red'>Nom d'utilisateur / mot de passe invalide. </font>";
                    }
                }
            }
            else if (!string.IsNullOrEmpty(Request.Form["uname"]))
            {
                string uname   = Request.Form["uname"].ToLower();
                var    student = db.Students.Where(x => x.UserName.ToLower() == uname).SingleOrDefault();
                if (student != null)
                {
                    string key = student.id.ToString();
                    //var ssu = sessionUsers.Where(x => x.Key == key).SingleOrDefault();
                    //if (ssu == null)
                    //{
                    string decryptedPass = StringCipher.Decrypt(student.Password);
                    if (Request.Form["passwd"] == decryptedPass)
                    {
                        SessionUser.Add(key, student.UserName);
                        Session["UserId"] = student.id;
                        Response.Redirect("level-" + student.levelId);
                    }
                    else
                    {
                        if (lang == "en")
                        {
                            msg.Text = "<font color='red'>Invalid Username/Password.</font>";
                        }
                        if (lang == "ar")
                        {
                            msg.Text = "<font color='red'>Nom d'utilisateur / mot de passe invalide. </font>";
                        }
                    }
                    //}
                    //else
                    //{
                    //    msg.Text = lang == "fr" ? "<font color='red'>Il y a une autre session utilisant ce compte, veuillez en utiliser une autre.</font>" : "<font color='red'>There is another Session using this account,please another one.</font>";
                    //}
                }
                else
                {
                    if (lang == "en")
                    {
                        msg.Text = "<font color='red'>Invalid Username/Password.</font>";
                    }
                    if (lang == "fr")
                    {
                        msg.Text = "<font color='red'>Nom d'utilisateur / mot de passe invalide. </font>";
                    }
                }
            }
        }
Beispiel #15
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            try
            {
                routes.MapPageRoute("ENHome", "en/home",
                                    "~/default.aspx", true, new RouteValueDictionary {
                    { "lang", "en" }, { "page", "home" }
                });
                routes.MapPageRoute("ENLogin", "en/login",
                                    "~/login.aspx", true, new RouteValueDictionary {
                    { "lang", "en" }, { "page", "login" }
                });
                routes.MapPageRoute("ENLogout", "en/logout",
                                    "~/logout.aspx", true, new RouteValueDictionary {
                    { "lang", "en" }, { "page", "logout" }
                });
                routes.MapPageRoute("ENPosters", "en/posters",
                                    "~/games.aspx", true, new RouteValueDictionary {
                    { "lang", "en" }, { "page", "posters" }
                });

                routes.MapPageRoute("ENVerifyAccount", "en/verify-account",
                                    "~/verify-account.aspx", true, new RouteValueDictionary {
                    { "lang", "en" }, { "page", "verify-account" }
                });
                routes.MapPageRoute("ENForgotPassword", "en/forgot-password",
                                    "~/forgot-password.aspx", true, new RouteValueDictionary {
                    { "lang", "en" }, { "page", "forgot-password" }
                });

                //French
                routes.MapPageRoute("FRLogin", "fr/login",
                                    "~/login.aspx", true, new RouteValueDictionary {
                    { "lang", "fr" }, { "page", "login" }
                });
                routes.MapPageRoute("FRLogout", "fr/logout",
                                    "~/logout.aspx", true, new RouteValueDictionary {
                    { "lang", "fr" }, { "page", "logout" }
                });
                routes.MapPageRoute("FRPosters", "fr/posters",
                                    "~/games.aspx", true, new RouteValueDictionary {
                    { "lang", "fr" }, { "page", "posters" }
                });

                routes.MapPageRoute("FRVerifyAccount", "fr/verify-account",
                                    "~/verify-account.aspx", true, new RouteValueDictionary {
                    { "lang", "fr" }, { "page", "verify-account" }
                });
                routes.MapPageRoute("FRForgotPassword", "fr/forgot-password",
                                    "~/forgot-password.aspx", true, new RouteValueDictionary {
                    { "lang", "fr" }, { "page", "forgot-password" }
                });
            }
            catch { }

            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            var books = db.Books.ToList();

            foreach (var book in books)
            {
                try
                {
                    if (book.lang == "en")
                    {
                        routes.MapPageRoute("ENBook" + book.id.ToString(), "en/book-" + book.id.ToString(),
                                            "~/product.aspx", true, new RouteValueDictionary {
                            { "id", book.id }, { "lang", "en" }, { "levelId", book.levelId }, { "page", "book-" + book.id }
                        });
                        routes.MapPageRoute("ENStories" + book.id.ToString(), "en/stories-" + book.id,
                                            "~/stories.aspx", true, new RouteValueDictionary {
                            { "lang", "en" }, { "page", "stories-" + book.id }, { "bookId", book.id }
                        });
                        routes.MapPageRoute("ENBookMenu" + book.id.ToString(), "en/bookmenu-" + book.id.ToString(),
                                            "~/bookmenu.aspx", true, new RouteValueDictionary {
                            { "id", book.id }, { "lang", "en" }, { "bookId", book.id }, { "page", "bookmenu-" + book.id }
                        });
                    }
                    else
                    {
                        routes.MapPageRoute("FRBook" + book.id.ToString(), "fr/book-" + book.id.ToString(),
                                            "~/product.aspx", true, new RouteValueDictionary {
                            { "id", book.id }, { "lang", "fr" }, { "levelId", book.levelId }, { "page", "book-" + book.id }
                        });
                        routes.MapPageRoute("FRBookMenu" + book.id.ToString(), "fr/bookmenu-" + book.id.ToString(),
                                            "~/bookmenu.aspx", true, new RouteValueDictionary {
                            { "id", book.id }, { "lang", "fr" }, { "bookId", book.id }, { "page", "bookmenu-" + book.id }
                        });
                        routes.MapPageRoute("FRStories" + book.id.ToString(), "fr/stories-" + book.id,
                                            "~/stories.aspx", true, new RouteValueDictionary {
                            { "lang", "fr" }, { "page", "stories-" + book.id }, { "bookId", book.id }
                        });
                    }
                }
                catch { }
            }
            var stories = db.BookStories.ToList();

            foreach (var story in stories)
            {
                try
                {
                    if (story.Book.lang == "en")
                    {
                        routes.MapPageRoute("ENStory" + story.id.ToString(), "en/story-" + story.id.ToString(),
                                            "~/story.aspx", true, new RouteValueDictionary {
                            { "id", story.id }, { "lang", "en" }, { "bookId", story.bookId }, { "page", "story-" + story.id }
                        });
                    }
                    else
                    {
                        routes.MapPageRoute("FRStory" + story.id.ToString(), "fr/story-" + story.id.ToString(),
                                            "~/story.aspx", true, new RouteValueDictionary {
                            { "id", story.id }, { "lang", "fr" }, { "bookId", story.bookId }, { "page", "story-" + story.id }
                        });
                    }
                }
                catch { }
            }
            var levels = db.BooksLevels.ToList();

            foreach (var level in levels)
            {
                try
                {
                    routes.MapPageRoute("ENLevel" + level.id.ToString(), "en/level-" + level.id.ToString(),
                                        "~/books.aspx", true, new RouteValueDictionary {
                        { "id", level.id }, { "lang", "en" }, { "levelId", level.id }, { "page", "level-" + level.id }
                    });

                    routes.MapPageRoute("FRLevel" + level.id.ToString(), "fr/level-" + level.id.ToString(),
                                        "~/books.aspx", true, new RouteValueDictionary {
                        { "id", level.id }, { "lang", "fr" }, { "levelId", level.id }, { "page", "level-" + level.id }
                    });
                }
                catch { }
            }
        }