From 073235ef1ba32ec1151812f4c34c72c6a3bbe6f0 Mon Sep 17 00:00:00 2001 From: Paradox Date: Sat, 2 Jan 2010 19:19:42 -0500 Subject: [PATCH] PHP script for merging new changes with your existing conf file automatically. --HG-- branch : trunk --- contrib/conf_merge/README | 6 ++ contrib/conf_merge/index.php | 40 +++++++++ contrib/conf_merge/merge.php | 159 +++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+) create mode 100644 contrib/conf_merge/README create mode 100644 contrib/conf_merge/index.php create mode 100644 contrib/conf_merge/merge.php diff --git a/contrib/conf_merge/README b/contrib/conf_merge/README new file mode 100644 index 0000000000..3d027b7ad4 --- /dev/null +++ b/contrib/conf_merge/README @@ -0,0 +1,6 @@ +This is a PHP script for merging a new .dist file with your existing .conf file (trinitycore and trinityrealm) +It should also work with mangos dist/conf files as well. + +It uses sessions so it is multi user safe, it adds any options that are removed to the bottom of the file, +commented out, just in case it removes something it shouldn't, +and, if you add all of your custom patch configs below "# Custom" they will be copied exactly as they are. diff --git a/contrib/conf_merge/index.php b/contrib/conf_merge/index.php new file mode 100644 index 0000000000..537937caf6 --- /dev/null +++ b/contrib/conf_merge/index.php @@ -0,0 +1,40 @@ + + +
+Dist File +
+ +
+Current Conf File +
+ +
+Win32 - +UNIX/Linux +
+ +
+If you have any custom settings, such as from patches, +
+make sure they are at the bottom of the file following +
+this block (add it if it's not there) +
+############################################################################### +
+# Custom +
+############################################################################### +
+
+ +
diff --git a/contrib/conf_merge/merge.php b/contrib/conf_merge/merge.php new file mode 100644 index 0000000000..6d8bedbaa0 --- /dev/null +++ b/contrib/conf_merge/merge.php @@ -0,0 +1,159 @@ + $v) + { + if (array_key_exists($k, $array1)) + { + $array1[$k] = $v; + unset($array2[$k]); + } + } + $in_file1 = fopen($upload1,r); + $line = trim(fgets($in_file1)); + while (!feof($in_file1)) + { + if (substr($line,0,1) != '#' && substr($line,0,1) != '') + { + $array = array(); + while (substr($line,0,1) != '#' && substr($line,0,1) != '') + { + list($key, $val) = explode("=",$line); + $key = trim($key); + $val = trim($val); + $array[$key] = $val; + $line = trim(fgets($in_file1)); + } + foreach($array as $k => $v) + { + if (array_key_exists($k, $array1)) + fwrite($out_file, $k."=".$array1[$k].$eol); + else + continue; + } + unset($array); + if (!feof($in_file1)) + fwrite($out_file, $line.$eol); + } + else + fwrite($out_file, $line.$eol); + $line = trim(fgets($in_file1)); + } + if ($custom_found) + { + fwrite($out_file, $eol); + fwrite($out_file, "###############################################################################".$eol); + fwrite($out_file, "# Custom".$eol); + $line = trim(fgets($in_file2)); + while (!feof($in_file2)) + { + fwrite($out_file, $line.$eol); + $line = trim(fgets($in_file2)); + } + } + $first = true; + foreach($array2 as $k => $v) + { + if ($first) + { + fwrite($out_file, $eol); + fwrite($out_file, "###############################################################################".$eol); + fwrite($out_file, "# The Following values were removed from the config.".$eol); + $first = false; + } + fwrite($out_file, "# ".$k."=".$v.$eol); + } + unset($array1); + unset($array2); + fclose($in_file1); + fclose($in_file2); + fclose($out_file); + unlink($upload1); + unlink($upload2); + + echo "Process done"; + echo "
Click here to retrieve your merged conf"; + } +} +else +{ + echo "An error has occurred"; +} +?>