示例#1
0
    protected void DataFolder_ItemCommand(object source, DataListCommandEventArgs e)
    {
        ConnectionClass mycon = new ConnectionClass();

        if (e.CommandName == "delete")
        {
            string path = e.CommandArgument.ToString();
            mycon.iud("update tbl_pvt set status='INACTIVE' where path='" + path + "'");
            string user_id = Session["u_id"].ToString();
            mycon.iud("insert into tbl_logs values('You have deleted a file from your Private folder','" + user_id + "','" + DateTime.Now.ToString() + "')");
        }
        else if (e.CommandName == "view")
        {
            string path = e.CommandArgument.ToString();
            //  done.NavigateUrl = path;
            string cd   = Request.QueryString["c_id"];
            string u_id = mycon.GetValue("select u_id from tbl_category where c_id=" + cd);
            string cdd  = mycon.GetValue("select c_id from tbl_category where u_id='" + u_id + "'AND c_name='Text'");
            if (Request.QueryString["c_id"].ToString() != cdd)
            {
                Response.Redirect(path);
            }
            else
            {
                SecureFile sf    = new SecureFile();
                string     p     = MapPath(path);
                int        index = path.IndexOf('-');
                int        len   = path.Length;
                string     fname = path.Substring(index, len - index);
                if (passs.Text != "")
                {
                    string pth = sf.decrypt(fname, p, passs.Text);
                    // Response.Redirect(pth);
                    if (pth != "")
                    {
                        string ext = Path.GetExtension(fname);
                        Response.Redirect("~/folder/" + fname + "_decrypted" + ext);
                    }
                    else
                    {
                        Response.Write("INVALID PASSWORD");
                    }
                }
            }
        }

        fillfolderdata();
    }