Changeset 376 for trunk/install/install2.php
- Timestamp:
- Sep 24, 2022, 1:11:18 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/install/install2.php
r364 r376 17 17 $DBuserName = mosGetParam( $_POST, 'DBuserName', '' ); 18 18 $DBpassword = mosGetParam( $_POST, 'DBpassword', '' ); 19 $ELEuserName = mosGetParam( $_POST, 'ELEuserName', '' ); 20 $ELEpassword = mosGetParam( $_POST, 'ELEpassword', '' ); 19 21 $DBname = mosGetParam( $_POST, 'DBname', '' ); 20 22 $DBPrefix = mosGetParam( $_POST, 'DBPrefix', 'soraldo' ); … … 49 51 db_err ("stepBack3","The database details provided are incorrect and/or empty."); 50 52 } 51 53 $dsn = "mysql:host=$DBhostname"; #dbname=$DBname"; 54 $opt = [ 55 PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, 56 PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, 57 PDO::ATTR_EMULATE_PREPARES => false, 58 ]; 59 $user=$DBuserName; 60 $password=$DBpassword; 52 61 53 62 if($DBPrefix == '') { 54 63 db_err ('stepBack','Non avete indicato il prefisso tabelle database.'); 55 64 } 65 try { 66 $database = new PDO($dsn, $user, $password, $opt); 67 } 68 catch(PDOException $e) 69 { 70 echo $sql . "<br>" . $e->getMessage();die(); 71 } 72 #sostituire questa riga con le variabili per il nuovo utente e la sua password da inserire nella pagina precedente 73 ######################################## 74 # $DBuserName='eleuser'; $DBpassword='elepass'; 56 75 try{ 57 $database = new PDO("mysql:host=$DBhostname;charset=latin1", $DBuserName, $DBpassword, array(PDO::ATTR_EMULATE_PREPARES => false, 58 PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION)); 59 $sql = "CREATE DATABASE IF NOT EXISTS $DBname; 60 CREATE USER `$DBuserName`@'$DBhostname' IDENTIFIED BY '$DBpassword'; 61 GRANT ALL ON `$DBname`.* TO `$DBuserName`@'$DBhostname'; 62 FLUSH PRIVILEGES;"; 76 $sql = "CREATE DATABASE IF NOT EXISTS $DBname;"; 77 $database->exec($sql); 78 } 79 catch(PDOException $e) 80 { 81 echo $sql . "<br>" . $e->getMessage();die(); 82 } 83 try { 84 $sql="CREATE USER if not exists `$ELEuserName`@'$DBhostname' IDENTIFIED BY '$ELEpassword';"; 85 $database->exec($sql); 86 # $sql= "GRANT ALL ON `$DBname`.* TO `roby`@'$DBhostname';"; 87 # $database->exec($sql); 88 $sql= "GRANT ALL ON `$DBname`.* TO `$ELEuserName`@'$DBhostname';"; 89 $database->exec($sql); 90 $sql= "FLUSH PRIVILEGES;"; 63 91 $database->exec($sql); 64 92 $sql = "use $DBname";
Note:
See TracChangeset
for help on using the changeset viewer.