<?php
    include("../Site/mysql.php");
    
    $ovpnconfdir  = db_getconfval("ovpnconfdir");
    $ovpnconffile = db_getconfval("ovpnconffile");
//    echo $ovpnconfdir."/".$ovpnconffile;

echo "
<html>
<head><title>Installer Page STEP 4</title></head>
<body>
<form action=\"install4.php\" method =\"post\">
Change the OpenVPN Server config...
<textarea name=\"inhalt\" rows=25 cols=100 wrap=\"virtual\">
";

include($ovpnconfdir."/".$ovpnconffile); 

echo "
</textarea>
<input name=\"submit\" type=\"submit\" id=\"submit\" value=\"Speichern\">
<input type=\"reset\" name=\"Submit2\" value=\"Reset\">

</form>";

	if ($_REQUEST["submit"] == "Speichern")
    {
		$fp = fopen($ovpnconfdir."/".$ovpnconffile,"w");
		$data =$_REQUEST["inhalt"];
		$data = str_replace("\r","",$data);
		fputs($fp,$data); 
		fclose($fp); 
    
		echo "<meta http-equiv=\"Refresh\" content=\"4; url=install4.php?changedone=1\">"; 
		$check_ok = "<font color = 'red'>Ihre Daten wurden erfolgreich geändert!<br>Bitte warten sie bis die Daten aktualisiert werden.</font>"; 
		echo $check_ok;
    } 
	if ($_REQUEST["changedone"] == "1")
	{
		$check_ok = "<font color = 'green'>Ihre Daten wurden erfolgreich gespeichert!</font>"; 
		echo $check_ok;
	}


echo "<form action=\"install5.php\" method=\"post\">
	<input type=\"submit\" value=\"Install! STEP 5\">
	</form> ";
?> 
</body>
</html> 
