<?php include '../config.php';?>
<?php 

$folder = '../Pic/Upload'; 

function image_filenames($dir) 
{ 
    $handle = @opendir($dir) 
        or die("I cannot open the directory '<b>$dir</b>' for reading."); 
    $images = array(); 
    while (false !== ($file = readdir($handle))) 
    { 
        if (eregi('\.(jpg|gif|png)$', $file)) 
        { 
            $images[] = $file; 
        } 
    } 
    closedir($handle); 
    return $images; 
} 
?>

<form action="write3.php" method="post">
<div style="width:100%;"> <!-- Main Div -->
<div style="float:left; width:50%;">
	FTP Enabled:  <input name="ftpvisible" id="id" type="checkbox" <?php if($ftpvisible > "0")  echo "checked=checked; "; ?> /><br />
	FTP Port:  <input type="text" value="<?php echo $ftpport ?>" name="ftpport" /><br />
	FTP Name:  <input type="text" value="<?php echo $ftpname ?>" name="ftpname" /><br />
	FTP Pic:  <?php 

echo '<select name="ftppic">'."\n". 
     dropdown_ftp(image_filenames($folder), @$_POST['image2']). 
     '</select>'."\n".'</br></br>'; 

function dropdown_ftp($options_array, $selected = null) 
{ 
global $ftppicname;
    $return = "<option></option>";
    foreach($options_array as $option) 
    { 
        $return .= '<option value="'.$option.'"'. 
                   (($option == $ftppicname) ? ' selected="selected"' : null ). 
                   '>'.$option.'</option>'."\n"; 
    } 
    return $return; 
} 

?>
	Torrent Enabled:  <input name="torrentvisible" id="id" type="checkbox" <?php if($torrentvisible > "0")  echo "checked=checked; "; ?> /><br />
	Torrent Type : <input type="radio" name="torrenttype" value="1" <?php if($torrenttype < "2")  echo "checked=checked; "; ?>>uTorrent / <input type="radio" name="torrenttype" value="2" <?php if($torrenttype > "1")  echo "checked=checked; "; ?>>Transmission<br />
	Torrent Port:  <input type="text" value="<?php echo $torrentport ?>" name="torrentport" /><br />
	Torrent Name:  <input type="text" value="<?php echo $torrentname ?>" name="torrentname" /><br />
	Torrent Pic:  <?php 

echo '<select name="torrentpic">'."\n". 
     dropdown_torrent(image_filenames($folder), @$_POST['image2']). 
     '</select>'."\n".'</br></br>'; 

function dropdown_torrent($options_array, $selected = null) 
{ 
global $torrentpicname;
$return = "<option></option>";
    foreach($options_array as $option) 
    { 
        $return .= '<option value="'.$option.'"'. 
                   (($option == $torrentpicname) ? ' selected="selected"' : null ). 
                   '>'.$option.'</option>'."\n"; 
    } 
    return $return; 
} 

?>
	Madsonic Enabled:  <input name="madsonicvisible" id="id" type="checkbox" <?php if($madsonicvisible > "0")  echo "checked=checked; "; ?> /><br />
	Madsonic Port:  <input type="text" value="<?php echo $madsonicport ?>" name="madsonicport" /><br />
	Madsonic Name:  <input type="text" value="<?php echo $madsonicname ?>" name="madsonicname" /><br />
	Madsonic Pic:  <?php 

echo '<select name="madpic">'."\n". 
     dropdown_mad(image_filenames($folder), @$_POST['image2']). 
     '</select>'."\n".'</br></br>'; 

function dropdown_mad($options_array, $selected = null) 
{ 
global $madsonicpicname;
$return = "<option></option>";
    foreach($options_array as $option) 
    { 
        $return .= '<option value="'.$option.'"'. 
                   (($option == $madsonicpicname) ? ' selected="selected"' : null ). 
                   '>'.$option.'</option>'."\n"; 
    } 
    return $return; 
} 

?> 

