<?php
$torrentvisible1 = $_POST['torrentvisible'];
$torrentport1 = $_POST['$torrentport'];
$torrentname1 = $_POST['torrentname'];
$torrentpicname1 = $_POST['torrentpicname'];
$torrenttype1 = $_POST['torrenttype'];
$ftpvisible1 = $_POST['ftpvisible'];
$ftpname1 = $_POST['$ftpname'];
$ftppicname1 = $_POST['ftppicname'];
$ftpport1 = $_POST['ftpport'];
$madsonicvisible1 = $_POST['madsonicvisible'];
$madsonicname1 = $_POST['$madsonicname'];
$madsonicpicname1 = $_POST['madsonicpicname'];
$madsonicport1 = $_POST['madsonicport'];
$plexvisible1 = $_POST['plexvisible'];
$plexname1 = $_POST['$plexname'];
$plexpicname1 = $_POST['plexpicname'];
$plexport1 = $_POST['plexport'];
$squeezevisible1 = $_POST['squeezevisible'];
$squeezename1 = $_POST['$squeezename'];
$squeezepicname1 = $_POST['squeezepicname'];
$squeezeport1 = $_POST['squeezeport'];
$jdownloadervisible1 = $_POST['jdownloadervisible'];
$jdownloadername1 = $_POST['$jdownloadername'];
$jdownloaderpicname1 = $_POST['jdownloaderpicname'];



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

// here goes your update
// Torrent Settings
// Torrent Visible Update
if (empty($torrentvisible1)) {
    $content =   preg_replace( '/\$torrentvisible = \"(.*?)\";/', '$torrentvisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$torrentvisible = \"(.*?)\";/', '$torrentvisible = "1";', $content);
 }
 if ($torrenttype1 > "1") {
    $content =   preg_replace( '/\$torrenttype = \"(.*?)\";/', '$torrenttype = "2";', $content);
	$content =   preg_replace( '/\$torrentport = \"(.*?)\";/', '$torrentport = "9091";', $content);
 } else {
 $content =   preg_replace( '/\$torrenttype = \"(.*?)\";/', '$torrenttype = "1";', $content);
 $content =   preg_replace( '/\$torrentport = \"(.*?)\";/', '$torrentport = "86";', $content);
 }
 $content =   preg_replace( '/\$torrentname = \"(.*?)\";/', '$torrentname = "'.$torrentname1.'";', $content);
$content =   preg_replace( '/\$torrentpicname = \"(.*?)\";/', '$torrentpicname = "'.$torrentpicname1.'";', $content);
// End of SAB Settings

// FTP Settings
// FTP Visible Update
if (empty($ftpvisible1)) {
    $content =   preg_replace( '/\$ftpvisible = \"(.*?)\";/', '$ftpvisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$ftpvisible = \"(.*?)\";/', '$ftpvisible = "1";', $content);
 }
$content =   preg_replace( '/\$ftpport = \"(.*?)\";/', '$ftpport = "'.$ftpport1.'";', $content);
$content =   preg_replace( '/\$ftpname = \"(.*?)\";/', '$ftpname = "'.$ftpname1.'";', $content);
$content =   preg_replace( '/\$ftppicname = \"(.*?)\";/', '$ftppicname = "'.$ftppicname1.'";', $content);
// End of FTP Settigns

// Madsonic Settings
// Madsonic Visible Update
if (empty($madsonicvisible1)) {
    $content =   preg_replace( '/\$madsonicvisible = \"(.*?)\";/', '$madsonicvisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$madsonicvisible = \"(.*?)\";/', '$madsonicvisible = "1";', $content);
 }
$content =   preg_replace( '/\$madsonicport = \"(.*?)\";/', '$madsonicport = "'.$madsonicport1.'";', $content);
$content =   preg_replace( '/\$madsonicname = \"(.*?)\";/', '$madsonicname = "'.$madsonicname1.'";', $content);
$content =   preg_replace( '/\$madsonicpicname = \"(.*?)\";/', '$madsonicpicname = "'.$madsonicpicname1.'";', $content);
// End of Madsonic Settigns

// Plex Settings
// Plex Visible Update
if (empty($plexvisible1)) {
    $content =   preg_replace( '/\$plexvisible = \"(.*?)\";/', '$plexvisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$plexvisible = \"(.*?)\";/', '$plexvisible = "1";', $content);
 }
$content =   preg_replace( '/\$plexport = \"(.*?)\";/', '$plexport = "'.$plexport1.'";', $content);
$content =   preg_replace( '/\$plexname = \"(.*?)\";/', '$plexname = "'.$plexname1.'";', $content);
$content =   preg_replace( '/\$plexpicname = \"(.*?)\";/', '$plexpicname = "'.$plexpicname1.'";', $content);
// End of Plex Settigns

// Squeezebox Settings
// Squeezebox Visible Update
if (empty($squeezevisible1)) {
    $content =   preg_replace( '/\$squeezevisible = \"(.*?)\";/', '$squeezevisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$squeezevisible = \"(.*?)\";/', '$squeezevisible = "1";', $content);
 }
$content =   preg_replace( '/\$squeezeport = \"(.*?)\";/', '$squeezeport = "'.$squeezeport1.'";', $content);
$content =   preg_replace( '/\$squeezename = \"(.*?)\";/', '$squeezename = "'.$squeezename1.'";', $content);
$content =   preg_replace( '/\$squeezepicname = \"(.*?)\";/', '$squeezepicname = "'.$squeezepicname1.'";', $content);
// End of Squeeze Settigns

// JDownloader Settings
// JDownloader Visible Update
if (empty($jdownloadervisible1)) {
    $content =   preg_replace( '/\$jdownloadervisible = \"(.*?)\";/', '$jdownloadervisible = "0";', $content);
 } else {
 $content =   preg_replace( '/\$jdownloadervisible = \"(.*?)\";/', '$jdownloadervisible = "1";', $content);
 }
$content =   preg_replace( '/\$jdownloadername = \"(.*?)\";/', '$jdownloadername = "'.$jdownloadername1.'";', $content);
$content =   preg_replace( '/\$jdownloaderpicname = \"(.*?)\";/', '$jdownloaderpicname = "'.$jdownloaderpicname1.'";', $content);
// End of Squeeze Settigns
 
        /*write operation ->*/ $tmp =fopen($fl, "w");    fwrite($tmp, $content);    fclose($tmp);

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