<?php if(!defined('ABSPATH')){ exit; }




function radiotvindoor_radio_settings_page() {

	$radioset = get_option ('tv_radioset', '1');	 
  	$urlradioset = get_option ('tv_url_radioset', 'https://urlouipdasuaradio.com');
	$portradioset = get_option ('tv_port_radioset', '9999');
	$volradioset = get_option ('tv_vol_radioset', '50');
	$buffradioset = get_option ('tv_buff_radioset', '0');
	$codecradioset = get_option ('tv_codecradioset', 'mp3');

  if (isset ($_POST ['radiook'])) {

	update_option ('tv_radioset', $_POST ['radioset']);
	update_option ('tv_url_radioset', $_POST ['url_radioset']);
	update_option ('tv_port_radioset', $_POST ['port_radioset']);
	update_option ('tv_vol_radioset', $_POST ['vol_radioset']);
	update_option ('tv_buff_radioset', $_POST ['buff_radioset']);
	update_option ('tv_codec_radioset', $_POST ['codec_radioset']);	

  }

	

?>



<div class = "wrap">

  <h1><?php echo __( 'Indoor Radio Settings', 'tvindoor' ); ?></h1>

  <p> <?php echo __( 'Setting here the background radio play in your Indoor TV', 'tvindoor' ); ?> </p>

  <form action = "<?php echo str_replace('% 7E', '~',$_SERVER ['REQUEST_URI']);?>" method = "post">

  	<INPUT TYPE="RADIO" NAME="radioset" VALUE="1" <?php if(isset($_POST ['radioset']) AND ($_POST ['radioset'] =="1")) echo "CHECKED";  else if ($radioset == "1") echo "CHECKED"; ?>> <?php echo __( 'Radio On', 'tvindoor' ); ?>

	<INPUT TYPE="RADIO" NAME="radioset" VALUE="0" <?php if (isset($_POST ['radioset']) AND ($_POST ['radioset'] !="1")) echo "CHECKED";  else if ($radioset == "0" && $_POST ['radioset'] !="1") echo "CHECKED"; ?>> <?php echo __( 'Radio Off', 'tvindoor' ); ?>

  <br />  

  <?php echo __( 'Streaming IP or URL', 'tvindoor' ); ?>: <input type = "url" value = "<?Php echo $urlradioset; ?>" Name = "url_radioset" placeholder = "<?Php echo $_POST ['url_radioset']; ?>"> <br />

  <?php echo __( 'Streaming Port', 'tvindoor' ); ?>: <input type = "number" value = "<?Php echo $portradioset; ?>" Name = "port_radioset" placeholder = "<?Php echo $_POST ['port_radioset']; ?>"> 

  <br />

   <?php echo __( 'Initial Volume (Into 0 and 100, 0 = mute)', 'tvindoor' ); ?>: <input type = "number" value = "<?Php echo $volradioset; ?>" Name = "vol_radioset" placeholder = "<?Php echo $_POST ['vol_radioset']; ?>"> 

  <br />

  <?php echo __( 'Buffer Time (In Seconds)', 'tvindoor' ); ?>: <input type = "number" value = "<?Php echo $buffradioset; ?>" Name = "buff_radioset" placeholder = "<?Php echo $_POST ['buff_radioset']; ?>"> <br />

  	<INPUT TYPE="RADIO" NAME="codec_radioset" VALUE="mp3" <?php if ($codecradioset == "mp3") echo "CHECKED"; ?>> MP3

	<INPUT TYPE="RADIO" NAME="codec_radioset" VALUE="aac" <?php if ($codecradioset == "aac") echo "CHECKED"; ?>> AAC

   	<INPUT TYPE="RADIO" NAME="codec_radioset" VALUE="ogg" <?php if ($codecradioset == "ogg") echo "CHECKED"; ?>> OGG

  <br /> 

 

  <input name = "radiook" type = "hidden" value = "1" />

  <input type = "submit" value = "<?php echo __( 'Save Radio Settings', 'tvindoor' ); ?>" />

  </form>

  <br />



</div>

<?php if (get_option ('tv_radioset') == "1") {

    $autoplay = true;
    $url = str_replace('http://', '', $urlradioset); 
    $url = str_replace('http://', '', $urlradioset);
	$urlverifica = $urlradioset.':'.$portradioset.'/;';
	if ($portradioset == "") { 
	$urlverifica = $urlradioset.'/;'; }
    if((substr_compare($urlverifica,"http://",0,7)) === 0) 
	$urlcompleta = plugins_url( 'stream/index.php?server='.$url.'&port='.$portradioset.'&mount='.$mountradioset.'&.mp3', dirname(__FILE__)  );//proxy
	    else 
    $urlcompleta = $urlverifica;//identica
    end_if;
} ?>

<script type="text/javascript" src="https://hosted.muses.org/mrp.js"></script>

<script type="text/javascript">

MRP.insert({

'url':'<?php echo $urlcompleta; ?>',

'codec':'<?php echo $codecradioset; ?>',

'volume':'<?php echo $volradioset; ?>',

'autoplay':'<?php echo $autoplay; ?>',

'forceHTML5':true,

'jsevents':false,

'buffering':<?php echo $buffradioset; ?>,

'title':'RadioTVIndoor',

'wmode':'transparent',

'skin':'largebayfm',

'width':451,

'height':90

});

</script>	

<br>

Se os dados parecem n&atilde;o terem sido gravados, apenas <a href="">CLIQUE AQUI </a> para atualizar a p&aacute;gina antes de rever as configura&ccedil;&otilde;es.

<?php

	

}









