protected void Page_PreInit(object sender, EventArgs e)
        {
            string serverURLPath = LSKYCommon.getServerURLPath(Request);

            if (Request.Form.AllKeys.Contains("selectedMenuItem"))
            {
                int selectedID = 0;

                if (int.TryParse(Request.Form["selectedMenuItem"], out selectedID))
                {
                    if (selectedID != 0)
                    {
                        List <NavMenuItem> NavMenu = getMainMenu();
                        foreach (NavMenuItem mi in NavMenu)
                        {
                            if (mi.id == selectedID)
                            {
                                //Response.Redirect(serverURLPath + mi.url);
                                Redirect(LSKYCommon.translateLocalURL(mi.url));
                            }
                        }
                    }
                }
            }

            Redirect(LSKYCommon.translateLocalURL("/"));
        }
        public void expireSession()
        {
            /* Remove the session from the server */
            if (loggedInUser != null)
            {
                String dbConnectionString = ConfigurationManager.ConnectionStrings["DataExplorerDatabase"].ConnectionString;
                using (SqlConnection dbConnection = new SqlConnection(dbConnectionString))
                {
                    session.expireSession(dbConnection, loggedInUser.getHash());
                }
            }

            /* Expire the cookie on the client side */
            if (Request.Cookies.AllKeys.Contains("lskyDataExplorer"))
            {
                HttpCookie newCookie = new HttpCookie("lskyDataExplorer");
                newCookie.Value   = "NOTHING TO SEE HERE";
                newCookie.Expires = DateTime.Now.AddDays(-1D);
                newCookie.Domain  = LSKYCommon.getServerName(Request);
                newCookie.Secure  = true;
                //Response.SetCookie(Response.Cookies["lskyDataExplorer"]);
                Response.Cookies.Add(newCookie);
            }

            /* Get rid of the object in memory... just in case...*/
            loggedInUser = null;

            /* Redirect to the login page */
            redirectToLogin();
        }
        private TableRow addNavItem(NavMenuItem item)
        {
            TableRow newRow = new TableRow();

            TableCell nameCell = new TableCell();

            string cssClass = "nav_link_normal";

            if (item.admin_only)
            {
                cssClass = "nav_link_admin";
            }

            nameCell.Text     = "<a href=\"" + LSKYCommon.translateLocalURL(item.url) + "\" class=\"" + cssClass + "\">" + item.name + "</a>";
            nameCell.CssClass = "navigation_table_name";
            newRow.Cells.Add(nameCell);

            TableCell descriptionCell = new TableCell();

            descriptionCell.Text     = item.description;
            descriptionCell.CssClass = "navigation_table_description";
            newRow.Cells.Add(descriptionCell);

            return(newRow);
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            foreach (string var in Request.ServerVariables)
            {
                tblVars.Rows.Add(addRow(var, Request.ServerVariables[var]));
            }



            lblTest.Text = LSKYCommon.getServerURLPath(Request);
        }
        public static session loadThisSession(SqlConnection connection, string hash, string ip, string useragent)
        {
            session returnMe = null;

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Connection  = connection;
            sqlCommand.CommandType = CommandType.Text;
            sqlCommand.CommandText = "SELECT * FROM sessions WHERE id_hash=@Hash AND ip=@IP AND useragent=@UA;";
            sqlCommand.Parameters.AddWithValue("@Hash", hash);
            sqlCommand.Parameters.AddWithValue("@IP", ip);
            sqlCommand.Parameters.AddWithValue("@UA", useragent);
            sqlCommand.Connection.Open();
            SqlDataReader dataReader = sqlCommand.ExecuteReader();

            if (dataReader.HasRows)
            {
                List <string> adminUsers = LSKYCommon.getGroupMembers("lskysd", LSKYCommon.adminGroupName);

                while (dataReader.Read())
                {
                    bool is_admin = false;
                    if (adminUsers.Contains(dataReader["username"].ToString()))
                    {
                        is_admin = true;
                    }

                    returnMe = new session(
                        dataReader["username"].ToString(),
                        dataReader["ip"].ToString(),
                        dataReader["id_hash"].ToString(),
                        dataReader["useragent"].ToString(),
                        DateTime.Parse(dataReader["sessionstarts"].ToString()),
                        DateTime.Parse(dataReader["sessionends"].ToString()),
                        is_admin
                        );
                }
            }

            sqlCommand.Connection.Close();
            return(returnMe);
        }
        public static List <session> loadActiveSessions(SqlConnection connection)
        {
            List <session> returnMe = new List <session>();

            using (SqlCommand sqlCommand = new SqlCommand())
            {
                sqlCommand.Connection  = connection;
                sqlCommand.CommandType = CommandType.Text;
                sqlCommand.CommandText = "SELECT * FROM sessions WHERE sessionstarts < {fn NOW()} AND sessionends > {fn NOW()};";

                sqlCommand.Connection.Open();
                SqlDataReader dbDataReader = sqlCommand.ExecuteReader();

                if (dbDataReader.HasRows)
                {
                    List <string> adminUsers = LSKYCommon.getGroupMembers("lskysd", LSKYCommon.adminGroupName);

                    while (dbDataReader.Read())
                    {
                        bool is_admin = false;
                        if (adminUsers.Contains(dbDataReader["username"].ToString()))
                        {
                            is_admin = true;
                        }

                        returnMe.Add(new session(
                                         dbDataReader["username"].ToString(),
                                         dbDataReader["ip"].ToString(),
                                         dbDataReader["id_hash"].ToString(),
                                         dbDataReader["useragent"].ToString(),
                                         DateTime.Parse(dbDataReader["sessionstarts"].ToString()),
                                         DateTime.Parse(dbDataReader["sessionends"].ToString()),
                                         is_admin
                                         ));
                    }
                }
                sqlCommand.Connection.Close();
            }

            return(returnMe);
        }
