<?php
/*
 **************************************************************************************************
 *    Copyright (c) 2010-2012 Just Another Video script
 *
 * 	  This file is part of Just Another Video Script.
 *    Version 1.4.3
 *    info@justanothervideoscript.com
 **************************************************************************************************
 *    Come to website for support or buying additional plugins/modules.
 *    http://justanothervideoscript.com/
 **************************************************************************************************
 *    By using this software you agree that you have read and acknowledged our End-User License
 *    Agreement available at http://justanothervideoscript.com/license and can be bound by it.
 **********************************************************************************
 */
include_once("adminfunctions.inc");


	if (isset($_POST['submit'])) { 
		$audiobitrate = $_POST['audiobitrate'] ;
		$db->query("UPDATE `setting` SET `value` = '".$audiobitrate."' WHERE `setting` = 'audiobitrate'") ;
		$audiofrequency = $_POST['audiofrequency'] ;
		$db->query("UPDATE `setting` SET `value` = '".$audiofrequency."' WHERE `setting` = 'audiofrequency'") ;
		$thumb_h1 = $_POST['thumb_h1'] ;
		$db->query("UPDATE `setting` SET `value` = '".$thumb_h1."' WHERE `setting` = 'thumb_h1'") ;		
		$thumb_w1 = $_POST['thumb_w1'] ;
		$db->query("UPDATE `setting` SET `value` = '".$thumb_w1."' WHERE `setting` = 'thumb_w1'") ;
		$thumb_num = $_POST['thumb_num'] ;
		$db->query("UPDATE `setting` SET `value` = '".$thumb_num."' WHERE `setting` = 'thumbsnumber'") ;		
		$curlpath = $_POST['curlpath'] ;
		$db->query("UPDATE `setting` SET `value` = '".$curlpath."' WHERE `setting` = 'curlpath'") ;
		$ffmpegpath = $_POST['ffmpegpath'] ;
		$db->query("UPDATE `setting` SET `value` = '".$ffmpegpath."' WHERE `setting` = 'ffmpegpath'") ;
		$flvtool2path = $_POST['flvtool2path'] ;
		$db->query("UPDATE `setting` SET `value` = '".$flvtool2path."' WHERE `setting` = 'flvtool2path'") ;
		$framerate = $_POST['framerate'] ;
		$db->query("UPDATE `setting` SET `value` = '".$framerate."' WHERE `setting` = 'framerate'") ;
		$default_thumbtime = $_POST['default_thumbtime'] ;
		$db->query("UPDATE `setting` SET `value` = '".$default_thumbtime."' WHERE `setting` = 'default_thumbtime'") ;		
		$directencode = $_POST['directencode'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$directencode."' WHERE `setting` = 'directencode'") ;	
		$encodesize = $_POST['encodesize'] ;	
		$db->query("UPDATE `setting` SET `value` = '".$encodesize."' WHERE `setting` = 'encodesize'") ;			
		$passcron = $_POST['passcron'] ;
		$db->query("UPDATE `setting` SET `value` = '".$passcron."' WHERE `setting` = 'passcron'") ;	
		$removeorifile = $_POST['removeorifile'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$removeorifile."' WHERE `setting` = 'removeorifile'") ;
		$keepencodelog = $_POST['keepencodelog'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$keepencodelog."' WHERE `setting` = 'keepencodelog'") ;
		$videoaspect = $_POST['videoaspect'] ;
		$db->query("UPDATE `setting` SET `value` = '".$videoaspect."' WHERE `setting` = 'videoaspect'") ;
		$videobitrate = $_POST['videobitrate'] ;
		$db->query("UPDATE `setting` SET `value` = '".$videobitrate."' WHERE `setting` = 'videobitrate'") ;	
		$submitmsg = "Everything has been updated now." ;

	}
	$audiobitrate = getSetting(audiobitrate, $db) ;
	$audiofrequency = getSetting(audiofrequency, $db) ;
	$thumb_num = getSetting(thumbsnumber, $db) ;
	$thumb_h1 = getSetting(thumb_h1, $db) ;
	$thumb_w1 = getSetting(thumb_w1, $db) ;
	$curlpath = getSetting(curlpath, $db) ;
	$ffmpegpath = getSetting(ffmpegpath, $db) ;
	$flvtool2path = getSetting(flvtool2path, $db) ;
	$default_thumbtime = getSetting(default_thumbtime, $db) ;
	$directencode = getSetting(directencode, $db) == 1 ? 'CHECKED' : '' ;
	$removeorifile = getSetting(removeorifile, $db) == 1 ? 'CHECKED' : '' ;
	$keepencodelog = getSetting(keepencodelog, $db) == 1 ? 'CHECKED' : '' ;
	$encodesize = getSetting(encodesize, $db) ;
	$framerate = getSetting(framerate, $db) ;
	$passcron = getSetting(passcron, $db) ;
	$sitefolder = getsetting("sitefolder", $db) ;
	$sitepath = "http://".$_SERVER['SERVER_NAME'].$sitefolder ;
	$croncommand = $curlpath. ' ' .$sitepath.'includes/encode.php?cronpass='.$passcron ;
	$videoaspect = getSetting(videoaspect, $db) ;
	$videobitrate = getSetting(videobitrate, $db) ;
