<?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'])) { 
		$sitename = $_POST['sitename'] ;
		$db->query("UPDATE `setting` SET `value` = '".$sitename."' WHERE `setting` = 'sitename'") ;
		$sitetitle = $_POST['sitetitle'] ;
		$db->query("UPDATE `setting` SET `value` = '".$sitetitle."' WHERE `setting` = 'sitetitle'") ;
		$sitefolder = $_POST['sitefolder'] ;
		$db->query("UPDATE `setting` SET `value` = '".$sitefolder."' WHERE `setting` = 'sitefolder'") ;
		$showdesc = $_POST['showdesc'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$showdesc."' WHERE `setting` = 'showdesc'") ;
		$contact_email = $_POST['contact_email'] ;
		$db->query("UPDATE `setting` SET `value` = '".$contact_email."' WHERE `setting` = 'contact_email'") ;
		$default_from = $_POST['default_from'] ;
		$db->query("UPDATE `setting` SET `value` = '".$default_from."' WHERE `setting` = 'default_from'") ;		
		$accountpageon = $_POST['accountpageon'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$accountpageon."' WHERE `setting` = 'accountpageon'") ;
		$activation = $_POST['activation'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$activation."' WHERE `setting` = 'activation'") ;		
		$titledisplaylength = $_POST['titledisplaylength'] ;
		$db->query("UPDATE `setting` SET `value` = '".$titledisplaylength."' WHERE `setting` = 'titledisplaylength'") ;
		$sitetemplate = $_POST['sitetemplate'] ;
		$db->query("UPDATE `setting` SET `value` = '".$sitetemplate."' WHERE `setting` = 'sitetemplate'") ;	
		$showsocial = $_POST['showsocial'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$showsocial."' WHERE `setting` = 'showsocial'") ;	
		
		$showdmca = $_POST['showdmca'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$showdmca."' WHERE `setting` = 'showdmca'") ;	
		$show2257 = $_POST['show2257'] == 'on' ? 1 : 0 ;
		$db->query("UPDATE `setting` SET `value` = '".$show2257."' WHERE `setting` = 'show2257'") ;	
		$submitmsg = "Everything has been updated now." ;

	}
	$sitename = getSetting(sitename, $db) ;
	$sitetitle = getSetting(sitetitle, $db) ;
	$sitefolder = getSetting(sitefolder, $db) ;
	$showdesc = getSetting(showdesc, $db) == 1 ? 'CHECKED' : '' ;
	$accountpageon = getSetting(accountpageon, $db) == 1 ? 'CHECKED' : '' ;
	$activation = getSetting(activation, $db) == 1 ? 'CHECKED' : '' ;
	$contact_email = getSetting(contact_email, $db) ;
	$default_from = getSetting(default_from, $db) ;
	$titledisplaylength = getSetting(titledisplaylength, $db) ;
	$sitetemplate = getSetting(sitetemplate, $db) ;
	$showdmca = getSetting(showdmca, $db) == 1 ? 'CHECKED' : '' ;
	$show2257 = getSetting(show2257, $db) == 1 ? 'CHECKED' : '' ;
	$showsocial = getSetting(showsocial, $db) == 1 ? 'CHECKED' : '' ;
?>
	
	
	
<h2>Global Settings</h2>


<div class="settings">

	<fieldset>
		<form action="" method="post" enctype="multipart/form-data">
		<table>
			<tr>
				<h3><?=$submitmsg?><h3>
			</tr>		
			<tr>
				<td>Sitename:</td>
				<td><input type="text" size="100" name="sitename" value="<?=$sitename?>"></td>
			</tr>
			<tr>
				<td>Site title:</td>
				<td><input type="text" size="100" name="sitetitle" value="<?=$sitetitle?>"></td>
			</tr>			
			<tr>
				<td>Sitefolder:</td>
				<td><input type="text" size="100" name="sitefolder" value="<?=$sitefolder?>"></td>
			</tr>
			<tr>
				<td>Template:</td>
				<td>
					<select name="sitetemplate" class="select">
						<? 
							foreach (dirList() as $template) {
								echo "<option" ;
								if ($template == $sitetemplate)
										echo " selected" ;
								echo ">".$template."</option>" ;
							}
						?>
					</select>
				</td>
			</tr>
			<tr>
				<td>Contact email:</td>
				<td><input type="text" size="50" name="contact_email" value="<?=$contact_email?>"></td>
			</tr>
			<tr>
				<td>From name for email:</td>
				<td><input type="text" size="50" name="default_from" value="<?=$default_from?>"></td>
			</tr>
			<tr>
				<td>Max title Length:</td>
				<td><input type="text" size="5" name="titledisplaylength" value="<?=$titledisplaylength?>"></td>
			</tr>
			<tr>
				<td>Go to account page after login:</td>
				<td><input type="checkbox" name="accountpageon" <?=$accountpageon?>></td>
			</tr>
			<tr>
				<td>New users need to verify email:</td>
				<td><input type="checkbox" name="activation" <?=$activation?>></td>
			</tr>
			<tr>
				<td>Show description on above video:</td>
				<td><input type="checkbox" name="showdesc" <?=$showdesc?>></td>
			</tr>
			<tr>
				<td>Show social icons under video:</td>
				<td><input type="checkbox" name="showsocial" <?=$showsocial?>></td>
			</tr>
			<tr>
				<td>Show DMCA in footer:</td>
				<td><input type="checkbox" name="showdmca" <?=$showdmca?>></td>
			</tr>
			<tr>
				<td>Show 2257 in footer:</td>
				<td><input type="checkbox" name="show2257" <?=$show2257?>></td>
			</tr>
			<tr>	
				<td><input class="submitbutton" type="submit" name="submit" value="Submit" /></td>
			</tr>
			
			
			
		</table>
		</form>

	</fieldset>
</div>		