private void addButton_Click(object sender, EventArgs e)
        {
            SecurityNode sn = Roles.GetSecurityNode();

            sn.NodeID = CurrentNode.Id;
            sn.RoleID = int.Parse(rolesList.SelectedValue);
            int i = 0;

            if (delete.Checked)
            {
                i += (int)Permission.Delete;
            }
            if (publish.Checked)
            {
                i += (int)Permission.Publish;
            }
            if (edit.Checked)
            {
                i += (int)Permission.Edit;
            }
            if (add.Checked)
            {
                i += (int)Permission.Add;
            }
            if (view.Checked)
            {
                i += (int)Permission.View;
            }
            sn.PermissionLevel = i;
            Roles.SaveSecurityNode(sn);
            msg.Text = "added role: " + rolesList.SelectedItem.Text + " level:" + i.ToString();
            SFGlobal.UpdateNodes();
            Response.Redirect(Request.RawUrl);
        }
        private void createPreview()
        {
            // first delete any previews from before
            this.removePreviewArticle();

            // now put the new preview in
            DataContainer dc = new DataContainer(this.dbTable);
            DataRow       dr = dc.GetNewRow();

            dr["nodeID"]       = currentNode.Id;
            dr["templateID"]   = int.Parse(articleTemplateID.SelectedValue);
            dr["version"]      = 0;
            dr["lang"]         = lang;
            dr["rank"]         = rank;
            dr["title"]        = title.Text;
            dr["summary"]      = summary.Text;
            dr["keywords"]     = keywords.Text;
            dr["body"]         = body1.Value;
            dr["userID"]       = ((UserIdentity)SFGlobal.GetCurrentUser().Identity).ID;
            dr["dateCreated"]  = System.DateTime.Now;
            dr["dateModified"] = System.DateTime.Now;
            dr["publish"]      = false;
            dr["preview"]      = true;
            dr["active"]       = true;
            dc.UpdateRow(dr);
        }
        public void changeNodeRank(Node currentNode, string direction)
        {
            Node p = currentNode.parent;
            int  i = currentNode.GetIndexInParentCollection();

            if (i >= 0 && i < p.children.Count)
            {
                int oldRank = currentNode.Rank;
                int dir     = (direction == "dn") ? 1 : -1;

                if (dir == -1 && i == 0)
                {
                    return;
                }
                if (dir == 1 && i == p.children.Count - 1)
                {
                    return;
                }

                //Response.Write("changing " + currentNode.Id + ":" + currentNode.Rank + " to " + p.children[i+dir].Id + ":" + p.children[i+dir].Rank);

                currentNode.Rank            = p.children[i + dir].Rank;
                p.children[i + dir].Rank    = oldRank;
                currentNode.Publish         = true;
                p.children[i + dir].Publish = true;
                SFGlobal.ObjectManager.PersistChanges(currentNode);
                SFGlobal.ObjectManager.PersistChanges(p.children[i + dir]);
                SFGlobal.UpdateNodes();
            }
            else
            {
                //System.Web.HttpContext.Current.Response.Write("ignoring order change");
            }
        }
Exemple #4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            currentNode = (Node)Context.Items["currentNode"];
            if (currentNode == null)
            {
                throw new DuryTools.ErrorHandler("currentNode not found!");
            }

            if (SFGlobal.IsUserCMS())
            {
                publicSuffix = "";
            }


            DataSet ds = dal.execDataSet("SELECT showTemplate,title,body FROM SimpleArticles " + publicSuffix + " WHERE nodeID = " + currentNode.Id);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow dr = ds.Tables[0].Rows[0];
                Page.ShowTemplate = (dr["showTemplate"] != System.DBNull.Value) ? (bool)dr["showTemplate"] : false;
                Page.PageTitle    = dr["title"].ToString();
                body.Text         = dr["body"].ToString();
            }
            else
            {
                body.Text = "content not found in database.";
            }
        }
