<?php
$drivespacevisible1 = $_POST['drivespacevisible'];
$drive1visible1 = $_POST['drive1visible'];
$drive1a = $_POST['drive1'];
$drive2visible1 = $_POST['drive2visible'];
$drive2a = $_POST['drive2'];
$drive3visible1 = $_POST['drive3visible'];
$drive3a = $_POST['drive3'];
$drive4visible1 = $_POST['drive4visible'];
$drive4a = $_POST['drive4'];
$drive5visible1 = $_POST['drive5visible'];
$drive5a = $_POST['drive5'];
$drive6visible1 = $_POST['drive6visible'];
$drive6a = $_POST['drive6'];
$drive7visible1 = $_POST['drive7visible'];
$drive7a = $_POST['drive7'];
//
$fl='../config.php'; 
        /*read operation ->*/ $tmp = fopen($fl, "r");   $content=fread($tmp,filesize($fl)); fclose($tmp);

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


// Drive1 Settings
// FTP Visible Update
if (empty($drive1visible1)) {
    $content =   preg_replace( '/\$drive1visible = \"(.*?)\";/', '$drive1visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$drive1visible = \"(.*?)\";/', '$drive1visible = "1";', $content);
 }
$content =   preg_replace( '/\$drive1 = \"(.*?)\";/', '$drive1 = "'.$drive1a.'";', $content);
// End of Settigns

// Drive2 Settings
// FTP Visible Update
if (empty($drive2visible1)) {
    $content =   preg_replace( '/\$drive2visible = \"(.*?)\";/', '$drive2visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$drive2visible = \"(.*?)\";/', '$drive2visible = "1";', $content);
 }
$content =   preg_replace( '/\$drive2 = \"(.*?)\";/', '$drive2 = "'.$drive2a.'";', $content);
// End of Settigns

// Drive3 Settings
// FTP Visible Update
if (empty($drive3visible1)) {
    $content =   preg_replace( '/\$drive3visible = \"(.*?)\";/', '$drive3visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$drive3visible = \"(.*?)\";/', '$drive3visible = "1";', $content);
 }
$content =   preg_replace( '/\$drive3 = \"(.*?)\";/', '$drive3 = "'.$drive3a.'";', $content);
// End of Settigns

// Drive4 Settings
// FTP Visible Update
if (empty($drive4visible1)) {
    $content =   preg_replace( '/\$drive4visible = \"(.*?)\";/', '$drive4visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$drive4visible = \"(.*?)\";/', '$drive4visible = "1";', $content);
 }
$content =   preg_replace( '/\$drive4 = \"(.*?)\";/', '$drive4 = "'.$drive4a.'";', $content);
// End of Settigns

// Drive5 Settings
// FTP Visible Update
if (empty($drive5visible1)) {
    $content =   preg_replace( '/\$drive5visible = \"(.*?)\";/', '$drive5visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$drive5visible = \"(.*?)\";/', '$drive5visible = "1";', $content);
 }
$content =   preg_replace( '/\$drive5 = \"(.*?)\";/', '$drive5 = "'.$drive5a.'";', $content);
// End of Settigns

// Drive6 Settings
// FTP Visible Update
if (empty($drive6visible1)) {
    $content =   preg_replace( '/\$drive6visible = \"(.*?)\";/', '$drive6visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$drive6visible = \"(.*?)\";/', '$drive6visible = "1";', $content);
 }
$content =   preg_replace( '/\$drive6 = \"(.*?)\";/', '$drive6 = "'.$drive6a.'";', $content);
// End of Settigns

// Drive7 Settings
// FTP Visible Update
if (empty($drive7visible1)) {
    $content =   preg_replace( '/\$drive7visible = \"(.*?)\";/', '$drive7visible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$drive7visible = \"(.*?)\";/', '$drive7visible = "1";', $content);
 }
$content =   preg_replace( '/\$drive7 = \"(.*?)\";/', '$drive7 = "'.$drive7a.'";', $content);
// End of Settigns
 
        /*write operation ->*/ $tmp =fopen($fl, "w");    fwrite($tmp, $content);    fclose($tmp);

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