<script type="text/javascript">
$(document).ready( function() {
	$("#setting1").click(function(){
		$('#settinginput1').show();
		$('#settinginput2').hide();
		$('#settinginput3').hide();
		$('#settinginput4').hide();
		$('#settinginput5').hide();
		$('#settinginput6').hide();
		$('#setting1').hide();
		$('#setting2').show();
		$('#setting3').show();
		$('#setting4').show();
		$('#setting5').show();
		$('#setting6').show();
	});
	$("#settingbtn1").click(function(){
		var post = $('#settingtext1').val();
		var mod = 'setting';
		var act =  'website_name';
		var dataString = 'post='+ post + '&mod='+ mod + '&act='+ act;
		$.ajax({
			type: "POST",
			url: "po-component/po-setting/proses.php",
			data: dataString,
			cache: false,
			success: function(html){
				$('#settingtext1').val(html);
				$('#setting1').html(html);
				$('#settinginput1').hide();
				$('#setting1').show();
			}
		});
		return false;
	});
});
</script>

<script type="text/javascript">
$(document).ready( function() {
	$("#setting2").click(function(){
		$('#settinginput1').hide();
		$('#settinginput2').show();
		$('#settinginput3').hide();
		$('#settinginput4').hide();
		$('#settinginput5').hide();
		$('#settinginput6').hide();
		$('#setting1').show();
		$('#setting2').hide();
		$('#setting3').show();
		$('#setting4').show();
		$('#setting5').show();
		$('#setting6').show();
	});
	$("#settingbtn2").click(function(){
		var post = $('#settingtext2').val();
		var mod = 'setting';
		var act =  'website_url';
		var dataString = 'post='+ post + '&mod='+ mod + '&act='+ act;
		$.ajax({
			type: "POST",
			url: "po-component/po-setting/proses.php",
			data: dataString,
			cache: false,
			success: function(html){
				$('#settingtext2').val(html);
				$('#setting2').html(html);
				$('#settinginput2').hide();
				$('#setting2').show();
			}
		});
		return false;
	});
});
</script>

<script type="text/javascript">
$(document).ready( function() {
	$("#setting3").click(function(){
		$('#settinginput1').hide();
		$('#settinginput2').hide();
		$('#settinginput3').show();
		$('#settinginput4').hide();
		$('#settinginput5').hide();
		$('#settinginput6').hide();
		$('#setting1').show();
		$('#setting2').show();
		$('#setting3').hide();
		$('#setting4').show();
		$('#setting5').show();
		$('#setting6').show();
	});
	$("#settingbtn3").click(function(){
		var post = $('#settingtext3').val();
		var mod = 'setting';
		var act =  'meta_description';
		var dataString = 'post='+ post + '&mod='+ mod + '&act='+ act;
		$.ajax({
			type: "POST",
			url: "po-component/po-setting/proses.php",
			data: dataString,
			cache: false,
			success: function(html){
				$('#settingtext3').val(html);
				$('#setting3').html(html);
				$('#settinginput3').hide();
				$('#setting3').show();
			}
		});
		return false;
	});
});
</script>

<script type="text/javascript">
$(document).ready( function() {
	$("#setting4").click(function(){
		$('#settinginput1').hide();
		$('#settinginput2').hide();
		$('#settinginput3').hide();
		$('#settinginput4').show();
		$('#settinginput5').hide();
		$('#settinginput6').hide();
		$('#setting1').show();
		$('#setting2').show();
		$('#setting3').show();
		$('#setting4').hide();
		$('#setting5').show();
		$('#setting6').show();
	});
	$("#settingbtn4").click(function(){
		var post = $('#settingtext4').val();
		var mod = 'setting';
		var act =  'meta_keyword';
		var dataString = 'post='+ post + '&mod='+ mod + '&act='+ act;
		$.ajax({
			type: "POST",
			url: "po-component/po-setting/proses.php",
			data: dataString,
			cache: false,
			success: function(html){
				$('#settingtext4').val(html);
				$('#setting4').html(html);
				$('#settinginput4').hide();
				$('#setting4').show();
			}
		});
		return false;
	});
});
</script>

