jianinclude4.ascx.cs
资源名称:论坛源码.rar [点击查看]
上传用户:scene123
上传日期:2010-02-19
资源大小:3311k
文件大小:4k
源码类别:
.net编程
开发平台:
C#
- namespace kuangren
- {
- 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.Text;
- using System.Configuration;
- /// <summary>
- /// jianinclude4 的摘要说明。
- /// </summary>
- public class jianinclude4 : System.Web.UI.UserControl
- {
- protected int intRunTime;
- protected DateTime dtStartTime = DateTime.Now;
- public string usercookies;
- public string jpower;
- public DataSet dsuser;
- public string sessionid;
- public string jhidden;
- public string boardid;
- public string OleDbSqlforum;
- protected System.Data.OleDb.OleDbCommand cmd4;
- public string OleDbSqlforum1;
- protected System.Data.OleDb.OleDbCommand cmd41;
- private void Page_Load(object sender, System.EventArgs e)
- {
- sessionid=""+Request.UserHostAddress+"";
- sessionid=sessionid.Replace(".","");
- if (Request.Cookies["jhidden"]!=null&&Request.Cookies["jhidden"].Value=="0")
- {
- usercookies=Request.Cookies["jusername"].Value;
- jpower=Request.Cookies["jpower"].Value;
- jhidden=Request.Cookies["jhidden"].Value;
- }
- else
- {
- jpower="42";
- usercookies="客人";
- jhidden="1";
- }
- if (Request.QueryString["f2_id"]!=null)
- {
- boardid=Request.QueryString["f2_id"];
- }
- else
- {
- boardid="0";
- }
- OleDbConnection conn;
- string OleDbsql;
- OleDbCommand cmd;
- StringBuilder sb=new StringBuilder();
- ArrayList values=new ArrayList();
- sb.Append("INSERT INTO [online](id,username,userclass,ip,startime,lastimebk,userhidden,boardid) values({0},'{1}',{2},'{3}','{4}','{5}',{6},{7})");
- values.Add(sessionid);
- values.Add(usercookies);
- values.Add(jpower);
- values.Add(Request.UserHostAddress);
- values.Add(DateTime.Now);
- values.Add(DateTime.Now);
- values.Add(jhidden);
- values.Add(boardid);
- OleDbsql=String.Format(sb.ToString(),values.ToArray());
- conn=new OleDbConnection(ConfigurationSettings.AppSettings["cnFriends.ConnectionString"]);
- cmd=new OleDbCommand("select id from online where id="+sessionid+"",conn);
- dsuser=new DataSet();
- cmd.Connection.Open();
- OleDbDataReader objDataReader ;
- objDataReader = cmd.ExecuteReader();
- if (objDataReader.Read() == false)
- {
- cmd=new OleDbCommand(OleDbsql,conn);
- }
- else
- {
- OleDbSqlforum="update [online] SET lastimebk='"+DateTime.Now+"',boardid="+boardid+",username='"+usercookies+"' ,userhidden="+jhidden+" ,userclass="+jpower+" WHERE id="+sessionid+" ";
- cmd4=new OleDbCommand(OleDbSqlforum,conn);
- }
- objDataReader.Close();
- OleDbSqlforum1="DELETE FROM online WHERE DATEDIFF('s', lastimebk, now()) >15*60 ";
- cmd41=new OleDbCommand(OleDbSqlforum1,conn);
- cmd.Connection.Close();
- conn.Open();
- bool doredirect=true;
- try
- {
- cmd.ExecuteNonQuery();
- cmd4.ExecuteNonQuery();
- cmd41.ExecuteNonQuery();
- }
- catch
- {
- doredirect=false;
- }
- finally
- {
- conn.Close();
- }
- if(doredirect)
- {
- }
- else
- {
- }
- }
- #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
- }
- }