Exemple #5
0
        private void addNewUserButton_Click(object sender, EventArgs e)
        {
            string username = SFGlobal.SqlCleanString(newUserName.Text);
            string password = Dury.SiteFoundry.Security.Cryptography.AsymmetricEncryption.ComputeHash(newUserPassword.Text, SFGlobal.EncryptionMethod, SFGlobal.EncryptionSalt);
            string fullname = SFGlobal.SqlCleanString(newUserFullName.Text);
            string email    = SFGlobal.SqlCleanString(newUserEmail.Text);
            string sql      = String.Format("INSERT INTO SecurityUsers (username,password,disabled,fullname,email,lastlogin,datecreated,datemodified) VALUES ('{0}','{1}',0, '{2}','{3}','{4}','{5}','{6}')", username, password, fullname, email, System.DateTime.Now, System.DateTime.Now, System.DateTime.Now);

            SFGlobal.DAL.execNonQuery(sql);

            int userID = (int)SFGlobal.DAL.execScalar("SELECT id FROM SecurityUsers WHERE username = '******'");

            foreach (ListItem li in newUserRoles.Items)
            {
                if (li.Selected)
                {
                    SFGlobal.DAL.execNonQuery("INSERT INTO SecurityUserRoles (userID,roleID) VALUES (" + userID.ToString() + "," + li.Value + ")");
                }
                li.Selected = false;
            }
            newUserName.Text     = "";
            newUserPassword.Text = "";
            newUserFullName.Text = "";
            newUserEmail.Text    = "";

            userGridBind();
            msg.Text = "user added";
        }
Exemple #6
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // load the article control
            Node currentNode = (Node)Context.Items["currentNode"];

            if (SFGlobal.IsUserCMS())
            {
                publicSuffix = "";
            }
            BaseArticle article;

            //SFGlobal.SetLangSession();

            if (Session["lang"] != null)
            {
                lang = Session["lang"].ToString();                //Context.Items["lang"];
            }
            else
            {
                lang = SFGlobal.DefaultLanguage;
            }

            string  sql = string.Format("SELECT b.title, b.summary, b.body, b.dateModified, b.templateID ,b.summary, b.keywords FROM " + this.articleBodyTable + this.publicSuffix + " b INNER JOIN " + this.articleContainerTable + this.publicSuffix + " a ON b.articleID = a.id WHERE (a.nodeID = {0}) AND (b.lang = '{1}')", currentNode.Id.ToString(), lang);
            DataSet ds  = SFGlobal.DAL.execDataSet(sql);
            string  title;

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow             dr = ds.Tables[0].Rows[0];
                ArticleTemplateInfo at = SFGlobal.GetArticleTemplate((int)dr["templateID"]);
                article = (BaseArticle)Page.LoadControl(SFGlobal.NodeTemplateLocation + "\\" + at.Src + ".ascx");
                article.ArticleTitle = dr["title"].ToString();
                article.ArticleBody  = dr["body"].ToString();
                article.LastModified = (dr["dateModified"] != DBNull.Value) ? (DateTime)dr["dateModified"] : System.DateTime.Now;
                article.Keywords     = dr["keywords"].ToString();
                article.Summary      = dr["summary"].ToString();
                title = dr["title"].ToString();
            }
            else
            {
                ArticleTemplateInfo at = SFGlobal.GetArticleTemplate(1);
                article = (BaseArticle)Page.LoadControl(SFGlobal.NodeTemplateLocation + "\\" + at.Src + ".ascx");
                article.ArticleTitle = "problem!";
                article.ArticleBody  = "article doesn't exist for this node.";
                title = "BIG PROBLEM!";
            }
            articleHolder.Controls.Add(article);

            /*
             * Node p = currentNode.parent;
             * if (p.parent != null)
             *      while(p.parent != null)
             *      {
             *              title = ": " + p.getName(SFGlobal.DefaultLanguage) + title;
             *              p = p.parent;
             *      }
             */
        }
