edit_articleto.aspx.cs
资源名称:论坛源码.rar [点击查看]
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:5k
源码类别:
.net编程
开发平台:
C#
- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using System.Data.OleDb;
- using System.Configuration;
- using System.Text;
- using System.Web.Security;
- using System.Security.Cryptography;
- namespace kuangren
- {
- /// <summary>
- /// edit_articleto 的摘要说明。
- /// </summary>
- public class edit_articleto : System.Web.UI.Page
- {
- public string usercookies;
- protected int intRunTime;
- protected DateTime dtStartTime = DateTime.Now;
- protected System.Data.OleDb.OleDbConnection conn;
- protected System.Data.OleDb.OleDbCommand cmd;
- protected System.Data.OleDb.OleDbCommand cmd5;
- protected string OleDbforum3;
- public DataSet dsPending;
- public DataSet dsuser;
- public DataSet dsPending1;
- protected int powerjudge;
- protected int usergrade;
- protected string powername;
- protected int powergrade;
- public string sql;
- public string sql1;
- protected string updatecontent;
- protected string judgeupdater;
- public int userjudge2;
- public int userjudge3;
- public string f3id;
- private void Page_Load(object sender, System.EventArgs e)
- {
- if (Request.Cookies["jusername"]!=null)
- {
- usercookies=Request.Cookies["jusername"].Value;
- }
- else
- {
- Response.Redirect("logine.aspx");
- }
- f3id=Convert.ToString(Request.Form["f3_id"]);
- string str=""+Request.Form["subject"]+"";
- string str1=""+Request.Form["content"]+"";
- userjudge2=System.Text.Encoding.Default.GetByteCount(str);
- userjudge3=System.Text.Encoding.Default.GetByteCount(str1);
- if (userjudge2>50||userjudge2==0||userjudge3>16240||userjudge3==0)
- {
- Response.Redirect("announcerror.aspx");
- }
- conn = new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
- //搜索主题信息
- sql="SELECT f3_motif,f3_content,f3_name,f3_sy FROM forum_3 WHERE f3_id ="+Request.Form["f3_id"]+"";
- dsPending=new DataSet();
- OleDbDataAdapter adWord=new OleDbDataAdapter(sql,conn);
- adWord.Fill(dsPending,"forum_3");
- Page.DataBind();
- //判断是否为该主题所属论坛斑竹
- powerjudge=Convert.ToInt32(dsPending.Tables[0].Rows[0]["f3_sy"]);
- powername=Convert.ToString(dsPending.Tables[0].Rows[0]["f3_name"]);
- dsuser=new DataSet();
- cmd=new OleDbCommand("select umf2_id from user_f2 where umf2_id="+powerjudge+" and um_name='"+Request.Cookies["jusername"].Value+"'",conn);
- OleDbDataReader objDataReader ;
- cmd.Connection.Open();
- //搜索该主题发帖人信息,判断斑竹或管理员是否有权限修改[剑气潇潇为超级用户]
- sql1="SELECT u_grade,u_user from userinfo WHERE u_user ='"+powername+"'";
- dsPending1=new DataSet();
- OleDbDataAdapter adWord1=new OleDbDataAdapter(sql1,conn);
- adWord1.Fill(dsPending1,"userinfo");
- Page.DataBind();
- string usergrade=Convert.ToString(dsPending1.Tables[0].Rows[0]["u_grade"]);
- powergrade=Convert.ToInt32(usergrade);
- objDataReader = cmd.ExecuteReader();
- //judgepower
- if (powername!=Request.Cookies["jusername"].Value)
- {
- if ((objDataReader.Read() != true) &&Convert.ToString(Request.Cookies["jpower"].Value)!="1")
- {
- Response.Redirect("power_error.aspx");
- }
- if(powergrade<=Convert.ToInt32(Request.Cookies["jpower"].Value)&&Convert.ToString(Request.Cookies["jusername"].Value)!="剑气潇潇")
- {
- Response.Redirect("power_error.aspx");
- }
- }
- cmd.Connection.Close();
- //end
- //执行修改
- //判断修改帖子者
- if (powername!=Request.Cookies["jusername"].Value)
- {
- if (Convert.ToInt32(Request.Cookies["jpower"].Value)==1)
- {judgeupdater="管理员";}
- if (Convert.ToInt32(Request.Cookies["jpower"].Value)==2)
- {judgeupdater="版主";}
- }
- else
- {
- judgeupdater="作者";
- }
- updatecontent=Request.Form["content"]+"[color=#FF0000]——该主题被"+judgeupdater+"于"+DateTime.Now+"修改过[/color]";
- OleDbforum3="update [forum_3] SET f3_motif='"+Request.Form["subject"]+"',f3_content='"+updatecontent+"',f3_face='"+Request.Form["f3_face"]+"',f3_now='"+DateTime.Now+"' where f3_id="+Request.Form["f3_id"]+"";
- cmd5=new OleDbCommand(OleDbforum3,conn);
- conn.Open();
- bool doredirect=true;
- try
- {
- cmd5.ExecuteNonQuery();
- }
- catch
- {
- doredirect=false;
- }
- finally
- {
- conn.Close();
- }
- if(doredirect)
- {
- }
- else
- {
- Response.Redirect("index.aspx");
- }
- //执行结束
- }
- #region Web 窗体设计器生成的代码
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- }
- }