<?php
session_name("s".base64_decode($_COOKIE[register]));
session_start ();
$sesspass = "base64_decode($_COOKIE[register])";
if (session_id() == "" and $_SESSION[$sesspass] != session_id()) 
{
	session_unset ();
	session_destroy ();
	header ("location: index.php?n=503");
}
if (!session_is_registered("s".base64_decode($_COOKIE[register]))) 
{
	session_unset ();
	session_destroy ();
	header ("location: index.php?n=503");
}
require "../inc/config.php";
require "engine/functions.php";
require "../inc/langs/".$s40[lang].".php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $l[admintitle]; ?></title>
<meta name="robots" content="NOFOLLOW,NOINDEX" />
<link href="style/style.css" rel="stylesheet" type="text/css" />
<link href="libs/jquery.colorbox.css" rel="stylesheet" type="text/css" />
<link href="libs/jquery.validate.css" rel="stylesheet" type="text/css" />
<link href="default.ico" rel="shortcut icon" type="image/icon" />
<script type="text/javascript" src="libs/jquery.js"></script>
<script type="text/javascript" src="libs/jquery.corners.js"></script>
<script type="text/javascript" src="libs/jquery.colorbox.js"></script>
<script type="text/javascript" src="libs/jquery.tablesorter.js"></script>
<?php if($_GET[a] == "settings"){include "inc/libs_settings.php";} ?>
<?php if($_GET[a] == "newpage"){include "inc/libs_newpage.php";} ?>
<?php if($_GET[a] == "editpage"){include "inc/libs_editpage.php";} ?>
<?php if($_GET[a] == "gallery"){include "inc/libs_gallery.php";} ?>
<?php if($_GET[a] == "addons"){include "inc/libs_addons.php";} ?>
<script type="text/javascript" src="libs/jquery.s40.js"></script>
<?php if($_GET[a] == "editor"){?>
<script type="text/javascript" src="libs/code_mirror/js/codemirror.js"></script>
<script type="text/javascript">
function submitForm() {
      document.getElementById("output").value = editor.getCode();
  }
</script> 
<?php } ?>
<?php if($_GET[a] == "backup" and $_GET[download]){?>
<script type="text/javascript">
function downloadArchive(){
	window.open('<?php echo $_GET[archive]; ?>');
}
</script> 
<?php } ?>
</head>
<body style="direction:<?php echo $s40[langdir];?>" <?php if ($_GET[download]) { echo "onload=\"downloadArchive()\""; }?> >
<?php echo notes($_GET[n],$s40[lang],$_GET[a]); ?>
<div id="header">
  <h1><?php echo $l[admintitle]; ?></h1>
  <h2><?php echo $s40[title]; ?></h2>
</div>
<div id="content">
<div id="top" class="roundtop"></div>
<div id="mid">
<ul id="nav">
	<li class="mainnav"><a href="main.php?a=settings"><?php echo $l[settings];?></a></li>
	<li class="mainnav"><a href="main.php?a=pages"><?php echo $l[pages];?></a>
		 <ul class="subnav">
			<li><a href="main.php?a=newpage"><?php echo $l[newpage];?></a></li>
    	</ul>
	</li>
    <li class="mainnav"><a href="main.php?a=gallery"><?php echo $l[gallery];?></a></li>
    <li class="mainnav"><a href="main.php?a=addons"><?php echo $l[addons];?></a>
    	<ul class="subnav">
			<li><a href="main.php?a=addons#languages"><?php echo $l[languages];?></a></li>
            <li><a href="main.php?a=addons#gadgets"><?php echo $l[gadgets];?></a></li>
            <li><a href="main.php?a=addons#themes"><?php echo $l[themes];?></a></li>
    	</ul>
    </li>
    <li class="mainnav"><a href="main.php?a=backup"><?php echo $l[backup];?></a></li>
    <li class="exit"><a href="engine/exit.php"><?php echo $l[logout];?></a></li>
</ul>
<div id="inner">
<?php include nav($_GET[a]); ?>
</div>
</div>
<div id="end" class="roundbtm"></div>
</div>
<div id="footer">
  <ul>
    <li><a href="http://s40.biz" target="_blank">S40 CMS v. <?php echo $s40[version]; ?> (2010<?php if(date("Y")>2010){echo " - ".date("Y");} ?>)</a> </li>
    <li><a href="../"><?php echo $l[backtosite]; ?></a></li>
  </ul>
</div>
<?php if($_GET[a] == "editor"){?>
<script type="text/javascript">
  var textarea = document.getElementById('code');
  var editor = new CodeMirror(CodeMirror.replace(textarea), {
    height: "400px",
    width: "auto",
    content: textarea.value,
    parserfile: ["parsecss.js", "tokenizejavascript.js", "parsejavascript.js", "parsehtmlmixed.js"],
    stylesheet: ["libs/code_mirror/css/csscolors.css", "libs/code_mirror/css/jscolors.css"],
    path: "libs/code_mirror/js/",
	continuousScanning: 500,
    lineNumbers: true,
    autoMatchParens: true,
	initCallback: function(getContents) {return editor.getCode();}
  });
  function save(){
	document.getElementById('code').value = editor.getContents; 
  }
</script>
<?php } ?>
</body>
</html>