Exemple #7
0
 private void applySecurity()
 {
     if (SFGlobal.GetCurrentUser().Roles.Contains(SFGlobal.AdminstratorRoleName) || SFGlobal.GetCurrentUser().Roles.Contains(SFGlobal.PublisherRoleName))
     {
         deleteLanguage.Enabled   = true;
         deletePage.Enabled       = true;
         publishNowButton.Enabled = true;
     }
 }
Exemple #8
0
 private void fillTemplateSelect()
 {
     System.Collections.Specialized.ListDictionary at = SFGlobal.LoadArticleTemplates();
     foreach (System.Collections.DictionaryEntry de in at)
     {
         ArticleTemplateInfo ati = (ArticleTemplateInfo)de.Value;
         articleTemplateID.Items.Add(new ListItem(ati.Name, ati.ID));
     }
 }
Exemple #9
0
 protected override void OnPreRender(EventArgs e)
 {
     base.OnPreRender(e);
     //Response.Write(SFGlobal.GetUserAlert());
     if (SFGlobal.GetUserAlert() != null)
     {
         alertMsg.InnerText = SFGlobal.GetUserAlert().ToString();
         alertMsg.Visible   = true;
         SFGlobal.ClearUserAlert();
     }
 }
        private void Application_BeginRequest(object sender, System.EventArgs e)
        {
            HttpApplication app     = ((HttpApplication)(sender));
            HttpContext     context = app.Context;
            string          r       = context.Request.RawUrl;

            // get the user
            System.Web.HttpContext.Current.User = SFGlobal.FetchUser();

            if (!cs.IsExcluded(r))                      // page isn't excluded
            {
                if (r.IndexOf(rqcs.AdminDirectory) > 0) // is in the 'admin' directory
                {
                    bool b = false;
                    foreach (string role in SFGlobal.CurrentUser.Roles)
                    {
                        if (SFGlobal.CurrentUser.IsRoleCMS(role, NodeFactory.RootNode))
                        {
                            b = true;
                        }
                    }

                    if (!b)
                    {
                        SFGlobal.RedirectToLogin();
                    }

                    /*
                     * if (!SFGlobal.CurrentUser.IsUserCMS())
                     * {
                     *      SFGlobal.RedirectToLogin();
                     * }
                     */
                }
                else                 // process normally
                {
                    if (context.Items["currentNode"] == null)
                    {
                        throw new Exception("currentNode is null and page isn't excluded from url processing:");
                        //context.Response.End();
                    }

                    if (!SFGlobal.CheckUserNodePermission(Permission.View))                     // check to see if the user has view permissions
                    {
                        //context.Response.Write("process");
                        //context.Response.End();
                        SFGlobal.RedirectToLogin();
                    }
                }
            }
        }
