@@ -120,17 +120,6 @@ public function configure_database()
120120 $ this ->error ('Unable to create MySQL database: ' .$ cf ['database ' ].'. ' );
121121 }
122122
123- //* Create the ISPConfig database user
124- $ query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON ' .$ cf ['database ' ].".* "
125- ."TO ' " .$ cf ['ispconfig_user ' ]."'@' " .$ cf ['host ' ]."' "
126- ."IDENTIFIED BY ' " .$ cf ['ispconfig_password ' ]."'; " ;
127- if (!$ this ->db ->query ($ query )) {
128- $ this ->error ('Unable to create database user: ' .$ cf ['ispconfig_user ' ]);
129- }
130-
131- //* Reload database privelages
132- $ this ->db ->query ('FLUSH PRIVILEGES; ' );
133-
134123 //* Set the database name in the DB library
135124 $ this ->db ->dbName = $ cf ['database ' ];
136125
@@ -156,6 +145,21 @@ public function configure_database()
156145 //** Create the server record in the database
157146 public function add_database_server_record () {
158147
148+ global $ conf ;
149+ $ cf = $ conf ['mysql ' ]; // make $conf['mysql'] more accessible
150+
151+ //* Create the ISPConfig database user
152+ $ query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON ' .$ cf ['database ' ].".* "
153+ ."TO ' " .$ cf ['ispconfig_user ' ]."'@' " .$ cf ['host ' ]."' "
154+ ."IDENTIFIED BY ' " .$ cf ['ispconfig_password ' ]."'; " ;
155+ if (!$ this ->db ->query ($ query )) {
156+ $ this ->error ('Unable to create database user: ' .$ cf ['ispconfig_user ' ]);
157+ }
158+
159+ //* Reload database privelages
160+ $ this ->db ->query ('FLUSH PRIVILEGES; ' );
161+
162+
159163 $ server_ini_content = rf ("tpl/server.ini.master " );
160164 $ server_ini_content = addslashes ($ server_ini_content );
161165
@@ -528,6 +532,8 @@ public function configure_getmail()
528532
529533 public function configure_pureftpd ()
530534 {
535+ global $ conf ;
536+
531537 $ config_dir = $ this ->conf ['pureftpd ' ]['config_dir ' ];
532538
533539 //* configure pam for SMTP authentication agains the ispconfig database
@@ -539,11 +545,11 @@ public function configure_pureftpd()
539545 exec ("chmod 400 $ config_dir/ $ configfile~ " );
540546 }
541547 $ content = rf ('tpl/pureftpd_mysql.conf.master ' );
542- $ content = str_replace ('{mysql_server_ispconfig_user} ' , $ this -> conf ["mysql " ]["ispconfig_user " ], $ content );
543- $ content = str_replace ('{mysql_server_ispconfig_password} ' , $ this -> conf ["mysql " ]["ispconfig_password " ], $ content );
544- $ content = str_replace ('{mysql_server_database} ' , $ this -> conf ["mysql " ]["database " ], $ content );
545- $ content = str_replace ('{mysql_server_ip} ' , $ this -> conf ["mysql " ]["ip " ], $ content );
546- $ content = str_replace ('{server_id} ' , $ this -> conf ["server_id " ], $ content );
548+ $ content = str_replace ('{mysql_server_ispconfig_user} ' , $ conf ["mysql " ]["ispconfig_user " ], $ content );
549+ $ content = str_replace ('{mysql_server_ispconfig_password} ' , $ conf ["mysql " ]["ispconfig_password " ], $ content );
550+ $ content = str_replace ('{mysql_server_database} ' , $ conf ["mysql " ]["database " ], $ content );
551+ $ content = str_replace ('{mysql_server_ip} ' , $ conf ["mysql " ]["ip " ], $ content );
552+ $ content = str_replace ('{server_id} ' , $ conf ["server_id " ], $ content );
547553 wf ("$ config_dir/ $ configfile " , $ content );
548554 exec ("chmod 600 $ config_dir/ $ configfile " );
549555 exec ("chown root:root $ config_dir/ $ configfile " );
@@ -561,9 +567,9 @@ public function configure_mydns()
561567 if (is_file ($ conf ["mydns " ]["config_dir " ].'/ ' .$ configfile )) copy ($ conf ["mydns " ]["config_dir " ].'/ ' .$ configfile ,$ conf ["mydns " ]["config_dir " ].'/ ' .$ configfile .'~ ' );
562568 if (is_file ($ conf ["mydns " ]["config_dir " ].'/ ' .$ configfile .'~ ' )) exec ('chmod 400 ' .$ conf ["mydns " ]["config_dir " ].'/ ' .$ configfile .'~ ' );
563569 $ content = rf ("tpl/ " .$ configfile .".master " );
564- $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ this -> conf ['mysql ' ]['ispconfig_user ' ],$ content );
565- $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ this -> conf ['mysql ' ]['ispconfig_password ' ], $ content );
566- $ content = str_replace ('{mysql_server_database} ' ,$ this -> conf ['mysql ' ]['database ' ],$ content );
570+ $ content = str_replace ('{mysql_server_ispconfig_user} ' ,$ conf ['mysql ' ]['ispconfig_user ' ],$ content );
571+ $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ conf ['mysql ' ]['ispconfig_password ' ], $ content );
572+ $ content = str_replace ('{mysql_server_database} ' ,$ conf ['mysql ' ]['database ' ],$ content );
567573 $ content = str_replace ('{mysql_server_host} ' ,$ conf ["mysql " ]["host " ],$ content );
568574 $ content = str_replace ('{server_id} ' ,$ conf ["server_id " ],$ content );
569575 wf ($ conf ["mydns " ]["config_dir " ].'/ ' .$ configfile ,$ content );
@@ -582,6 +588,8 @@ public function configure_apache()
582588
583589 public function install_ispconfig ()
584590 {
591+ global $ conf ;
592+
585593 $ install_dir = $ this ->conf ['ispconfig_install_dir ' ];
586594
587595 //* Create the ISPConfig installation directory
@@ -614,10 +622,10 @@ public function install_ispconfig()
614622 copy ("$ install_dir/interface/lib/ $ configfile " , "$ install_dir/interface/lib/ $ configfile~ " );
615623 }
616624 $ content = rf ("tpl/ $ configfile.master " );
617- $ content = str_replace ('{mysql_server_ispconfig_user} ' , $ this -> conf ['mysql ' ]['ispconfig_user ' ], $ content );
618- $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ this -> conf ['mysql ' ]['ispconfig_password ' ], $ content );
619- $ content = str_replace ('{mysql_server_database} ' , $ this -> conf ['mysql ' ]['database ' ], $ content );
620- $ content = str_replace ('{mysql_server_host} ' , $ this -> conf ['mysql ' ]['host ' ], $ content );
625+ $ content = str_replace ('{mysql_server_ispconfig_user} ' , $ conf ['mysql ' ]['ispconfig_user ' ], $ content );
626+ $ content = str_replace ('{mysql_server_ispconfig_password} ' ,$ conf ['mysql ' ]['ispconfig_password ' ], $ content );
627+ $ content = str_replace ('{mysql_server_database} ' , $ conf ['mysql ' ]['database ' ], $ content );
628+ $ content = str_replace ('{mysql_server_host} ' , $ conf ['mysql ' ]['host ' ], $ content );
621629 wf ("$ install_dir/interface/lib/ $ configfile " , $ content );
622630
623631 //* Create the config file for ISPConfig server
@@ -626,11 +634,11 @@ public function install_ispconfig()
626634 copy ("$ install_dir/server/lib/ $ configfile " , "$ install_dir/interface/lib/ $ configfile~ " );
627635 }
628636 $ content = rf ("tpl/ $ configfile.master " );
629- $ content = str_replace ('{mysql_server_ispconfig_user} ' , $ this -> conf ['mysql ' ]['ispconfig_user ' ], $ content );
630- $ content = str_replace ('{mysql_server_ispconfig_password} ' , $ this -> conf ['mysql ' ]['ispconfig_password ' ], $ content );
631- $ content = str_replace ('{mysql_server_database} ' , $ this -> conf ['mysql ' ]['database ' ], $ content );
632- $ content = str_replace ('{mysql_server_host} ' , $ this -> conf ['mysql ' ]['host ' ], $ content );
633- $ content = str_replace ('{server_id} ' , $ this -> conf ['server_id ' ], $ content );
637+ $ content = str_replace ('{mysql_server_ispconfig_user} ' , $ conf ['mysql ' ]['ispconfig_user ' ], $ content );
638+ $ content = str_replace ('{mysql_server_ispconfig_password} ' , $ conf ['mysql ' ]['ispconfig_password ' ], $ content );
639+ $ content = str_replace ('{mysql_server_database} ' , $ conf ['mysql ' ]['database ' ], $ content );
640+ $ content = str_replace ('{mysql_server_host} ' , $ conf ['mysql ' ]['host ' ], $ content );
641+ $ content = str_replace ('{server_id} ' , $ conf ['server_id ' ], $ content );
634642 wf ("$ install_dir/server/lib/ $ configfile " , $ content );
635643
636644
@@ -713,7 +721,7 @@ public function install_ispconfig()
713721 // Dont just copy over the virtualhost template but add some custom settings
714722
715723 $ content = rf ("tpl/apache_ispconfig.vhost.master " );
716- $ content = str_replace ('{vhost_port} ' , $ this -> conf ['apache ' ]['vhost_port ' ], $ content );
724+ $ content = str_replace ('{vhost_port} ' , $ conf ['apache ' ]['vhost_port ' ], $ content );
717725 wf ("$ vhost_conf_dir/ispconfig.vhost " , $ content );
718726
719727 //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
0 commit comments