diff --git a/App_Code/autoBindDataTable.cs b/App_Code/autoBindDataTable.cs new file mode 100644 index 0000000..ccd5e6c --- /dev/null +++ b/App_Code/autoBindDataTable.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Data.SqlClient; +using System.Data; +using System.Configuration; + +/// +/// autoBindDataTable 的摘要描述 +/// +public class autoBindDataTable +{ + private string _strSQL = ""; + private SqlConnection _objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString); + private SqlCommand _objCmd; + private SqlDataAdapter _objDataAdapter; + private SqlCommandBuilder _objDataCommandBuilder; + private DataTable _objDataTable = new DataTable(); + + public autoBindDataTable(string strSQL) + { + // + // TODO: 在這裡新增建構函式邏輯 + // + _strSQL = strSQL; + + try + { + _objConn.Open(); + _objCmd = new SqlCommand(_strSQL, _objConn); + _objDataAdapter = new SqlDataAdapter(_objCmd); + _objDataCommandBuilder = new SqlCommandBuilder(_objDataAdapter); + _objDataAdapter.Fill(_objDataTable); + _objConn.Close(); + } + catch (Exception ex) + { + _objConn.Close(); + throw new Exception("Bind DataTable 發生錯誤! " + ex.Message); + } + } + + public DataRow newRow + { + get + { + DataRow objRow = this._objDataTable.NewRow(); + return objRow; + } + } + + public void updateDataTable() + { + try + { + _objConn.Open(); + _objDataAdapter.Update(_objDataTable); + _objConn.Close(); + } + catch (Exception ex) + { + _objConn.Close(); + throw new Exception("DataTable 資料庫更新發生錯誤[" + _objDataTable.TableName + "], " + ex.Message); + } + } + + public void disConnection() + { + _objConn.Close(); + _objConn.Dispose(); + } + + public DataRowCollection dataRows + { + get { return this._objDataTable.Rows; } + } + + public DataRow[] selectedRows(string value) + { + return this._objDataTable.Select(value); + } + + public int columnNumber + { + get { return this._objDataTable.Columns.Count; } + } + + public string columnName(int columnIndex) { + string colName = ""; + + try + { + colName = this._objDataTable.Columns[columnIndex].ColumnName; + } + catch { + + } + + return colName; + } +} \ No newline at end of file diff --git a/BackEnd/Login.aspx.cs b/BackEnd/Login.aspx.cs index fcdcf8f..ae8ea1d 100644 --- a/BackEnd/Login.aspx.cs +++ b/BackEnd/Login.aspx.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; +using abbott_2024_event; namespace abbott_2024_event.BackEnd { @@ -34,9 +35,37 @@ namespace abbott_2024_event.BackEnd isAllow = true; } + string myIP_2 = myIP.Substring(0, myIP.LastIndexOf('.')) + ".*"; + + autoBindDataTable objAllow2 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_2)); + + if (objAllow2.dataRows.Count > 0) + { + isAllow = true; + } + + string myIP_3 = myIP_2.Substring(0, myIP_2.Replace(".*", "").LastIndexOf('.')) + ".*.*"; + + autoBindDataTable objAllow3 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_3)); + + if (objAllow3.dataRows.Count > 0) + { + isAllow = true; + } + + string myIP_4 = myIP.Substring(0, myIP.IndexOf('.')) + ".*.*.*"; + + autoBindDataTable objAllow4 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_4)); + + if (objAllow4.dataRows.Count > 0) + { + isAllow = true; + } + + if (isAllow == false) { - Response.Redirect("auth-error-v3.html"); + Response.Redirect("auth-error-v3.html?ip=" + myIP); return; } } diff --git a/BackEnd/Main.Master.cs b/BackEnd/Main.Master.cs index 5ad5e84..097a326 100644 --- a/BackEnd/Main.Master.cs +++ b/BackEnd/Main.Master.cs @@ -37,6 +37,33 @@ namespace abbott_2024_event.BackEnd isAllow = true; } + string myIP_2 = myIP.Substring(0, myIP.LastIndexOf('.')) + ".*"; + + autoBindDataTable objAllow2 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_2)); + + if (objAllow2.dataRows.Count > 0) + { + isAllow = true; + } + + string myIP_3 = myIP_2.Substring(0, myIP_2.Replace(".*", "").LastIndexOf('.')) + ".*.*"; + + autoBindDataTable objAllow3 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_3)); + + if (objAllow3.dataRows.Count > 0) + { + isAllow = true; + } + + string myIP_4 = myIP.Substring(0, myIP.IndexOf('.')) + ".*.*.*"; + + autoBindDataTable objAllow4 = new autoBindDataTable(string.Format("select * from ipTable where ipTable_address = '{0}'", myIP_4)); + + if (objAllow4.dataRows.Count > 0) + { + isAllow = true; + } + if (isAllow == false) { Response.Redirect("auth-error-v3.html"); diff --git a/abbott_2024_event.csproj b/abbott_2024_event.csproj index 3102586..4381d79 100644 --- a/abbott_2024_event.csproj +++ b/abbott_2024_event.csproj @@ -26491,6 +26491,7 @@ + diff --git a/bin/abbott_2024_event.dll b/bin/abbott_2024_event.dll index 80cb1d7..aa6db27 100644 Binary files a/bin/abbott_2024_event.dll and b/bin/abbott_2024_event.dll differ diff --git a/bin/app.publish/bin/abbott_2024_event.dll b/bin/app.publish/bin/abbott_2024_event.dll index 80cb1d7..aa6db27 100644 Binary files a/bin/app.publish/bin/abbott_2024_event.dll and b/bin/app.publish/bin/abbott_2024_event.dll differ diff --git a/webapi/lineLogin.ashx.cs b/webapi/lineLogin.ashx.cs index 3fca355..fe3c2bb 100644 --- a/webapi/lineLogin.ashx.cs +++ b/webapi/lineLogin.ashx.cs @@ -36,23 +36,23 @@ namespace abbott_2024_event.webapi return; } - if (line_displayName == "") - { - objRet.ret = "no"; - objRet.err_code = "2002"; - objRet.message = "line_displayname為空字串!"; - json.WriteObject(context.Response.OutputStream, objRet); - return; - } + //if (line_displayName == "") + //{ + // objRet.ret = "no"; + // objRet.err_code = "2002"; + // objRet.message = "line_displayname為空字串!"; + // json.WriteObject(context.Response.OutputStream, objRet); + // return; + //} - if (line_phone == "") - { - objRet.ret = "no"; - objRet.err_code = "2003"; - objRet.message = "line_phone為空字串!"; - json.WriteObject(context.Response.OutputStream, objRet); - return; - } + //if (line_phone == "") + //{ + // objRet.ret = "no"; + // objRet.err_code = "2003"; + // objRet.message = "line_phone為空字串!"; + // json.WriteObject(context.Response.OutputStream, objRet); + // return; + //} lineUser lineUser = conn.QueryFirstOrDefault("select * from lineUser where line_uid = @line_uid", new { line_uid = line_uid });