<script type="text/javascript">
$(document).ready( function() {
	$("#setting5").click(function(){
		$('#settinginput1').hide();
		$('#settinginput2').hide();
		$('#settinginput3').hide();
		$('#settinginput4').hide();
		$('#settinginput5').show();
		$('#settinginput6').hide();
		$('#setting1').show();
		$('#setting2').show();
		$('#setting3').show();
		$('#setting4').show();
		$('#setting5').hide();
		$('#setting6').show();
	});
});
</script>

<script type="text/javascript">
$(document).ready( function() {
	$("#setting6").click(function(){
		$('#settinginput1').hide();
		$('#settinginput2').hide();
		$('#settinginput3').hide();
		$('#settinginput4').hide();
		$('#settinginput5').hide();
		$('#settinginput6').show();
		$('#setting1').show();
		$('#setting2').show();
		$('#setting3').show();
		$('#setting4').show();
		$('#setting5').show();
		$('#setting6').hide();
	});
	$("#settingbtn6").click(function(){
		var post = $('#settingtext6').val();
		var mod = 'setting';
		var act =  'email';
		var dataString = 'post='+ post + '&mod='+ mod + '&act='+ act;
		$.ajax({
			type: "POST",
			url: "po-component/po-setting/proses.php",
			data: dataString,
			cache: false,
			success: function(html){
				$('#settingtext6').val(html);
				$('#setting6').html(html);
				$('#settinginput6').hide();
				$('#setting6').show();
			}
		});
		return false;
	});
});
</script>

<script type="text/javascript">
$(document).ready( function() {
    // Dialog Link
    $('#tbleditoauthfb').click(function () {
        $('#editoauthfb').dialog('open');
        return false;
    });
	$('#tbleditoauthtw').click(function () {
        $('#editoauthtw').dialog('open');
        return false;
    });
});
</script>

<script type="text/javascript">
$(document).ready( function() {
    $('.editoauthfb').dialog({
        autoOpen: false,
        width: 400,
		modal: true
    });
	$('.editoauthtw').dialog({
        autoOpen: false,
        width: 400,
		modal: true
    });
});
</script>

