author | Dan |
Wed, 27 May 2009 01:17:11 -0400 | |
changeset 2 | 0c0d5dadfca3 |
parent 0 | 67e1cc6cd929 |
child 3 | 0cce88c7cf7c |
permissions | -rw-r--r-- |
0 | 1 |
!macro ShowRange hwnd low high value |
2 |
!define tmp_id ${__LINE__} |
|
3 |
StrCpy $R0 ${low} |
|
4 |
loop.${tmp_id}: |
|
5 |
GetDlgItem $R1 ${hwnd} $R0 |
|
6 |
ShowWindow $R1 ${value} |
|
7 |
IntOp $R0 $R0 + 1 |
|
8 |
IntCmp $R0 ${high} loop.${tmp_id} loop.${tmp_id} |
|
9 |
||
10 |
!undef tmp_id |
|
11 |
!macroend |
|
12 |
!define ShowRange "!insertmacro ShowRange" |
|
13 |
||
14 |
Page custom DatabaseConfigCreate DatabaseConfigLeave " - Database configuration" |
|
15 |
||
16 |
Function DatabaseConfigCreate |
|
17 |
StrCmp $XPUI_ABORTED 1 0 +2 |
|
18 |
Return |
|
19 |
!insertmacro XPUI_INSTALLOPTIONS_EXTRACT_AS "pages\DatabaseConfig.ini" "DatabaseConfig.ini" |
|
20 |
!insertmacro XPUI_HEADER_TEXT "Database configuration" "Configure how $(^Name) will access your database." |
|
21 |
WriteINIStr "$PLUGINSDIR\DatabaseConfig.ini" "Field 9" "Text" \ |
|
22 |
"$(^Name) needs database access to work properly. Setup can create a database for you if you provide \ |
|
23 |
$db_dbmsname's administration password, or you can choose to enter credentials for a database that already exists." |
|
24 |
||
25 |
!insertmacro XPUI_INSTALLOPTIONS_INITDIALOG "DatabaseConfig.ini" |
|
26 |
Pop $XPUI_HWND |
|
27 |
||
28 |
${ShowRange} $XPUI_HWND 1204 1207 ${SW_HIDE} |
|
29 |
${ShowRange} $XPUI_HWND 1210 1213 ${SW_HIDE} |
|
30 |
||
31 |
!insertmacro XPUI_INSTALLOPTIONS_SHOW |
|
32 |
FunctionEnd |
|
33 |
||
34 |
Function DatabaseConfigLeave |
|
35 |
StrCmp $XPUI_ABORTED 1 0 +2 |
|
36 |
Return |
|
37 |
||
38 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Settings" "State" |
|
39 |
StrCmp $0 1 RadioButtonClicked |
|
40 |
StrCmp $0 2 RadioButtonClicked |
|
41 |
StrCmp $0 3 UseManualClicked |
|
42 |
Goto NextClicked |
|
43 |
||
44 |
RadioButtonClicked: |
|
45 |
LockWindow on |
|
46 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 1" "State" |
|
47 |
IntCmp $0 0 SetUseExisting |
|
48 |
||
49 |
; Show root password |
|
50 |
GetDlgItem $0 $XPUI_HWND 1203 |
|
51 |
ShowWindow $0 ${SW_SHOW} |
|
52 |
GetDlgItem $0 $XPUI_HWND 1209 |
|
53 |
ShowWindow $0 ${SW_SHOW} |
|
54 |
||
55 |
GetDlgItem $0 $XPUI_HWND 1202 ; Checkbox |
|
56 |
SendMessage $0 ${BM_SETCHECK} ${BST_UNCHECKED} 0 |
|
57 |
EnableWindow $0 1 |
|
58 |
${ShowRange} $XPUI_HWND 1204 1207 ${SW_HIDE} |
|
59 |
${ShowRange} $XPUI_HWND 1210 1213 ${SW_HIDE} |
|
60 |
LockWindow off |
|
61 |
Abort |
|
62 |
||
63 |
SetUseExisting: |
|
64 |
||
65 |
; Hide root password |
|
66 |
GetDlgItem $0 $XPUI_HWND 1203 |
|
67 |
ShowWindow $0 ${SW_HIDE} |
|
68 |
GetDlgItem $0 $XPUI_HWND 1209 |
|
69 |
ShowWindow $0 ${SW_HIDE} |
|
70 |
||
71 |
GetDlgItem $0 $XPUI_HWND 1202 ; Checkbox |
|
72 |
SendMessage $0 ${BM_SETCHECK} ${BST_CHECKED} 0 |
|
73 |
EnableWindow $0 0 |
|
74 |
${ShowRange} $XPUI_HWND 1204 1207 ${SW_SHOW} |
|
75 |
${ShowRange} $XPUI_HWND 1210 1213 ${SW_SHOW} |
|
76 |
LockWindow off |
|
77 |
Abort |
|
78 |
||
79 |
UseManualClicked: |
|
80 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 3" "State" |
|
81 |
IntOp $0 $0 * ${SW_SHOW} |
|
82 |
${ShowRange} $XPUI_HWND 1204 1207 $0 |
|
83 |
${ShowRange} $XPUI_HWND 1210 1213 $0 |
|
84 |
Abort |
|
85 |
||
86 |
NextClicked: |
|
87 |
||
88 |
; Figure out how we want to go about this. |
|
89 |
StrCpy $db_needroot 0 |
|
90 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 1" "State" |
|
91 |
IntCmp $0 0 UseCustomLogin |
|
92 |
||
93 |
; Validate based on root password. |
|
94 |
StrCpy $db_needroot 1 |
|
95 |
ReadINIStr $db_rootpass "$PLUGINSDIR\DatabaseConfig.ini" "Field 4" "State" |
|
96 |
${db_connect} $1 "$db_rootuser" "$db_rootpass" |
|
97 |
IntCmp $1 0 +3 |
|
98 |
MessageBox MB_OK|MB_ICONEXCLAMATION "The $db_dbmsname root password you entered is incorrect. Please re-enter it." |
|
99 |
Abort |
|
100 |
||
101 |
; Does the user have their own credentials? |
|
102 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 3" "State" |
|
103 |
IntCmp $0 0 GenerateRandomLogin |
|
104 |
||
105 |
UseCustomLogin: |
|
106 |
||
107 |
; Pull database settings from dialog |
|
108 |
ReadINIStr $db_name "$PLUGINSDIR\DatabaseConfig.ini" "Field 5" "State" |
|
109 |
ReadINIStr $db_user "$PLUGINSDIR\DatabaseConfig.ini" "Field 6" "State" |
|
110 |
ReadINIStr $db_password "$PLUGINSDIR\DatabaseConfig.ini" "Field 7" "State" |
|
111 |
ReadINIStr $R0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 8" "State" |
|
112 |
||
113 |
; Check password length |
|
114 |
; but don't if the user entered credentials that already exist |
|
115 |
IntCmp $db_needroot 0 SkipLengthCheck |
|
116 |
StrLen $R1 $R0 |
|
117 |
IntCmp $R1 6 +3 0 +3 |
|
118 |
MessageBox MB_OK|MB_ICONEXCLAMATION "Please choose a database password that is at least 6 characters in length." |
|
119 |
Abort |
|
120 |
||
121 |
SkipLengthCheck: |
|
122 |
; Check password/confirm fields |
|
123 |
StrCmp $db_password $R0 +3 |
|
124 |
MessageBox MB_OK|MB_ICONEXCLAMATION "The passwords you entered do not match. Please enter them again." |
|
125 |
Abort |
|
126 |
||
127 |
; If we're root, we can assume the login doesn't exist yet, so skip the validation |
|
2
0c0d5dadfca3
Added LockWindow calls to all custom page exit paths to smooth transitions
Dan
parents:
0
diff
changeset
|
128 |
IntCmp $db_needroot 0 +3 |
0c0d5dadfca3
Added LockWindow calls to all custom page exit paths to smooth transitions
Dan
parents:
0
diff
changeset
|
129 |
LockWindow on |
0 | 130 |
Return |
131 |
||
132 |
${db_connect} $R0 $db_user $db_password |
|
133 |
IntCmp $R0 0 +3 |
|
134 |
; Database auth failed |
|
135 |
MessageBox MB_OK|MB_ICONEXCLAMATION "The username and password you entered are invalid. Please enter them again." |
|
136 |
Abort |
|
137 |
||
138 |
; This can be an error-prone process because entering credentials manually will keep |
|
139 |
; the installer from touching the database. If tables already exist, Enano's installer |
|
140 |
; will throw an error. Confirm this with the user. |
|
141 |
MessageBox MB_YESNO|MB_ICONQUESTION "Do you really want to use manual database settings?$\r$\n\ |
|
142 |
$\r$\n\ |
|
143 |
Setup will not attempt to modify your existing database. If there is \ |
|
144 |
already an installation of $(^Name) in the database, the installer will \ |
|
145 |
fail. This option is recommended only for advanced users." IDYES +2 |
|
146 |
Abort ; on No |
|
147 |
||
2
0c0d5dadfca3
Added LockWindow calls to all custom page exit paths to smooth transitions
Dan
parents:
0
diff
changeset
|
148 |
LockWindow on |
0 | 149 |
Return |
150 |
||
151 |
GenerateRandomLogin: |
|
152 |
StrCpy $db_name "bn_enanocms" |
|
153 |
StrCpy $db_user "bn_enanocms" |
|
154 |
Call GenerateRandomPassword |
|
155 |
Pop $db_password |
|
2
0c0d5dadfca3
Added LockWindow calls to all custom page exit paths to smooth transitions
Dan
parents:
0
diff
changeset
|
156 |
LockWindow on |
0 | 157 |
Return |
158 |
||
159 |
FunctionEnd |
|
160 |
||
161 |
Function GenerateRandomPassword |
|
162 |
SetOutPath $PLUGINSDIR |
|
163 |
File "inst-resources\randompass.php" |
|
164 |
nsExec::ExecToStack '"$stack_instdir\php\php.exe" "$PLUGINSDIR\randompass.php"' |
|
165 |
Pop $R0 |
|
166 |
FunctionEnd |