Centralize credentials and make migration idempotent
- Move all DB credentials to config.asp with DSN/ODBC toggle - Add Zabbix API URL and token to centralized config - Update sql.asp, api.asp, apiusb.asp, zabbix.asp to use config - Add GetConnectionString() and GetEmployeeConnectionString() functions - Make migration SQL idempotent (safe to run multiple times) - Add duplicate index cleanup (appname_2) to migration - Document employee DB access limitation in CLAUDE.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,8 +10,17 @@
|
||||
'=============================================================================
|
||||
|
||||
'-----------------------------------------------------------------------------
|
||||
' Database Configuration
|
||||
' Database Configuration - ShopDB (primary)
|
||||
'-----------------------------------------------------------------------------
|
||||
' Set USE_DSN = True for production (DSN-based), False for dev (direct ODBC)
|
||||
Const USE_DSN = False
|
||||
|
||||
' DSN configuration (production)
|
||||
Const DB_DSN = "shopdb"
|
||||
Const DB_DSN_USER = "570005354"
|
||||
Const DB_DSN_PASSWORD = "570005354"
|
||||
|
||||
' Direct ODBC configuration (development)
|
||||
Const DB_DRIVER = "MySQL ODBC 9.4 Unicode Driver"
|
||||
Const DB_SERVER = "192.168.122.1"
|
||||
Const DB_PORT = "3306"
|
||||
@@ -19,6 +28,25 @@ Const DB_NAME = "shopdb"
|
||||
Const DB_USER = "570005354"
|
||||
Const DB_PASSWORD = "570005354"
|
||||
|
||||
'-----------------------------------------------------------------------------
|
||||
' Database Configuration - Employee Database
|
||||
'-----------------------------------------------------------------------------
|
||||
' Set USE_EMP_DSN = True for production (DSN-based), False for dev (direct ODBC)
|
||||
Const USE_EMP_DSN = True
|
||||
|
||||
' DSN configuration (production)
|
||||
Const EMP_DB_DSN = "wjf_employees"
|
||||
Const EMP_DB_DSN_USER = "root"
|
||||
Const EMP_DB_DSN_PASSWORD = "WJF11sql"
|
||||
|
||||
' Direct ODBC configuration (development) - configure if needed
|
||||
Const EMP_DB_DRIVER = "MySQL ODBC 9.4 Unicode Driver"
|
||||
Const EMP_DB_SERVER = "localhost"
|
||||
Const EMP_DB_PORT = "3306"
|
||||
Const EMP_DB_NAME = "wjf_employees"
|
||||
Const EMP_DB_USER = "root"
|
||||
Const EMP_DB_PASSWORD = "WJF11sql"
|
||||
|
||||
'-----------------------------------------------------------------------------
|
||||
' Application Settings
|
||||
'-----------------------------------------------------------------------------
|
||||
@@ -42,11 +70,17 @@ Const DEFAULT_MODEL_ID = 1 ' Default model
|
||||
Const DEFAULT_OS_ID = 1 ' Default operating system
|
||||
|
||||
'-----------------------------------------------------------------------------
|
||||
' External Services
|
||||
' External Services - ServiceNow
|
||||
'-----------------------------------------------------------------------------
|
||||
Const SNOW_BASE_URL = "https://geit.service-now.com/now/nav/ui/search/"
|
||||
Const SNOW_TICKET_PREFIXES = "geinc,gechg,gerit,gesct" ' Valid ServiceNow ticket prefixes
|
||||
|
||||
'-----------------------------------------------------------------------------
|
||||
' External Services - Zabbix API
|
||||
'-----------------------------------------------------------------------------
|
||||
Const ZABBIX_URL = "http://10.48.130.113:8080/api_jsonrpc.php"
|
||||
Const ZABBIX_API_TOKEN = "9e60b0544ec77131d94825eaa2f3f1645335539361fd33644aeb8326697aa48d"
|
||||
|
||||
'-----------------------------------------------------------------------------
|
||||
' File Upload
|
||||
'-----------------------------------------------------------------------------
|
||||
@@ -59,18 +93,45 @@ Const ALLOWED_EXTENSIONS = "jpg,jpeg,png,gif,pdf"
|
||||
|
||||
'-----------------------------------------------------------------------------
|
||||
' FUNCTION: GetConnectionString
|
||||
' PURPOSE: Returns the database connection string with all parameters
|
||||
' RETURNS: Complete ODBC connection string
|
||||
' PURPOSE: Returns the database connection string based on USE_DSN setting
|
||||
' RETURNS: DSN connection string (production) or direct ODBC string (dev)
|
||||
'-----------------------------------------------------------------------------
|
||||
Function GetConnectionString()
|
||||
GetConnectionString = "Driver={" & DB_DRIVER & "};" & _
|
||||
"Server=" & DB_SERVER & ";" & _
|
||||
"Port=" & DB_PORT & ";" & _
|
||||
"Database=" & DB_NAME & ";" & _
|
||||
"User=" & DB_USER & ";" & _
|
||||
"Password=" & DB_PASSWORD & ";" & _
|
||||
"Option=3;" & _
|
||||
"Pooling=True;Max Pool Size=100;"
|
||||
If USE_DSN Then
|
||||
' Production: DSN-based connection with pooling
|
||||
GetConnectionString = "DSN=" & DB_DSN & ";Uid=" & DB_DSN_USER & ";Pwd=" & DB_DSN_PASSWORD & ";Option=3;Pooling=True;Max Pool Size=100;"
|
||||
Else
|
||||
' Development: Direct ODBC driver connection
|
||||
GetConnectionString = "Driver={" & DB_DRIVER & "};" & _
|
||||
"Server=" & DB_SERVER & ";" & _
|
||||
"Port=" & DB_PORT & ";" & _
|
||||
"Database=" & DB_NAME & ";" & _
|
||||
"User=" & DB_USER & ";" & _
|
||||
"Password=" & DB_PASSWORD & ";" & _
|
||||
"Option=3;" & _
|
||||
"Pooling=True;Max Pool Size=100;"
|
||||
End If
|
||||
End Function
|
||||
|
||||
'-----------------------------------------------------------------------------
|
||||
' FUNCTION: GetEmployeeConnectionString
|
||||
' PURPOSE: Returns the employee database connection string based on USE_EMP_DSN
|
||||
' RETURNS: DSN connection string (production) or direct ODBC string (dev)
|
||||
'-----------------------------------------------------------------------------
|
||||
Function GetEmployeeConnectionString()
|
||||
If USE_EMP_DSN Then
|
||||
' Production: DSN-based connection
|
||||
GetEmployeeConnectionString = "DSN=" & EMP_DB_DSN & ";Uid=" & EMP_DB_DSN_USER & ";Pwd=" & EMP_DB_DSN_PASSWORD
|
||||
Else
|
||||
' Development: Direct ODBC driver connection
|
||||
GetEmployeeConnectionString = "Driver={" & EMP_DB_DRIVER & "};" & _
|
||||
"Server=" & EMP_DB_SERVER & ";" & _
|
||||
"Port=" & EMP_DB_PORT & ";" & _
|
||||
"Database=" & EMP_DB_NAME & ";" & _
|
||||
"User=" & EMP_DB_USER & ";" & _
|
||||
"Password=" & EMP_DB_PASSWORD & ";" & _
|
||||
"Option=3;"
|
||||
End If
|
||||
End Function
|
||||
|
||||
'-----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user