<?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'])) { 
		$showallvideos = $_POST['showallvideos'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$showallvideos."' WHERE `setting` = 'showallvideos'") ;
		$showtoprated = $_POST['showtoprated'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$showtoprated."' WHERE `setting` = 'showtoprated'") ;		
		$showmostviewed = $_POST['showmostviewed'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$showmostviewed."' WHERE `setting` = 'showmostviewed'") ;
		$showcategorie = $_POST['showcategorie'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$showcategorie."' WHERE `setting` = 'showcategorie'") ;	
		$showcommunity = $_POST['showcommunity'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$showcommunity."' WHERE `setting` = 'showcommunity'") ;			
		$showmembers = $_POST['showmembers'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$showupload."' WHERE `setting` = 'showupload'") ;		
		$showfrontpage = $_POST['showfrontpage'] ;
		$db->query("UPDATE `setting` SET `value` = '".$showfrontpage."' WHERE `setting` = 'showfrontpage'") ;	
		$showupload = $_POST['showupload'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$showupload."' WHERE `setting` = 'showupload'") ;
		$showembed = $_POST['showembed'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$showembed."' WHERE `setting` = 'showembed'") ;	

		$enablelogin = $_POST['enablelogin'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$enablelogin."' WHERE `setting` = 'enablelogin'") ;
		
		if (getSetting(enablelogin, $db) == '0') {
			$db->query("UPDATE `setting` SET `value` = '0' WHERE `setting` = 'showembed'") ;	
			$db->query("UPDATE `setting` SET `value` = '0' WHERE `setting` = 'showupload'") ;
		
		}
		
		if ((getSetting(showallvideos, $db) == '0') && (getSetting(showfrontpage, $db) == 'allvideos')) {
			$db->query("UPDATE `setting` SET `value` = 'home' WHERE `setting` = 'showfrontpage'") ;	
		}
		if ((getSetting(showtoprated, $db) == '0') && (getSetting(showfrontpage, $db) == 'toprated')) {
			$db->query("UPDATE `setting` SET `value` = 'home' WHERE `setting` = 'showfrontpage'") ;	
		}		
		if ((getSetting(showmostviewed, $db) == '0') && (getSetting(showfrontpage, $db) == 'mostviewed')) {
			$db->query("UPDATE `setting` SET `value` = 'home' WHERE `setting` = 'showfrontpage'") ;	
		}			
		if ((getSetting(showcategorie, $db) == '0') && (getSetting(showfrontpage, $db) == 'catlist')) {
			$db->query("UPDATE `setting` SET `value` = 'home' WHERE `setting` = 'showfrontpage'") ;	
		}
		if ((getSetting(showcommunity, $db) == '0') && (getSetting(showfrontpage, $db) == 'community')) {
			$db->query("UPDATE `setting` SET `value` = 'home' WHERE `setting` = 'showfrontpage'") ;	
		}		
		if ((getSetting(showupload, $db) == '0') && (getSetting(showfrontpage, $db) == 'upload')) {
			$db->query("UPDATE `setting` SET `value` = 'home' WHERE `setting` = 'showfrontpage'") ;	
		}
		$submitmsg = "Everything has been updated now." ;

	}

	$showfrontpage = getSetting(showfrontpage, $db) ;
	$showallvideos = getSetting(showallvideos, $db) == 1 ? 'CHECKED' : '' ;
	$showtoprated = getSetting(showtoprated, $db) == 1 ? 'CHECKED' : '' ;
	$showmostviewed = getSetting(showmostviewed, $db) == 1 ? 'CHECKED' : '' ;
	$showcategorie = getSetting(showcategorie, $db) == 1 ? 'CHECKED' : '' ;
	$showcommunity = getSetting(showcommunity, $db) == 1 ? 'CHECKED' : '' ;
	$showupload = getSetting(showupload, $db) == 1 ? 'CHECKED' : '' ;
	$showembed = getSetting(showembed, $db) == 1 ? 'CHECKED' : '' ;
	$enablelogin = getSetting(enablelogin, $db) == 1 ? 'CHECKED' : '' ;
?>


<h2>Menu Settings</h2>
<div class="settings">
	<h4>You can turn pages off in menu and on the actual page. Turning off members turns off upload.</h4>
	<fieldset>
		<form action="" method="post" enctype="multipart/form-data">
		<table>
			<tr>
				<h3><?=$submitmsg?><h3>
			</tr>

			<tr>
					<td>Front page:</td>
					<td>
					<select name="showfrontpage" class="select">
						<? 
							foreach (homelist() as $frontlist) {
								echo "<option" ;
								if ($frontlist == $showfrontpage)
										echo " selected" ;
								echo ">".$frontlist."</option>" ;
							}
						?>
					</select>
					</td>
			</tr>
			<tr>
					<td>Show videos:</td>
					<td><input type="checkbox" name="showallvideos" <?=$showallvideos?>></td>
			</tr>
			<tr>
					<td>Show Top Rated:</td>
					<td><input type="checkbox" name="showtoprated" <?=$showtoprated?>></td>
			</tr>		
			<tr>
					<td>Show Most viewed:</td>
					<td><input type="checkbox" name="showmostviewed" <?=$showmostviewed?>></td>
			</tr>		
			<tr>
					<td>Show Categories:</td>
					<td><input type="checkbox" name="showcategorie" <?=$showcategorie?>></td>
			</tr>	
			<tr>
					<td>Show Community:</td>
					<td><input type="checkbox" name="showcommunity" <?=$showcommunity?>></td>
			</tr>	
			<tr>
					<td>Show Uploads:</td>
					<td><input type="checkbox" name="showupload" <?=$showupload?>></td>
			</tr>		
			<tr>
					<td>Show Embed:</td>
					<td><input type="checkbox" name="showembed" <?=$showembed?>></td>
			</tr>	
			<tr>
					<td>enable all login options:</td>
					<td><input type="checkbox" name="enablelogin" <?=$enablelogin?>></td>
			</tr>
			<tr>	
				<td><input class="submitbutton" type="submit" name="submit" value="Submit" /></td>
			</tr>
		</table>
		</form>

	</fieldset>
</div>


	