<?php
session_start();
if (empty($_SESSION['namauser']) AND empty($_SESSION['passuser'])){
	header('location:404.php');
}else{
$aksi="po-component/po-setting/proses.php";

$availableEditor = array("redactor", "tinymce", "newtinymce");
$localEditor = $_COOKIE['Popoji_CMS_Editor'];

function getAvailableEditor(){
	$oute = "";
	while(list($key,$editorId) = each($GLOBALS['availableEditor'])){
		$editorLib = ($GLOBALS['editorTranslated'][$editorId])? $GLOBALS['editorTranslated'][$editorId] : $editorId;
		$oute .= '<option value="'.$editorId.'"'.(($GLOBALS['localEditor']==$editorId)? ' selected="selected"' : '' ).'>'.$editorLib.'</option>'."\n";
	}
	return $oute;
}
?>
	<div class="contentTop">
        <span class="pageTitle"><span class="icon-cog"></span><?php echo $langsetting1; ?></span>
    </div>
    <!-- Breadcrumbs line -->
    <div class="breadLine">
        <div class="bc">
            <ul id="breadcrumbs" class="breadcrumbs">
                <li><a href="admin.php?mod=home"><?php echo $langmenu1; ?></a></li>
                <li class="current"><a><?php echo $langsetting2; ?></a></li>
            </ul>
        </div>
    </div>
    <!-- Main content -->
    <div class="wrapper">
<?php
switch($_GET[act]){
  default:
  if ($_SESSION[leveluser]=='admin'){
?>
	<div class="widget">
		<div class="whead"><h6><?php echo $langsetting1; ?></h6><a href="#" class="dataNumGrey"><?php echo $langsetting10; ?></a><div class="clear"></div></div>
			<div id="dyn" class="hiddenpars">
<?php
				$tablesetting = new PoTable('setting');
				$currentSetting = $tablesetting->findBy(id_setting, '1');
				$currentSetting = $currentSetting->current();
?>
				<table class="tDefault" cellpadding="0" cellspacing="0" width="100%">
					<thead><tr><td><?php echo $langsetting3; ?></td><td><?php echo $langsetting4; ?></td></tr></thead>
					<tbody>
					<tr>
                        <td><?php echo $langsetting5; ?></td>
                        <td>
							<div id="setting1" style="cursor:pointer;"><?php echo $currentSetting->website_name; ?></div>
							<div class="formRow" id="settinginput1" style="display:none; border:none;">
								<input id="settingtext1" style="width: 312px;" type="text" value="<?php echo $currentSetting->website_name; ?>">
								<button id="settingbtn1" class="buttonS bBlack mb10" type="button"><?php echo $langsetting11; ?></button>
							</div>
						</td>
					</tr>
					<tr>
                        <td><?php echo $langsetting6; ?></td>
                        <td>
							<div id="setting2" style="cursor:pointer;"><?php echo $currentSetting->website_url; ?></div>
							<div class="formRow" id="settinginput2" style="display:none; border:none;">
								<input id="settingtext2" style="width: 312px;" type="text" value="<?php echo $currentSetting->website_url; ?>">
								<button id="settingbtn2" class="buttonS bBlack mb10" type="button"><?php echo $langsetting11; ?></button>
							</div>
						</td>
					</tr>
					<tr>
                        <td><?php echo $langsetting7; ?></td>
                        <td>
							<div id="setting3" style="cursor:pointer;"><?php echo $currentSetting->meta_description; ?></div>
							<div class="formRow" id="settinginput3" style="display:none; border:none;">
								<input id="settingtext3" style="width: 312px;" type="text" value="<?php echo $currentSetting->meta_description; ?>">
								<button id="settingbtn3" class="buttonS bBlack mb10" type="button"><?php echo $langsetting11; ?></button>
							</div>
						</td>
					</tr>
					<tr>
                        <td><?php echo $langsetting8; ?></td>
                        <td>
							<div id="setting4" style="cursor:pointer;"><?php echo $currentSetting->meta_keyword; ?></div>
							<div class="formRow" id="settinginput4" style="display:none; border:none;">
								<input id="settingtext4" style="width: 312px;" type="text" value="<?php echo $currentSetting->meta_keyword; ?>">
								<button id="settingbtn4" class="buttonS bBlack mb10" type="button"><?php echo $langsetting11; ?></button>
							</div>
						</td>
					</tr>
					<tr>
                        <td><?php echo $langsetting9; ?></td>
                        <td>
							<div id="setting5" style="cursor:pointer;"><img src="../<?php echo $currentSetting->favicon; ?>" /></div>
							<form method="post" action="<?php echo $aksi; ?>" enctype="multipart/form-data" autocomplete="off">
							<input type="hidden" name="mod" value="setting">
							<input type="hidden" name="act" value="favicon">
							<div class="formRow" id="settinginput5" style="display:none; border:none;">
								<input style="opacity: 0;" size="24" class="fileInput" id="fileInput" name="fupload" type="file" required>
								<button class="buttonS bBlack mb10" type="submit"><?php echo $langsetting13; ?></button>
							</div>
							</form>
						</td>
					</tr>
					<tr>
                        <td>Email</td>
                        <td>
							<div id="setting6" style="cursor:pointer;"><?php echo $currentSetting->website_email; ?></div>
							<div class="formRow" id="settinginput6" style="display:none; border:none;">
								<input id="settingtext6" style="width: 312px;" type="text" value="<?php echo $currentSetting->website_email; ?>">
								<button id="settingbtn6" class="buttonS bBlack mb10" type="button"><?php echo $langsetting11; ?></button>
							</div>
						</td>
					</tr>
					<tr>
                        <td>Editor</td>
                        <td>
						<form action="<?php echo $aksi; ?>" method="POST">
						<div class="grid12 noSearch">
							<input type="hidden" name="mod" value="setting">
							<input type="hidden" name="act" value="editor">
							<select class="select" name="editor" onChange="submit()" style="width:30%;"><?php echo getAvailableEditor(); ?></select>
						</div>
						</form>
						</td>
					</tr>
					<tr>
                        <td>Timezone</td>
                        <td>
							Active Timezone : <?php echo $currentSetting->timezone; ?><br />
							Active Date & Time : <?php echo "$thn_sekarang-$bln_sekarang-$tgl_skrg & $jam_sekarang"; ?><br /><br />
							Change :
							<form action="<?php echo $aksi; ?>" method="POST">
							<div class="grid12 searchDrop">
								<input type="hidden" name="mod" value="setting">
								<input type="hidden" name="act" value="timezone">
								<select class="select" name="timezone" onChange="submit()" style="width:30%;">
									<?php
										$timezoneList = timezoneList();
										foreach ($timezoneList as $value => $label) {
											echo "<option value='$value'>$label</option>";
										}
									?>
								</select>
							</div>
							</form>
						</td>
					</tr>
				</tbody></table>
			</div>
	</div>
	<div class="widget">
		<div class="whead"><h6>PopojiCMSOAuth - Facebook Connect</h6><div class="clear"></div></div>
			<div id="dyn" class="hiddenpars">
<?php
				$tableoauthfb = new PoTable('oauth');
				$currentOauthfb = $tableoauthfb->findBy(id_oauth, '1');
				$currentOauthfb = $currentOauthfb->current();
?>
				<table class="tDefault" cellpadding="0" cellspacing="0" width="100%">
					<thead><tr><td><?php echo $langsetting3; ?></td><td><?php echo $langsetting4; ?></td></tr></thead>
					<tbody>
					<tr>
                        <td>Facebook App Id</td>
                        <td><?php echo $currentOauthfb->oauth_key; ?></td>
					</tr>
					<tr>
                        <td>Facebook App Secret</td>
                        <td><?php echo $currentOauthfb->oauth_secret; ?></td>
					</tr>
					<tr>
                        <td>Facebook Id</td>
                        <td><?php echo $currentOauthfb->oauth_id; ?></td>
					</tr>
					<tr>
                        <td>Facebook User</td>
                        <td><?php echo $currentOauthfb->oauth_user; ?></td>
					</tr>
					<tr>
                        <td>Facebook Type</td>
                        <td><?php echo $currentOauthfb->oauth_fbtype; ?></td>
					</tr>
					<tr>
                        <td colspan="2">
							<form method="post" action="<?php echo $aksi; ?>" autocomplete="off">
								<input type="hidden" name="mod" value="setting">
								<input type="hidden" name="act" value="deloauthfb">
								<a class="buttonS bBlack mb10" id="tbleditoauthfb">Edit App Connect</a>
								<a href="po-component/po-oauth/facebook/index.php" class="buttonS bBlack mb10">New Or Renew OAuth</a>
								<button class="buttonS bBlack mb10" type="submit">Delete OAuth</button>
							</form>
						</td>
					</tr>
				</tbody></table>
			</div>
			<!-- Dialog content -->
			<div id="editoauthfb" class="editoauthfb" title="Edit App Connect">
				<form id="formeditoauthfb" method="post" action="<?php echo $aksi; ?>" autocomplete="off">
					<input type="hidden" name="mod" value="setting">
					<input type="hidden" name="act" value="editoauthfb">
					<label>Facebook App Id</label><br /><input class="required" type="text" id="oauth_key" name="oauth_key" value="<?php echo $currentOauthfb->oauth_key; ?>" style="width:97%;" required>
					<label>Facebook App Secret</label><br /><input class="required" type="text" id="oauth_secret" name="oauth_secret" value="<?php echo $currentOauthfb->oauth_secret; ?>" style="width:97%;" required>
					<span class="floatR"><a href="https://developers.facebook.com/docs/web/tutorials/scrumptious/register-facebook-application/" target="_blank">Help?</a></span>
					<div class="divider"><span></span></div>
					<span class="floatR" style="margin-top:5px; margin-bottom:5px;"><input class="buttonM bBlue" type="submit" value="Submit"></span>
				</form>
			</div>
	</div>
	<div class="widget">
		<div class="whead"><h6>PopojiCMSOAuth - Twitter Connect</h6><div class="clear"></div></div>
			<div id="dyn" class="hiddenpars">
<?php
				$tableoauthtw = new PoTable('oauth');
				$currentOauthtw = $tableoauthtw->findBy(id_oauth, '2');
				$currentOauthtw = $currentOauthtw->current();
?>
				<table class="tDefault" cellpadding="0" cellspacing="0" width="100%">
					<thead><tr><td><?php echo $langsetting3; ?></td><td><?php echo $langsetting4; ?></td></tr></thead>
					<tbody>
					<tr>
                        <td>Twitter Consumer Key</td>
                        <td><?php echo $currentOauthtw->oauth_key; ?></td>
					</tr>
					<tr>
                        <td>Twitter Consumer Secret</td>
                        <td><?php echo $currentOauthtw->oauth_secret; ?></td>
					</tr>
					<tr>
                        <td>Twitter Id</td>
                        <td><?php echo $currentOauthtw->oauth_id; ?></td>
					</tr>
					<tr>
                        <td>Twitter User</td>
                        <td><?php echo $currentOauthtw->oauth_user; ?></td>
					</tr>
					<tr>
                        <td colspan="2">
							<form method="post" action="<?php echo $aksi; ?>" autocomplete="off">
								<input type="hidden" name="mod" value="setting">
								<input type="hidden" name="act" value="deloauthtw">
								<a class="buttonS bBlack mb10" id="tbleditoauthtw">Edit App Connect</a>
								<a href="po-component/po-oauth/twitter/index.php" class="buttonS bBlack mb10">New Or Renew OAuth</a>
								<button class="buttonS bBlack mb10" type="submit">Delete OAuth</button>
							</form>
						</td>
					</tr>
				</tbody></table>
			</div>
			<!-- Dialog content -->
			<div id="editoauthtw" class="editoauthtw" title="Edit App Connect">
				<form id="formeditoauthtw" method="post" action="<?php echo $aksi; ?>" autocomplete="off">
					<input type="hidden" name="mod" value="setting">
					<input type="hidden" name="act" value="editoauthtw">
					<label>Twitter Consumer Key</label><br /><input class="required" type="text" id="oauth_key" name="oauth_key" value="<?php echo $currentOauthtw->oauth_key; ?>" style="width:97%;" required>
					<label>Twitter Consumer Secret</label><br /><input class="required" type="text" id="oauth_secret" name="oauth_secret" value="<?php echo $currentOauthtw->oauth_secret; ?>" style="width:97%;" required>
					<span class="floatR"><a href="http://iag.me/socialmedia/how-to-create-a-twitter-app-in-8-easy-steps/" target="_blank">Help?</a></span>
					<div class="divider"><span></span></div>
					<span class="floatR" style="margin-top:5px; margin-bottom:5px;"><input class="buttonM bBlue" type="submit" value="Submit"></span>
				</form>
			</div>
	</div>
<?php
	}else{
?>
    <div class="wrapper" id="errorWrapperadmin">
		<span class="errorNum">404</span>
		<div class="errorContent">
			<span class="errorDesc"><span class="icon-warning"></span>Ooops! Error Somethings Wrong</span>
			<div class="fluid">
				<?php
					$url = rtrim("http://".$_SERVER['HTTP_HOST'], "/").$_SERVER['PHP_SELF'];
					$url2 = preg_replace("/\/po-admin\/(admin\.php$)/","",$url);
					$siteurl = $url2;
				?>
				<a title="Back to Previous page" class="buttonM bLightBlue grid6" onClick="history.back();">Back to previous page</a>
				<a href="<?php echo $siteurl; ?>" title="Back to the website" class="buttonM bRed grid6">Back to the website</a>
			</div>
		</div>
	</div>
<?php
	}
    break;  
}
?>
	</div>
<?php
}
?>