protected void Page_Load(object sender, EventArgs e) { AuthenticateUser(); intProfile = Int32.Parse(Request.Cookies["profileid"].Value); // Response.Redirect("/redirect.aspx?referrer=/frame/document_repository_rename.aspx?id=" + intDocId); oCustomized = new Customized(intProfile, dsn); oIcon = new Icons(intProfile, dsn); if (Request.QueryString["id"] != null && Request.QueryString["id"] != "") { intDocId = Int32.Parse(Request.QueryString["id"]); strType = oCustomized.GetDocumentRepository(intDocId, "type"); if (!IsPostBack) { txtName.Text = oCustomized.GetDocumentRepository(intDocId, "name"); if (txtName.Text.EndsWith(strType)) { txtName.Text = txtName.Text.Substring(0, txtName.Text.IndexOf(strType)); } Page.ClientScript.RegisterStartupScript(typeof(Page), "loader", "<script type=\"text/javascript\">document.getElementById('" + txtName.ClientID + "').focus();document.getElementById('" + txtName.ClientID + "').select();<" + "/" + "script>"); } } // Security code strSecurity = oCustomized.GetDocumentRepositorySharesByIds(intDocId, "security"); if (strSecurity == "") { strSecurity = oCustomized.GetDocumentRepository(intDocId, "security"); } strOwner = oCustomized.GetDocumentRepositorySharesByIds(intDocId, "ownerid"); if (strOwner == "") { strOwner = oCustomized.GetDocumentRepository(intDocId, "profileid"); } strPath = oCustomized.GetDocumentRepository(intDocId, "path"); strProfile = oCustomized.GetDocumentRepository(intDocId, "profileid"); strApplication = oCustomized.GetDocumentRepository(intDocId, "applicationid"); btnRename.Attributes.Add("onclick", "return ValidateText('" + txtName.ClientID + "','Please enter a valid name');"); }
protected void Page_Load(object sender, EventArgs e) { AuthenticateUser(); intProfile = Int32.Parse(Request.Cookies["profileid"].Value); oCustomized = new Customized(intProfile, dsn); oIcon = new Icons(intProfile, dsn); oFunction = new Functions(intProfile, dsn, intEnvironment); if (Request.QueryString["docid"] != null && Request.QueryString["docid"] != "") { Int32.TryParse(oFunction.decryptQueryString(Request.QueryString["docid"]), out intDocId); } int intApplication = 0; if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "") { intApplication = Int32.Parse(Request.Cookies["application"].Value); } if (intDocId > 0) { string strSecurity = oCustomized.GetDocumentRepositorySharesByIds(intDocId, "security"); if (strSecurity == "") { strSecurity = oCustomized.GetDocumentRepository(intDocId, "security"); } string strOwner = oCustomized.GetDocumentRepositorySharesByIds(intDocId, "ownerid"); if (strOwner == "") { strOwner = oCustomized.GetDocumentRepository(intDocId, "profileid"); } string strType = oCustomized.GetDocumentRepository(intDocId, "type"); string strPath = oCustomized.GetDocumentRepository(intDocId, "path"); string strName = oCustomized.GetDocumentRepository(intDocId, "name"); string strSize = oCustomized.GetDocumentRepository(intDocId, "size"); int intIsDepartment = Int32.Parse(oCustomized.GetDocumentRepository(intDocId, "department")); int intDepartment = Int32.Parse(oCustomized.GetDocumentRepository(intDocId, "applicationid")); if (strSecurity == "1" || strSecurity == "10" || strOwner == intProfile.ToString() || (strSecurity == "-1" && intIsDepartment == 1 && intDepartment == intApplication) ) { if (strType != "Folder" && new System.IO.FileInfo(strPath).Exists == true) { DataSet ds = oIcon.Get(strType.ToUpper()); if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["content_type"].ToString() != "") { Response.ContentType = ds.Tables[0].Rows[0]["content_type"].ToString(); } else { Response.Redirect(strPath); } //Response.ContentType = "application/octet-stream"; Response.AppendHeader("content-disposition", "inline;filename=" + strName); Response.AppendHeader("content-length", strSize); Response.WriteFile(strPath); Response.Flush(); Response.End(); } } else { Response.Write("<script type=\"text/javascript\">alert('Access Denied (" + strSecurity.ToString() + "." + intIsDepartment.ToString() + "." + strOwner + "." + intProfile.ToString() + "." + intDepartment.ToString() + "." + intApplication.ToString() + ")!');window.close();</script>"); } } else { Response.Write("<script type=\"text/javascript\">alert('Access Denied!');window.close();</script>"); } }