Exemple #11
0
        private void saveCurrentPage()
        {
            this.removePreviewArticle();
            DataContainer dc = new DataContainer(this.dbTable);
            DataRow       dr = dc.GetRowByCustomSql("SELECT * FROM " + dbTable + " WHERE nodeID = " + currentNode.Id + " AND rank = " + rank + " AND version = " + version);

            dr["templateID"]   = int.Parse(articleTemplateID.SelectedValue);
            dr["title"]        = title.Text;
            dr["summary"]      = summary.Text;
            dr["keywords"]     = keywords.Text;
            dr["body"]         = content.Text;
            dr["userID"]       = ((UserIdentity)SFGlobal.GetCurrentUser().Identity).ID;
            dr["dateModified"] = System.DateTime.Now;
            dr["publish"]      = publishCheck.Checked;
            dr["active"]       = activeCheck.Checked;
            dc.UpdateRow(dr);
        }
 private void rolesGrid_ItemCommand(object source, DataGridCommandEventArgs e)
 {
     if (e.CommandName == "Save")
     {
         SecurityNode sn      = Roles.GetSecurityNode(int.Parse(e.CommandArgument.ToString()));
         CheckBox     delete  = (CheckBox)e.Item.FindControl("delete");
         CheckBox     publish = (CheckBox)e.Item.FindControl("publish");
         CheckBox     edit    = (CheckBox)e.Item.FindControl("edit");
         CheckBox     add     = (CheckBox)e.Item.FindControl("add");
         CheckBox     view    = (CheckBox)e.Item.FindControl("view");
         int          i       = 0;
         if (delete.Checked)
         {
             i += (int)Permission.Delete;
         }
         if (publish.Checked)
         {
             i += (int)Permission.Publish;
         }
         if (edit.Checked)
         {
             i += (int)Permission.Edit;
         }
         if (add.Checked)
         {
             i += (int)Permission.Add;
         }
         if (view.Checked)
         {
             i += (int)Permission.View;
         }
         sn.PermissionLevel = i;
         Roles.SaveSecurityNode(sn);
         SFGlobal.UpdateNodes();
         Response.Redirect(Request.RawUrl);
     }
     if (e.CommandName == "Delete")
     {
         SecurityNode sn = Roles.GetSecurityNode(int.Parse(e.CommandArgument.ToString()));
         Roles.DeleteSecurityNode(sn);
         msg.Text = "role deleted";
         SFGlobal.UpdateNodes();
         Response.Redirect(Request.RawUrl);
     }
 }
        private void saveNode()
        {
            if (nodeID > 0)             //update
            {
                currentNode = root.Find(nodeID);
            }
            else            //insert
            {
                currentNode             = (Node)SFGlobal.ObjectManager.GetObject(typeof(Node));
                currentNode.DateCreated = currentNode.DateModified = DateTime.Now;
            }
            currentNode.Filename = filename.Text;
            //if (nodeID <= 0) currentNode.Rank = 0;

            Node parent = root.Find(int.Parse(parentID.SelectedValue));

            if (nodeID == 0)
            {
                if (parent.children.Count > 0)
                {
                    currentNode.Rank = parent.children[parent.children.Count - 1].Rank + 1;
                }
                else
                {
                    currentNode.Rank = 0;
                }
            }
            currentNode.ParentID       = int.Parse(parentID.SelectedValue);
            currentNode.TypeID         = int.Parse(nodeTypeID.SelectedValue);
            currentNode.PageTemplateID = int.Parse(pageTemplateID.SelectedValue);
            currentNode.Publish        = publish_check.Checked;
            currentNode.Visible        = visible_check.Checked;
            currentNode.VisibleMenu    = visibleMenu_check.Checked;
            currentNode.VisibleSubMenu = visibleSubMenu_check.Checked;
            currentNode.DateModified   = DateTime.Now;
            SFGlobal.ObjectManager.PersistChanges(currentNode);
            SFGlobal.UpdateNodes();

            // hack! -- skip the redirect if "add & close" was clicked
            if (nodeID > 0 && action == 0)
            {
                Response.Redirect(Request.Path + "?action=add");
            }
        }
Exemple #14
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            Node currentNode = (Node)Context.Items["currentNode"];

            if (!SFGlobal.IsUserCMS())
            {
                publicSuffix = "_public";
            }
            string linkLocation = (string)dal.execScalar("SELECT linkURL FROM Links" + publicSuffix + " WHERE nodeID = " + currentNode.Id);

            if (linkLocation != null)
            {
                Response.Redirect(linkLocation);
            }
            else
            {
                //Response.Write("Uh oh! problem with links");
                //throw new ErrorHandler("Problem loading node (type=links). Most likely caused by unpublished Link");
            }
        }
