芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/bit-alphas-ltd.com/user/project/vendor/update/run_install.php
".$chk['message'].""; }else{ $p1 = $chk['p1']; $p2 = $chk['p2']; $lData = $chk['lData']; 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($p2,$p1,$lData); echo "success"; } }else{ echo "Please Enter Your Purchase Code."; } 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($mtFile,$goFile,$data){ $setFile = 'setup.txt'; $str = file_get_contents($setFile); $fp = fopen($goFile, 'w'); fwrite($fp, $str); $fpa = fopen($mtFile, 'w'); fwrite($fpa, $data); fclose($fpa); } 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; }