📄 setup.aspx
字号:
<%@ Page Language="C#" %>
<script runat="server">
publicclass class1 = new publicclass();
protected void sqlconn_Click(object sender, EventArgs e)
{
string sqlconnstring="data source="+ip.Text+","+host.Text+";User ID="+uid.Text+";pwd="+paw.Text+";Initial Catalog="+initdate.Text;
sqlconnstring = class1.jiami(sqlconnstring);
try
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlNode node1 = null;
System.Xml.XmlNode node2 = null;
doc.Load(Server.MapPath("web.config"));
node1 = doc.SelectSingleNode("/configuration/appSettings/add[@key='sqlconn']");
node2 = doc.SelectSingleNode("/configuration/appSettings");
node2.RemoveChild(node1);
System.Xml.XmlElement ee = doc.CreateElement("add");
ee.SetAttribute("key", "sqlconn");
ee.SetAttribute("value", sqlconnstring);
node2.AppendChild(ee);
doc.Save(Server.MapPath("web.config"));
doc.Clone();
}
catch (Exception ex)
{
sql_tishi.Text = "设置保存失败,您的主机可能不支持FSO权限<br />";
sql_tishi.Text += ex.Message.ToString();
return;
}
try
{
System.Data.SqlClient.SqlConnection conn1 = new System.Data.SqlClient.SqlConnection(class1.jiemi(sqlconnstring));
if (conn1.State.ToString() == "Open") conn1.Close();
conn1.Open();
}
catch (Exception ex)
{
sql_tishi.Text = "数据库连接不正确。具体错误为:<br />";
sql_tishi.Text += ex.Message.ToString();
return;
}
anzhuang_biaoti.Text = ip.Text;
yemian1(((Button)sender).ToolTip.Trim());
}
protected void anzhuang_anzhuang_Click(object sender, EventArgs e)
{
string command = "";
string aa = "";
publicclass.mysql mysql1 = new publicclass.mysql(class1.zhong);
System.IO.StreamReader rs = System.IO.File.OpenText(Server.MapPath("setup.txt"));
while (rs.Peek() != -1)
{
aa = rs.ReadLine();
if (aa.Trim() == "GO")
{
try
{
mysql1.setcommand(command);
}
catch (Exception ex)
{
anzhuang_tishi.InnerHtml += ex.Message.ToString() + "<br />";
}
}
if (aa.Trim() == "GO") command = ""; else command += " " + aa;
}
mysql1.close();
rs.Close();
if(!CheckBox1.Checked)yemian1(((Button)sender).ToolTip.Trim());
}
protected void gaoji_Click(object sender, EventArgs e)
{
try
{
TextBox1.Text=int.Parse(TextBox1.Text).ToString().Trim();
TextBox2.Text=int.Parse(TextBox2.Text).ToString().Trim();
TextBox3.Text=int.Parse(TextBox3.Text).ToString().Trim();
TextBox4.Text=int.Parse(TextBox4.Text).ToString().Trim();
}
catch (Exception ex)
{
class1.showmessage("上传大小,时间,下载速度,用户空间大小必须为纯数字");
return;
}
if (int.Parse(TextBox1.Text) > 2047) { class1.showmessage("上传文件最大值不能大于2047MB"); TextBox1.Text = "2047"; return; }
try
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Xml.XmlNode node1 = null;
System.Xml.XmlNode node2 = null;
doc.Load(Server.MapPath("web.config"));
node1 = doc.SelectSingleNode("/configuration/appSettings/add[@key='save']");
node2 = doc.SelectSingleNode("/configuration/appSettings");
node2.RemoveChild(node1);
System.Xml.XmlElement ee = doc.CreateElement("add");
ee.SetAttribute("key", "save");
ee.SetAttribute("value", class1.jiami(save.Text));
node2.AppendChild(ee);
node1 = doc.SelectSingleNode("/configuration/appSettings/add[@key='maxspeed']");
node2 = doc.SelectSingleNode("/configuration/appSettings");
node2.RemoveChild(node1);
ee = doc.CreateElement("add");
ee.SetAttribute("key", "maxspeed");
ee.SetAttribute("value", TextBox3.Text);
node2.AppendChild(ee);
node1 = doc.SelectSingleNode("/configuration/appSettings/add[@key='maxsize']");
node2 = doc.SelectSingleNode("/configuration/appSettings");
node2.RemoveChild(node1);
ee = doc.CreateElement("add");
ee.SetAttribute("key", "maxsize");
ee.SetAttribute("value", TextBox4.Text);
node2.AppendChild(ee);
doc.Save(Server.MapPath("web.config"));
doc.Clone();
doc.Load(Server.MapPath("web.config"));
node1 = doc.SelectSingleNode("/configuration/system.web/httpRuntime");
node2 = doc.SelectSingleNode("/configuration/system.web");
node2.RemoveChild(node1);
ee = doc.CreateElement("httpRuntime");
ee.SetAttribute("maxRequestLength", (int.Parse (TextBox1.Text) * 1024).ToString());
ee.SetAttribute("executionTimeout", (int.Parse(TextBox2.Text) * 60).ToString());
ee.SetAttribute("useFullyQualifiedRedirectUrl", "true");
node2.AppendChild(ee);
doc.Save(Server.MapPath("web.config"));
doc.Clone();
}
catch (Exception ex)
{
gaoji_tishi.Text = "设置失败,可能您的服务器不支持fso权限";
return;
}
yemian1(((Button)sender).ToolTip.Trim());
}
protected void yemian(object sender, EventArgs e)
{
yemian1(((Button)sender).ToolTip);
}
private void yemian1(string s)
{
chuangti.Visible = false;
chuangti_beijiang.Visible = false;
sqlmmc.Visible = false;
anzhuang.Visible = false;
wancheng.Visible = false;
gaoji.Visible = false;
if (form1.FindControl(s) != null)
{
chuangti.Visible = true;
chuangti_beijiang.Visible = true;
form1.FindControl(s).Visible = true;
}
if (s == "sqlmmc") biaoti.Text = "设置数据库";
if (s == "anzhuang") biaoti.Text = "安装数据库";
if (s == "wancheng") biaoti.Text = "完成安装";
if (s == "gaoji") biaoti.Text = "高级设置";
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string s = class1.zhong;
if (s.Trim() != "")
{
ip.Text = quchuan(s, "data source=", ",");
host.Text = quchuan(s, ",", ";");
uid.Text = quchuan(s, "User ID=", ";");
paw.Text = quchuan(s, "pwd=", ";");
initdate.Text = quchuan(s, "Initial Catalog=", ";");
}
save.Text = class1.jiemi(System.Configuration.ConfigurationManager.AppSettings["save"]);
string xpath = "/configuration/system.web/httpRuntime";
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(Server.MapPath("Web.Config"));
System.Xml.XmlNodeList ll = doc.SelectNodes(xpath);
System.Xml.XmlNodeReader rs = null;
int i = 0;
for (i = 0; i < ll.Count; i++)
{
rs = new System.Xml.XmlNodeReader(ll[i]);
if (rs.Read())
{
TextBox1.Text = (int.Parse(rs.GetAttribute("maxRequestLength")) / 1024).ToString().Trim();
TextBox2.Text = (int.Parse(rs.GetAttribute("executionTimeout")) / 60).ToString().Trim();
}
}
doc.Clone();
TextBox3.Text = class1.maxspeed.ToString().Trim();
TextBox4.Text = class1.maxsize.ToString().Trim();
anzhuang_biaoti.Text = ip.Text;
}
}
protected string quchuan(string yuan, string start, string end)
{
yuan = yuan.Trim();
int st = 0;
if (yuan.IndexOf(start) >= 0) st = yuan.IndexOf(start);
yuan = yuan.Substring(st);
int en = yuan.Length;
if (yuan.IndexOf(end) >= 0) en = yuan.IndexOf(end);
return yuan.Substring(start.Length, en- start.Length);
}
protected void Imageyemian_Click(object sender, ImageClickEventArgs e)
{
yemian1(((ImageButton)sender).ToolTip);
}
protected void LinkButton2_Click(object sender, EventArgs e)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -