<?php
$sabvis1 = $_POST['sabvisible'];
$sabport1 = $_POST['sabport'];
$sabname1 = $_POST['sabname'];
$sabpicname1 = $_POST['sabpicname'];
$sickvis1 = $_POST['sickvisible'];
$sicktype1 = $_POST['sicktype'];
$sickname1 = $_POST['sickname'];
$sickpicname1 = $_POST['sickpicname'];
$sickport1 = $_POST['sickport'];
$couchvisible1 = $_POST['couchvisible'];
$cpadultsvisible1 = $_POST['cpadultsvisible'];
$cpadultsname1 = $_POST['cpadultsname'];
$cpadultspicname1 = $_POST['cpadultspicname'];
$cpadults1 = $_POST['cpadults'];
$cpkidsvisible1 = $_POST['cpkidsvisible'];
$cpkidsname1 = $_POST['cpkidsname'];
$cpkidspicname1 = $_POST['cpkidspicname'];
$cpkids1 = $_POST['cpkids'];
//
$fl='../config.php'; 
        /*read operation ->*/ $tmp = fopen($fl, "r");   $content=fread($tmp,filesize($fl)); fclose($tmp);

// here goes your update
// SAB Settings
// SAB Visible Update
if (empty($sabvis1)) {
    $content =   preg_replace( '/\$sabvisible = \"(.*?)\";/', '$sabvisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$sabvisible = \"(.*?)\";/', '$sabvisible = "1";', $content);
 }
$content =   preg_replace( '/\$sabport = \"(.*?)\";/', '$sabport = "'.$sabport1.'";', $content);
$content =   preg_replace( '/\$sabname = \"(.*?)\";/', '$sabname = "'.$sabname1.'";', $content);
$content =   preg_replace( '/\$sabpicname = \"(.*?)\";/', '$sabpicname = "'.$sabpicname1.'";', $content);
// End of SAB Settings

// Sick Settings
// Sick Visible Update
if (empty($sickvis1)) {
    $content =   preg_replace( '/\$sickvisible = \"(.*?)\";/', '$sickvisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$sickvisible = \"(.*?)\";/', '$sickvisible = "1";', $content);
 }
// Sick Type Update
if ($sicktype1 > "1") {
    $content =   preg_replace( '/\$sicktype = \"(.*?)\";/', '$sicktype = "2";', $content);
 } else {
 $content =   preg_replace( '/\$sicktype = \"(.*?)\";/', '$sicktype = "1";', $content);
 }
$content =   preg_replace( '/\$sickport = \"(.*?)\";/', '$sickport = "'.$sickport1.'";', $content);
$content =   preg_replace( '/\$sickname = \"(.*?)\";/', '$sickname = "'.$sickname1.'";', $content);
$content =   preg_replace( '/\$sickpicname = \"(.*?)\";/', '$sickpicname = "'.$sickpicname1.'";', $content);
// End of Sick Settigns

// Couch Settings
// CPAdults Visible Update
if (empty($couchvisible1)) {
    $content =   preg_replace( '/\$couchvisible = \"(.*?)\";/', '$couchvisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$couchvisible = \"(.*?)\";/', '$couchvisible = "1";', $content);
 }
// CPAdults Update
if ($cpadultsvisible1 > "1") {
    $content =   preg_replace( '/\$cpadultsvisible = \"(.*?)\";/', '$cpadultsvisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$cpadultsvisible = \"(.*?)\";/', '$cpadultsvisible = "1";', $content);
 }
$content =   preg_replace( '/\$cpadultsname = \"(.*?)\";/', '$cpadultsname = "'.$cpadultsname1.'";', $content);
$content =   preg_replace( '/\$cpadultspicname = \"(.*?)\";/', '$cpadultspicname = "'.$cpadultspicname1.'";', $content);
$content =   preg_replace( '/\$cpadults = \"(.*?)\";/', '$cpadults = "'.$cpadults1.'";', $content);
// CPKids Visible Update
if ($cpkidsvisible1 > "1") {
    $content =   preg_replace( '/\$cpkidsvisible = \"(.*?)\";/', '$cpkidsvisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$cpkidsvisible = \"(.*?)\";/', '$cpkidsvisible = "1";', $content);
 }
$content =   preg_replace( '/\$cpkidsname = \"(.*?)\";/', '$cpkidsname = "'.$cpkidsname1.'";', $content);
$content =   preg_replace( '/\$cpkidspicname = \"(.*?)\";/', '$cpkidspicname = "'.$cpkidspicname1.'";', $content);
$content =   preg_replace( '/\$cpkids = \"(.*?)\";/', '$cpkids = "'.$cpkids1.'";', $content);
// End of Couch Settigns
 
        /*write operation ->*/ $tmp =fopen($fl, "w");    fwrite($tmp, $content);    fclose($tmp);

		//sleep for 5 seconds
		
		
		header("Location: re1.php");
die();
		
		?>