Exemplo n.º 1
0
 public static void check_auth_user()
 {
     if (!ClsAuth.IsUser())
     {
         HttpContext.Current.Response.Redirect("~/");
     }
 }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ClsAuth.check_auth_admin();

        // This is to avoid the double submission problem when refreshing a submitted page.
        if (Request["ok"] != null)
        {
            this.form1.Text = "";
            this.msg.Text   = "<font color='green'>The new user has been added.</font> <br/><br/><a href='new.aspx'>Add Another New User</a>";
            return;
        }

        this.user.retrieveRequest(this.IsPostBack, Request);
        if (this.IsPostBack)
        {
            this.form1.Text = "";
            try
            {
                this.insert();
                Response.Redirect("new.aspx?ok=1");
                //this.msg.Text = "<font color='green'>The new user has been added.</font> <br/><br/><a href='new.aspx'>Add Another New User</a>";
            }
            catch (Exception ex) {
                this.msg.Text   = "<p><font color='red'>" + ex.Message + "</font></p>";
                this.form1.Text = ShowNewForm();
            }
        }
        else
        {
            this.msg.Text   = "";
            this.form1.Text = ShowNewForm();
        }
    }
Exemplo n.º 3
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);
    }
Exemplo n.º 4
0
    public static string getMenuUserName()
    {
        string s = "Home";

        if (ClsAuth.IsUser())
        {
            s = ClsUtil.CapitalizeFirstLetter(HttpContext.Current.Session["username"].ToString());
        }
        return(s);
    }
Exemplo n.º 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ClsAuth.check_auth_admin();
     if (this.IsPostBack)
     {
         this.client.download_pdf(ClsUtil.getStrVal(Request["print_id"]));
     }
     ShowAtoZList();
     ShowClientList();
 }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
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"));
     }
 }
Exemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ClsAuth.check_auth_admin();

        ID = ClsUtil.getStrVal(Request["id"]);
        if (ID == "")
        {
            return;
        }

        this.retrieve(ID);
        this.lblProfile.Text = this.ShowViewForm();
    }
Exemplo n.º 9
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"));
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Twitterの認証情報確認
        /// </summary>
        public void ConfirmationTwitterAuth()
        {
            List <string> auth = ClsAuth.AuthInfoGet();

            if (auth.Count == 2)
            {
                MainService = new TwitterService(ClsConst.ConsumerKey, ClsConst.ConsumerSecret);
                MainService.AuthenticateWith(auth[0], auth[1]);
                TwitterAuth = Visibility.Visible;
            }
            else
            {
                TwitterAuth = Visibility.Hidden;
            }
        }
Exemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ClsAuth.check_auth_admin();

        string ID = ClsUtil.getStrVal(Request["id"]);

        this.retrieve(ID);
        this.lblProfile.Text = this.ShowViewForm();


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

                if (this.new_pwd != this.new_pwd2)
                {
                    this.msg.Text = "<p><font color='red'>New passwords not match.</font></p>";
                }
                else
                {
                    string check = check_pwd(this.new_pwd);
                    if (check != "")
                    {
                        this.msg.Text = "<p><font color='red'>" + check + ".</font></p>";
                    }
                    else
                    {
                        this.update(ID);
                        this.msg.Text = "<p><font color='green'>User password has been updated.</font> </p>";
                    }
                }
            }
            catch (Exception ex)
            {
                this.msg.Text = "<p><font color='red'>" + ex.Message + "</font></p>";
            }
        }
        else
        {
            this.msg.Text = "";
        }
    }
Exemplo n.º 12
0
 /// <summary>
 /// 認証解除
 /// </summary>
 public void ReleaseAuth()
 {
     try
     {
         // 起動時に認証済みのままにしない時
         ClsAuth.AuthInfoDelete();
         Service = null;
         MainModel.SetServiceProp(Service);
         ButtonEnabled = false;
         MessageBox.Show("認証解除をしました。");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ClsConst.ErrorMessage);
         ClsLogWrite.LogWrite(ex.Message, ex);
     }
 }
Exemplo n.º 13
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 = "";
        }
    }
Exemplo n.º 14
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();
    }
Exemplo n.º 15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ClsAuth.check_auth_admin();

        string ID = ClsUtil.getStrVal(Request["id"]);

        if (ID == "")
        {
            this.msg.Text   = "Not a valid user.";
            this.form1.Text = "";
            return;
        }

        if (this.IsPostBack)
        {
            this.form1.Text = "";
            try
            {
                this.user.retrieveRequest(this.IsPostBack, Request);
                this.user.update(ID, Session["userid"].ToString());

                this.msg.Text = "<p><font color='green'>This profile has been updated.</font> </p>";
                if (ClsDB.DEBUG())
                {
                    Response.Write(this.user.strQuery());
                }
            }
            catch (Exception ex)
            {
                this.msg.Text = "<p><font color='red'>" + ex.Message + "</font></p>";
            }

            this.user.retrieveDB(ID);
            this.form1.Text = ShowEditForm();
        }
        else
        {
            this.user.retrieveDB(ID);
            this.msg.Text   = "";
            this.form1.Text = ShowEditForm();
        }
    }
Exemplo n.º 16
0
 /// <summary>
 /// 認証完了
 /// </summary>
 public void CompletionAuth()
 {
     try
     {
         OAuthAccessToken access = Service.GetAccessToken(RequestToken, PinCode);
         Service.AuthenticateWith(access.Token, access.TokenSecret);
         // トークン情報保存(次回起動時に認証済みのままにするため)
         ClsAuth.AuthInfoSet(access);
         MessageBox.Show("認証が完了しました。");
         // 認証情報をメインウインドウで使うため。
         MainModel.SetServiceProp(Service);
         ButtonEnabled = true;
         // 完了したら自動で画面閉じる?
         //this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ClsConst.ErrorMessage);
         ClsLogWrite.LogWrite(ex.Message, ex);
     }
 }
Exemplo n.º 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ClsAuth.check_auth_admin();

        if (this.IsPostBack)
        {
            this.form1.Text = "";
            try
            {
                this.add();
                this.msg.Text = "<font color='green'>The new user has been added.</font> <br/><br/><a href='new.aspx'>Add Another New User</a>";
            }
            catch (Exception ex) {
                this.msg.Text   = "<p><font color='red'>" + ex.Message + "</font></p>";
                this.form1.Text = ShowNewForm();
            }
        }
        else
        {
            this.msg.Text   = "";
            this.form1.Text = ShowNewForm();
        }
    }
Exemplo n.º 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ClsAuth.check_auth_admin();

        string ID = ClsUtil.getStrVal(Request["id"]);

        if (ID == "")
        {
            this.msg.Text   = "Not a valid user.";
            this.form1.Text = "";
            return;
        }

        if (this.IsPostBack)
        {
            this.form1.Text = "";
            try
            {
                this.update(ID);
                this.msg.Text = "<p><font color='green'>This profile has been updated.</font> </p>";
            }
            catch (Exception ex)
            {
                this.msg.Text = "<p><font color='red'>" + ex.Message + "</font></p>";
            }
            //this.retrievePostVal();
            this.retrieve(ID);
            this.form1.Text = ShowEditForm();
        }
        else
        {
            this.retrieve(ID);
            this.msg.Text   = "";
            this.form1.Text = ShowEditForm();
        }
    }
Exemplo n.º 19
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);
    }
Exemplo n.º 20
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);
    }
Exemplo n.º 21
0
 protected void Page_Load(object sender, EventArgs e)
 {
     ClsAuth.check_auth_admin();
     ShowList();
 }