author | Dan Fuhry <dan@enanocms.org> |
Sat, 21 Aug 2010 18:20:18 -0400 | |
changeset 11 | b62383876fdb |
parent 10 | 014d58335b6d |
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." |
|
3 | 24 |
|
25 |
StrCpy $R2 0 ; Hide manual credential items |
|
26 |
StrCpy $R3 0 ; Hide root password/set manual to disabled |
|
27 |
||
28 |
; if the back button was clicked we might have use manual checked |
|
29 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 3" "State" |
|
30 |
IntCmp $0 1 UseManualIsOn |
|
31 |
||
32 |
StrCpy $R2 1 |
|
33 |
||
34 |
UseManualIsOn: |
|
35 |
||
36 |
; do we need to disable the checkbox? |
|
37 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 2" "State" |
|
38 |
IntCmp $0 1 0 ShowDialog ShowDialog |
|
39 |
||
40 |
StrCpy $R3 1 |
|
41 |
||
42 |
ShowDialog: |
|
43 |
||
0 | 44 |
!insertmacro XPUI_INSTALLOPTIONS_INITDIALOG "DatabaseConfig.ini" |
45 |
Pop $XPUI_HWND |
|
3 | 46 |
|
10
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
47 |
; Our bold font |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
48 |
CreateFont $2 "$(^Font)" "$(^FontSize)" 700 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
49 |
; Paint controls |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
50 |
GetDlgItem $1 $XPUI_HWND 1200 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
51 |
SendMessage $1 ${WM_SETFONT} $2 0 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
52 |
GetDlgItem $1 $XPUI_HWND 1201 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
53 |
SendMessage $1 ${WM_SETFONT} $2 0 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
54 |
GetDlgItem $1 $XPUI_HWND 1214 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
55 |
SendMessage $1 ${WM_SETFONT} $2 0 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
56 |
|
3 | 57 |
IntCmp $R2 1 "" SkipHideManual |
58 |
||
59 |
${ShowRange} $XPUI_HWND 1204 1207 ${SW_HIDE} |
|
60 |
${ShowRange} $XPUI_HWND 1210 1213 ${SW_HIDE} |
|
61 |
||
62 |
SkipHideManual: |
|
63 |
||
64 |
IntCmp $R3 1 "" SkipForceManual |
|
0 | 65 |
|
3 | 66 |
; check the box and disable |
67 |
GetDlgItem $0 $XPUI_HWND 1202 |
|
68 |
SendMessage $0 ${BM_SETCHECK} ${BST_CHECKED} 0 |
|
69 |
EnableWindow $0 0 |
|
70 |
||
71 |
; hide the root password, enter manually is selected |
|
72 |
GetDlgItem $0 $XPUI_HWND 1203 |
|
73 |
ShowWindow $0 ${SW_HIDE} |
|
74 |
GetDlgItem $0 $XPUI_HWND 1209 |
|
75 |
ShowWindow $0 ${SW_HIDE} |
|
0 | 76 |
|
3 | 77 |
SkipForceManual: |
78 |
||
0 | 79 |
!insertmacro XPUI_INSTALLOPTIONS_SHOW |
80 |
FunctionEnd |
|
81 |
||
82 |
Function DatabaseConfigLeave |
|
83 |
StrCmp $XPUI_ABORTED 1 0 +2 |
|
84 |
Return |
|
85 |
||
86 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Settings" "State" |
|
87 |
StrCmp $0 1 RadioButtonClicked |
|
88 |
StrCmp $0 2 RadioButtonClicked |
|
10
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
89 |
StrCmp $0 15 RadioButtonClicked |
0 | 90 |
StrCmp $0 3 UseManualClicked |
91 |
Goto NextClicked |
|
92 |
||
93 |
RadioButtonClicked: |
|
94 |
LockWindow on |
|
10
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
95 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 15" "State" |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
96 |
IntCmp $0 1 SetBypass |
0 | 97 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 1" "State" |
98 |
IntCmp $0 0 SetUseExisting |
|
99 |
||
100 |
; Show root password |
|
101 |
GetDlgItem $0 $XPUI_HWND 1203 |
|
102 |
ShowWindow $0 ${SW_SHOW} |
|
103 |
GetDlgItem $0 $XPUI_HWND 1209 |
|
104 |
ShowWindow $0 ${SW_SHOW} |
|
105 |
||
106 |
GetDlgItem $0 $XPUI_HWND 1202 ; Checkbox |
|
107 |
SendMessage $0 ${BM_SETCHECK} ${BST_UNCHECKED} 0 |
|
108 |
EnableWindow $0 1 |
|
109 |
${ShowRange} $XPUI_HWND 1204 1207 ${SW_HIDE} |
|
110 |
${ShowRange} $XPUI_HWND 1210 1213 ${SW_HIDE} |
|
111 |
LockWindow off |
|
112 |
Abort |
|
113 |
||
114 |
SetUseExisting: |
|
115 |
||
116 |
; Hide root password |
|
117 |
GetDlgItem $0 $XPUI_HWND 1203 |
|
118 |
ShowWindow $0 ${SW_HIDE} |
|
119 |
GetDlgItem $0 $XPUI_HWND 1209 |
|
120 |
ShowWindow $0 ${SW_HIDE} |
|
121 |
||
122 |
GetDlgItem $0 $XPUI_HWND 1202 ; Checkbox |
|
123 |
SendMessage $0 ${BM_SETCHECK} ${BST_CHECKED} 0 |
|
124 |
EnableWindow $0 0 |
|
125 |
${ShowRange} $XPUI_HWND 1204 1207 ${SW_SHOW} |
|
126 |
${ShowRange} $XPUI_HWND 1210 1213 ${SW_SHOW} |
|
127 |
LockWindow off |
|
128 |
Abort |
|
10
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
129 |
|
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
130 |
SetBypass: |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
131 |
|
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
132 |
; Hide root password |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
133 |
GetDlgItem $0 $XPUI_HWND 1203 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
134 |
ShowWindow $0 ${SW_HIDE} |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
135 |
GetDlgItem $0 $XPUI_HWND 1209 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
136 |
ShowWindow $0 ${SW_HIDE} |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
137 |
|
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
138 |
GetDlgItem $0 $XPUI_HWND 1202 ; Checkbox |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
139 |
SendMessage $0 ${BM_SETCHECK} ${BST_UNCHECKED} 0 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
140 |
EnableWindow $0 0 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
141 |
${ShowRange} $XPUI_HWND 1204 1207 ${SW_HIDE} |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
142 |
${ShowRange} $XPUI_HWND 1210 1213 ${SW_HIDE} |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
143 |
LockWindow off |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
144 |
Abort |
0 | 145 |
|
146 |
UseManualClicked: |
|
147 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 3" "State" |
|
148 |
IntOp $0 $0 * ${SW_SHOW} |
|
149 |
${ShowRange} $XPUI_HWND 1204 1207 $0 |
|
150 |
${ShowRange} $XPUI_HWND 1210 1213 $0 |
|
151 |
Abort |
|
152 |
||
153 |
NextClicked: |
|
154 |
||
155 |
; Figure out how we want to go about this. |
|
156 |
StrCpy $db_needroot 0 |
|
10
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
157 |
StrCpy $skip_install 0 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
158 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 15" "State" |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
159 |
IntCmp $0 1 BypassInstaller |
0 | 160 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 1" "State" |
161 |
IntCmp $0 0 UseCustomLogin |
|
162 |
||
163 |
; Validate based on root password. |
|
164 |
StrCpy $db_needroot 1 |
|
165 |
ReadINIStr $db_rootpass "$PLUGINSDIR\DatabaseConfig.ini" "Field 4" "State" |
|
166 |
${db_connect} $1 "$db_rootuser" "$db_rootpass" |
|
167 |
IntCmp $1 0 +3 |
|
168 |
MessageBox MB_OK|MB_ICONEXCLAMATION "The $db_dbmsname root password you entered is incorrect. Please re-enter it." |
|
169 |
Abort |
|
170 |
||
171 |
; Does the user have their own credentials? |
|
172 |
ReadINIStr $0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 3" "State" |
|
173 |
IntCmp $0 0 GenerateRandomLogin |
|
174 |
||
175 |
UseCustomLogin: |
|
176 |
||
177 |
; Pull database settings from dialog |
|
178 |
ReadINIStr $db_name "$PLUGINSDIR\DatabaseConfig.ini" "Field 5" "State" |
|
179 |
ReadINIStr $db_user "$PLUGINSDIR\DatabaseConfig.ini" "Field 6" "State" |
|
180 |
ReadINIStr $db_password "$PLUGINSDIR\DatabaseConfig.ini" "Field 7" "State" |
|
181 |
ReadINIStr $R0 "$PLUGINSDIR\DatabaseConfig.ini" "Field 8" "State" |
|
182 |
||
183 |
; Check password length |
|
184 |
; but don't if the user entered credentials that already exist |
|
185 |
IntCmp $db_needroot 0 SkipLengthCheck |
|
186 |
StrLen $R1 $R0 |
|
187 |
IntCmp $R1 6 +3 0 +3 |
|
188 |
MessageBox MB_OK|MB_ICONEXCLAMATION "Please choose a database password that is at least 6 characters in length." |
|
189 |
Abort |
|
190 |
||
191 |
SkipLengthCheck: |
|
192 |
; Check password/confirm fields |
|
193 |
StrCmp $db_password $R0 +3 |
|
194 |
MessageBox MB_OK|MB_ICONEXCLAMATION "The passwords you entered do not match. Please enter them again." |
|
195 |
Abort |
|
196 |
||
197 |
; 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
|
198 |
IntCmp $db_needroot 0 +3 |
0c0d5dadfca3
Added LockWindow calls to all custom page exit paths to smooth transitions
Dan
parents:
0
diff
changeset
|
199 |
LockWindow on |
0 | 200 |
Return |
201 |
||
202 |
${db_connect} $R0 $db_user $db_password |
|
203 |
IntCmp $R0 0 +3 |
|
204 |
; Database auth failed |
|
205 |
MessageBox MB_OK|MB_ICONEXCLAMATION "The username and password you entered are invalid. Please enter them again." |
|
206 |
Abort |
|
207 |
||
10
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
208 |
/* |
0 | 209 |
; This can be an error-prone process because entering credentials manually will keep |
210 |
; the installer from touching the database. If tables already exist, Enano's installer |
|
211 |
; will throw an error. Confirm this with the user. |
|
10
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
212 |
MessageBox MB_YESNO|MB_ICONQUESTION "Are you sure you want to use manual database settings?$\r$\n\ |
0 | 213 |
$\r$\n\ |
10
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
214 |
Without your database root password, Setup cannot change your existing database. If there is an Enano installation \ |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
215 |
in this database already, the installer will fail with this option; you should go back and choose the $\"Upgrade or \ |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
216 |
configure database manually$\" option." IDYES +2 |
0 | 217 |
Abort ; on No |
10
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
218 |
*/ |
0 | 219 |
|
2
0c0d5dadfca3
Added LockWindow calls to all custom page exit paths to smooth transitions
Dan
parents:
0
diff
changeset
|
220 |
LockWindow on |
0 | 221 |
Return |
222 |
||
10
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
223 |
BypassInstaller: |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
224 |
|
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
225 |
; No validation - the user opted to configure everything manually. |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
226 |
StrCpy $skip_install 1 |
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
227 |
|
0 | 228 |
GenerateRandomLogin: |
229 |
StrCpy $db_name "bn_enanocms" |
|
230 |
StrCpy $db_user "bn_enanocms" |
|
231 |
Call GenerateRandomPassword |
|
232 |
Pop $db_password |
|
2
0c0d5dadfca3
Added LockWindow calls to all custom page exit paths to smooth transitions
Dan
parents:
0
diff
changeset
|
233 |
LockWindow on |
0 | 234 |
Return |
235 |
||
236 |
FunctionEnd |
|
237 |
||
238 |
Function GenerateRandomPassword |
|
239 |
SetOutPath $PLUGINSDIR |
|
240 |
File "inst-resources\randompass.php" |
|
241 |
nsExec::ExecToStack '"$stack_instdir\php\php.exe" "$PLUGINSDIR\randompass.php"' |
|
242 |
Pop $R0 |
|
243 |
FunctionEnd |
|
10
014d58335b6d
Changed behavior of the entire database selection process. A real "upgrade"/"don't touch the database" option was added, and the old options unconditionally delete the database.
Dan Fuhry <dan@enanocms.org>
parents:
3
diff
changeset
|
244 |