Menu

[2eb2a2]: / install_execution.php  Maximize  Restore  History

Download this file

234 lines (179 with data), 8.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<html>
<head>
<title>deltasql - Installing ...</title>
<link rel="stylesheet" type="text/css" href="deltasql.css">
<link rel="shortcut icon" href="pictures/favicon.ico" />
</head>
<body>
<?php
include("head.inc.php");
include("utils/utils.inc.php");
include("utils/constants.inc.php");
include("utils/installutils.inc.php");
$debug_output_script=false;
echo "<br><br>Collecting data... <br>";
$mysqlrootuser = $_POST['mysqlrootuser'];
if ($mysqlrootuser=="") die("<b>Please enter the mySQL root user</b> <a href=\"install.php\">Back</a>");
$mysqlrootpassword = $_POST['mysqlrootpassword'];
/*
// we do not check for empty mySQL root password as XAMPP installs mySQL with empty
// root password by default
if ($mysqlrootpassword=="") die("<b>Please enter the mySQL root password</b> <a href=\"install.php\">Back</a>");
*/
$deltasqladminpassword = $_POST['deltasqladminpassword'];
if ($deltasqladminpassword=="") die("<b>Please enter the deltasql admin password</b> <a href=\"install.php\">Back</a>");
$dnsname = $_POST['dnsname'];
$mysqlhost = $_POST['mysqlhost'];
if ($mysqlhost=="") die("<b>Please enter the mySQL host</b> <a href=\"install.php\">Back</a>");
$deltasqlschemaname = $_POST['deltasqlschemaname'];
if ($deltasqlschemaname=="") die("<b>Please enter the deltasql schema name</b> <a href=\"install.php\">Back</a>");
$deltasqlschemapassword = $_POST['deltasqlschemapassword'];
if ($deltasqlschemapassword=="") die("<b>Please enter the deltasql schema password</b> <a href=\"install.php\">Back</a>");
$deltasqlschemauser = $_POST['deltasqlschemauser'];
if ($deltasqlschemauser=="") die("<b>Please enter the deltasql schema user</b> <a href=\"install.php\">Back</a>");
$dbdefault = $_POST['frmdbtype'];
$enterpriselogo = $_POST['enterpriselogo'];
$enterpriselinktext = $_POST['enterpriselinktext'];
$enterpriselinkurl = $_POST['enterpriselinkurl'];
$testgroup=$_POST['testgroup'];
$sqlgroup=$_POST['sqlgroup'];
$editiongroup = $_POST['editiongroup'];
$toptengroup = $_POST['toptengroup'];
$emailgroup = $_POST['emailgroup'];
$copypastegroup = $_POST['copypastegroup'];
$statsgroup = $_POST['statsgroup'];
$privacy = $_POST['privacy'];
$dbintegrity = $_POST['dbintegrity'];
$testsystem="false";
$disablesqlhighlightning="false";
$enterpriseedition="false";
$disable_topten_submitters="false";
$emails_enable="true";
$copypaste_enable="0";
$stats_enable="true";
$keep_private="false";
$db_integrity_check="true";
if ($testgroup=="testsystemyes") $testsystem="true";
if ($sqlgroup=="donotusesqlhighlighting") $disablesqlhighlightning="true";
if ($editiongroup=="enterpriseedition") $enterpriseedition = "true";
if ($toptengroup=="no") $disable_topten_submitters = "true";
if ($emailgroup=="no") $emails_enable="false";
if ($copypastegroup=="yes") $copypaste_enable="1";
if ($statsgroup=="no") $stats_enable="false";
if ($privacy=="yes") $keep_private="true";
if ($dbintegrity=="no") $db_integrity_check="false";
if (!$debug_output_script) {
if ($deltasqlschemauser!=$mysqlrootuser) {
echo "Creating mySQL user '$deltasqlschemauser'... <br>";
mysql_connect($mysqlhost, $mysqlrootuser, $mysqlrootpassword);
$queryuseranddb="CREATE USER '$deltasqlschemauser' IDENTIFIED BY '$deltasqlschemapassword';";
$result=mysql_query($queryuseranddb);
if ($result==1) echo "<b>User created</b><br>"; else die("<b>Not possible to create the user '$deltasqlschemauser' (does the user '$deltasqlschemauser' already exist?)</b>");
mysql_close();
}
echo "Creating database schema '$deltasqlschemaname'...<br>";
mysql_connect($mysqlhost, $mysqlrootuser, $mysqlrootpassword);
$queryuseranddb="CREATE DATABASE `$deltasqlschemaname` ;";
$result=mysql_query($queryuseranddb);
if ($result==1) echo "<b>Database created</b><br>"; else die("<b>Not possible to create database '$deltasqlschemaname' (does the schema already exist?)</b>");
echo "Grant usage on $deltasqlchemaname to $deltasqlschemauser ...<br>";
$queryuseranddb="GRANT USAGE ON * . * TO '$deltasqlschemauser'@'$mysqlhost' IDENTIFIED BY '$deltasqlschemapassword' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;";
$result=mysql_query($queryuseranddb);
if ($result==1) echo "<b>Usage grants to user '$deltasqlschemauser' assigned</b><br>";
else die("<b>Not possible to assign user grants to '$deltasqlschemauser'</b>");
echo "Grant all privileges on '$deltasqlschemaname' to'$deltasqlschemauser'@'$mysqlhost' ...<br>";
$queryuseranddb="GRANT ALL PRIVILEGES ON `$deltasqlschemaname` . * TO '$deltasqlschemauser'@'$mysqlhost';";
$result=mysql_query($queryuseranddb);
if ($result==1) echo "<b>All privileges granted to the user</b><br>";
else die("<b>Not possible to assign all privileges to '$deltasqlschemauser'</b>");
echo "Flush privileges...";
$queryprivileges = "FLUSH PRIVILEGES;";
$result = mysql_query($queryprivileges);
if ($result==1) echo "<b>Privileges assigned</b><br>"; else die("<b>Not possible to flush privileges</b>");
mysql_close();
echo "mySQL user and database created. <br>";
echo "mySQL schema creation... <br>";
mysql_connect($mysqlhost, $mysqlrootuser, $mysqlrootpassword);
@mysql_select_db($deltasqlschemaname) or die("Unable to select user database for schema creation with user '$mysqlrootuser'");
executeScripts("db/tables", "table_", 15);
executeScripts("db/data", "data_", 5);
if ($testgroup=="testsystemyes") {
executeScripts("db/test-data", "data_", 53);
}
// generate random salt and store it into database (to be done really only once)
$c = uniqid (rand (),true);
$salt = md5($c);
set_parameter('SECURITY', 'PWD_HASH_SALT', "$salt", '');
// update admin password
$hashpwd=salt_and_hash("$deltasqladminpassword", "$salt");
$query4="UPDATE tbuser SET password='****',passwhash='$hashpwd',encrypted=1 WHERE username='admin';";
mysql_query($query4);
// set TBSYNCHRONIZE to correct tag, used to detect updates
$query5="UPDATE tbsynchronize SET tagname='TAG_deltasql_$ds_schema_version' WHERE versionnr in (0,3);"; // 3 is when test data set is installed
mysql_query($query5);
mysql_close();
echo "mySQL schema created. <br>";
}
// Creating the configuration file :-)
$fh = fopen($configurationfile, 'w') or die("Can't open file $configurationfile <br> You could try to copy example_config.inc.php to config.inc.php and to adapt it then...");
fwrite($fh, "<?php\n");
fwrite($fh, "
//ERROR_REPORTING(E_ALL);
// [mySQL Settings]
\$username=\"$deltasqlschemauser\";
\$password=\"$deltasqlschemapassword\";
\$database=\"$deltasqlschemaname\";
// computer, on which the mySQL instance runs
\$dbserver = \"$mysqlhost\";
// [Apache Settings]
// on which DNS name the Apache deltasql server is published (no SLASH at the end)
\$dns_name=\"$dnsname\";
// [Email Settings]
// The following settings are used, if users need to be notified by email
// of new scripts entered in deltasql
// email settings (all other settings are configured in sendmail)
\$emails_enable=$emails_enable;
\$emails_sender=\"admin@deltasql.org\";
\$emails_subject_identifier=\"[deltasql]\";
//for Unix
//\$sendmail_command=\"/usr/bin/sendmail -t <\";
//\$deltasql_path=\"/var/www/deltasql/\";
//for XAMPP under Windows
\$sendmail_command=\"D:\\\\xampplite\\\\sendmail\\\\sendmail.exe -t <\";
\$deltasql_path=\"D:\\\\xampplite\\\\htdocs\\\\deltasql\\\\\";
// [Edition Settings]
\$dbdefault=\"$dbdefault\";
// If set to true, the wiki and mailing lists are disabled
// The \$enterprise_logo is used as logo
\$enterprise_edition=$enterpriseedition;
\$enterprise_name=\"$enterpriselinktext\";
\$enterprise_website=\"$enterpriselinkurl\";
\$enterprise_logo=\"$enterpriselogo\";
// [Options]
// if all contents of deltasql are available only if logged in
\$keep_private=$keep_private;
// for performance reason, you might want disable SQL highlighting in the
// synchronization form
\$disable_sql_highlighting=$disablesqlhighlightning;
// enables server statistics
\$enable_server_stats=$stats_enable;
// enables top ten statistics
\$disable_topten_submitters=$disable_topten_submitters;
// if set to false, it disables the database consistency check in index.php
// useful for systems where deltasql is developed and where the schema is updated regularly.
\$db_integrity_check=$db_integrity_check;
// default script title when submitting a new script
\$default_script_title=\"db update\";
// if the copy&paste functionality is enabled by default or not
\$default_copypaste = $copypaste_enable;
//script prefix and suffix when outputting scripts as single files
\$script_prefix = \"script_\";
\$script_extension = \".sql\";
");
fwrite($fh, "?>\n");
fclose($fh);
echo "Configuration script created. <br>";
//js_redirect("index.php");
?>
</body>
</html>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.