<?php
$serverstatusvisible1 = $_POST['serverstatusvisible'];
$server1visible1 = $_POST['server1visible'];
$server1name1 = $_POST['server1name'];
$server1url1 = $_POST['server1url'];
$server2visible1 = $_POST['server2visible'];
$server2name1 = $_POST['server2name'];
$server2url1 = $_POST['server2url'];
$server3visible1 = $_POST['server3visible'];
$server3name1 = $_POST['server3name'];
$server3url1 = $_POST['server3url'];
$server4visible1 = $_POST['server4visible'];
$server4name1 = $_POST['server4name'];
$server4url1 = $_POST['server4url'];
$customfeed1visible1 = $_POST['customfeed1visible'];
$customfeed1name1 = $_POST['customfeed1name'];
$customfeed1url1 = $_POST['customfeed1url'];
$customfeed2visible1 = $_POST['customfeed2visible'];
$customfeed2name1 = $_POST['customfeed2name'];
$customfeed2url1 = $_POST['customfeed2url'];
$customfeed3visible1 = $_POST['customfeed3visible'];
$customfeed3name1 = $_POST['customfeed3name'];
$customfeed3url1 = $_POST['customfeed3url'];

//
$fl='../config.php'; 
        /*read operation ->*/ $tmp = fopen($fl, "r");   $content=fread($tmp,filesize($fl)); fclose($tmp);

// here goes your update
// ServerStatus Visible Update
if (empty($serverstatusvisible1)) {
    $content =   preg_replace( '/\$serverstatusvisible = \"(.*?)\";/', '$serverstatusvisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$serverstatusvisible = \"(.*?)\";/', '$serverstatusvisible = "1";', $content);
 }


// Drive1 Settings
// FTP Visible Update
if (empty($server1visible1)) {
    $content =   preg_replace( '/\$server1visible = \"(.*?)\";/', '$server1visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$server1visible = \"(.*?)\";/', '$server1visible = "1";', $content);
 }
$content =   preg_replace( '/\$server1name = \"(.*?)\";/', '$server1name = "'.$server1name1.'";', $content);
$content =   preg_replace( '/\$server1url = \"(.*?)\";/', '$server1url = "'.$server1url1.'";', $content);
// End of Settigns

// Drive2 Settings
// FTP Visible Update
if (empty($server2visible1)) {
    $content =   preg_replace( '/\$server2visible = \"(.*?)\";/', '$server2visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$server2visible = \"(.*?)\";/', '$server2visible = "1";', $content);
 }
$content =   preg_replace( '/\$server2name = \"(.*?)\";/', '$server2name = "'.$server2name1.'";', $content);
$content =   preg_replace( '/\$server2url = \"(.*?)\";/', '$server2url = "'.$server2url1.'";', $content);
// End of Settigns

// Drive3 Settings
// FTP Visible Update
if (empty($server3visible1)) {
    $content =   preg_replace( '/\$server3visible = \"(.*?)\";/', '$server3visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$server3visible = \"(.*?)\";/', '$server3visible = "1";', $content);
 }
$content =   preg_replace( '/\$server3name = \"(.*?)\";/', '$server3name = "'.$server3name1.'";', $content);
$content =   preg_replace( '/\$server3url = \"(.*?)\";/', '$server3url = "'.$server3url1.'";', $content);
// End of Settigns

// Drive4 Settings
// FTP Visible Update
if (empty($server4visible1)) {
    $content =   preg_replace( '/\$server4visible = \"(.*?)\";/', '$server4visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$server4visible = \"(.*?)\";/', '$server4visible = "1";', $content);
 }
$content =   preg_replace( '/\$server4name = \"(.*?)\";/', '$server4name = "'.$server4name1.'";', $content);
$content =   preg_replace( '/\$server4url = \"(.*?)\";/', '$server4url = "'.$server4url1.'";', $content);
// End of Settigns

// RSS1 Settings
// FTP Visible Update
if (empty($customfeed1visible1)) {
    $content =   preg_replace( '/\$customfeed1visible = \"(.*?)\";/', '$customfeed1visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$customfeed1visible = \"(.*?)\";/', '$customfeed1visible = "1";', $content);
 }
$content =   preg_replace( '/\$customfeed1name = \"(.*?)\";/', '$customfeed1name = "'.$customfeed1name1.'";', $content);
$content =   preg_replace( '/\$customfeed1url = \"(.*?)\";/', '$customfeed1url = "'.$customfeed1url1.'";', $content);
// End of Settigns
// RSS2 Settings
// FTP Visible Update
if (empty($customfeed2visible1)) {
    $content =   preg_replace( '/\$customfeed2visible = \"(.*?)\";/', '$customfeed2visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$customfeed2visible = \"(.*?)\";/', '$customfeed2visible = "1";', $content);
 }
$content =   preg_replace( '/\$customfeed2name = \"(.*?)\";/', '$customfeed2name = "'.$customfeed2name1.'";', $content);
$content =   preg_replace( '/\$customfeed2name = \"(.*?)\";/', '$customfeed2name = "'.$customfeed2name1.'";', $content);
// End of Settigns
// RSS3 Settings
// FTP Visible Update
if (empty($customfeed3visible1)) {
    $content =   preg_replace( '/\$customfeed3visible = \"(.*?)\";/', '$customfeed3visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$customfeed3visible = \"(.*?)\";/', '$customfeed3visible = "1";', $content);
 }
$content =   preg_replace( '/\$customfeed3name = \"(.*?)\";/', '$customfeed3name = "'.$customfeed3name1.'";', $content);
$content =   preg_replace( '/\$customfeed3name = \"(.*?)\";/', '$customfeed3name = "'.$customfeed3name1.'";', $content);
// End of Settigns

 
        /*write operation ->*/ $tmp =fopen($fl, "w");    fwrite($tmp, $content);    fclose($tmp);

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