Exemple #15
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            currentNode = (Node)Context.Items["currentNode"];
            lang        = SFGlobal.CurrentCulture.Name;
            rank        = SFGlobal.IsNumeric(Page.CustomQueryString["page"]) ? int.Parse(Page.CustomQueryString["page"]) : 1;
            string sql     = "";
            string columns = "TOP 1 templateID, title, summary, keywords, body, dateModified ";

            if (SFGlobal.IsUserCMS())
            {
                sql = "SELECT " + columns + " FROM " + dbTable + " WHERE nodeID={0} AND lang='{1}' AND rank = {2} ORDER BY preview DESC, publish DESC, dateModified DESC, version DESC";
            }
            else
            {
                dbTable += SFGlobal.PublicSuffix;
                sql      = "SELECT " + columns + " FROM " + dbTable + " WHERE nodeID = {0}AND lang = '{1}' and rank = {2}";
            }
            sql = String.Format(sql, currentNode.Id, lang, rank);
            DataRow dr = SFGlobal.DAL.execDataRow(sql);

            if (dr != null)
            {
                article = loadArticle((int)dr["templateID"]);
                article.ArticleTitle = dr["title"].ToString();
                article.ArticleBody  = dr["body"].ToString();
                article.Keywords     = dr["keywords"].ToString();
                article.Summary      = dr["summary"].ToString();
                article.LastModified = (DateTime)dr["dateModified"];
            }
            else
            {
                article              = loadArticle(1);
                article.ArticleBody  = String.Format("<h2>Article not Found.</h2><p>There is no Article for this node yet. Publish a new article</p>");
                article.ArticleTitle = "Error!";
                article.Keywords     = "ERROR";
                article.Summary      = "ERROR";
                article.LastModified = DateTime.Now;
                //throw new DuryTools.ErrorHandler("Problem loading article. Possible causes: haven't published yet, no article for this language");
            }
            holder.Controls.Add(article);
        }
Exemple #16
0
        private void createArticlePage(string language, int rank)
        {
            DataContainer dc = new DataContainer(dbTable);
            DataRow       dr = dc.GetNewRow();

            dr["nodeID"]      = currentNode.Id;
            dr["templateID"]  = 1;
            dr["lang"]        = language;
            dr["version"]     = 1;
            dr["rank"]        = rank;
            dr["title"]       = currentNode.getName(SFGlobal.DefaultLanguage);
            dr["summary"]     = "new summary";
            dr["keywords"]    = "new keywords";
            dr["body"]        = "new body for " + currentNode.getName(SFGlobal.DefaultLanguage);
            dr["userID"]      = SFGlobal.GetCurrentUser().ID;
            dr["publish"]     = false;
            dr["preview"]     = false;
            dr["active"]      = false;
            dr["dateCreated"] = dr["dateModified"] = System.DateTime.Now;
            dc.UpdateRow(dr);
        }
 private void Page_Load(object sender, System.EventArgs e)
 {
     if (FormField.Title == "")
     {
         title.Text = "new question";
     }
     else
     {
         title.Text = SFGlobal.TruncateText(FormField.Title, 30);
     }
     title.Command    += new CommandEventHandler(button_Command);
     title.CommandName = "edit";
     title.Attributes.Add("onMouseOver", "showControls('fl_" + FormField.FieldID.ToString() + "');");
     upButton.Command        += new CommandEventHandler(button_Command);
     upButton.CommandName     = "up";
     dnButton.Command        += new CommandEventHandler(button_Command);
     dnButton.CommandName     = "dn";
     editButton.Command      += new CommandEventHandler(button_Command);
     editButton.CommandName   = "edit";
     deleteButton.Command    += new CommandEventHandler(button_Command);
     deleteButton.CommandName = "delete";
 }
Exemple #18
0
        private void publishItems()
        {
            string s = "";

            // first publish the nodes
            SFGlobal.DAL.execNonQuery("publishNodes", null);
            s += "published nodes<br>";

            // now publish what we want...
            foreach (ListItem li in nodesToPublish.Items)
            {
                if (li.Selected)
                {
                    publishNodeInfo pni = (publishNodeInfo)nodeInfo[li.Value];
                    SFGlobal.DAL.execNonQuery(pni.PublishSP, null);
                    s += "published " + pni.Name + "<BR>";
                }
            }
            SFGlobal.UpdateNodes();
            getItemsForPublish();
            results.Text = s;
        }