?>

<h2>Encoding Settings</h2>
<div class="settings">

	<fieldset>
		<form action="" method="post" enctype="multipart/form-data">
		<table>
			<tr>
				<h3><?=$submitmsg?><h3>
			</tr>
			<tr>
					<td>Direct encode after upload:</td>
					<td><input type="checkbox" name="directencode" <?=$directencode?>></td>
			</tr>
			<tr>
					<td>Remove original uploaded file after encoding:</td>
					<td><input type="checkbox" name="removeorifile" <?=$removeorifile?>></td>
			</tr>
			<tr>
					<td>Make encoding logs:</td>
					<td><input type="checkbox" name="keepencodelog" <?=$keepencodelog?>></td>
			</tr>
			<tr>
					<td>Encoding size:</td>
					<td><input type="text" size="10" name="encodesize" value="<?=$encodesize?>"></td>
			</tr>
			<tr>
					<td>Frame rate:</td>
					<td><input type="text" size="10" name="framerate" value="<?=$framerate?>"></td>
			</tr>
			<tr>
					<td>Video aspect:</td>
					<td><input type="text" size="10" name="videoaspect" value="<?=$videoaspect?>"></td>
			</tr>
			<tr>
					<td>Video bitrate:</td>
					<td><input type="text" size="10" name="videobitrate" value="<?=$videobitrate?>"></td>
			</tr>
			<tr>
					<td>Audiobitrate:</td>
					<td><input type="text" size="10" name="audiobitrate" value="<?=$audiobitrate?>"></td>
			</tr>
			<tr>
					<td>Audiofrequency:</td>
					<td><input type="text" size="10" name="audiofrequency" value="<?=$audiofrequency?>"></td>
			</tr>
			<tr>
					<td>Time in seconds when thumb is made:</td>
					<td><input type="text" size="10" name="default_thumbtime" value="<?=$default_thumbtime?>"></td>
			</tr>
			<tr>
					<td>Number of thumbs:</td>
					<td><input type="text" size="10" name="thumb_num" value="<?=$thumb_num?>"></td>
			</tr>
			<tr>
					<td>Thumb height:</td>
					<td><input type="text" size="10" name="thumb_h1" value="<?=$thumb_h1?>"></td>
			</tr>
			<tr>
					<td>Thumb width:</td>
					<td><input type="text" size="10" name="thumb_w1" value="<?=$thumb_w1?>"></td>
			</tr>				
			<tr>
					<td>Curl path:</td>
					<td><input type="text" size="50" name="curlpath" value="<?=$curlpath?>"></td>
			</tr>	
			<tr>
					<td>FFmpeg path:</td>
					<td><input type="text" size="50" name="ffmpegpath" value="<?=$ffmpegpath?>"></td>
			</tr>	
			<tr>
					<td>FLVtools2 path:</td>
					<td><input type="text" size="50" name="flvtool2path" value="<?=$flvtool2path?>"></td>
			</tr>			
			<tr>
					<td>Cron password:</td>
					<td><input type="text" size="50" name="passcron" value="<?=$passcron?>"></td>
			</tr>	
			<tr>
					<td>Cronjob command for encoding</td>
					<td><input size=100 value="<?= $croncommand?>" onClick="this.select()"></td>
			</tr>
			<tr>	
				<td><input class="submitbutton" type="submit" name="submit" value="Submit" /></td>
			</tr>
		</table>
		</form>

	</fieldset>
</div>