</div>
<div style="float:right; width:50%; ">	
	<br />
	Plex Enabled:  <input name="plexvisible" id="id" type="checkbox" <?php if($plexvisible > "0")  echo "checked=checked; "; ?> /><br />
	Plex Port:  <input type="text" value="<?php echo $plexport ?>" name="plexport" /><br />
	Plex Name:  <input type="text" value="<?php echo $plexname ?>" name="plexname" /><br />
	Plex Pic:  <?php 

echo '<select name="plexpic">'."\n". 
     dropdown_plex(image_filenames($folder), @$_POST['image2']). 
     '</select>'."\n".'</br></br>'; 

function dropdown_plex($options_array, $selected = null) 
{ 
global $plexpicname;
$return = "<option></option>";
    foreach($options_array as $option) 
    { 
        $return .= '<option value="'.$option.'"'. 
                   (($option == $plexpicname) ? ' selected="selected"' : null ). 
                   '>'.$option.'</option>'."\n"; 
    } 
    return $return; 
} 

?>  
		Squeezebox Enabled:  <input name="squeezevisible" id="id" type="checkbox" <?php if($squeezevisible > "0")  echo "checked=checked; "; ?> /><br />
	Squeezebox Port:  <input type="text" value="<?php echo $squeezeport ?>" name="squeezeport" /><br />
	Squeezebox Name:  <input type="text" value="<?php echo $squeezename ?>" name="squeezename" /><br />
	Squeezebox Pic:  <?php 

echo '<select name="squeezepic">'."\n". 
     dropdown_squeeze(image_filenames($folder), @$_POST['image2']). 
     '</select>'."\n".'</br></br>'; 

function dropdown_squeeze($options_array, $selected = null) 
{ 
global $squeezepicname;
$return = "<option></option>";
    foreach($options_array as $option) 
    { 
        $return .= '<option value="'.$option.'"'. 
                   (($option == $squeezepicname) ? ' selected="selected"' : null ). 
                   '>'.$option.'</option>'."\n"; 
    } 
    return $return; 
} 

?>  
		Jdownloader Enabled:  <input name="jdownloadervisible" id="id" type="checkbox" <?php if($jdownloadervisible > "0")  echo "checked=checked; "; ?> /><br />
	Jdownloader Name:  <input type="text" value="<?php echo $jdownloadername ?>" name="jdownloadername" /><br />
	Jdownloader Pic:  <?php 

echo '<select name="jdpic">'."\n". 
     dropdown_jd(image_filenames($folder), @$_POST['image2']). 
     '</select>'."\n".'</br></br>'; 

function dropdown_jd($options_array, $selected = null) 
{ 
global $jdownloaderpicname;
$return = "<option></option>";
    foreach($options_array as $option) 
    { 
        $return .= '<option value="'.$option.'"'. 
                   (($option == $jdownloaderpicname) ? ' selected="selected"' : null ). 
                   '>'.$option.'</option>'."\n"; 
    } 
    return $return; 
} 

?>  
HeadPhones Enabled:  <input name="headphonesvisible" id="id" type="checkbox" <?php if($headvisible > "0")  echo "checked=checked; "; ?> /><br />
HeadPhones Port:  <input type="text" value="<?php echo $headport ?>" name="headport" /><br />
	HeadPhones Name:  <input type="text" value="<?php echo $headname ?>" name="headphonesname" /><br />
	HeadPhones Pic:  <?php 

echo '<select name="headpic">'."\n". 
     dropdown_head(image_filenames($folder), @$_POST['image2']). 
     '</select>'."\n".'</br></br>'; 

function dropdown_head($options_array, $selected = null) 
{ 
global $headphonespicname;
$return = "<option></option>";
    foreach($options_array as $option) 
    { 
        $return .= '<option value="'.$option.'"'. 
                   (($option == $headphonespicname) ? ' selected="selected"' : null ). 
                   '>'.$option.'</option>'."\n"; 
    } 
    return $return; 
} 

?>  
	<br /> 
</div>
 
</div>
	<div>
    <input type="submit"  name="submit" value="Update" />
</div>
</div>


</form>