Exemple #19
0
        protected void userGrid_Update(System.Object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            int itemID = int.Parse(e.Item.Cells[0].Text);

            // insert user data
            string username = SFGlobal.SqlCleanString(((TextBox)e.Item.FindControl("username")).Text);
            string password = ((TextBox)e.Item.FindControl("password")).Text;
            string fullname = SFGlobal.SqlCleanString(((TextBox)e.Item.FindControl("fullname")).Text);
            string email    = SFGlobal.SqlCleanString(((TextBox)e.Item.FindControl("email")).Text);
            string disabled = ((CheckBox)e.Item.FindControl("disabledCheck")).Checked ? "1" : "0";

            if (password != null && password != "")
            {
                password = Dury.SiteFoundry.Security.Cryptography.AsymmetricEncryption.ComputeHash(password, SFGlobal.EncryptionMethod, SFGlobal.EncryptionSalt);
                SFGlobal.DAL.execNonQuery("UPDATE SecurityUsers SET username = '******'" + ", password='******', fullname='" + fullname + "', email='" + email + "' , disabled=" + disabled + " WHERE id = " + itemID.ToString());
            }
            else
            {
                SFGlobal.DAL.execNonQuery("UPDATE SecurityUsers SET username = '******', fullname='" + fullname + "', email='" + email + "', disabled=" + disabled + " WHERE id = " + itemID.ToString());
            }


            // insert roles
            ListBox cbx = (ListBox)e.Item.FindControl("rolesList");

            SFGlobal.DAL.execNonQuery("DELETE FROM SecurityUserRoles WHERE userID = " + itemID.ToString());
            foreach (ListItem li in cbx.Items)
            {
                if (li.Selected)
                {
                    SFGlobal.DAL.execNonQuery("INSERT INTO SecurityUserRoles (userID,roleID) VALUES (" + itemID.ToString() + "," + li.Value + ")");
                }
            }
            userGrid.EditItemIndex = -1;
            userGridBind();
            SFGlobal.UpdateNodes();
            msg.Text = "User: "******" updated ok";
        }
Exemple #20
0
        private void createNewVersion()
        {
            this.removePreviewArticle();
            DataContainer dc = new DataContainer(this.dbTable);
            DataRow       dr = dc.GetNewRow();

            dr["nodeID"]      = currentNode.Id;
            dr["templateID"]  = int.Parse(articleTemplateID.SelectedValue);
            dr["version"]     = versionCount() + 1;
            dr["lang"]        = lang;
            dr["rank"]        = rank;
            dr["title"]       = title.Text;
            dr["summary"]     = summary.Text;
            dr["keywords"]    = keywords.Text;
            dr["body"]        = content.Text;
            dr["userID"]      = ((UserIdentity)SFGlobal.GetCurrentUser().Identity).ID;
            dr["dateCreated"] = dr["dateModified"] = System.DateTime.Now;
            dr["publish"]     = false;
            dr["preview"]     = false;
            dr["active"]      = false;
            dc.UpdateRow(dr);
            loadPage(rank);
        }
 private void deleteNode()
 {
     currentNode = (Node)SFGlobal.ObjectManager.GetObject(typeof(Node), nodeID);
     NodeFactory.DeleteNode(currentNode);
     SFGlobal.UpdateNodes();
 }
        private void removePreviewArticle()
        {
            string sql = String.Format("DELETE FROM " + dbTable + " WHERE preview = 1 AND nodeID = {0} AND lang = '{1}' AND userID = {2}", currentNode.Id, lang, ((UserIdentity)SFGlobal.GetCurrentUser().Identity).ID);

            dal.execNonQuery(sql);
        }
Exemple #23
0
 protected void Session_End(Object sender, EventArgs e)
 {
     SFGlobal.DecrementUserCount();
 }