function radiotvindoor_plugin_page(){

	global $tvcapi;

	global $tvc_verify_res;

	$tvc_activate_res = null;

	$tvc_deactivate_res = null;

	if(!empty($_POST['client_name'])&&!empty($_POST['license_code'])){

		check_admin_referer('tvc_update_license', 'tvc_update_license_sec');

		$tvc_activate_res = $tvcapi->activate_license(

			strip_tags(trim($_POST['license_code'])), 

			strip_tags(trim($_POST['client_name']))

		);

		$tvc_verify_res = $tvcapi->verify_license();

	}

	if(!empty($_POST['tvc_deactivate'])){

		check_admin_referer('tvc_deactivate_license', 'tvc_deactivate_license_sec');

		$tvc_deactivate_res = $tvcapi->deactivate_license();

		$tvc_verify_res = $tvcapi->verify_license();

	}

	$tvc_update_data = $tvcapi->check_update(); ?>



	<div class="wrap">

		<h1><?php echo __( 'License Code Plugin - Settings', 'tvindoor' ); ?></h1>

		<?php if($tvc_verify_res['status']){ ?> 

			<div class="notice notice-info">

				<p><?php echo __( 'Actived! Your license is valid.', 'tvindoor' ); ?></p>

			</div> 

		<?php }else{ ?> 

			<div class="notice notice-error">

				<p><?php echo (!empty($tvc_activate_res['message']))?$tvc_activate_res['message']:__( 'No License Setting or Invalid License', 'tvindoor' ) ?></p>

			</div> 

		<?php }?>

		<form action="" method="post">

			<?php wp_nonce_field('tvc_update_license', 'tvc_update_license_sec'); ?>

			<table>   

				<tr>

					<th><?php echo __( 'License Code', 'tvindoor' ); ?></th>

					<td>

						<input type="text" name="license_code" size="50" placeholder="<?php 

						if($tvc_verify_res['status']){

							echo __( 'Type here your License Code for Update', 'tvindoor' );

						}else{

							echo __( 'Type here your License Code', 'tvindoor' );

						} ?>" required>

					</td>

				</tr>

				<tr>

					<th><?php echo __( 'Licensed Name', 'tvindoor' ); ?></th>

					<td>

						<input type="text" name="client_name" size="50" placeholder="<?php 

						if($tvc_verify_res['status']){

							echo __( 'Type here the Name of Licensed for Update', 'tvindoor' );

						}else{

							echo __( 'Type here the Name of Licensed', 'tvindoor' );

						} ?>" required>

					</td>

				</tr>    

				<tr>

					<td>

						<div style="padding-top: 10px;">

							<input type="submit" value="<?php echo __( 'Active', 'tvindoor' ); ?>" class="button button-primary">

						</div>

					</td>

				</tr>

			</table>

		</form>

		<?php if($tvc_verify_res['status']){ ?>

			<h2 class="title" style="padding-top:10px;"><?php echo __( 'Disable License', 'tvindoor' ); ?></h2>

			<p style="max-width: 450px;"><?php echo __( 'If desire use this license for activate this plugin in another server, your first deactivate your license in this server,', 'tvindoor' ); ?>

			</p>

			<?php if(empty($tvc_deactivate_res)){ ?>

				<form action="" method="post">

					<?php wp_nonce_field('tvc_deactivate_license', 'tvc_deactivate_license_sec'); ?>

					<input type="hidden" name="tvc_deactivate" value="yes">

					<input type="submit" value="<?php echo __( 'Deactive', 'tvindoor' ); ?>" class="button">

				</form>

			<?php } ?>

		<?php } ?>

		<?php if($tvc_verify_res['status']){ ?>

			<h2 class="title" style="padding-top:10px;"><?php echo __( 'Plugin Updates', 'tvindoor' ); ?></h2>

			<p>

				<strong><?php echo esc_html($tvc_update_data['message']); ?></strong>

			</p>

			<?php if($tvc_update_data['status']){ ?>

				<p style="max-width: 700px;"><?php echo __( 'Changelogs:', 'tvindoor' ); ?> 

					<?php echo strip_tags($tvc_update_data['changelog'], '<ol><ul><li><i><b><strong><p><br><a><blockquote>'); ?>

				</p>

				<?php if(!empty($_POST['update_id'])){

					check_admin_referer('tvc_update_download', 'tvc_update_download_sec');

					$tvcapi->download_update(

						strip_tags(trim($_POST['update_id'])), 

						strip_tags(trim($_POST['has_sql'])), 

						strip_tags(trim($_POST['version']))

					);

					if (false !== get_transient('tradiotvindoor_next_update_check')) {

						delete_transient('radiotvindoor_next_update_check');

					}

				?>

				<?php }else{ ?>

					<form action="" method="POST">

						<?php wp_nonce_field('tvc_update_download', 'tvc_update_download_sec'); ?>

						<input type="hidden" value="<?php echo esc_attr($tvc_update_data['update_id']); ?>" name="update_id">

						<input type="hidden" value="<?php echo esc_attr($tvc_update_data['has_sql']); ?>" name="has_sql">

						<input type="hidden" value="<?php echo esc_attr($tvc_update_data['version']); ?>" name="version">

						<div style="padding-top: 10px;">

							<input type="submit" value="<?php echo __( 'Download and Install Update', 'tvindoor' ); ?>" class="button button-secondary">

						</div>

					</form>

				<?php } ?>

			<?php } ?>

		<?php } ?>

	</div>

<?php }

