📄 article_det.aspx.cs
字号:
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;
namespace yezhuforum
{
/// <summary>
/// article_det 的摘要说明。
/// </summary>
public class article_det : System.Web.UI.Page
{
protected int intRunTime;
protected DateTime dtStartTime = DateTime.Now;
protected System.Web.UI.WebControls.Repeater parent;
protected System.Web.UI.WebControls.Repeater Repeater1;
protected System.Web.UI.WebControls.Repeater Repeater2;
protected Wuqi.Webdiyer.AspNetPager AspNetPager1;
protected System.Data.OleDb.OleDbCommand cmd;
protected System.Data.OleDb.OleDbCommand cmd2;
protected System.Data.OleDb.OleDbCommand cmd3;
protected System.Web.UI.HtmlControls.HtmlForm repeater;
protected System.Data.OleDb.OleDbConnection conn;
public DataSet dsPending;
public string sql;
public string usercookies;
public string OleDbSqlvisited;
protected string FilterBadWords(string msg)
{
// 在此处添加网站限制的词汇
string badwords="qqqqq|rrrrr";
string[] tempstr=badwords.Split('|');
string finalstr=msg;
for(int i=0;i<tempstr.Length;i++)
{
finalstr=finalstr.Replace(tempstr[i],new String('*',tempstr[i].Length));
}
return finalstr;
return msg;
}
//结束
//定义显示用户头衔
public string judgetouxian(object touxian)
{
if (Convert.IsDBNull(touxian) || (string)touxian== "")
return "";
else
return "头衔:<font color=red><b>"+touxian+"</b></font><br>";
}
//结束
//定义显示用户来自何处
public string judgedizhi(object dizhi)
{
if (Convert.IsDBNull(dizhi) || (string)dizhi== "")
return "";
else
return "来自:"+dizhi+"<br>";
}
//结束
//定义显示主页图标
public string judgehomepage(object homepage)
{
if ((string)homepage== "http://")
return "";
else
return "<a href="+homepage+" target=_blank><img src=images/homepage.gif alt=访问"+dsPending.Tables[0].Rows[0]["f3_name"]+"的个人主页 width=53 height=19 border=0></a>";
}
//定义显示头像
public string judgetouxiang(object touxiang)
{
if ((string)touxiang== "notimage")
return "touxiang.gif";
else
return ""+touxiang+"";
}
public string judgehomepageerply(object homepage1)
{
if ((string)homepage1== "http://")
return "";
else
return "<a href="+homepage1+" target=_blank><img src=images/homepage.gif width=53 height=19 border=0></a>";
}
//结束
//判断用户发言是否被屏蔽
public string judgepingbi(string ucontent,string upingbi)
{
if (upingbi=="0")
return ""+ucontent+"";
else
return "<font color=red><br>————————————————<br>———该用户发言已经被屏蔽———<br>————————————————</font>";
}
//结束
private void Page_Load(object sender, System.EventArgs e)
{
conn = new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
if (Request.Cookies["jusername"]!=null)
{
usercookies=Request.Cookies["jusername"].Value;
}
else
{
Response.Redirect("logine.aspx");
}
if(!Page.IsPostBack)
{
cmd=new OleDbCommand("select count(f4_id) from forum_4 where f4_sy2="+Request.QueryString["f3_id"]+"",conn);
conn.Open();
AspNetPager1.RecordCount=(int)cmd.ExecuteScalar();
conn.Close();
DataBind();
}
if(!Page.IsPostBack)
{
sql="SELECT f3_id, f3_motif, f3_content,f3_state,f3_top, f3_distillate,f3_count, f3_face, f3_sy, f3_name, f3_now, f3_date, f3_time, f3_replyname,u_id, u_User, u_Email, u_Oicq, u_Homepage, u_Signature, u_address,u_Regtime, u_xiao, u_grade, u_images, u_offer, u_iflock, u_pingbi, u_post,u_fenshu,g_id,g_grade,g_tb,g_txt from (forum_3 inner join userinfo on forum_3.f3_name=userinfo.u_user) inner join usergrade on usergrade.g_id=userinfo.u_grade WHERE f3_id = " + Request.QueryString["f3_id"]+ "";
dsPending=new DataSet();
OleDbDataAdapter adWord=new OleDbDataAdapter(sql,conn);
adWord.Fill(dsPending,"forum_3");
Page.DataBind();
}
OleDbSqlvisited="update [forum_3] set f3_count=f3_count+1 where f3_id="+Request.QueryString["f3_id"]+"";
cmd3=new OleDbCommand(OleDbSqlvisited,conn);
conn.Open();
bool doredirect=true;
try
{
cmd3.ExecuteNonQuery();
}
catch
{
doredirect=false;
}
finally
{
conn.Close();
}
if(doredirect)
{
}
else
{
}
}
public string UbbReplace(string content)
{
content = content.Replace("\n","<BR>");
content=content.Replace("\t"," ");
content=content.Replace(" "," ");
for(int i=1;i<43;i++)
content = content.Replace("[em"+i+"]","<IMG SRC=\"pic/em"+i+".gif\">");
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[url=(?<x>[^\]]*)\](?<y>[^\]]*)\[/url\]",@"<a href=$1 target=_blank>$2</a>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[email=(?<x>[^\]]*)\](?<y>[^\]]*)\[/email\]",@"<a href=mailto:$1>$2</a>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[flash](?<x>[^\]]*)\[/flash]",@"<OBJECT codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,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>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[img](?<x>[^\]]*)\[/img]",@"<IMG SRC=""$1"" border=0>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[color=(?<x>[^\]]*)\](?<y>[^\]]*)\[/color\]",@"<font color=$1>$2</font>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[face=(?<x>[^\]]*)\](?<y>[^\]]*)\[/face\]",@"<font face=$1>$2</font>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[size=(?<x>[^\]]*)\](?<y>[^\]]*)\[/size\]",@"<font size=$1>$2</font>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[align=(?<x>[^\]]*)\](?<y>[^\]]*)\[/align\]",@"<div align=$1>$2</div>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[fly](?<x>[^\]]*)\[/fly]",@"<marquee width=90% behavior=alternate scrollamount=3>$1</marquee>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[move](?<x>[^\]]*)\[/move]",@"<marquee scrollamount=3>$1</marquee>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[glow=(?<x>[^\]]*),(?<y>[^\]]*),(?<z>[^\]]*)\](?<w>[^\]]*)\[/glow\]",@"<table width=$1 style=""filter:glow(color=$2, strength=$3)"">$4</table>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[shadow=(?<x>[^\]]*),(?<y>[^\]]*),(?<z>[^\]]*)\](?<w>[^\]]*)\[/shadow\]",@"<table width=$1 style=""filter:shadow(color=$2, strength=$3)"">$4</table>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[b\](?<x>[^\]]*)\[/b\]",@"<b>$1</b>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[i\](?<x>[^\]]*)\[/i\]",@"<i>$1</i>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[u\](?<x>[^\]]*)\[/u\]",@"<u>$1</u>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[h1\](?<x>[^\]]*)\[/h1\]",@"<h1>$1</h1>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[h2\](?<x>[^\]]*)\[/h2\]",@"<h2>$1</h2>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[h3\](?<x>[^\]]*)\[/h3\]",@"<h3>$1</h3>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[h4\](?<x>[^\]]*)\[/h4\]",@"<h4>$1</h4>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[h5\](?<x>[^\]]*)\[/h5\]",@"<h5>$1</h5>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[h6\](?<x>[^\]]*)\[/h6\]",@"<h6>$1</h6>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[small\](?<x>[^\]]*)\[/small\]",@"<small>$1</small>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[big\](?<x>[^\]]*)\[/big\]",@"<big>$1</big>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[del\](?<x>[^\]]*)\[/del\]",@"<del>$1</del>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[blink\](?<x>[^\]]*)\[/blink\]",@"<blink>$1</blink>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[sub\](?<x>[^\]]*)\[/sub\]",@"<sub>$1</sub>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[sup\](?<x>[^\]]*)\[/sup\]",@"<sup>$1</sup>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[list\](?<x>[^\]]*)\[/list\]",@"<li>$1</li>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[indent\](?<x>[^\]]*)\[/indent\]",@"<blockquote><p>$1</p></blockquote>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
content = System.Text.RegularExpressions.Regex.Replace(content,@"\[quote\](?<x>[^\]]*)\[/quote\]",@"以下内容为引用:<table border=0 width=95% cellpadding=10 cellspacing=1 bgcolor=#000000><tr><td bgcolor=#FFFFFF>$1</td></tr></table>",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
return content;
}
void DataBind()
{
cmd=new OleDbCommand("SELECT f4_id, f4_motif, f4_content, f4_face, f4_sy1, f4_name, f4_date, f4_time,"+
"f4_sy2,u_id, u_User, u_Email, u_Oicq, u_Homepage, u_Signature, u_address,u_Regtime, u_xiao, u_grade, u_images,"+
"u_offer, u_iflock, u_pingbi, u_post,u_fenshu,g_id,g_grade,g_tb,g_txt FROM (forum_4 inner join userinfo on forum_4.f4_name=userinfo.u_user) "+
"inner join usergrade on usergrade.g_id=userinfo.u_grade WHERE f4_sy2 = " +Request.QueryString["f3_id"]+ " ORDER BY f4_id ASC",conn);
OleDbDataAdapter adapter=new OleDbDataAdapter(cmd);
DataSet ds=new DataSet();
adapter.Fill(ds,AspNetPager1.PageSize*(AspNetPager1.CurrentPageIndex-1),AspNetPager1.PageSize,"forum_4");
Repeater1.DataSource=ds.Tables["forum_4"];
Repeater1.DataBind();
//动态设置用户自定义文本内容
AspNetPager1.CustomInfoText="记录总数:<b>"+AspNetPager1.RecordCount.ToString()+"</b>";
AspNetPager1.CustomInfoText+=" 总页数:<b>"+AspNetPager1.PageCount.ToString()+"</b>";
AspNetPager1.CustomInfoText+=" 当前页:<font color=\"red\"><b>"+AspNetPager1.CurrentPageIndex.ToString()+"</b></font>";
ds.Clear();
conn.Close();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.AspNetPager1.PageChanged += new Wuqi.Webdiyer.PageChangedEventHandler(this.AspNetPager1_PageChanged);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
{
AspNetPager1.CurrentPageIndex=e.NewPageIndex;
DataBind();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -