roycms_tp.aspx.cs
来自「ROYcms 是国内CMS市场的新秀、也是国内少有的采用微软的ASP.NET 2」· CS 代码 · 共 702 行 · 第 1/3 页
CS
702 行
using System;
using System.Data;
using System.Web;
using ROYcms.Common;
using System.Data.SqlClient;
using System.Globalization;
using System.Web.UI.WebControls;
using ROYcms.DB;
using System.IO;
namespace ROYcms.Tools.Tp
{
public partial class ROYcms_TP : System.Web.UI.Page
{
public int TIME;
public string userip = null;//获取当前IP
public string Redirect;
public string tp_id = null;//
public string[] tp_id_z = null;//
public string ConfigPath = "~/App_Cinfig/ROYcms_TP.config";//
protected void Page_Load(object sender, EventArgs e)
{
XmlControl Config = new XmlControl(Server.MapPath(ConfigPath));
this.TIME = Convert.ToInt32(Config.GetText("//TP_time"));//同一IP 限定时间;
this.Redirect = Config.GetText("//TP_Redirect");//投票成功之后返回的页面;
if (!IsPostBack)
{
SystemCms.AdminSesion();
Page.Session["TP_admin"] = "ADMIN";
if (Request["tp_id"] == null && Request["tp_id[]"] == null)
{
BIND();
if (Session["TP_admin"] != null)
{
Panel_index.Visible = true;
Panel_tu.Visible = false;
switch (Request["t"])
{
case "del":
del(); BIND(); MessageBox.ResponseScript(this, "TabbedPanels1.showPanel(2)");
break;
case "y":
update(); BIND(); MessageBox.ResponseScript(this, "TabbedPanels1.showPanel(2)");
break;
case "group_del":
group_del(); BIND(); MessageBox.ResponseScript(this, "TabbedPanels1.showPanel(5)");
break;
case "group_edit":
Panel_edit_group.Visible = true;
group_edit_bind(); MessageBox.ResponseScript(this, "TabbedPanels1.showPanel(5)");
break;
case "date_edit":
Panel_edit_date.Visible = true;
date_edit_bind(); MessageBox.ResponseScript(this, "TabbedPanels1.showPanel(2)");
break;
case "remark_del":
remark_del(); BIND(); MessageBox.ResponseScript(this, "TabbedPanels1.showPanel(7)");
break;
case "baoming_del":
baoming_del(); BIND(); MessageBox.ResponseScript(this, "TabbedPanels1.showPanel(7)");
break;
case "logout":
Session["group"] = null;
Session["group_name"] = null;
BIND();
break;
case "out":
Session["TP_admin"] = null;
Response.Redirect("ROYcms_TP.aspx");
break;
}
}
else
{
Panel_index.Visible = false;
Panel_tu.Visible = true;
}
}
else
{
Panel_index.Visible = false;
Panel_tu.Visible = false;
if (Request["tp_id[]"] != null)
{
tp_id_z = Request["tp_id[]"].Trim().Split(',');
}
if (Request["tp_id"] != null)
{
tp_id_z = Request["tp_id"].Trim().Split(',');
}
for (int i = 0; i < tp_id_z.Length; ++i)
{
tp_id = tp_id_z[i];
//投票
userip = Request.UserHostAddress.ToString();
//如果配置文件设置关闭了限制同一IP投票 则在这里直接投票
if (Config.GetText("//TP_IP_Y") == "false")
{
addIP();//添加IP
tt(); //投票
}
else
{
//ip存在
if (checkVoterIP() == true)
{
//接下来要做的事情是检测该用户上次投票时间间隔
if (checkTime() == true)
{
if (tp_id_z.Length == 1)
{
Response.Write("对不起,为了公平,请不要反复投票!");
MessageBox.ShowAndRedirect(this, "对不起,为了公平,请不要反复投票!", Redirect);
}
}
else
{
update_date();//修改IP时间
tt();//投票
}
}
//IP不存在时
else
{
addIP();//添加IP
tt(); //投票
}
}
}
if (tp_id_z.Length > 1)
{
Response.Write("批量投" + tp_id_z.Length + "票成功!");
MessageBox.ShowAndRedirect(this, "批量投" + tp_id_z.Length + "票成功!", Redirect);
}
else
{
MessageBox.ShowAndRedirect(this, "你没有选择!", Redirect);
}
}
//评论
if (Request["remark_title"] != null)
{
Panel_index.Visible = false;
Panel_tu.Visible = false;
add_remark();
}
//
if (Request["administrator"] != null)
{
Panel_administrator.Visible = true;
}
}
}
//<summary>
//覆盖系统默认的错误页
//</summary>
protected override void OnError(EventArgs e)
{
HttpContext ctx = HttpContext.Current;
Exception exception = ctx.Server.GetLastError();
string errorInfo =
"<br /><br /><br /><center>\r\n请不要试图破坏本系统<br /><b>发生错误的 URL:</b> <font color=red>" + ctx.Request.Url.ToString() +
"</font>" +
"\r\n<br /><b>错误源: </b> <font color=red>" + exception.Source +
"</font>" +
"\r\n<br /><b>错误信息: </b> <font color=red>" + exception.Message +
"</font>" +
"\r\n<br /><b>Stack trace: </b> <br /><font color=red>" + exception.StackTrace +
"</font></center>";
ctx.Response.Write(errorInfo);
ctx.Server.ClearError();
base.OnError(e);
}
private void baoming_del()
{
string SQL = "delete [ROYcms_TP_baoming] where id= '" + Request["id"] + "'";
SqlHelper.ExecuteNonQuery(SqlHelper.Conn, CommandType.Text, SQL, null);
}
//删除组
private void group_del()
{
string SQL = "delete [ROYcms_TP_group] where id= '" + Request["id"] + "'";
SqlHelper.ExecuteNonQuery(SqlHelper.Conn, CommandType.Text, SQL, null);
//同时删除组里的所有所有项目
//string SQL2 = "delete [ROYcms_TP_date] where z_id= '" + Request["id"] + "'";
//SqlHelper.ExecuteNonQuery(SqlHelper.Conn, CommandType.Text, SQL2, null);
}
//百分比计算
public string ny(int n)
{
string strSql = "select sum(ballot) from [ROYcms_TP_date] where y = '1' ";
if (Session["group"] != null) { strSql = "select sum(ballot) from [ROYcms_TP_date] where z_id='" + Session["group"] + "' and y = '1'"; }
float i = 0;
try
{
i = Convert.ToInt64(SqlHelper.ExecuteScalar(SqlHelper.Conn, CommandType.Text, strSql, null));
}
catch
{
i = 1;
}
return ((((n / i) > 0.98 ? 0.98 : (n / i)) * 100).ToString() + "0000").Substring(0, 2).Replace(".", "") + "%";
}
//审核连接显示
public string no(string id)
{
return " - <a href='?id=" + id + "&t=y' >审核</a>";
}
public void adddate(string img_path)
{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?