/**
         * 加载apache网站列表
         */

        public void load_apache_web()
        {
            dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView1.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            try
            {
                string           sql    = "select * from apacheweblist order by id desc";
                SQLiteDataReader reader = DbHelperSQLite.ExecuteReader(sql);
                int count = dataGridView1.RowCount;
                if (count > 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        dataGridView1.Rows.Clear();
                    }
                }
                while (reader.Read())
                {
                    DataGridViewRow row   = new DataGridViewRow();
                    int             index = this.dataGridView1.Rows.Add(row);
                    this.dataGridView1.Rows[index].Cells[0].Value = reader["id"];
                    this.dataGridView1.Rows[index].Cells[1].Value = reader["domain"];
                    this.dataGridView1.Rows[index].Cells[2].Value = reader["port"];
                    this.dataGridView1.Rows[index].Cells[3].Value = reader["type"];
                    this.dataGridView1.Rows[index].Cells[4].Value = "编辑";
                    this.dataGridView1.Rows[index].Cells[5].Value = "删除";
                }
            }
            catch (Exception ep)
            {
            }
        }
        /**
         * 加载mysql数据库列表
         */

        public void load_mysql_list()
        {
            dataGridView2.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView2.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

            try
            {
                string           sql    = "select * from `mysql` order by id desc";
                SQLiteDataReader reader = DbHelperSQLite.ExecuteReader(sql);

                int count = dataGridView2.RowCount;
                if (count > 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        dataGridView2.Rows.Clear();
                    }
                }
                while (reader.Read())
                {
                    Console.WriteLine(12321);
                    DataGridViewRow row   = new DataGridViewRow();
                    int             index = this.dataGridView2.Rows.Add(row);
                    this.dataGridView2.Rows[index].Cells[0].Value = reader["id"];
                    this.dataGridView2.Rows[index].Cells[1].Value = reader["dbname"];
                    this.dataGridView2.Rows[index].Cells[2].Value = reader["dbuser"];
                    this.dataGridView2.Rows[index].Cells[3].Value = reader["dbpass"];;
                    this.dataGridView2.Rows[index].Cells[4].Value = "改密";
                    this.dataGridView2.Rows[index].Cells[5].Value = "删除";
                    this.dataGridView2.Rows[index].Cells[6].Value = "导入";
                }
            }catch (Exception ep)
            {
            }
        }
Esempio n. 3
0
        private string recordID(string query, int passCount)
        {
            query = StringHelper.ReplaceBadSQL(query);
            string result = string.Empty;

            using (IDataReader dr = DbHelperSQLite.ExecuteReader(query))
            {
                while (dr.Read())
                {
                    if (passCount < 1)
                    {
                        result += "," + dr.GetInt32(0);
                    }
                    passCount--;
                }
            }
            return(result.Substring(1));
        }
Esempio n. 4
0
        public void setApacheConf(string domain, string domain2, string webindex, string port, string path, int https)
        {
            string rewrite = this.textBox5.Text;
            string gzip    = checkBox2.Checked ? @"
<IfModule deflate_module>
    SetOutputFilter DEFLATE
    DeflateCompressionLevel 6
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
    AddOutputFilter DEFLATE css|js|txt|xml|rss|html|htm
    Header append Vary User-Agent env=!dont-vary
    SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|bmp|tif|ico|eot|svg|ttf|woff)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|7z|bz2|sit|rar|bin|iso)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:pdf|doc|docx|xls|xlsx|ppt|pptx)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI .(?:mov|flv|avi|mp3|mp4|rm|webm|ogv)$ no-gzip dont-vary
</IfModule>" : "";

            string proxy = checkBox4.Checked ? @"
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    ProxyPass " + this.textBox10.Text + @" " + this.textBox9.Text + @"
    ProxyPassReverse " + this.textBox10.Text + @" " + this.textBox9.Text + @"" : "";

            string php_cgi = this.comboBox2.Text.Equals("PHP") ? @"
    FcgidInitialEnv PHPRC """ + Application.StartupPath.Replace("\\", "/") + @"/soft/php/php7.0.9nts/""
    AddHandler fcgid-script .php
    FcgidWrapper """ + Application.StartupPath.Replace("\\", "/") + @"/soft/php/php7.0.9nts/php-cgi.exe"" .php
