📄 rule_manage.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MySql.Data.MySqlClient;
using System.Net;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
public partial class rule_manage : System.Web.UI.Page
{
MySqlConnection mysqlcon;
MySqlDataAdapter mysqlda;
DataSet getdata;
public static DataSet myds;
public static string guize2;
public static string guize3;
ArrayList link;
ArrayList title;
public static ArrayList acrtil1;
savedata fds = new savedata();
ArrayList linktedian;
ArrayList linkteddian1;
Regex regexzj;
Regex regexwl;
protected void Page_Load(object sender, EventArgs e)
{
// RadioButtonList1.Items[3].Selected = true;
HttpCookieCollection cookie = Request.Cookies;
if (cookie.Count != 0)
{
for (int i = 0; i < cookie.Keys.Count; i++)
{
if (cookie[i].Name == "ECSCP_ID")
{
DateTime DateTime1970 = new DateTime(1970, 1, 1);
TimeSpan t = DateTime.Now.AddHours(-8) - DateTime1970;
string id = cookie[i].Value.Substring(0, 32);
string sql = string.Format("select data from ecs_sessions where sesskey='{0}' and ip='{1}' and adminid>0", id, Request.UserHostAddress.ToString());
DataSet thisds = setmysqldata(sql);
if (thisds.Tables[0].Rows.Count != 0)
{
string mystring = thisds.Tables[0].Rows[0][0].ToString();
string mylist = mystring.Substring(mystring.IndexOf("action_list\"") + "action_list\"".Length);
string endlist = mylist.Substring(mylist.IndexOf('"') + "\"".Length);
string list = endlist.Substring(0, endlist.IndexOf('"')); //list
if (list.IndexOf("all") == -1)
{
if (list.IndexOf("ad_manage") == -1)
{
Response.Redirect("error.aspx");
}
}
}
else
{
Response.Redirect("http://test1.maodao.com:8080/admin/privilege.php?act=login");
}
}
}
}
else
{
Response.Redirect("http://test1.maodao.com:8080/admin/privilege.php?act=login");
}
}
public bool openmysqldb() //mysql
{
try
{
string constring = string.Format("server=192.168.1.18; user id=xudengke; password=xudengke123; database=shichuangshop; pooling=false;charset=gbk;");
mysqlcon = new MySqlConnection(constring);
mysqlcon.Open();
return true;
}
catch
{
}
return false;
}
public DataSet setmysqldata(string sql) //mysql
{
if (openmysqldb())
{
mysqlda = new MySqlDataAdapter();
mysqlda.SelectCommand = new MySqlCommand();
mysqlda.SelectCommand.Connection = mysqlcon;
mysqlda.SelectCommand.CommandText = sql;
getdata = new DataSet();
mysqlda.Fill(getdata);
return getdata;
}
return null;
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
if (this.CheckBox1.Checked)
{
this.Label1.Visible = true;
this.TextBox3.Visible = true;
this.TextBox4.Visible = true;
}
else
{
this.Label1.Visible = false;
this.TextBox3.Visible = false;
this.TextBox4.Visible = false;
}
}
protected void Button3_Click(object sender, EventArgs e)
{
if (this.TextBox1.Text == "")
{
this.Label4.Text = "请选择";
this.Label5.Text = "";
this.Label2.Text = "";
}
else if (this.TextBox1.Text == "[object]")
{
this.Label4.Text = "[object]不能作为名称";
this.Label5.Text = "";
this.Label2.Text = "";
}
else if (this.TextBox2.Text == "")
{
this.Label4.Text = "";
this.Label2.Text = "";
this.Label5.Text = "请填写";
}
else if (this.TextBox5.Text == "")
{
this.Label4.Text = "";
this.Label5.Text = "";
this.Label2.Text = "请填写";
}
else if (this.RadioButtonList2.Text == "")
{
Response.Write("<script>alert('请选择采集模式')</script>");
}
else
{
if (this.CheckBox1.Checked)
{
this.Label4.Text = "";
this.Label5.Text = "";
this.Label2.Text = "";
if (this.TextBox3.Text == "" || this.TextBox4.Text == "")
{
this.Label3.Text = "请填写";
}
else
{
this.Label3.Text = "";
this.ListBox1.Items.Clear();
try
{
for (int i = int.Parse(this.TextBox3.Text.Trim()); i <= int.Parse(this.TextBox4.Text.Trim()); i++)
{
string okurl = this.TextBox2.Text.Replace("[var]",i.ToString());
HttpWebRequest adsdf = (HttpWebRequest)WebRequest.Create(okurl);
HttpWebResponse aaaaaaaaa = (HttpWebResponse)adsdf.GetResponse();
Stream strm = aaaaaaaaa.GetResponseStream();
StreamReader sr = new StreamReader(strm, Encoding.GetEncoding(this.TextBox5.Text.Trim()));
string dataHTML = sr.ReadToEnd();
StripHTML(dataHTML);
strm.Close();
}
}
catch
{
}
}
}
else
{
this.Label4.Text = "";
this.Label5.Text = "";
this.Label2.Text = "";
this.Label3.Text = "";
this.ListBox1.Items.Clear();
try
{
string okurl = this.TextBox2.Text.Trim();
HttpWebRequest adsdf = (HttpWebRequest)WebRequest.Create(okurl);
HttpWebResponse aaaaaaaaa = (HttpWebResponse)adsdf.GetResponse();
Stream strm = aaaaaaaaa.GetResponseStream();
StreamReader sr = new StreamReader(strm, Encoding.GetEncoding(this.TextBox5.Text.Trim()));
string dataHTML = sr.ReadToEnd();
StripHTML(dataHTML);
strm.Close();
}
catch
{
}
}
}
}
public void StripHTML(string strHtml)
{
link = new ArrayList();
title = new ArrayList();
ArrayList enddata = new ArrayList();
ArrayList endlink = new ArrayList();
linktedian = new ArrayList();
linkteddian1 = new ArrayList();
try
{
string strOutput = strHtml.Substring(strHtml.IndexOf(this.TextBox6.Text.Trim()));
strOutput = strOutput.Substring(0, strOutput.IndexOf(this.TextBox7.Text.Trim()));
string[] exper = split(this.TextBox8.Text.Trim(), "||||");
if (RadioButtonList2.Items[0].Selected == true)
{
regexwl = new Regex(exper[0].Trim(), RegexOptions.IgnoreCase);
}
if (RadioButtonList2.Items[1].Selected == true)
{
regexwl = new Regex(exper[0].Trim(), RegexOptions.Singleline);
}
if (RadioButtonList2.Items[2].Selected == true)
{
regexwl = new Regex(exper[0].Trim(), RegexOptions.ExplicitCapture);
}
if (RadioButtonList2.Items[3].Selected == true)
{
regexwl = new Regex(exper[0].Trim(), RegexOptions.Multiline);
}
MatchCollection matches = regexwl.Matches(strOutput);
System.Collections.IEnumerator enu = matches.GetEnumerator();
while (enu.MoveNext() && enu.Current != null)
{
Match match = (Match)(enu.Current);
enddata.Add(match.Value);
}
int a = 0;
for (int i = 0; i < enddata.Count; i++)
{
for (int j = 0; j < enddata.Count; j++)
{
if (enddata[i].ToString() == enddata[j].ToString())
{
a++;
}
}
if (a == 2)
{
enddata.RemoveAt(i);
}
a = 0;
}
int c = 0;
for (int i = 0; i < enddata.Count; i++)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -