Beispiel #1
0
 public static void check_auth_user()
 {
     if (!ClsAuth.IsUser())
     {
         HttpContext.Current.Response.Redirect("~/");
     }
 }
Beispiel #2
0
    public string writeMenu()
    {
        string s          = "";
        string page_title = Page.Header.Title;

        string current = ((page_title == "Home") ? " class='current'" : "");

        s += "<li" + current + "><a href='Default.aspx'>Home</a></li>\r\n";

        //current = ((page_title == "About Us") ? " class='current'" : "");
        //s += "<li" + current + "><a href='About.aspx'>About Us</a></li>\r\n";

        //if (isset($_SESSION['role']) && $_SESSION['role'] == "admin") {
        if (Session["role"] != null && Session["role"].ToString() == "admin")
        {
            if (page_title == "Site Admin")
            {
                s += "<li class='current'><a href='adminhome.aspx'>Site Admin</a>\r\n";
            }
            else
            {
                current = "";
                if (page_title.StartsWith("Site Admin"))
                {
                    current = " class='current'";
                }
                s += "<li" + current + "><a href='adminhome.aspx'>Site Admin</a>\r\n";
            }
            s += "<ul>\r\n";
            s += "<li><a href='./users/'>Manage Users</a></li>\r\n";
            s += "</ul>\r\n";
            s += "</li>\r\n";
        }

        if (Session["username"] != null && Session["username"].ToString() != "")
        {
            if (page_title == "My Profile")
            {
                s += "<li class='current'><a href='profile/view.aspx'>My Profile</a></li>\r\n";
            }
            else
            {
                s += "<li><a href='profile/view.aspx'>My Profile</a></li>\r\n";
            }

            string t = "<a href='logout.aspx'>Log out</a>";
            s += "<li>" + t + "</li>\r\n";
        }

        s = "<ul id='nav'>\r\n" + s + "</ul>\r\n";

        if (ClsAuth.IsUser())
        {
            s = ClsAuth.addMenuUserName(s);
        }
        return(s);
    }
Beispiel #3
0
    public static string getMenuUserName()
    {
        string s = "Home";

        if (ClsAuth.IsUser())
        {
            s = ClsUtil.CapitalizeFirstLetter(HttpContext.Current.Session["username"].ToString());
        }
        return(s);
    }
Beispiel #4
0
 // Add user name to the right side of menu bar.
 public static string addMenuUserName(string s)
 {
     if (ClsAuth.IsUser())
     {
         s = "<table cellpadding='0' cellspacing='0' style='border: 0px; width: 100%; background-color: #6666ff;'>" +
             "<tr><td>" + s + "</td>" +
             "<td align='right' style='color: #dedeff; font-weight:bold;'> " +
             ClsUtil.CapitalizeFirstLetter(HttpContext.Current.Session["username"].ToString()) + "&nbsp;&nbsp;</td></tr></table>";
     }
     return(s);
 }
Beispiel #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (ClsAuth.IsUser())
     {
         btnLogin.Visible = false;
     }
     else
     {
         //((TextBox)btnLogin.FindControl("UserName")).Focus();
         SetFocus(btnLogin.FindControl("UserName"));
     }
 }
Beispiel #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (ClsAuth.IsUser())
     {
         btnLogin.Visible = false;
     }
     else
     {
         ((TextBox)btnLogin.FindControl("UserName")).Width = 150;
         ((TextBox)btnLogin.FindControl("Password")).Width = 150; // Otherwise this is shorter in IE.
         //((TextBox)btnLogin.FindControl("UserName")).Focus();
         SetFocus(btnLogin.FindControl("UserName"));
     }
 }
Beispiel #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!ClsAuth.IsUser())
        {
            this.msg.Text = "Not a valid user.";
            return;
        }
        string ID = Session["userid"].ToString();

        if (this.IsPostBack)
        {
            try
            {
                this.msg.Text = "";
                this.retrieveRequest();
                this.retrieveDB(ID);
                //Response.Write(this.db_old_pwd_hash + "=?=" + this.old_pwd );

                if (this.db_old_pwd_hash != this.old_pwd)
                {
                    this.msg.Text = "<p><font color='red'>Invalid old password.</font></p>";
                }
                else
                {
                    string check = ClsUser.validate_pwd(this.new_pwd, this.new_pwd2);
                    if (check != "")
                    {
                        this.msg.Text = "<p><font color='red'>" + check + ".</font></p>";
                    }
                    else
                    {
                        this.update(ID);
                        this.msg.Text = "<p><font color='green'>Your password has been updated.</font> </p>";
                    }
                }
            }
            catch (Exception ex)
            {
                this.msg.Text = "<p><font color='red'>" + ex.Message + "</font></p>";
            }
        }
        else
        {
            this.msg.Text = "";
        }
    }
Beispiel #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!ClsAuth.IsUser())
        {
            Session.Clear();
            if (Page.Title != "Home" && Page.Title != "About Us")
            {
                Response.Redirect("../");
            }
        }

        //
        // Use this, so the Back button of browser does not return to a logged in page.
        //
        Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Page.Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
        Page.Response.Cache.SetNoStore();
    }
Beispiel #9
0
    public string writeMenu()
    {
        string s          = "";
        string page_title = Page.Header.Title;

        string current = ((page_title == "Home") ? " class='current'" : "");

        //s += "<li" + current + "><a href='../Default.aspx'>Home</a></li>\r\n";
        //s += "<li" + current + "><a href='../Default.aspx'>" + ClsAuth.getMenuUserName() + "</a></li>\r\n";
        s += "<li" + current + "><a href='../Default.aspx'>Home</a>";
        if (false && ClsAuth.IsUser())
        {
            s += "<ul>";
            s += "<li><a href='../profile/view.aspx'>My Profile</a></li>";
            s += "<li><a href='../profile/changepwd.aspx'>Change My Password</a></li>";
            s += "<li><a href='../logout.aspx'>Log out</a></li>\r\n";
            s += "</ul>";
        }
        s += "</li>";

        //current = ((page_title == "About Us") ? " class='current'" : "");
        //s += "<li" + current + "><a href='../About.aspx'>About Us</a></li>\r\n";

        if (ClsAuth.IsAdmin())
        {
            if (page_title == "Site Admin")
            {
                s += "<li class='current'><a href='../adminhome.aspx'>Site Admin</a>\r\n";
            }
            else
            {
                current = "";
                if (page_title.StartsWith("Site Admin"))
                {
                    current = " class='current'";
                }
                s += "<li" + current + "><a href='../adminhome.aspx'>Site Admin</a>\r\n";
            }
            s += "<ul>\r\n";
            s += "<li><a href='../users/'>Manage Users</a></li>\r\n";
            s += "<li><a href='../client/admin.aspx'>Manage Clients</a></li>\r\n";
            s += "</ul>\r\n";
            s += "</li>\r\n";
        }

        if (ClsAuth.IsUser())
        {
            if (page_title == "Client Management")
            {
                s += "<li class='current'><a href='../client/'>Client Management</a></li>\r\n";
            }
            else
            {
                s += "<li><a href='../client/'>Client Management</a></li>\r\n";
            }


            if (page_title == "My Profile")
            {
                s += "<li class='current'><a href='../profile/view.aspx'>My Profile</a></li>\r\n";
            }
            else
            {
                s += "<li><a href='../profile/view.aspx'>My Profile</a></li>\r\n";
            }

            s += "<li><a href='../logout.aspx'>Log out</a></li>\r\n";
        }

        s = "<ul id='nav'>\r\n" + s + "</ul>\r\n";

        if (ClsAuth.IsUser())
        {
            s = ClsAuth.addMenuUserName(s);
        }
        return(s);
    }
Beispiel #10
0
    public string writeMenu()
    {
        string s          = "";
        string page_title = Page.Header.Title;

        string current = ((page_title == "Home") ? " class='current'" : "");

        s += "<li" + current + "><a href='Default.aspx'>Home</a>";

        //current = ((page_title == "About Us") ? " class='current'" : "");
        //s += "<li" + current + "><a href='About.aspx'>About Us</a>";

        /*
         * //if (isset($_SESSION['role']) && $_SESSION['role'] == "admin") {
         * if (Session["role"] != null && Session["role"].ToString() == "admin")
         * {
         *  if (page_title == "Site Admin")
         *  {
         *      s += "<li class='current'><a href='#'>Site Admin</a>";
         *  }
         *  else
         *  {
         *      current = "";
         *      if (page_title.StartsWith("Site Admin")) current = "class='current'";
         *      s += "<li $current><a href='adminhome.aspx'>Site Admin</a>";
         *  }
         *  s += "<ul>";
         *  s += "<li><a href='admin_users.php'>Manage Users</a></li>";
         *  //$s .= "<li><a href='admin_images.php'>Manage Images</a></li>";
         *  s += "<li><a href='#' onclick='javascript: open_file(\"admin_images.php\");'>Manage Images</a></li>";
         *  s += "<li><a href='admin_create_schema.aspx'>Create Schema For Tables</a></li>";
         *  s += "<li><a href='admin_dump_table.aspx'>Dump Contents Of Tables</a></li>";
         *  s += "<li><a href='admin_backup_db.aspx'>Backup Database</a></li>";
         *  s += "</ul>";
         *  s += "</li>";
         * }
         *
         * if (Session["username"] != null && Session["username"].ToString() != "")
         * {
         *  if (page_title == "Member Home")
         *  {
         *      s += "<li class='current'><a href='#'>Member Home</a></li>";
         *  }
         *  else
         *  {
         *      s += "<li><a href='home.aspx'>Member Home</a></li>";
         *  }
         *
         *  if (page_title == "My Profile")
         *  {
         *      s += "<li class='current'><a href='#'>My Profile</a></li>";
         *  }
         *  else
         *  {
         *      s += "<li><a href='profile.aspx'>My Profile</a></li>";
         *  }
         *
         *  string t = "<a href='logout.aspx'>Log out</a>";
         *  s += "<li>" + t + "</li>";
         * }
         */

        s = "<ul id='nav'>" + s + "</ul>";

        if (ClsAuth.IsUser())
        {
            s = ClsAuth.addMenuUserName(s);
        }
        return(s);
    }