" : "";


            string conf = @"
<VirtualHost *:" + port + @">
    DocumentRoot """ + path + @"""
    ServerName " + domain + @" " + domain2 + @"
    ServerAlias
    " + php_cgi + @"
" + gzip + @"
" + proxy + @"
  <Directory """ + path + @""">
      Options FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
      Require all granted
      DirectoryIndex " + webindex + @"
  </Directory>
</VirtualHost>";


            string httpsconf = @"
<VirtualHost *:443>
    DocumentRoot """ + path + @"""
    ServerName " + domain + @" " + domain2 + @"
    ServerAlias
    " + php_cgi + @"
    SSLEngine on
    SSLProtocol TLSv1 TLSv1.1 TLSv1.2
    SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
    SSLCertificateFile """ + Application.StartupPath + "\\soft\\apache\\Apache24\\conf\\ssl\\" + domain + @"\ca.pem" + @"""
    SSLCertificateKeyFile """ + Application.StartupPath + "\\soft\\apache\\Apache24\\conf\\ssl\\" + domain + @"\private.key" + @"""
" + proxy + @"
  <Directory """ + path + @""">
      Options FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
      Require all granted
      DirectoryIndex " + webindex + @"
  </Directory>
</VirtualHost>
";

            if (this.checkBox3.Checked)
            {
                conf = conf + httpsconf;

                try
                {
                    System.IO.Directory.CreateDirectory(Application.StartupPath + "\\soft\\apache\\Apache24\\conf\\ssl\\" + domain);
                    System.IO.File.WriteAllText(Application.StartupPath + "\\soft\\apache\\Apache24\\conf\\ssl\\" + domain + @"\ca.pem", this.textBox6.Text, new System.Text.UTF8Encoding(false));
                    System.IO.File.WriteAllText(Application.StartupPath + "\\soft\\apache\\Apache24\\conf\\ssl\\" + domain + @"\private.key", this.textBox8.Text, new System.Text.UTF8Encoding(false));
                }
                catch (Exception ep)
                {
                    Form1.form1.writeLog("创建HTTPS证书文件失败");
                    MessageBox.Show("创建HTTPS证书文件失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            try
            {
                System.IO.File.WriteAllText(Application.StartupPath + "\\soft\\apache\\Apache24\\conf\\vhosts\\" + domain + "_" + port + ".conf", conf, new System.Text.UTF8Encoding(false));


                string           listen = "Listen 443\n";
                string           sql    = "select * from apacheweblist group by port";
                SQLiteDataReader reader = DbHelperSQLite.ExecuteReader(sql);
                while (reader.Read())
                {
                    listen += "listen " + reader["port"] + "\n";
                }

                System.IO.File.WriteAllText(Application.StartupPath + "\\soft\\apache\\Apache24\\conf\\vhosts\\Listen.conf", listen, new System.Text.UTF8Encoding(false));
            }
            catch (Exception e)
            {
                Form1.form1.writeLog("创建网站配置文件失败");
                MessageBox.Show("创建网站配置文件失败!请删除后重试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            string subPath = this.textBox3.Text.Trim();

            if (false == System.IO.Directory.Exists(subPath))
            {
                try
                {
                    System.IO.Directory.CreateDirectory(subPath);
                }
                catch (Exception e)
                {
                    Form1.form1.writeLog("创建根目录失败");
                    MessageBox.Show("创建根目录失败,请自行创建", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            if (!rewrite.Equals(""))
            {
                try
                {
                    if (false == System.IO.Directory.Exists(subPath))
                    {
                        System.IO.Directory.CreateDirectory(subPath);
                    }

                    System.IO.File.WriteAllText(this.textBox3.Text.Trim() + "\\.htaccess", rewrite, new System.Text.UTF8Encoding(false));
                }
                catch (Exception e)
                {
                    Form1.form1.writeLog("生成网站伪静态文件失败");
                    MessageBox.Show("生成网站伪静态文件失败!请自行创建", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }