Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!string.IsNullOrWhiteSpace(Request["Page"]))
         {
             string RealPath = Request.PhysicalApplicationPath + Request["Page"];
             if (!File.Exists(RealPath))
             {
                 Response.Redirect("404.aspx?AttemptedUrl=" + Request["Page"]);
             }
             else
             {
                 content.Text = ProcessContent(File.ReadAllLines(RealPath));
             }
         }
         else
         {
             Response.Redirect("Default.aspx");
         }
     }
     catch (Exception ex)
     {
         ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
         content.Text = ex.ToString();
     }
 }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (null == Request.Cookies[Settings.Default.SessionCookieKey])
         {
             LoginInfo.Text = "Please <a href=\"Account/Login.aspx\">Log in</a>";
         }
         else if (String.IsNullOrEmpty(Request.Cookies[Settings.Default.SessionCookieKey].Value))
         {
             LoginInfo.Text = "Please <a href=\"Account/Login.aspx\">Log in</a>";
         }
         else
         {
             Int64 UserID = UserMgmt.LookupSession(Request.Cookies[Settings.Default.SessionCookieKey].Value);
             LoginInfo.Text = "Welcome to the world of secure banking, " + UserMgmt.LookupUsername(UserID) + "!<br />" +
                              "<a href=\"Logout.aspx\">Log out</a>";
         }
     }
     catch (Exception ex)
     {
         ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
         Response.Write(ex.ToString());
     }
 }
Esempio n. 3
0
        private string ProcessContent(string[] Lines)
        {
            string returnval = "";

            try
            {
                string newPage = "<h1>{0}</h1><div><a href=\"{1}\">{1}</a></div><div>{2}</div>";

                string title = Lines[0];
                string link  = Lines[1];

                StringBuilder sb = new StringBuilder();
                for (Int64 i = 2; i < Lines.Length; i++)
                {
                    sb.AppendLine(Lines[i]);
                }
                returnval = string.Format(newPage, title, link, sb.ToString());
            }
            catch (Exception ex)
            {
                ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
                returnval = ex.ToString();
            }
            return(returnval);
        }
Esempio n. 4
0
 protected void Submit_Click(object sender, EventArgs e)
 {
     try
     {
         using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ssbcon"].ConnectionString))
         {
             SqlCommand command = new SqlCommand(SQLCommand.Text, conn);
             conn.Open();
             if (!SQLCommand.Text.ToLower().Contains("select"))
             {
                 output.Visible     = true;
                 output.Text        = command.ExecuteNonQuery() + " row(s) affected";
                 outputGrid.Visible = false;
             }
             else
             {
                 outputGrid.Visible    = true;
                 outputGrid.DataSource = command.ExecuteReader();
                 outputGrid.DataBind();
                 output.Visible = false;
             }
         }
     }
     catch (Exception ex)
     {
         ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
         output.Text = ex.ToString();
     }
 }
Esempio n. 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         try
         {
             if (null != Request.Cookies[Settings.Default.SessionCookieKey])
             {
                 Int64 userID = UserMgmt.LookupSession(Request.Cookies[Settings.Default.SessionCookieKey].Value);
                 if (0 == userID)
                 {
                     Response.Redirect("Account/Login.aspx?ReturnUrl=/Forum.aspx");
                 }
                 else
                 {
                     FromAccount.Items.Clear();
                     FromAccount.Items.AddRange(AccountMgmt.GetAccountList(userID));
                 }
             }
         }
         catch (ThreadAbortException tae)
         {
             //nothing
         }
         catch (Exception ex)
         {
             ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
             message.Visible = true;
             message.Text    = ex.ToString();
         }
     }
 }
Esempio n. 6
0
        protected void DoTransfer_Click(object sender, EventArgs e)
        {
            try
            {
                Int64 amount = 0;
                if (Int64.TryParse(AmountToTransfer.Text, out amount))
                {
                    Int64 FromAcctNumber = Convert.ToInt64(FromAccount.SelectedValue);
                    Int64 ToAcctNumber   = Convert.ToInt64(ToAccount.Text);

                    if (AccountMgmt.GetBalance(FromAcctNumber) - amount >= 0)
                    {
                        Response.Redirect(string.Format("DoTransfer.aspx?ToAccount={0}&FromAccount={1}&Amount={2}", ToAcctNumber, FromAcctNumber, amount));
                    }
                    else
                    {
                        message.Text = "Please verify the source account has enough money to cover this transfer";
                    }
                }
                else
                {
                    message.Text = "Please make sure the amount entered in the Amount text box only numeric values (0-9)";
                }
            }
            catch (Exception ex)
            {
                ErrorLogging.AddException("Error in Transfer", ex);

                message.Text = ex.ToString();
            }
        }
Esempio n. 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (null != Request.Cookies[Settings.Default.SessionCookieKey])
         {
             if (0 != UserMgmt.LookupSession(Request.Cookies[Settings.Default.SessionCookieKey].Value))
             {
                 Anon.Visible = false;
                 Authen.Visible = true;
             }
             else
             {
                 Anon.Visible = true;
                 Authen.Visible = false;
             }
         }
         else
         {
             Anon.Visible = true;
             Authen.Visible = false;
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.ToString());
         ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
     }
 }
Esempio n. 8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (null != Request.Cookies[Settings.Default.SessionCookieKey])
         {
             Int64 userID = UserMgmt.LookupSession(Request.Cookies[Settings.Default.SessionCookieKey].Value);
             if (0 == userID)
             {
                 Response.Redirect("Account/Login.aspx?ReturnUrl=Forum.aspx");
             }
             else
             {
                 Accounts.DataSource = AccountMgmt.GetAccounts(userID);
                 Accounts.DataBind();
             }
         }
     }
     catch (Exception ex)
     {
         ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
         message.Visible = true;
         message.Text    = ex.ToString();
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                foreach (string f in Directory.EnumerateFiles(Server.MapPath("Content")))
                {
                    DirectoryEntry    entry  = GetEntry(sender, path);
                    DirectorySearcher search = new DirectorySearcher(entry)
                    {
                        SearchScope = SearchScope.Subtree,
                        Filter      = "(&" + "(objectClass=user)" + "(givenname=s*)" + "(samaccountname=*100)" + ")"
                    };
                    search.PropertiesToLoad.Add("distinguishedname");
                    SearchResultCollection result = search.FindAll();

                    if (Path.GetExtension(f) == ".dat")
                    {
                        FileList.Text += string.Format("<li><a href=\"ViewPage.aspx?Page=Content\\{0}\">{1}</a></li>", Path.GetFileName(f), GetTitle(f));
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
                Response.Write(printstacktrace(ex.ToString()));
            }
        }
 protected void Submit_Click(object sender, EventArgs e)
 {
     try{
         AccountMgmt.CreateAccount(UserMgmt.LookupSession(Request.Cookies[Settings.Default.SessionCookieKey].Value),
                                   AccountType.SelectedValue, StartingBalance.Value, AccountLevel.SelectedValue, 1);
         Response.Redirect(string.Format(@"ActionDone.aspx?Title=Application Completed&Text=Thank you for applying for a new {0} account with SuperSecure Bank, your applicaiton will be reviewed and a banker will be with you shortly. At any time you can check on the status of your account by going to the <a href=""ViewAccount.aspx"">View Accounts Page</a>", AccountType.SelectedItem));
     }
     catch (Exception ex)
     {
         ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
         message.Visible = true;
         message.Text    = ex.ToString();
     }
 }
Esempio n. 11
0
 protected void ResetSesions_Click(object sender, EventArgs e)
 {
     try{
         string        deleteSessions = @"DELETE FROM sessions";
         SqlConnection conn           = new SqlConnection(ConfigurationManager.ConnectionStrings["ssbcon"].ConnectionString);
         conn.Open();
         SqlCommand command = new SqlCommand(deleteSessions, conn);
         command.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception ex)
     {
         ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
         Response.Write(ex.ToString());
     }
 }
Esempio n. 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                TitleText.Text = Request.Params["Title"];
                BodyText.Text  = Request.Params["Text"];

                if (string.IsNullOrEmpty(TitleText.Text) && string.IsNullOrEmpty(BodyText.Text))
                {
                    Response.Redirect("Default.aspx");
                }
            }
            catch (Exception ex)
            {
                ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
                BodyText.Text = ex.ToString();
            }
        }
Esempio n. 13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         foreach (string f in Directory.EnumerateFiles(Server.MapPath("Content")))
         {
             if (Path.GetExtension(f) == ".dat")
             {
                 FileList.Text += string.Format("<li><a href=\"ViewPage.aspx?Page=Content\\{0}\">{1}</a></li>", Path.GetFileName(f), GetTitle(f));
             }
         }
     }
     catch (Exception ex)
     {
         ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
         Response.Write(ex.ToString());
     }
 }
Esempio n. 14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (null != Request.Cookies[Settings.Default.SessionCookieKey])
         {
             Int64 userID = UserMgmt.LookupSession(Request.Cookies[Settings.Default.SessionCookieKey].Value);
             if (0 == userID || "admin" != UserMgmt.LookupUsername(userID).ToLower())
             {
                 Response.Redirect("404.aspx?AttemptedUrl=/ApplyForAccount.aspx");
             }
         }
     }
     catch (Exception ex)
     {
         ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
         message.Visible = true;
         message.Text    = ex.ToString();
     }
 }
Esempio n. 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                AccountMgmt.Transfer(Convert.ToInt64(Request.Params["FromAccount"]),
                                     Convert.ToInt64(Request.Params["ToAccount"]),
                                     Convert.ToInt64(Request.Params["Amount"]));
                Response.Redirect("ActionDone.aspx?Title=Transfer Success&Text=Your transfer was successful. If you moved funds within SuperSecure Bank accounts your funds are immediately available.");
            }
            catch (ThreadAbortException tae)
            {
                //nothing
            }
            catch (Exception ex)
            {
                ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);

                Response.Redirect("ActionDone.aspx?Title=Transfer Failed&Text=We're sorry, but there was an error transferring your funds. Please try again at a later date or call support at: 1-800-555-1212");
            }
        }
Esempio n. 16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try{
         if (!string.IsNullOrWhiteSpace(Request["aspxerrorpath"]))
         {
             if (File.Exists(Request["aspxerrorpath"]))
             {
                 message.Text = "You do not have permissions to view that file";
             }
             else
             {
                 message.Text = string.Format("The file - {0} - doesn't exist", Request["aspxerrorpath"]);
             }
         }
     }
     catch (Exception ex)
     {
         ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
         message.Text = ex.ToString();
     }
 }
Esempio n. 17
0
 protected void PostComment_Click(object sender, EventArgs e)
 {
     try
     {
         Int64         valid         = Validated.Value == "False" ? 0 : 1;
         Int64         userID        = UserMgmt.LookupSession(Request.Cookies[Settings.Default.SessionCookieKey].Value);
         string        insertComment = "INSERT INTO Comments VALUES ({0}, '{1}', '{2}', '{3}', {4})";
         SqlConnection conn          = new SqlConnection(ConfigurationManager.ConnectionStrings["ssbcon"].ConnectionString);
         conn.Open();
         insertComment = String.Format(insertComment, userID, TitleBox.Text, BodyBox.Text, DateTime.Now, valid);
         SqlCommand command = new SqlCommand(insertComment, conn);
         command.ExecuteNonQuery();
         conn.Close();
         Response.Redirect("Forum.aspx");
     }
     catch (Exception ex)
     {
         ErrorLogging.AddException("Error in " + Path.GetFileName(Request.PhysicalPath), ex);
         Response.Write(ex.ToString());
     }
 }
Esempio n. 18
0
 void Application_Error(object sender, EventArgs e)
 {
     ErrorLogging.AddException("Application_Error Caught!", Server.GetLastError().GetBaseException());
 }