|
1 /** |
|
2 * Verify credentials for a MySQL database. Assumes we are connecting to BitNami's DB. |
|
3 * @param string Username |
|
4 * @param string Password |
|
5 * @return int 0 if successful, >0 on error. Will push an error string to the stack if >0. |
|
6 */ |
|
7 |
|
8 Function mysql_connect |
|
9 Pop $R1 ; Password |
|
10 Pop $R0 ; Username |
|
11 |
|
12 SetOutPath $PLUGINSDIR |
|
13 File "inst-resources\mysqlutil.php" |
|
14 |
|
15 nsExec::ExecToLog '"$stack_instdir\php\php.exe" "$PLUGINSDIR\mysqlutil.php" $db_port "$R0" "$R1"' |
|
16 Delete "$PLUGINSDIR\mysqlutil.php" |
|
17 ; just be done; nsExec's result is on the top of the stack. |
|
18 FunctionEnd |
|
19 |
|
20 /** |
|
21 * Create a MySQL database and grant privileges on it to the given user. |
|
22 * @param string User to connect with |
|
23 * @param string Password to connect with |
|
24 * @param string Database name |
|
25 * @param string New user |
|
26 * @param string New user's password |
|
27 */ |
|
28 |
|
29 Function mysql_create_db |
|
30 Pop $R5 ; Password |
|
31 Pop $R4 ; User |
|
32 Pop $R3 ; Database |
|
33 Pop $R1 ; Password |
|
34 Pop $R0 ; Username |
|
35 |
|
36 ReadINIStr $R2 "$stack_instdir\properties.ini" "MySQL" "mysql_root_directory" |
|
37 IfFileExists "$R2\data\$R3" 0 DatabaseDoesNotExist |
|
38 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "The database $\"$R3$\" already exists. Do you want to delete and recreate it?$\n$\nIf you choose No, Setup will not alter MySQL's permissions, and you may need to set up permissions manually." IDYES +2 |
|
39 Return |
|
40 |
|
41 DatabaseDoesNotExist: |
|
42 |
|
43 SetOutPath $PLUGINSDIR |
|
44 File "inst-resources\mysqlutil.php" |
|
45 |
|
46 nsExec::ExecToLog '"$stack_instdir\php\php.exe" "$PLUGINSDIR\mysqlutil.php" $db_port "$R0" "$R1" \ |
|
47 "DROP DATABASE IF EXISTS `$R3`; \ |
|
48 CREATE DATABASE `$R3`; \ |
|
49 GRANT ALL PRIVILEGES ON `$R3`.* TO `$R4`@localhost \ |
|
50 IDENTIFIED BY $\'$R5$\' WITH GRANT OPTION;"' |
|
51 Delete "$PLUGINSDIR\mysqlutil.php" |
|
52 FunctionEnd |
|
53 |