huang.cs
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:46k
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System;
- using System.Data.OleDb;
- using System.Data;
- using System.Collections;
- using System.Web.UI.HtmlControls;
- using System.Text.RegularExpressions;
- using System.Web.Caching;
- namespace huang {
- //------------------------index.aspx------------------------------------------------
- public class index : Page{
- public OleDbConnection MyConn;
- public DateTime n1 ;
- public DateTime n2 ;
- public TimeSpan n3 ;
- public OleDbDataReader dr_Index;
- public String Fid1;
- public string sql_Index;
- public void Page_Load(Object src,EventArgs e)
- {
- DateTime now= DateTime.Now;
- n1= DateTime.Now;//创建连接
- gong cc= new gong();
- MyConn=cc.qidong();
- cksub();
- OleDbCommand com_TopicTotal = new OleDbCommand(sql_Index,MyConn);
- dr_Index=com_TopicTotal.ExecuteReader();
- }
- public void cksub(){
- if (Request.QueryString["Fid1"]==null){
- sql_Index = "Select TopicTotal,id,Fid1,Fid2,Fid1Name,Fid2Name,Fimg,Des,ban,ReplyTotal from state order by Fid1 asc ";
- }
- else {
- Fid1=Request.QueryString["Fid1"].ToString();
- sql_Index = "Select TopicTotal,id,Fid1,Fid2,Fid1Name,Fid2Name,Fimg,Des,ban,ReplyTotal from state where Fid1="+Fid1+" order by Fid1 asc ";
- }
- }
- public void Page_Unload(Object src,EventArgs e)
- {
- MyConn.Close();
- }
- }
- //--------------------------list.aspx----------------------------------------------
- public class list : Page{
- public Repeater score;
- public OleDbConnection MyConn;
- public int PageSize=20;//每页记录数可以自己修改
- public int CurrentPage;//
- public int TopicTotal;//共计记录数目
- public String Fid1;
- public String Fid2;
- public String Table_Topic;
- public String Fid1Name;
- public String Fid2Name;
- public string Noti;
- public DateTime n1 ;
- public DateTime n2 ;
- public TimeSpan n3 ;
- public string ban;
- public OleDbDataReader dr_TopicTotal;
- public void Page_Load(Object src,EventArgs e)
- {
- DateTime now= DateTime.Now;
- n1= DateTime.Now;
- Fid1=Request.QueryString["Fid1"];
- Fid2=Request.QueryString["Fid2"];
- Table_Topic=Fid1+"Topic"+Fid2;
- if (Request.QueryString["page"]!=""){
- CurrentPage=Int32.Parse(Request.QueryString["page"].ToString());
- }
- else
- {
- CurrentPage=1;
- }
- //创建连接
- gong cc= new gong();
- MyConn=cc.qidong();
- getsubinfo();
- ListBind();
- MyConn.Close();
- n2= DateTime.Now;
- n3=n2-n1;
- MyConn.Close();
- }
- ICollection CreateSource()
- {
- int StartIndex;
- StartIndex = (CurrentPage)*PageSize;
- string strSel = "select top "+StartIndex.ToString()+" Expression,TopicId,Topic,Postuser,LastReply,DateAndTime from "+Table_Topic+" order by DateAndTime desc ";
- DataSet ds = new DataSet();
- OleDbDataAdapter MyAdapter = new OleDbDataAdapter(strSel,MyConn);
- MyAdapter.Fill(ds,StartIndex-PageSize,PageSize,Table_Topic);
-
- return ds.Tables[Table_Topic].DefaultView;
- }
- public void ListBind()
- {
- score.DataSource =CreateSource();
- score.DataBind();
- }
- public void getsubinfo(){
- string sql_TopicTotal = "Select TopicTotal,id,Fid1,Fid2,Fid1Name,Fid2Name,ban,Noti from state where Fid1="+Fid1+" and Fid2="+Fid2;
- OleDbCommand com_TopicTotal = new OleDbCommand(sql_TopicTotal,MyConn);
- dr_TopicTotal=com_TopicTotal.ExecuteReader();
- while(dr_TopicTotal.Read())
- {
- TopicTotal=(int)dr_TopicTotal["TopicTotal"];
- Fid1Name=dr_TopicTotal["Fid1Name"].ToString();
- Fid2Name=dr_TopicTotal["Fid2Name"].ToString();
- ban=dr_TopicTotal["ban"].ToString();
- Noti=dr_TopicTotal["Noti"].ToString();
- }
- dr_TopicTotal.Close();
- }
-
- }
- //--------------------------query.aspx----------------------------------------------
- public class query : Page{
- public Repeater score;
- public OleDbConnection MyConn;
- public string Fid1Name;
- public string Fid2Name;
- public string actionname;
- public string ban;
- public string Noti;
- public string tab;
- public string Fid1;
- public string Fid2;
- public string sql;
- public string type;
- public string keyword;
- public string item1;//标题
- public string item2;//TopicId
- public string item3;//作者或者最后回复者
- public string item4;//时间日期
- public OleDbDataReader dr_TopicTotal;
- public void Page_Load(Object src,EventArgs e)
- {
- if (Request.QueryString["keyword"]==""){
- Response.Redirect("er.aspx?ms=8");
- }
- gong cc= new gong();
- MyConn=cc.qidong();
- getsql();
- getsubinfo();
- ListBind();
- MyConn.Close();
- }
- ICollection CreateSource()
- {
- int StartIndex;
- DataSet ds = new DataSet();
- OleDbDataAdapter MyAdapter = new OleDbDataAdapter(sql,MyConn);
- MyAdapter.Fill(ds,tab);
- return ds.Tables[tab].DefaultView;
- }
- public void ListBind()
- {
- score.DataSource =CreateSource();
- score.DataBind();
- }
- public void getsql()
- {
- Fid1=Request.QueryString["Fid1"];
- Fid2=Request.QueryString["Fid1"];
- type=Request.QueryString["type"];
- keyword=Request.QueryString["keyword"];
- if (Request.QueryString["table"]=="topic"){
- actionname="搜索主题";
- tab=Fid1+"Topic"+Fid2;
- item1="Topic";
- item2="TopicId";
- item3="LastReply";
- item4="DateAndTime";
- if (type=="title"){
- sql="select top 50 Topic,TopicId,LastReply,DateAndTime from "+Fid1+"Topic"+Fid2+" where Topic like '%"+keyword+"%' order by DateAndtime desc";
- }
- else {
- sql="select top 50 Topic,TopicId,LastReply,DateAndTime from "+Fid1+"Topic"+Fid2+" where Postuser= '"+keyword+"' order by DateAndtime desc";
- }
- }
- if (Request.QueryString["table"]=="reply") {
- actionname="搜索回复";
- tab=Fid1+"Reply"+Fid2;
- item1="Title";
- item2="TopicId";
- item3="Postuser";
- item4="DateAndTime";
- if (type=="title"){
- sql="select top 50 Title,TopicId,Postuser,DateAndTime from "+Fid1+"reply"+Fid2+" where Title like '%"+keyword+"%' order by DateAndtime desc";
- }
- else {
- sql="select top 50 Title,TopicId,Postuser,DateAndTime from "+Fid1+"reply"+Fid2+" where Postuser= '"+keyword+"' order by DateAndtime desc";
- }
- }
- }
- public void getsubinfo(){
- string sql_TopicTotal = "Select TopicTotal,id,Fid1,Fid2,Fid1Name,Fid2Name,ban,Noti from state where Fid1="+Fid1+" and Fid2="+Fid2;
- OleDbCommand com_TopicTotal = new OleDbCommand(sql_TopicTotal,MyConn);
- dr_TopicTotal=com_TopicTotal.ExecuteReader();
- while(dr_TopicTotal.Read())
- {
- Fid1Name=dr_TopicTotal["Fid1Name"].ToString();
- Fid2Name=dr_TopicTotal["Fid2Name"].ToString();
- ban=dr_TopicTotal["ban"].ToString();
- Noti=dr_TopicTotal["Noti"].ToString();
- }
- dr_TopicTotal.Close();
- }
- }
- //------------------------admin_notice.aspx------------------------------------------------
- public class admin_notice : Page{
- public String Fid1;
- public String Fid2;
- public void Page_Load(Object src,EventArgs e)
- {
- Fid1=Request.QueryString["Fid1"];
- Fid2=Request.QueryString["Fid2"];
- }
- }
- //------------------------er.aspx------------------------------------------------
- public class er : Page{
- public string[] content;
- public void Page_Load(Object src,EventArgs e)
- {
- content=new string[14];
- content[1]="你还没有登陆,登陆请点击 <a href='log.htm'><font color=red>登陆</font></a> 如果你没有注册请点击<a href='reg_pre.aspx?action=reg&UserName='><font color=red>注册</font></a>";
- content[2]="你不具有本操作的权限";
- content[3]="你的输入不正确或则含有非法字符";
- content[4]="已经有人取了这个用户名,请另外选择一个";
- content[5]="回复的帖子标题和主题不能两者都为空";
- content[6]="主题标题不能为空";
- content[7]="输入的数据不符合要求";
- content[8]="输入的关键字长度太短";
- content[9]="你不是管理员";
- content[10]="登陆不成功";
- content[11]="输入的数据或者字符不正确,用户名和密码是必须填写的项目";
- content[12]="两次密码输入不同";
- }
- }
- //------------------------admin_front.aspx------------------------------------------------
- public class admin_front : Page{
- public OleDbConnection MyConn;
- public HttpCookie readcookie;
- public string Postuser;
- public string Pass;
- public OleDbDataReader dr_admin;
- public String Fid1;
- public String Fid2;
- public string sql_admin;
- public string[] arrwords;
- public string UserName;
- public string type;
- public string Action;
- public string ban;
- public string id;
- public int i;
- public int n;
- public string Expression;
- public string content;
- public OleDbCommand com_admin ;
- public gong cc;
- public void Page_Load(Object src,EventArgs e)
- {
- Fid1=Request.QueryString["Fid1"];
- Fid2=Request.QueryString["Fid2"];
- type=Request.QueryString["type"];
- Action=Request.QueryString["Action"];
- id=Request.QueryString["id"];
- n=0;
- sql_admin="select ban from state where Fid1="+Fid1+" and Fid2="+Fid2;
- cc= new gong();
- MyConn=cc.qidong();
- UserName=userck();
- if (UserName=="bad"){
- Response.Redirect("er.aspx?ms=1");
- }
- ckban();
- doaction();
- MyConn.Close();
- }
- public string userck(){
- if (Request.Cookies["huangliang"]==null){
- return("bad");
- }
-
- else{
- readcookie = Request.Cookies["huangliang"];
- if (readcookie.Values["UserName"].ToString()!=null){
- Postuser= readcookie.Values["UserName"].ToString();
- Pass= readcookie.Values["Pass"].ToString();
- return(Postuser);
- }
- else{
- return("bad");
- }
- }
- }
-
-
-
- public void ckban(){
-
- com_admin = new OleDbCommand(sql_admin,MyConn);
- dr_admin=com_admin.ExecuteReader();
- while(dr_admin.Read())
- {
- ban=dr_admin["ban"].ToString();
- }
- dr_admin.Close();
- arrwords=cc.splitstring(ban);
- for (int i=0 ;i<arrwords.Length;i++)
- {
- if (arrwords[i]==UserName){
- n=1;
- }
- }
- if (n!=1){
- Response.Write("你不具有本版的管理权");
- Response.Redirect("er.aspx?ms=2");
- }
-
-
- }
-
- public void doaction()
- {
- if (Action=="del"&&type=="reply"){
- sql_admin="delete from "+Fid1+"Reply"+Fid2+" where id="+id;
- com_admin.CommandText=sql_admin;
- com_admin.ExecuteNonQuery();
- sql_admin="update state set ReplyTotal=ReplyTotal-1 where Fid1="+Fid1+"and Fid2="+Fid2;
- com_admin.CommandText=sql_admin;
- com_admin.ExecuteNonQuery();
- }
- if (Action=="del"&&type=="topic"){
- sql_admin="delete from "+Fid1+"Topic"+Fid2+" where TopicId="+id;
- com_admin.CommandText=sql_admin;
- com_admin.ExecuteNonQuery();
- sql_admin="delete from "+Fid1+"Reply"+Fid2+" where TopicId="+id;
- com_admin.CommandText=sql_admin;
- com_admin.ExecuteNonQuery();
- sql_admin="update state set TopicTotal=TopicTotal-1 where Fid1="+Fid1+"and Fid2="+Fid2;
- com_admin.CommandText=sql_admin;
- com_admin.ExecuteNonQuery();
- }
- if (Action=="lock"){
- sql_admin="select Expression from "+Fid1+"Topic"+Fid2+" where TopicId="+id;
- com_admin.CommandText=sql_admin;
- dr_admin=com_admin.ExecuteReader();
- while(dr_admin.Read())
- {
- Expression=dr_admin["Expression"].ToString();
- }
- dr_admin.Close();
- arrwords=cc.splitstring(Expression);
- Expression="<img src='img/f-lock.gif' border=0>"+"|"+arrwords[1]+"|"+arrwords[2];
- Expression=Expression.Replace("'","''");
- sql_admin="update "+Fid1+"Topic"+Fid2+" set Islocked=1,Expression='"+Expression+"' where TopicId="+id;
- com_admin.CommandText=sql_admin;
- com_admin.ExecuteNonQuery();
- }
- if (Action=="unlock"){
- sql_admin="select Expression from "+Fid1+"Topic"+Fid2+" where TopicId="+id;
- com_admin.CommandText=sql_admin;
- dr_admin=com_admin.ExecuteReader();
- while(dr_admin.Read())
- {
- Expression=dr_admin["Expression"].ToString();
- }
- dr_admin.Close();
- arrwords=cc.splitstring(Expression);
- Expression="<img src='img/f-open.gif' border=0>"+"|"+arrwords[1]+"|"+arrwords[2];
- Expression=Expression.Replace("'","''");
- sql_admin="update "+Fid1+"Topic"+Fid2+" set Islocked=0,Expression='"+Expression+"' where TopicId="+id;
- com_admin.CommandText=sql_admin;
- com_admin.ExecuteNonQuery();
- }
- if (Action=="best"){
- sql_admin="select Expression from "+Fid1+"Topic"+Fid2+" where TopicId="+id;
- com_admin.CommandText=sql_admin;
- dr_admin=com_admin.ExecuteReader();
- while(dr_admin.Read())
- {
- Expression=dr_admin["Expression"].ToString();
- }
- dr_admin.Close();
- arrwords=cc.splitstring(Expression);
- Expression="<img src='img/best.gif' border=0>"+"|"+arrwords[1]+"|"+arrwords[2];
- Expression=Expression.Replace("'","''");
- sql_admin="update "+Fid1+"Topic"+Fid2+" set Isbest=1,Expression='"+Expression+"' where TopicId="+id;
- com_admin.CommandText=sql_admin;
- com_admin.ExecuteNonQuery();
- }
- if (Action=="unbest"){
- sql_admin="select Expression from "+Fid1+"Topic"+Fid2+" where TopicId="+id;
- com_admin.CommandText=sql_admin;
- dr_admin=com_admin.ExecuteReader();
- while(dr_admin.Read())
- {
- Expression=dr_admin["Expression"].ToString();
- }
- dr_admin.Close();
- arrwords=cc.splitstring(Expression);
- Expression="<img src='img/f-open.gif' border=0>"+"|"+arrwords[1]+"|"+arrwords[2];
- Expression=Expression.Replace("'","''");
- sql_admin="update "+Fid1+"Topic"+Fid2+" set Isbest=0,Expression='"+Expression+"' where TopicId="+id;
- com_admin.CommandText=sql_admin;
- com_admin.ExecuteNonQuery();
- }
- if (Action=="notice"){
- content=Request.Form["content"];
- content=content.Replace("'","''");
- sql_admin="update state set Noti='"+content+"' where Fid1="+Fid1+"and Fid2="+Fid2;
- com_admin.CommandText=sql_admin;
- com_admin.ExecuteNonQuery();
- }
- if (Action=="release"){
- sql_admin="update state set Noti='本版暂无通知 :)' where Fid1="+Fid1+"and Fid2="+Fid2;
- com_admin.CommandText=sql_admin;
- com_admin.ExecuteNonQuery();
- }
- }
-
- }
- //-----------------------display.aspx-------------------------------------------------
- public class display : Page{
- public DataGrid score;
- public OleDbConnection MyConn;
- public DateTime n1 ;
- public DateTime n2 ;
- public TimeSpan n3 ;
- public String id;
- public OleDbDataReader dr_Topic;
- public string[] arrwords;
- public String Expression;
- public string Topic_UserName;
- public string Topic_HeadImg;
- public string Topic_pub;
- public string Topic_pos;
- public string Topic_Topic;
- public string Topic_Body;
- public string Topic_width;
- public string Topic_height;
- public string Topic_sign;
- public string Topic_DateAndTime;
- public int Islocked;
- public String Fid1;
- public String Fid2;
- public gong cc;
- public void Page_Load(Object src,EventArgs e)
- {
- Fid1=Request.QueryString["Fid1"];
- Fid2=Request.QueryString["Fid2"];
- id=Request.QueryString["id"];
- n1= DateTime.Now;
- //创建连接
- cc= new gong();
- MyConn=cc.qidong();
- string sql_Topic= "select a.Topic,a.Body,a.Islocked,a.Postuser,a.Expression,a.DateAndTime,u.UserName,u.HeadImg,u.pub,u.pos,u.width,u.height,u.sign from "+Fid1+"Topic"+Fid2+" a LEFT OUTER JOIN usertable u ON a.Postuser=u.UserName where a.TopicId="+id;
- OleDbCommand com_Topic = new OleDbCommand(sql_Topic,MyConn);
- dr_Topic=com_Topic.ExecuteReader();
- while(dr_Topic.Read())
- {
- Expression=dr_Topic["Expression"].ToString();
- Topic_UserName=dr_Topic["UserName"].ToString();
- Topic_HeadImg=dr_Topic["HeadImg"].ToString();
- Topic_pub=dr_Topic["pub"].ToString();
- Topic_pos=dr_Topic["pos"].ToString();
- Topic_Topic=dr_Topic["Topic"].ToString();
- Topic_Body=dr_Topic["Body"].ToString();
- Topic_width=dr_Topic["width"].ToString();
- Topic_height=dr_Topic["height"].ToString();
- Topic_sign=dr_Topic["sign"].ToString();
- Topic_DateAndTime=dr_Topic["DateAndTime"].ToString();
- Islocked=(int)dr_Topic["Islocked"];
- }
- dr_Topic.Close();
- string words=Request.QueryString["word"];
- char[] chSplit = {'|'};
- arrwords=Expression.Split(chSplit);
- Expression=arrwords[0]+"|"+(Int32.Parse(arrwords[1])+1).ToString()+"|"+arrwords[2];
- Expression=Expression.Replace("'","''");
- String sql_up="Update "+Fid1+"Topic"+Fid2+" set Expression='"+Expression+"' where TopicId="+id;
- com_Topic.CommandText=sql_up;
- com_Topic.ExecuteNonQuery();
- ListBind();
- MyConn.Close();
- n2= DateTime.Now;
- n3=n2-n1;
- }
- ICollection CreateSource()
- {
- string strSel = "select a.DateAndTime,a.TopicId,a.Title,a.Body,a.Postuser,a.Expression,a.DateAndTime,a.id,u.UserName,u.HeadImg,u.pub,u.pos,u.width,u.height,u.sign from "+Fid1+"reply"+Fid2+" a LEFT OUTER JOIN usertable u ON a.Postuser=u.UserName where a.TopicId="+id+" order by a.DateAndTime asc ";
- DataSet ds = new DataSet();
- OleDbDataAdapter MyAdapter = new OleDbDataAdapter(strSel,MyConn);
- MyAdapter.Fill(ds,Fid1+"reply"+Fid2);
- return ds.Tables[Fid1+"reply"+Fid2].DefaultView;
- }
- public void ListBind()
- {
- score.DataSource =CreateSource();
- score.DataBind();
- }
- public void DataGrid_PageChanged(Object sender,DataGridPageChangedEventArgs e)
- {
- score.CurrentPageIndex = e.NewPageIndex;
- score.DataBind();
- }
- }
- //-----------------------log.aspx-------------------------------------------------
- public class log : Page{
- public OleDbConnection MyConn;
- public OleDbCommand com;
- public String UserName;
- public String Pass;
- public String CTime;
- public String sql_check;
- public int check=0;
- public OleDbDataReader dr_check;
- public TimeSpan ts;
- public void Page_Load(Object src,EventArgs e)
- {
- UserName=Request.Form["UserName"];
- Pass=Request.Form["Pass"];
- CTime=Request.Form["Cookies_Time"];
- //创建连接
- gong cc= new gong();
- MyConn=cc.qidong();
- sql_check="select UserName,Pass,Pos from usertable where UserName='"+UserName+"' and Pass='"+Pass+"'";
- OleDbCommand com_add = new OleDbCommand(sql_check,MyConn);
- dr_check=com_add.ExecuteReader();
- while(dr_check.Read())
- {
- check++;
- if (dr_check["Pos"].ToString()=="管理员"){
- Session["au"]="yes";
- }
- }
- dr_check.Close();
- if (check==1){
- HttpCookie cookie = new HttpCookie("huangliang");
- DateTime dt = DateTime.Now;
- switch (CTime)
- {
- case "1":
- ts = new TimeSpan(0,0,1,0);
- Response.Write("1");
- break;
- case "2":
- ts = new TimeSpan(0,23,0,0);
- Response.Write("2");
- break;
- case "3":
- ts = new TimeSpan(29,0,0,0);
- Response.Write("3");
- break;
- case "4":
- ts = new TimeSpan(364,0,0,0);
- Response.Write("4");
- break;
- }
- cookie.Expires = dt.Add(ts);
- cookie.Values.Add("UserName",UserName.ToString());
- cookie.Values.Add("Pass",Pass.ToString());
- Response.AppendCookie(cookie);
- }
- else {
- Response.Redirect("er.aspx?ms=10");
- }
- }
- }
- //------------------------newtopic.aspx------------------------------------------------
- public class newtopic : Page{
- public DateTime n1 ;
- public DateTime n2 ;
- public TimeSpan n3 ;
- public string Fid1;
- public string Fid2;
- public void Page_Load(Object src,EventArgs e)
- {
- DateTime now= DateTime.Now;
- n1= DateTime.Now;
- Fid1=Request.QueryString["Fid1"];
- Fid2=Request.QueryString["Fid2"];
- n2= DateTime.Now;
- n3=n2-n1;
- }
- }
- //------------------------savetopic.aspx------------------------------------------------
- public class savetopic : Page{
- public string Topic;
- public string Title;
- public HttpCookie readcookie;
- public string Postuser;
- public string Pass;
- public string sql_add;
- public string Expression;
- public OleDbConnection MyConn;
- public string Fid1;
- public string Fid2;
- public OleDbCommand com_add;
- public void Page_Load(Object src,EventArgs e)
- {
- Fid1=Request.QueryString["Fid1"];
- Fid2=Request.QueryString["Fid2"];
- gong ff =new gong();
- Title=Request.Form["zhuti"];
- if (Title==""){
- Response.Redirect("er.aspx?ms=6");
- }
- Title=ff.texttohtml(Title);
- Topic=Request.Form["nr"].ToString();
- Topic=ff.texttohtml(Topic);
- Topic=ff.changechr(Topic);
- Title="<img src='emotion/"+Request.Form["bqselect"]+".gif' border=0>"+Title;
- Expression="<img src='img/f-open.gif'>|0|0";
- Expression=Expression.Replace("'","''");
- Postuser=userck();
- if (Postuser=="bad"){
- Response.Redirect("er.aspx?ms=1");
- }
- MyConn=ff.qidong();
- Title=Title.Replace("'","''");
- Topic=Topic.Replace("'","''");
- //定义sql语句
- sql_add=" insert into "+Fid1+"Topic"+Fid2+" (Topic,Body,Postuser,Expression) values ('"+Title+"','"+Topic+"','"+Postuser+"','"+Expression+"')";
- OleDbCommand com_add = new OleDbCommand(sql_add,MyConn);
- com_add.ExecuteNonQuery();
- string sql_usertable="update usertable set pub=pub+1 where UserName='"+Postuser+"'";
- com_add.CommandText=sql_usertable;
- com_add.ExecuteNonQuery();
- string sql_state="update state set TopicTotal=TopicTotal+1 where Fid1="+Fid1.ToString()+" and Fid2="+Fid2.ToString();
- com_add.CommandText=sql_state;
- com_add.ExecuteNonQuery();
- }
-
- public string userck(){
- if (Request.Cookies["huangliang"]==null){
- return("bad");
- }
-
- else{
- readcookie = Request.Cookies["huangliang"];
- if (readcookie.Values["UserName"].ToString()!=null){
- Postuser= readcookie.Values["UserName"].ToString();
- Pass= readcookie.Values["Pass"].ToString();
- return(Postuser);
- }
- else{
- return("bad");
- }
- }
- }
- }
- //------------------------------reply.aspx------------------------------------------
- public class reply : Page{
- public DateTime n1 ;
- public DateTime n2 ;
- public TimeSpan n3 ;
- public string Fid1;
- public string Fid2;
- public string TopicId;
- public string add;
- public OleDbConnection MyConn;
- public OleDbCommand com_quote;
- public OleDbDataReader dr_q;
- public string type;
- public string sql_r;
- public string quoteid;
- public gong dd;
- public void Page_Load(Object src,EventArgs e)
- {
- DateTime now= DateTime.Now;
- n1= DateTime.Now;
- Fid1=Request.QueryString["Fid1"];
- Fid2=Request.QueryString["Fid2"];
- TopicId=Request.QueryString["TopicId"];
- if (Request.QueryString["quote"]!=null){
- type=Request.QueryString["Type"];
- quoteid=Request.QueryString["quote"];
- add="";
- quote();
- }
- n2= DateTime.Now;
- n3=n2-n1;
- }
- public void quote(){
- dd=new gong();
- MyConn=dd.qidong();
- if (type=="Reply"){
- sql_r= "Select Postuser,Body,DateAndTime from "+Fid1+"Reply"+Fid2+" where id="+quoteid;
- }
- else {
- sql_r= "Select Postuser,Body,DateAndTime from "+Fid1+"Topic"+Fid2+" where TopicId="+quoteid;
- }
- com_quote = new OleDbCommand(sql_r,MyConn);
- dr_q=com_quote.ExecuteReader();
- while(dr_q.Read())
- {
- if (type=="Reply"){
- add="[quote]以下是引用"+dr_q["Postuser"].ToString()+"在"+dr_q["DateAndTime"].ToString()+"的发言:n"+dr_q["Body"].ToString()+"[/quote]";
- add.Replace("<center>—— 以下是引用 ——<table border='1' width='80%' cellpadding='10' cellspacing='0' style='font-size: 9pt'><tr><td>","");
- add.Replace("</td></tr></table>—— 引用完毕 ——</center>","");
- }
- else {
- add="[quote]以下是引用"+dr_q["Postuser"].ToString()+"在"+dr_q["DateAndTime"].ToString()+"的发言:n"+dr_q["Body"].ToString()+"[/quote]";
- add.Replace("<center>—— 以下是引用 ——<table border='1' width='80%' cellpadding='10' cellspacing='0' style='font-size: 9pt'><tr><td>","");
- add.Replace("</td></tr></table>—— 引用完毕 ——</center>","");
- }
- }
- dr_q.Close();
- }
-
- }
- //-------------------------post_reply.aspx-----------------------------------------------
- public class post_reply : Page{
- public OleDbConnection MyConn;
- public OleDbCommand com_add;
- public String TopicId;
- public String Title;
- public String Postuser;
- public String Pass;
- public String Body;
- public String sql_add;
- public String sql_LastReply;
- public HttpCookie readcookie;
- public OleDbDataReader dr_r;
- public String Expression;
- public string[] arrwords;
- public String Fid1;
- public String Fid2;
- public DateTime nn;
- public void Page_Load(Object src,EventArgs e)
- {
- //得到数据
- gong dd=new gong();
- Fid1=Request.QueryString["Fid1"];
- Fid2=Request.QueryString["Fid2"];
- TopicId=Request.Form["TopicId"];
- Title=Request.Form["zhuti"];
- Body=Request.Form["nr"];
- if (Title==""&&Body==""){
- Response.Redirect("er.aspx?ms=5");
- }
- Body=dd.texttohtml(Body);
- Title=dd.texttohtml(Title);
- if (Request.QueryString["type"]=="fast"){
- Title="<img src='emotion/1.gif' border=0>"+Title;
- }
- else {
- Title="<img src='emotion/"+Request.Form["bqselect"]+".gif' border=0>"+Title;
- }
- Title=Title.Replace("'","''");
- Body=dd.changechr(Body);
- Body=Body.Replace("'","''");
- //取得登陆信息
- Postuser=userck();
- if (Postuser=="bad"){
- Response.Redirect("er.aspx?ms=1");
- }
- //向回复表中插入数据
- sql_add=" insert into "+Fid1+"reply"+Fid2+" (TopicId,Title,Postuser,Body) values ("+TopicId+",'"+Title+"','"+Postuser+"','"+Body+"')";
- MyConn=dd.qidong();
- OleDbCommand com_add = new OleDbCommand(sql_add,MyConn);
- com_add.ExecuteNonQuery();
- //
- nn= DateTime.Now;
- string sql_LastReply="Update "+Fid1+"topic"+Fid2+" Set LastReply='"+Postuser.ToString()+"' where TopicId="+TopicId.ToString();
- com_add.CommandText=sql_LastReply;
- com_add.ExecuteNonQuery();
- //
- string sql_r= "Select Expression from "+Fid1+"Topic"+Fid2+" where TopicId="+TopicId;
- //---------
- com_add.CommandText=sql_r;
- dr_r=com_add.ExecuteReader();
- //------得到Expression
- while(dr_r.Read())
- {
- Expression=dr_r["Expression"].ToString();
- }
- dr_r.Close();
- string words=Request.QueryString["word"];
- char[] chSplit = {'|'};
- arrwords=Expression.Split(chSplit);
- Expression=arrwords[0]+"|"+arrwords[1]+"|"+(Int32.Parse(arrwords[2])+1).ToString();
- //--------
- DateTime now= DateTime.Now;
- Expression=Expression.Replace("'","''");
- String sql_up="Update "+Fid1+"topic"+Fid2+" set Expression='"+Expression+"',DateAndTime=Now() where TopicId="+TopicId;
- com_add.CommandText=sql_up;
- com_add.ExecuteNonQuery();
- String sql_usertable="Update usertable set pub=pub+1 where UserName='"+Postuser+"'";
- com_add.CommandText=sql_usertable;
- com_add.ExecuteNonQuery();
- String sql_state="Update state set ReplyTotal=ReplyTotal+1 where Fid1="+Fid1+" and Fid2="+Fid2;
- com_add.CommandText=sql_state;
- com_add.ExecuteNonQuery();
- }
- public string userck(){
- if (Request.Cookies["huangliang"]==null){
- return("bad");
- }
-
- else{
- readcookie = Request.Cookies["huangliang"];
- if (readcookie.Values["UserName"].ToString()!=null){
- Postuser= readcookie.Values["UserName"].ToString();
- Pass= readcookie.Values["Pass"].ToString();
- return(Postuser);
- }
- else{
- return("bad");
- }
- }
- }
- }
- //--------------------------reg_pre.aspx----------------------------------------------
- public class reg_pre :Page{
- public OleDbConnection MyConn;
- public OleDbDataReader dr_user;
- public string Postuser;
- public HttpCookie readcookie;
- public string Pass_c;
- public string UserName;
- public string Action;
- public string Pass;
- public string QQ;
- public string mail;
- public string loca;
- public string Sign;
- public string Description;
- public string HeadImg;
- public string sex;
- public string height;
- public string width;
- public void Page_Load(Object src,EventArgs e)
- {
- Action=Request.QueryString["Action"].ToString();
- UserName=Request.QueryString["UserName"].ToString();
- if (UserName==""){
- UserName=userck();
- if (UserName=="bad"&&Action!="reg"){
- Response.Redirect("er.aspx?ms=1");
- }
- }
- //创建连接
- gong cc= new gong();
- MyConn=cc.qidong();
- if (Action=="modify"){
- string sql_user = "select UserName,Pass,QQ,mail,loca,Sign,Description,HeadImg,sex,height,width from usertable where UserName='"+UserName+"'";
- OleDbCommand com_user = new OleDbCommand(sql_user,MyConn);
- dr_user=com_user.ExecuteReader();
- while(dr_user.Read())
- {
- UserName=dr_user["UserName"].ToString();
- Pass=dr_user["Pass"].ToString();
- QQ=dr_user["QQ"].ToString();
- mail=dr_user["mail"].ToString();
- loca=dr_user["loca"].ToString();
- Sign=dr_user["Sign"].ToString();
- Description=dr_user["Description"].ToString();
- HeadImg=dr_user["HeadImg"].ToString();
- sex=dr_user["sex"].ToString();
- height=dr_user["height"].ToString();
- width=dr_user["width"].ToString();
- }
- dr_user.Close();
- }
- else {
- UserName="";
- Pass="";
- QQ="";
- mail="";
- loca="";
- Sign="";
- Description="";
- HeadImg="";
- sex="1";
- height="32";
- width="32";
- }
- }
- public string userck(){
- if (Request.Cookies["huangliang"]==null){
- return("bad");
- }
-
- else{
- readcookie = Request.Cookies["huangliang"];
- if (readcookie.Values["UserName"].ToString()!=null){
- Postuser= readcookie.Values["UserName"].ToString();
- Pass= readcookie.Values["Pass"].ToString();
- return(Postuser);
- }
- else{
- return("bad");
- }
- }
- }
- }
- //-----------------------user_modify.aspx-------------------------------------------------
- public class user_modify :Page{
- public OleDbConnection MyConn;
- public OleDbCommand com_modify;
- public String UserName;
- public String Pass;
- public String Sex;
- public String mail;
- public String QQ;
- public String Loca;
- public String Sign;
- public String sql_modify;
- public String sql_check;
- public int check=0;
- public String er;
- public string face;
- public string face_url;
- public string head_type;
- public int width;
- public int height;
- public string HeadImg;
- public string Postuser;
- public HttpCookie readcookie;
- public string Pass_c;
- public void Page_Load(Object src,EventArgs e)
- {
- UserName=Request.Form["UserName"];
- Pass=Request.Form["PassWord"];
- Sex=Request.Form["Sex"];
- mail=Request.Form["mail"];
- QQ=Request.Form["QQ"];
- Loca=Request.Form["Location"];
- Sign=Request.Form["Sign"];
- head_type=Request.Form["head_type"];
- width=Int32.Parse(Request.Form["width"].ToString());
- height=Int32.Parse(Request.Form["height"].ToString());
- face=Request.Form["face"];
- if (head_type=="1"){
- HeadImg=face;
- }
- else {
- HeadImg=""+face_url;
- }
- HeadImg=HeadImg.Replace("'","''");
- //连接语句
-
- //定义sql语句
- sql_modify="update usertable set Pass='"+Pass+"',sex="+Sex+",mail='"+mail+"',QQ="+QQ+",Loca='"+Loca+"',Sign='"+Sign+"',width="+width+",height="+height+",HeadImg='"+HeadImg+"' where UserName='"+userck()+"'";
- gong cc= new gong();
- MyConn=cc.qidong();
- OleDbCommand com_modify = new OleDbCommand(sql_modify,MyConn);
- com_modify.ExecuteNonQuery();
- }
- public string userck()
- { readcookie = Request.Cookies["huangliang"];
- if (readcookie.Values["UserName"].ToString()!=null){
- Postuser= readcookie.Values["UserName"].ToString();
- Pass_c= readcookie.Values["Pass"].ToString();
- return(Postuser);
- }
- else{
- return("bad");
- }
- }
- }
- //---------------------------reg.aspx---------------------------------------------
- public class reg :Page{
- public OleDbConnection MyConn;
- public OleDbCommand com_add;
- public String UserName;
- public String Pass;
- public String Sex;
- public String mail;
- public String QQ;
- public String Loca;
- public String Sign;
- public String sql_adduser;
- public String sql_check;
- public int check=0;
- public String er;
- public string face;
- public string face_url;
- public string head_type;
- public int width;
- public int height;
- public string Pass2;
- public string HeadImg;
- public OleDbDataReader dr_check;
- public void Page_Load(Object src,EventArgs e)
- {
- gong gg=new gong();
- UserName=Request.Form["UserName"];
- Pass=Request.Form["PassWord"];
- Pass2=Request.Form["PassWord2"];
- Sex=Request.Form["Sex"];
- mail=Request.Form["mail"];
- QQ=Request.Form["QQ"];
- Loca=Request.Form["Location"];
- Sign=gg.changechr(Request.Form["Sign"].ToString()).Replace("'","''");
- head_type=Request.Form["head_type"];
- width=Int32.Parse(Request.Form["width"].ToString());
- height=Int32.Parse(Request.Form["height"].ToString());
- face=Request.Form["face"];
- if (head_type=="1"){
- HeadImg=face;
- }
- else {
- HeadImg=""+face_url;
- }
- HeadImg=HeadImg.Replace("'","''");
- //连接语句
- if (width>120||height>120){
- Response.Redirect("er.aspx?ms=11");
- }
- if (Pass2!=Pass){
- Response.Redirect("er.aspx?ms=12");
- }
- if (UserName==""||Pass==""){
- Response.Redirect("er.aspx?ms=11");
- }
- //定义sql语句
- sql_adduser="insert into usertable (UserName,Pass,Sex,mail,QQ,Loca,Sign,HeadImg,width,height) values ('"+UserName+"','"+Pass+"',"+Sex+",'"+mail+"',"+QQ+",'"+Loca+"','"+Sign+"','"+HeadImg+"',"+width.ToString()+","+height.ToString()+")";
- sql_check="select UserName from usertable where UserName='"+UserName+"'";
- gong cc= new gong();
- MyConn=cc.qidong();
- OleDbCommand com_add = new OleDbCommand(sql_check,MyConn);
- dr_check=com_add.ExecuteReader();
- while(dr_check.Read())
- {
- check=1;
- }
- dr_check.Close();
- if (check==0){
- com_add.CommandText=sql_adduser;
- com_add.ExecuteNonQuery();
- }
- if (check==1){
- er=UserName+"这个名字有人使用了";
- }
- else {
- er="注册成功";
- }
- }
- }
- //-----------------------------admin_add.aspx----------------------------------------------
- public class admin_add : Page{
- public OleDbConnection MyConn;
- public DateTime n1 ;
- public DateTime n2 ;
- public TimeSpan n3 ;
- public OleDbDataReader dr_Index;
- public String Fid1;
- public string LastFid1;
- public string sql_Index;
- public void Page_Load(Object src,EventArgs e)
- {
- if (Request.QueryString["Fid1"]==null){
- sql_Index = "Select TopicTotal,id,Fid1,Fid2,Fid1Name,Fid2Name,Fimg,Des,ban,ReplyTotal from state order by Fid1 asc ";
- }
- else {
- Fid1=Request.QueryString["Fid1"].ToString();
- sql_Index = "Select TopicTotal,id,Fid1,Fid2,Fid1Name,Fid2Name,Fimg,Des,ban,ReplyTotal from state where Fid1="+Fid1+" order by Fid1 asc ";
- }
- DateTime now= DateTime.Now;
- n1= DateTime.Now;
- //创建连接
- gong cc= new gong();
- MyConn=cc.qidong();
- if (cc.adminck()=="bad"){
- Response.Redirect("er.aspx?ms=9");
- }
- OleDbCommand com_TopicTotal = new OleDbCommand(sql_Index,MyConn);
- dr_Index=com_TopicTotal.ExecuteReader();
- }
- }
- //-----------------------------admin_user.aspx----------------------------------------------
- public class admin_user : Page{
- public OleDbConnection MyConn;
- public OleDbDataReader dr_user;
- public string UserName;
- public string sql_user;
- public string pos;
- public string Himg;
- public string Sign;
- public string Pass;
- public Label id;
- public OleDbCommand com_user;
- public TextBox postext;
- public TextBox Himgtext;
- public TextBox Signtext;
- public TextBox Passtext;
- public TextBox UserNametext;
- public void Page_Load(Object src,EventArgs e)
- {
- gong cc= new gong();
- MyConn=cc.qidong();
- if (cc.adminck()=="bad"){
- Response.Redirect("er.aspx?ms=9");
- }
- if(!Page.IsPostBack)
- {
- UserName=Request.Form["username"];
- getuser();
- }
- }
- public void Button_up(Object sender,CommandEventArgs e)
- {
- sql_user="update usertable set Pos='"+postext.Text+"',Sign='"+Signtext.Text+"',Pass='"+Passtext.Text+"' where UserName='"+UserNametext.Text+"'";
- com_user = new OleDbCommand(sql_user,MyConn);
- com_user.ExecuteNonQuery();
- }
- public void Button_del(Object sender,CommandEventArgs e)
- {
- sql_user="delete from usertable where UserName='"+UserNametext.Text+"'";
- Response.Write(sql_user);
- com_user = new OleDbCommand(sql_user,MyConn);
- com_user.ExecuteNonQuery();
- }
- public void getuser()
- {
- sql_user="select * from usertable where UserName='"+UserName+"'";
- com_user = new OleDbCommand(sql_user,MyConn);
- dr_user=com_user.ExecuteReader();
- while(dr_user.Read())
- {
- pos=dr_user["pos"].ToString();
- Himg=dr_user["HeadImg"].ToString();
- Sign=dr_user["Sign"].ToString();
- Pass=dr_user["Pass"].ToString();
- id.Text=dr_user["id"].ToString();
- }
- dr_user.Close();
- postext.Text=pos;
- Himgtext.Text=Himg;
- Signtext.Text=Sign;
- Passtext.Text=Pass;
- UserNametext.Text=UserName;
- }
- }
- //-----------------------------admin_do1.aspx----------------------------------------------
- public class admin_do1 : Page{
- public string Fid1;
- public string Fid1Name;
- public OleDbConnection MyConn;
- public OleDbDataReader dr;
- public string sql;
- public int lastn;
- public void Page_Load(Object src,EventArgs e)
- {
- Fid1=Request.QueryString["Fid1"];
- Fid1Name=Request.QueryString["Fid1Name"];
- sql="select top 1 * from state where Fid1="+Fid1+" order by Fid2 desc";
- gong cc= new gong();
- MyConn=cc.qidong();
- if (cc.adminck()=="bad"){
- Response.Redirect("er.aspx?ms=9");
- }
- OleDbCommand com = new OleDbCommand(sql,MyConn);
- dr=com.ExecuteReader();
- while(dr.Read())
- {
- lastn=(int)dr["Fid2"];
- }
- dr.Close();
- }
- }
- //-----------------------------admin_do.aspx----------------------------------------------
- public class admin_do : Page{
- public string Fid1;
- public string Fid1Name;
- public string Fid2;
- public string Fid2Name;
- public string Fimg;
- public string Des;
- public string ban;
- public OleDbConnection MyConn;
- public string sql;
- public string action;
- public string table_topic;
- public string table_reply;
- public void Page_Load(Object src,EventArgs e)
- {
- //读取参数
- action=Request.QueryString["Action"];
- gong cc= new gong();
- MyConn=cc.qidong();
- if (cc.adminck()=="bad"){
- Response.Redirect("er.aspx?ms=9");
- }
- OleDbCommand com = new OleDbCommand(sql,MyConn);
- if (action=="create"){
- Fid1=Request.Form["Fid1"];
- Fid1Name=Request.Form["Fid1Name"];
- Fid2=Request.Form["Fid2"];
- Fid2Name=Request.Form["Fid2Name"];
- Fimg=Request.Form["Fimg"];
- Des=Request.Form["Des"];
- ban=Request.Form["ban"];
- sql="insert into state (Fid1,Fid2,Fid1Name,Fid2Name,Fimg,Des,ban) values ("+Fid1+","+Fid2+",'"+Fid1Name+"','"+Fid2Name+"','"+Fimg+"','"+Des+"','"+ban+"')";
- com.CommandText=sql;
- com.ExecuteNonQuery();
- //建立表
- table_topic=Fid1.ToString()+"Topic"+Fid2.ToString();
- sql="Create table "+table_topic+" (DateAndTime DateTime default now(),TopicID IDENTITY(1,1),Topic text(200),body memo,Isbest int default 0,Istop int default 0,Postuser Text(20),LastReply Text(20),Islocked int default 0,Expression Text(50))";
- com.CommandText=sql;
- com.ExecuteNonQuery();
- sql="Create Index DateAndTime ON "+table_topic+" (DateAndTime desc) with disallow null";
- com.CommandText=sql;
- com.ExecuteNonQuery();
- sql="Create Index TopicId ON "+table_topic+" (TopicId desc) with PRIMARY ";
- com.CommandText=sql;
- com.ExecuteNonQuery();
- table_reply=Fid1.ToString()+"Reply"+Fid2.ToString();
- sql="Create table "+table_reply+" (DateAndTime DateTime default now(),TopicId int,title text(200),body memo,Postuser Text(20),Expression Text(50),id IDENTITY(1,1))";
- com.CommandText=sql;
- com.ExecuteNonQuery();
- sql="Create Index DateAndTime ON "+table_reply+" (DateAndTime asc) with disallow null";
- com.CommandText=sql;
- com.ExecuteNonQuery();
- sql="Create Index id ON "+table_reply+" (id asc) with disallow null ";
- com.CommandText=sql;
- com.ExecuteNonQuery();
- sql="Create Index TopicId ON "+table_reply+" (TopicId asc) with disallow null ";
- com.CommandText=sql;
- com.ExecuteNonQuery();
- //
- }
- }
- }
- //----------------------------admin_class.aspx------------------------------------------
- public class admin_class :Page{
- public OleDbConnection MyConn;
- public OleDbDataReader dr;
- public DataGrid huang;
- public TextBox td1;
- public TextBox td2;
- public TextBox td3;
- public TextBox td4;
- public TextBox td5;
- public TextBox td6;
- public void Page_Load(Object src,EventArgs e)
- {
- gong cc= new gong();
- MyConn=cc.qidong();
- if (cc.adminck()=="bad"){
- Response.Redirect("er.aspx?ms=9");
- }
- if(!Page.IsPostBack)
- {
- BindGrid();
- }
- }
- ICollection CreateTable()
- {
- string strSel = "select * from state order by id desc";
- DataSet ds = new DataSet();
- OleDbDataAdapter MyAdapter = new OleDbDataAdapter(strSel,MyConn);
- MyAdapter.Fill(ds,"main");
- return ds.Tables["main"].DefaultView;
- }
- public void BindGrid()
- {
- huang.DataSource = CreateTable();
- huang.DataBind();
- }
- public void DataGrid_EditCommand(Object sender,DataGridCommandEventArgs e)
- { string id2=e.Item.Cells[1].Text;
- string str ="select * from state where id="+id2;
- OleDbCommand MyComm = new OleDbCommand(str,MyConn);
- dr=MyComm.ExecuteReader();
- while(dr.Read())
- { td1.Text=dr["Fid1"].ToString();
- td2.Text=dr["Fid2"].ToString();
- td3.Text=dr["Fid2Name"].ToString();
- td4.Text=dr["des"].ToString();
- td5.Text=dr["Fimg"].ToString();
- td6.Text=dr["ban"].ToString();
- }
- dr.Close();
- huang.EditItemIndex = (int)e.Item.ItemIndex;
- BindGrid();
- }
- public void DataGrid_CancelCommand(Object sender,DataGridCommandEventArgs e)
- { string id=e.Item.Cells[1].Text;
- string del="delete from state where id="+id;
- OleDbCommand MyComm = new OleDbCommand(del,MyConn);
- MyComm.ExecuteNonQuery();
- MyComm.CommandText=del;
- del="drop table "+e.Item.Cells[2].Text+"Topic"+e.Item.Cells[3].Text;
- MyComm.CommandText=del;
- MyComm.ExecuteNonQuery();
- del="drop table "+e.Item.Cells[2].Text+"Reply"+e.Item.Cells[3].Text;
- MyComm.CommandText=del;
- MyComm.ExecuteNonQuery();
- BindGrid();
- }
- public void DataGrid_UpdateCommand(Object sender,DataGridCommandEventArgs e)
- {
- string Fid1 = td1.Text.ToString().Replace("'","''");
- string Fid2 = td2.Text.ToString().Replace("'","''");
- string name = td3.Text.ToString().Replace("'","''");
- string des = td4.Text.ToString().Replace("'","''");
- string logo = td5.Text.ToString().Replace("'","''");
- string ban = td6.Text.ToString().Replace("'","''");
- string id=e.Item.Cells[1].Text;
- string strUpdate = "update state set Fid1="+Fid1+",Fid2="+Fid2+",Fid2Name='"+name+"',Des='"+des+"',Fimg='"+logo+"',ban='"+ban+"' where id="+id;
- OleDbCommand MyComm = new OleDbCommand(strUpdate,MyConn);
- MyComm.ExecuteNonQuery();
- huang.EditItemIndex = -1;
- BindGrid();
- }
- }
- //-------------------------gong类,在此可以指定数据库地址和一些常用的参数------------------------------------
- public class gong :Page{
- public string Postuser;
- public HttpCookie readcookie;
- public string Pass;
- public int isubb=1;
- public int ishtml=0;
- public int isscript=0;
- public int isflash=1;
- public int isimg=1;
- public string[] arrwords;
- public OleDbConnection MyConn;
- public OleDbConnection qidong()
- {
- string MyConnString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="D:崔岩的文件论坛DataBaseld1.mdb;";
- MyConn = new OleDbConnection(MyConnString);
- MyConn.Open();
- return(MyConn);
- }
- public string texttohtml(string chr)
- {
- if(chr==null)
- return "";
- chr=chr.Replace("<","<");
- chr=chr.Replace(">",">");
- chr=chr.Replace("n","<br>");
- chr=chr.Replace(" "," ");
- return(chr);
- }
- public string changechr(string chr)
- {
- if(chr==null)
- return "";
- if(false)
- {
- chr=chr.Replace("<","<");
- chr=chr.Replace(">",">");
- chr=chr.Replace("n","<br>");
- }
- else
- {
- if(isscript==0)
- {
- chr = Regex.Replace(chr,@"<script(?<x>[^>]*)>(?<y>[^>]*)</script>",@"<script$1>$2</script>",RegexOptions.IgnoreCase);
- }
- }
- if( isubb == 1)
- {
- chr = Regex.Replace(chr,@"[url=(?<x>[^]]*)](?<y>[^]]*)[/url]",@"<a href=$1 target=_blank>$2</a>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[url](?<x>[^]]*)[/url]",@"<a href=$1 target=_blank>$1</a>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[email=(?<x>[^]]*)](?<y>[^]]*)[/email]",@"<a href=$1>$2</a>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[email](?<x>[^]]*)[/email]",@"<a href=mailto:$1>$1</a>",RegexOptions.IgnoreCase);
- if(isflash==1)
- {
- chr = Regex.Replace(chr,@"[flash](?<x>[^]]*)[/flash]",@"<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 width=500 height=400><PARAM NAME=movie VALUE=""$1""><PARAM NAME=quality VALUE=high><embed src=""$1"" quality=high pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width=500 height=400>$1</embed></OBJECT>",RegexOptions.IgnoreCase);
- }
- if(isimg==1)
- {
- chr = Regex.Replace(chr,@"[img](?<x>[^]]*)[/img]",@"<IMG SRC=""$1"" border=0 onload='javascript:if(this.width>screen.width-333)this.width=screen.width-333' >",RegexOptions.IgnoreCase);
- }
- chr = Regex.Replace(chr,@"[color=(?<x>[^]]*)](?<y>[^]]*)[/color]",@"<font color=$1>$2</font>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[face=(?<x>[^]]*)](?<y>[^]]*)[/face]",@"<font face=$1>$2</font>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[size=1](?<x>[^]]*)[/size]",@"<font size=1>$1</font>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[size=2](?<x>[^]]*)[/size]",@"<font size=2>$1</font>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[size=3](?<x>[^]]*)[/size]",@"<font size=3>$1</font>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[size=4](?<x>[^]]*)[/size]",@"<font size=4>$1</font>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[align=(?<x>[^]]*)](?<y>[^]]*)[/align]",@"<align=$1>$2</align>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[fly](?<x>[^]]*)[/fly]",@"<marquee width=90% behavior=alternate scrollamount=3>$1</marquee>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[move](?<x>[^]]*)[/move]",@"<marquee scrollamount=3>$1</marquee>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[glow=(?<x>[^]]*),(?<y>[^]]*),(?<z>[^]]*)](?<w>[^]]*)[/glow]",@"<table width=$1 style='filter:glow(color=$2, strength=$3)'>$4</table>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[shadow=(?<x>[^]]*),(?<y>[^]]*),(?<z>[^]]*)](?<w>[^]]*)[/shadow]",@"<table width=$1 style='filter:shadow(color=$2, strength=$3)'>$4</table>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[b](?<x>[^]]*)[/b]",@"<b>$1</b>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[i](?<x>[^]]*)[/i]",@"<i>$1</i>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[u](?<x>[^]]*)[/u]",@"<u>$1</u>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[code](?<x>[^]]*)[/code]",@"<pre id=code><font size=1 face='Verdana, Arial' id=code>$1</font id=code></pre id=code>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[list](?<x>[^]]*)[/list]",@"<ul>$1</ul>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[list=1](?<x>[^]]*)[/list]",@"<ol type=1>$1</ol id=1>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[list=a](?<x>[^]]*)[/list]",@"<ol type=a>$1</ol id=a>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[*](?<x>[^]]*)[/*]",@"<li>$1</li>",RegexOptions.IgnoreCase);
- chr = Regex.Replace(chr,@"[quote](?<x>.*)[/quote]",@"<center>—— 以下是引用 ——<table border='1' width='80%' cellpadding='10' cellspacing='0' style='font-size: 9pt'><tr><td>$1</td></tr></table>—— 引用完毕 ——</center>",RegexOptions.IgnoreCase);
- }
- return(chr);
- }
- public string[] splitstring(string oldstring){
- if (oldstring!=""){
- char[] ch = {'|'};
- arrwords=oldstring.Split(ch);
- return(arrwords);
- }
- else {
- return(null);
- }
-
- }
- public string adminck(){
- if (Session["au"]=="yes"){
- return("yes");
- }
- else {
- return("bad");
- }
- }
- }
- }