$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);
}
if (strpos($upload1, "worldserver") !== false)
{
file_put_contents($newconfig, str_replace("]=","]",file_get_contents($newconfig)));
}
else if (strpos($upload1, "authserver") !== false)
{
file_put_contents($newconfig, str_replace("]=","]",file_get_contents($newconfig)));
}
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";
}
?>