function installsql() { global $app, $ehcpinstalldir, $ip, $lang, $user_email, $user_name, $ehcpmysqlpass, $rootpass, $newrootpass, $ehcpadminpass; bosluk2(); if ($newrootpass != '') { $tmprootpass = $newrootpass; } else { $tmprootpass = $rootpass; } echo "extracting and importing sql to mysql:\n"; # check if ehcp db already exists... $baglanti = mysqli_connect("localhost", "root", $tmprootpass); $ret = mysqli_select_db($baglanti, "ehcp"); if ($ret === true) { echo "seems to found old ehcp db..(will try to backup existing ehcp db with timestamp... )"; echo "\nATTENTION ! EHCP DB WILL BE DROPPED IF EXISTS, EXIT NOW (by ctrl-C) if you don't want !\n\n"; sleep(10); # backup any existing ehcp db, if any #$ehcpdb="ehcpbackup".date("YmdHis"); # disabled because gives error on some systems: Fatal error: date(): Timezone database is corrupt - this should *never* happen! in ... $ehcpdb = "ehcpbackup" . exec('date +%Y%m%d%H%M%S'); passthru("cp -Rf /var/lib/mysql/ehcp /var/lib/mysql/{$ehcpdb}"); passthru("chown -Rf mysql:mysql /var/lib/mysql/{$ehcpdb}"); #--end backup ehcp db } # end check.. # echo 'var_dump($ehcpmysqlpass,$rootpass,$newrootpass,$ehcpadminpass);\n'; # var_dump($ehcpmysqlpass,$rootpass,$newrootpass,$ehcpadminpass); # burasi replace ile olacagina, writeoutput ile yapilabilir: replacelineinfile('$dbrootpass='******'{$tmprootpass}';", $ehcpinstalldir . "/config.php"); replacelineinfile('$dbpass='******'{$ehcpmysqlpass}';", $ehcpinstalldir . "/config.php"); if ($lang != 'en') { replacelineinfile('$defaultlanguage=', "\$defaultlanguage='{$lang}';", $ehcpinstalldir . "/config.php"); } $filecontent = "\n\tdrop database if exists ehcp;\n\tcreate database ehcp;\n\tgrant all privileges on ehcp.* to ehcp@'localhost' identified by '{$ehcpmysqlpass}' with grant option;\n\tgrant all privileges on ehcp.* to ehcp@'127.0.0.1' identified by '{$ehcpmysqlpass}' with grant option;\n\tflush privileges;\n\t"; if ($newrootpass != '') { # if we need to change root pass... in versions prior to 0.29, mysql root pass could be changed from within ehcp install. $filecontent .= "SET PASSWORD FOR 'root'@'localhost'=PASSWORD('{$newrootpass}');"; } writeoutput($ehcpinstalldir . "/ehcp1.sql", $filecontent, "w"); echo "executing: mysql -u root --password='******' < {$ehcpinstalldir}/ehcp1.sql \n "; passthru("mysql -u root --password='******' < {$ehcpinstalldir}/ehcp1.sql"); # root pass changes here... if different , disabled echo "importing ehcp sql: \n"; passthru("mysql -D ehcp -u root --password='******' < {$ehcpinstalldir}/ehcp.sql"); # passthru("mysql -u root --password=$tmprootpass < $ehcpinstalldir/ehcp_html.sql"); # bu niye vardı tam hatırlamıyorum. heralde html iceren sql burdaydı... passthru("cp {$ehcpinstalldir}/config.php ./config.php"); passthru("rm {$ehcpinstalldir}/ehcp1.sql"); # removed for security, root pass was there.. $app = new Application(); $app->connecttodb(); $app->set_ehcp_dir($ehcpinstalldir); $app->setConfigValue("ehcpdir", $ehcpinstalldir); $app->setConfigValue("dnsip", $ip); // this configures dns ip to be used by ehcp, may be changed if using another dns server $app->setConfigValue('adminname', $user_name); $app->setConfigValue('adminemail', $user_email); // set email to send info about ehcp install to installer(admin)... $app->executequery("UPDATE panelusers SET password=MD5('{$ehcpadminpass}'),email='{$user_email}' WHERE panelusername='******'"); $app->commandline = true; }