Esempio n. 7
0
 public override string ToString()
 {
     return("Track: { Name: " + this.name + ", ID: " + this.ID + ", Daily: " + LSKYCommon.boolToYesOrNo(this.daily) + ", SchoolID: " + this.schoolID + ",  Starts: " + this.startDate.ToShortDateString() + ", Ends: " + this.endDate.ToShortDateString() + "}");
 }
        public void displayNavDropdown()
        {
            /* Load the menu items */
            if (MainMenu == null)
            {
                MainMenu = Nav.getMainMenu();
            }

            // Figure out which menu items to display
            List <NavMenuItem> displayedMenuItems = new List <NavMenuItem>();

            foreach (NavMenuItem item in MainMenu)
            {
                if (!item.hidden)
                {
                    if (loggedInUser.is_admin)
                    {
                        displayedMenuItems.Add(item);
                    }
                    else
                    {
                        if ((!item.admin_only) && (!item.hidden))
                        {
                            displayedMenuItems.Add(item);
                        }
                    }
                }
            }
            displayedMenuItems.Sort();

            // Figure out which categories to display
            List <string> MenuCategories = new List <string>();

            foreach (NavMenuItem item in displayedMenuItems)
            {
                if (!MenuCategories.Contains(item.category))
                {
                    MenuCategories.Add(item.category);
                }
            }


            // Display the list in a dropdown box
            Response.Write("<form method=\"post\" action=\"" + LSKYCommon.translateLocalURL("Nav.aspx") + "\" style=\"margin: 0; padding: 0;\">");
            Response.Write("<span class=\"nav_link\">Navigation:</span> ");
            Response.Write("<select name=\"selectedMenuItem\">");
            Response.Write("<option value=\"0\" selected=\"selected\"> -- Front Page --</option>");
            foreach (string MenuCat in MenuCategories)
            {
                Response.Write("<option value=\"0\" style=\"font-weight: bold;\">" + MenuCat.ToUpper() + "</option>");
                foreach (NavMenuItem mi in displayedMenuItems)
                {
                    if (mi.category == MenuCat)
                    {
                        Response.Write("<option value=\"" + mi.id + "\">&nbsp;&nbsp;&nbsp;" + mi.name + "</option>");
                    }
                }
            }


            Response.Write("</select>");
            Response.Write("&nbsp;<input type=\"submit\" value=\"Go\">");
            Response.Write("</form>");
        }
 public override string ToString()
 {
     return("Class: { Name: " + this.name + ", Course Name: " + this.courseName + ", ClassID: " + this.classid + ", CourseID: " + this.courseid + ", Has Objectives: " + this.Outcomes.Count + ", IsHighSchool: " + LSKYCommon.boolToYesOrNo(this.isHighSchoolLevel()) + ", LowGrade: " + this.lowestGrade + ", HighGrade: " + this.highestGrade + ", Translated grade: " + this.getGradeLevel() + ", Grade Legend: " + this.gradeLegend + "}");
 }
        public override string ToString()
        {
            bool hasObjectiveAlso = false;

            if (this.outcome != null)
            {
                hasObjectiveAlso = true;
            }

            bool hasReportPeriod = false;

            if (this.reportPeriod != null)
            {
                hasReportPeriod = true;
            }

            return("OutcomeMark: { ID: " + this.objectiveMarkID + ", Objective ID: " + this.objectiveID + ", Course ID: " + this.courseID + ", nMark: " + this.nMark + ", cMark: " + this.cMark + ", Report Period: " + this.reportPeriodID + ", HasOutcomeInfo: " + LSKYCommon.boolToYesOrNo(hasObjectiveAlso) + " , HasReportPeriod: " + LSKYCommon.boolToYesOrNo(hasReportPeriod) + " }");
        }