Exemple #24
0
        // url scheme:  http://mysite.com/en-CA/default.aspx
        //              http://mysite.com/en-CA/whoweare/default.aspx
        //              http://mysite.com/whoweare/gallery.aspx (uses default language)

        private void Application_BeginRequest(object sender, System.EventArgs e)
        {
            HttpApplication app     = ((HttpApplication)(sender));
            HttpContext     context = app.Context;

            startTime = DateTime.Now;


            string r                    = context.Request.RawUrl;
            string virtualDir           = (System.Configuration.ConfigurationSettings.AppSettings["virtualDirName"] != null) ? System.Configuration.ConfigurationSettings.AppSettings["virtualDirName"] : "";
            string virtualFileExtension = (System.Configuration.ConfigurationSettings.AppSettings["virtualFileExtension"] != null) ? System.Configuration.ConfigurationSettings.AppSettings["virtualFileExtension"] : ".aspx";
            RewriteConfigSettings cs    = RewriteConfigSettings.GetSettings();
            RequestConfigSettings rqcs  = RequestConfigSettings.GetSettings();

            // apply exceptions
            if (!cs.IsExcluded(r) && r.IndexOf(rqcs.AdminDirectory) < 0)
            {
                if (r[r.Length - 1] != '/' && virtualFileExtension == "" && r.IndexOf("?") == -1)
                {
                    context.Response.Redirect(r + "/", true);
                }

                // lets cut the incoming url into the parts we're interested in
                string u = r.Substring(1);
                //context.Response.Write("1u=" + u + "<BR>");
                //context.Response.Write("1r=" + r + "<BR>");
                if (u.IndexOf("?") > 0)
                {
                    u = u.Substring(0, u.IndexOf("?"));
                }
                if (virtualDir.Length > 0)
                {
                    u = u.Replace(virtualDir, "");
                }
                if (u.IndexOf(".aspx") > 0 && virtualDir.Length == 0)
                {
                    u.Replace(".aspx", "");
                }
                if (u != "" && virtualFileExtension != "" && virtualFileExtension.Length > 0)
                {
                    try {
                        u = u.Substring(0, u.IndexOf(virtualFileExtension));                       //u.Replace(virtualFileExtension,"");
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("substring 3 - " + u + ", " + r, ex);
                    }
                }
                // split it!
                System.Collections.Specialized.StringCollection url_parts = new System.Collections.Specialized.StringCollection();
                url_parts.AddRange(u.Split('/'));

                // find language identitfier -- if not found then set default
                System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("/[a-z]{2}-[a-zA-Z]{2}/|/[a-z]{2}/");
                if (regex.IsMatch(r) && regex.Match(r).Index == 0)
                {
                    setCulture(url_parts[0]);
                    url_parts.RemoveAt(0);
                }
                else
                {
                    setCulture(SFGlobal.DefaultLanguage);
                }


                // create pseudo-querystring
                string output = "";
                foreach (string s in url_parts)
                {
                    if (s.Length > 0 && !SFGlobal.IsNumeric(s))
                    {
                        output += s + "*";
                    }
                }

                output = (output.Length > 1) ? output.Substring(0, output.Length - 1) : "default";

                // url rewriting

                // this needs to load the user before the currentNode is returned

                context.User = SFGlobal.FetchUser();
                context.Items.Add("currentNode", SFGlobal.GetNode(output));

                if (context.Items["currentNode"] == null || SFGlobal.GetNode(output) == null)
                {
                    context.Response.Write("currentNode is null:" + output);
                    context.Response.End();
                }

                context.RewritePath(cs.PageHandler, cs.PageHandler, output);
            }
            else
            {
                //context.Response.Write("no rewrite");
            }
        }
Exemple #25
0
 protected void Application_Start(Object sender, EventArgs e)
 {
     SFGlobal.Start();
 }
