init deps
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
==== PHP merger (index.php + merge.php) ====
|
||||
|
||||
This is a PHP script for merging a new .dist file with your existing .conf file (worldserver.conf.dist and bnetserver.conf.dist)
|
||||
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.
|
||||
|
||||
==== Perl merger (tc-conf-merger.pl) ====
|
||||
|
||||
Perl based command line merger script. This script feeds a .conf.dist file with variables that exist in an old .conf file,
|
||||
comments and custom options are ignored.
|
||||
@@ -0,0 +1,169 @@
|
||||
<!--
|
||||
@title Configuration file merger/differ.
|
||||
@about This script allows you to diff two config files and select which value to pick between the two.
|
||||
It will then give you an updated configuration file with the settings you chose.
|
||||
How-to: a) Paste both versions of your config file, submit the form.
|
||||
b) Select values you want to keep in the next form, then submit said form.
|
||||
c) Copy the output'd config file and profit!
|
||||
Note: if either one of your config file has custom values, make sure that it is set to be the NEW
|
||||
config file on the first step (right hand textarea). This will be adressed at a later date.
|
||||
@author Warpten
|
||||
@date 05/17/2014
|
||||
@license GNU GPL v2(GPL)
|
||||
@version 0.0.1
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title><world/auth>server.conf diff</title>
|
||||
<style type="text/css">
|
||||
form * { font-family: Verdana; font-size: 11px; }
|
||||
form#step1 { position: relative; width: 800px; }
|
||||
form#step2 { width: 500px; }
|
||||
form > div { position: absolute; width: 50%; height: 500px; }
|
||||
form > div:nth-child(1) { right: 0px; }
|
||||
textarea { width: 90%; height: 500px; }
|
||||
h3 { display: block; margin: 3px; padding: auto; text-align: center; }
|
||||
input.valueName { border: 0px; background-color: white; }
|
||||
form > p { margin: 0; padding: 3px; border-bottom: 1px solid black; }
|
||||
textarea#result { width: 1000px; }
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
|
||||
function printIndent($string, $indent = 1)
|
||||
{
|
||||
echo str_pad("\r\n" . $string, $indent, " ");
|
||||
}
|
||||
|
||||
if (!isset($_POST['step']))
|
||||
{
|
||||
?>
|
||||
<form action="" method="POST" id="step1">
|
||||
<div>
|
||||
<h3>Paste the new configuration file</h3>
|
||||
<textarea name="leftFile"></textarea>
|
||||
</div><div>
|
||||
<h3>Paste the old configuration file</h3>
|
||||
<textarea name="rightFile"></textarea>
|
||||
<input type="submit" value="Compare files" />
|
||||
</div>
|
||||
<input type="hidden" name="step" value="0" />
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
else if ($_POST['step'] == 0)
|
||||
{
|
||||
if (@empty($_POST['leftFile']) || @empty($_POST['rightFile']))
|
||||
printf("You did not provide either the old or the new configuration file.<br />");
|
||||
|
||||
define('EOL', "\n\n");
|
||||
$settingsData = array();
|
||||
|
||||
// Process them
|
||||
$newFile = explode(EOL, $_POST['leftFile']);
|
||||
$oldFile = explode(EOL, $_POST['rightFile']);
|
||||
|
||||
for ($i = 0, $o = count($oldFile); $i < $o; ++$i)
|
||||
{
|
||||
$oldFile[$i] = explode(PHP_EOL, $oldFile[$i]);
|
||||
for ($j = 0, $p = count($oldFile[$i]); $j < $p; ++$j)
|
||||
{
|
||||
$currentLine = $oldFile[$i][$j];
|
||||
if (preg_match("#^([A-Z.]+) = (?:\"?)(.*)(?:\"?)$#iU", $currentLine, $data) !== false)
|
||||
if (strlen($data[1]) != 0)
|
||||
$settingsData[$data[1]]["oldValue"] = str_replace('"', '', trim($data[2]));
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0, $o = count($newFile); $i < $o; ++$i)
|
||||
{
|
||||
$newFile[$i] = explode(PHP_EOL, $newFile[$i]);
|
||||
for ($j = 0, $p = count($newFile[$i]); $j < $p; ++$j)
|
||||
{
|
||||
$currentLine = $newFile[$i][$j];
|
||||
if (preg_match("#^([A-Z.]+) = (?:\"?)(.*)(?:\"?)$#iU", $currentLine, $data) !== false)
|
||||
if (strlen($data[1]) != 0)
|
||||
$settingsData[$data[1]]["newValue"] = str_replace('"', '', trim($data[2]));
|
||||
}
|
||||
}
|
||||
|
||||
printIndent("<p>Please select values you want to keep. Note the script will default to new values, unless said <i>new</i> value does not exist.<br />You also can take advantage of this form and edit fields.</p>", 1);
|
||||
printIndent('<form action="" method="POST" id="step2">', 1);
|
||||
|
||||
foreach ($settingsData as $itemName => &$values)
|
||||
{
|
||||
$displayOld = isset($values['oldValue']) ? $values['oldValue'] : "Value missing";
|
||||
$displayNew = isset($values['newValue']) ? $values['newValue'] : "Value missing";
|
||||
|
||||
if ($displayOld == $displayNew)
|
||||
continue;
|
||||
|
||||
$line = '<p><input type="text" class="valueName" name="nameCross[]" value="' . $itemName . '" />';
|
||||
$line .= '<input type="radio" name="optionSelector[' . $itemName . ']" value="oldValue" ' . ($displayOld != "Value missing" ? "checked" : "") . '/>';
|
||||
$line .= '<input type="text" name="oldValue[]" value="' . $displayOld . '" /> ';
|
||||
$line .= '<input type="radio" name="optionSelector[' . $itemName . ']" value="newValue" ' . ($displayNew != "Value missing" ? "checked" : "") . '/>';
|
||||
$line .= '<input type="text" name="newValue[]" value="' . $displayNew . '" /></p>';
|
||||
printIndent($line, 2);
|
||||
}
|
||||
printIndent('<input type="hidden" name="step" value="1" />', 2);
|
||||
printIndent('<input type="submit" value="Gief resulting configuration file" />', 2);
|
||||
printIndent('<input type="hidden" name="file" value="' . htmlspecialchars($_POST['rightFile']) . '" />', 2);
|
||||
printIndent('</form>', 1);
|
||||
}
|
||||
else if ($_POST['step'] == 1)
|
||||
{
|
||||
$errors = array();
|
||||
|
||||
$confFile = $_POST['file'];
|
||||
|
||||
foreach ($_POST['optionSelector'] as $valueName => &$keyName)
|
||||
{
|
||||
$definiteValueIndex = -1;
|
||||
foreach ($_POST['nameCross'] as $index => &$key)
|
||||
{
|
||||
if ($key == $valueName)
|
||||
{
|
||||
$definiteValueIndex = $index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($definiteValueIndex == -1)
|
||||
{
|
||||
// TODO: Handle custom values that get lost
|
||||
continue;
|
||||
}
|
||||
|
||||
$newStr = $_POST[$keyName][$definiteValueIndex];
|
||||
$oldStr = $_POST[$keyName == "oldValue" ? "newValue" : "oldValue"][$definiteValueIndex];
|
||||
if (!ctype_digit($newStr))
|
||||
$newStr = '"' . $newStr . '"';
|
||||
if (!ctype_digit($oldStr))
|
||||
$oldStr = '"' . $oldStr . '"';
|
||||
|
||||
$newValueString = $valueName . " = " . $newStr;
|
||||
$oldValueString = $valueName . " = " . $oldStr;
|
||||
$confFile = str_replace($oldValueString, $newValueString, $confFile);
|
||||
}
|
||||
echo "<p>Here is your new configuration file:</p>";
|
||||
echo '<form><textarea id="result">';
|
||||
printf('%s', $confFile);
|
||||
echo '</textarea></form>';
|
||||
|
||||
if (!empty($errors))
|
||||
{
|
||||
echo "<p>The following errors happened during processing:</p><ul><li>";
|
||||
echo implode("</li><li>", $errors);
|
||||
echo "</li>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/*
|
||||
* Project Name: Config File Merge For Mangos/Trinity Server
|
||||
* Date: 01.01.2010 inital version (0.0.1a)
|
||||
* Author: Paradox
|
||||
* Copyright: Paradox
|
||||
* Email: [email protected] (paypal email)
|
||||
* License: GNU General Public License v2(GPL)
|
||||
*/
|
||||
?>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
|
||||
<FORM enctype="multipart/form-data" ACTION="merge.php" METHOD="POST">
|
||||
Dist File
|
||||
<br />
|
||||
<INPUT name="File1" TYPE="file">
|
||||
<br />
|
||||
Current Conf File
|
||||
<br />
|
||||
<INPUT name="File2" TYPE="file">
|
||||
<br />
|
||||
<INPUT TYPE=RADIO NAME="eol" VALUE="0" CHECKED >Win32 -
|
||||
<INPUT TYPE=RADIO NAME="eol" VALUE="1" >UNIX/Linux
|
||||
<br />
|
||||
<INPUT TYPE="submit" VALUE="Submit">
|
||||
<br />
|
||||
If you have any custom settings, such as from patches,
|
||||
<br />
|
||||
make sure they are at the bottom of the file following
|
||||
<br />
|
||||
this block (add it if it's not there)
|
||||
<br />
|
||||
###############################################################################
|
||||
<br />
|
||||
# Custom
|
||||
<br />
|
||||
###############################################################################
|
||||
<br />
|
||||
<br />
|
||||
|
||||
</FORM>
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
/*
|
||||
* Project Name: Config File Merge For Mangos/Trinity Server
|
||||
* Date: 01.01.2010 inital version (0.0.1a)
|
||||
* Author: Paradox
|
||||
* Copyright: Paradox
|
||||
* Email: [email protected] (paypal email)
|
||||
* License: GNU General Public License v2(GPL)
|
||||
*/
|
||||
if (!empty($_FILES['File1']) && !empty($_FILES['File2']))
|
||||
{
|
||||
session_id();
|
||||
session_start();
|
||||
$basedir = "merge";
|
||||
$eol = "\r\n";
|
||||
if ($_POST['eol'])
|
||||
$eol = "\n";
|
||||
else
|
||||
$eol = "\r\n";
|
||||
if (!file_exists($basedir))
|
||||
mkdir($basedir);
|
||||
if (!file_exists($basedir."/".session_id()))
|
||||
mkdir($basedir."/".session_id());
|
||||
$upload1 = $basedir."/".session_id()."/".basename($_FILES['File1']['name']);
|
||||
$upload2 = $basedir."/".session_id()."/".basename($_FILES['File2']['name']);
|
||||
$newconfig = $basedir."/".session_id()."/trinitycore.conf.merged";
|
||||
$out_file = fopen($newconfig, w);
|
||||
$success = false;
|
||||
if (move_uploaded_file($_FILES['File1']['tmp_name'], $upload1))
|
||||
{
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$success = false;
|
||||
}
|
||||
if (move_uploaded_file($_FILES['File2']['tmp_name'], $upload2))
|
||||
{
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$success = false;
|
||||
}
|
||||
|
||||
if ($success)
|
||||
{
|
||||
$custom_found = false;
|
||||
$in_file1 = fopen($upload1,r);
|
||||
$in_file2 = fopen($upload2,r);
|
||||
$array1 = array();
|
||||
$array2 = array();
|
||||
$line = trim(fgets($in_file1));
|
||||
while (!feof($in_file1))
|
||||
{
|
||||
if ((substr($line,0,1) != '#' && substr($line,0,1) != ''))
|
||||
{
|
||||
list($key, $val) = explode("=",$line);
|
||||
$key = trim($key);
|
||||
$val = trim($val);
|
||||
$array1[$key] = $val;
|
||||
}
|
||||
$line = trim(fgets($in_file1));
|
||||
}
|
||||
$line = trim(fgets($in_file2));
|
||||
while (!feof($in_file2) && !$custom_found)
|
||||
{
|
||||
if (substr($line,0,1) != '#' && substr($line,0,1) != '')
|
||||
{
|
||||
list($key, $val) = explode("=",$line);
|
||||
$key = trim($key);
|
||||
$val = trim($val);
|
||||
$array2[$key] = $val;
|
||||
}
|
||||
if (strtolower($line) == "# custom")
|
||||
$custom_found = true;
|
||||
else
|
||||
$line = trim(fgets($in_file2));
|
||||
}
|
||||
fclose($in_file1);
|
||||
foreach($array2 as $k => $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 "<br /><a href=".$newconfig.">Click here to retrieve your merged conf</a>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "An error has occurred";
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
# Author: leak
|
||||
# Date: 2010-12-06
|
||||
# Note: Based on conf file format of rev 10507
|
||||
|
||||
use strict;
|
||||
|
||||
if (@ARGV != 3)
|
||||
{
|
||||
print("Usage:\ntc-conf-merger.pl <path to new .conf.dist> <path to old .conf> <path to output .conf>\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (! -e $ARGV[0])
|
||||
{
|
||||
print("No file found at: ".$ARGV[0]);
|
||||
exit(1);
|
||||
}
|
||||
elsif (! -e $ARGV[1])
|
||||
{
|
||||
print("No file found at: ".$ARGV[1]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
open CONFDIST, "<", $ARGV[0] or die "Error: Could not open ".$ARGV[0]."\n";
|
||||
my $confdist = join "", <CONFDIST>;
|
||||
close CONFDIST;
|
||||
|
||||
open CONFOLD, "<", $ARGV[1] or die "Error: Could not open ".$ARGV[1]."\n";
|
||||
my $confold = join "", <CONFOLD>;
|
||||
close CONFOLD;
|
||||
|
||||
while ($confold =~ m/^(?!#)(.*?)\s+?=\s+?(.*?)$/mg) {
|
||||
my $key = $1, my $value = $2;
|
||||
$confdist =~ s/^(\Q$key\E)(\s+?=\s+?)(.*)/$1$2$value/mg;
|
||||
}
|
||||
|
||||
open OUTPUT, ">", $ARGV[2] or die "Error: Could not open ".$ARGV[2]."\n";
|
||||
binmode(OUTPUT);
|
||||
print OUTPUT $confdist;
|
||||
close OUTPUT;
|
||||
Reference in New Issue
Block a user