<?php
/*
* Simlery by Simlution.org
* www.simlution.org
*/
extract( $_GET );
define( 'SESSION_KEY_NAME', dirname( $_SERVER['REQUEST_URI'] ) );

require 'config/general.php';
require DB_CONFIG_LANG;

session_start( );

require_once DIR_LANG.LANGUAGE.'.php';
header( 'Content-Type: text/html; charset='.$config['charset'] );
require_once DIR_LIBRARIES.'TplParser.php';
require_once DIR_LIBRARIES.'FileJobs.php';
require_once DIR_LIBRARIES.'FlatFiles.php';
require_once DIR_LIBRARIES.'FotoJobs.php';
require_once DIR_LIBRARIES.'Trash.php';
require_once DIR_PLUGINS.'plugins.php';

require_once DIR_CORE.'common.php';
require_once DIR_CORE.'common-admin.php';
require_once DIR_CORE.'pages.php';
require_once DIR_CORE.'pages-admin.php';
require_once DIR_CORE.'images.php';
require_once DIR_CORE.'images-admin.php';
require_once DIR_CORE.'votes-comments.php';
require_once DIR_CORE.'votes-comments-admin.php';
require_once DIR_CORE.'lang-admin.php';

require_once DIR_PLUGINS.'edit/htmleditor.php';

if( !isset( $p ) || empty( $p ) )
  $p  = 'news';

$aActions = getAction( $p );

$oFF =& FlatFiles::getInstance( );
$oFoto =& FotoJobs::getInstance( );
$oTpl =& TplParser::getInstance( DIR_TEMPLATES.'admin/', $config['embed_php'] );
$oFF->cacheFilesIndexes( $config_db );

$oPage =& PagesAdmin::getInstance( );
$oImage =& ImagesAdmin::getInstance( );
$content = null;

loginActions( $p, SESSION_KEY_NAME, 'container.tpl' );

if( $p == 'news' || $p == 'login' )
  $content .= $oTpl->tbHtml( 'container.tpl', 'HOME' );
elseif( isset( $aActions ) && is_file( 'actions_admin/'.$aActions['f'].'.php' ) )
  require 'actions_admin/'.$aActions['f'].'.php';

if( empty( $content ) )
  $content .= $oTpl->tbHtml( 'messages.tpl', 'ERROR' );

$sLangSelect = throwLangSelect( $config['language'] );

if( isset( $config['login'] ) && isset( $config['pass'] ) && $config['login'] == $config['pass'] )
  $sMsg .= $oTpl->tbHtml( 'messages.tpl', 'CHANGE_LOGIN_PASSWORD' );

echo $oTpl->tbHtml( 'container.tpl', 'HEAD' ).$oTpl->tbHtml( 'container.tpl', 'BODY' ).$content.$oTpl->tbHtml( 'container.tpl', 'FOOT' );
?>