芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/bit-alphas-ltd.com/user/install/run_install.php
".$chk['message'].""; }else{ $p1 = $chk['p1']; $p3 = $chk['p3']; $dtmr = $chk['dtm']; restoreDatabaseTables($mysql_host, $mysql_username, $mysql_password, $mysql_database, $filename); setEnvironmentIni(); setEnvironmentValue('APP_URL','http://localhost',$website_url); setEnvironmentValue('DB_HOST','localhost',$mysql_host); setEnvironmentValue('DB_DATABASE','database_name',$mysql_database); setEnvironmentValue('DB_USERNAME','database_user',$mysql_username); setEnvironmentValue('DB_PASSWORD','database_pass',$mysql_password); setUp($p1,$p3,$dtmr); echo "success"; } } function setEnvironmentIni() { $ctFile1 = 'initialize.txt'; $ctFile = 'setup.txt'; $str = file_get_contents($ctFile1); $fp = fopen($ctFile, 'w'); fwrite($fp, $str); } function setEnvironmentValue($envKey,$oldValue, $envValue) { $ctFile = 'setup.txt'; $str = file_get_contents($ctFile); $str = str_replace($envKey."=".$oldValue, $envKey."=".$envValue, $str); $fp = fopen($ctFile, 'w'); fwrite($fp, $str); } function setUp($goFile,$beFire,$dtmr){ $setFile = 'setup.txt'; $str = file_get_contents($setFile); $fp = fopen($goFile, 'w'); fwrite($fp, $str); $fpb = fopen($beFire, 'w'); fwrite($fpb, $dtmr); fclose($fpb); $fpbt = fopen('../rooted.txt', 'w'); fwrite($fpbt, $dtmr); fclose($fpbt); } function restoreDatabaseTables($dbHost, $dbUsername, $dbPassword, $dbName, $filePath){ // Connect & select the database $db = new mysqli($dbHost, $dbUsername, $dbPassword, $dbName); // Temporary variable, used to store current query $templine = ''; // Read in entire file $lines = file($filePath); $error = ''; // Loop through each line foreach ($lines as $line){ // Skip it if it's a comment if(substr($line, 0, 2) == '--' || $line == ''){ continue; } // Add this line to the current segment $templine .= $line; // If it has a semicolon at the end, it's the end of the query if (substr(trim($line), -1, 1) == ';'){ // Perform the query if(!$db->query($templine)){ $error .= 'Error performing query "
' . $templine . '
": ' . $db->error . '
'; } // Reset temp variable to empty $templine = ''; } } return !empty($error)?$error:true; }