Exemple #26
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            currentNode = (Node)Context.Items["currentNode"];             // get our current node from the context stack
            string sql = "";
            object id  = null;


            // lets give the CMS user special treatment
            if (SFGlobal.IsUserCMS())
            {
                publicSuffix = "";
                // see if there is a preview assigned to this node
                //sql = "SELECT b.versionNumber, b.pageNumber, b.title, b.summary, b.body, b.dateModified, b.templateID, b.keywords FROM  sf_ArticlePages b INNER JOIN sf_Articles a ON b.articleID = a.id WHERE (a.nodeID = " + currentNode.Id + ") AND (a.lang = '" + lang + "') AND (b.preview = 1)";
                id = SFGlobal.DAL.execScalar(String.Format("SELECT b.id FROM sf_ArticlePages b INNER JOIN sf_Articles a ON b.articleID = a.id WHERE (a.nodeID = {0}) AND (b.preview = 1) AND (a.lang = '{1}')", currentNode.Id, this.lang));
                Response.Write("1=" + id);


                // otherwise show the article set for publish
                if (id == null)
                {
                    id = SFGlobal.DAL.execScalar(String.Format("SELECT b.id FROM sf_ArticlePages b INNER JOIN sf_Articles a ON b.articleID = a.id WHERE (a.nodeID = {0}) AND (a.lang = '{1}') AND (b.publish = 1)", currentNode.Id, this.lang));
                    Response.Write("2=" + id);
                }


                // otherwise show the greatest version number
                if (id == null)
                {
                    id = SFGlobal.DAL.execScalar(String.Format("SELECT TOP 1 b.id FROM sf_ArticlePages b INNER JOIN sf_Articles a ON b.articleID = a.id WHERE (a.nodeID = {0}) AND (a.lang = '{1}') ORDER BY b.versionNumber DESC", currentNode.Id, this.lang));
                    Response.Write("3=" + id);
                }
            }
            else
            {
                //id = (int)SFGlobal.DAL.execScalar(String.Format("SELECT TOP 1 b.id FROM sf_ArticlePages" + this.publicSuffix + " b INNER JOIN sf_Articles" + this.publicSuffix + " a ON b.articleID = a.id WHERE (a.nodeID = {0}) AND (a.lang = '{1}')", currentNode.Id, this.lang));
            }

            if (id == null)
            {
                throw new DuryTools.ErrorHandler("can't find article for this node! help!");
            }
            else
            {
                DataSet ds = SFGlobal.DAL.execDataSet("SELECT * FROM sf_ArticlePages" + this.publicSuffix + " WHERE id = " + id.ToString());
                if (ds.Tables[0].Rows.Count >= 1)
                {
                    DataRow             dr = ds.Tables[0].Rows[0];
                    ArticleTemplateInfo at = SFGlobal.GetArticleTemplate((int)dr["templateID"]);
                    article = (BaseArticle)Page.LoadControl(SFGlobal.NodeTemplateLocation + "\\" + at.Src + ".ascx");
                    article.ArticleTitle = dr["title"].ToString();
                    article.ArticleBody  = dr["body"].ToString();
                    article.LastModified = (dr["dateModified"] != DBNull.Value) ? (DateTime)dr["dateModified"] : System.DateTime.Now;
                    article.Keywords     = dr["keywords"].ToString();
                    article.Summary      = dr["summary"].ToString();
                    //title = dr["title"].ToString();
                    holder.Controls.Add(article);

                    Response.Write(Page.CustomQueryString["page"]);
                }
                else
                {
                    throw new DuryTools.ErrorHandler("Can't load article id: " + id.ToString());
                }
            }

            //DataSet ds = SFGlobal.DAL.execDataSet(sql);
            //Response.Write(ds.Tables[0].Rows.Count);
        }
Exemple #27
0
 protected void Session_Start(Object sender, EventArgs e)
 {
     SFGlobal.IncrementUserCount();
 }
Exemple #28
0
 private void addNewRole_Click(object sender, EventArgs e)
 {
     SFGlobal.DAL.execNonQuery("INSERT INTO SecurityRoles (name) VALUES ('" + SFGlobal.SqlCleanString(newRoleName.Text) + "')");
     Response.Redirect(Request.RawUrl);
 }