<?php

/*
=================================================================
Bullet Energy - by White-Master 
-----------------------------------------------------------------
http://white-master.ru/
-----------------------------------------------------------------
Copyright (c) 2011 White-Master
=================================================================
Данный код защищен авторскими правами
=================================================================
Файл: bullet_energy.php
=================================================================
*/
//:TODO: refrect switch
if (!defined('DATALIFEENGINE') or !defined('LOGGED_IN')) {
   die("Hacking attempt!");
}
if ($member_id['user_group'] != 1) {
   msg("error", $lang['addnews_denied'], $lang['db_denied']);
}
require_once ENGINE_DIR . '/bullet_energy/classes/admin.class.php';
require_once ENGINE_DIR . '/bullet_energy/library/language/' . $config['langs'] . '/admin.lng';
$option = array('action' => strtolower(strip_tags(totranslit($_REQUEST['be_action'], true, true))), 'subAction' => strtolower(strip_tags(totranslit($_REQUEST['sub_action'], true, true))));
$bulletAdmin = new bullet_energy_admin;
switch ($option['action']) {
   case 'activate':
      $result = $bulletAdmin->activate();
      break;
   case 'configure':
      if ($_POST['save'] == 'all_configure' and is_array($_POST['save_param']) and $_POST['submit'] == "") {
         if ($bulletAdmin->save_config()) {
            @header("Location: {$_SERVER['HTTP_REFERER']}");
         }
      }
      $option['config'] = $bulletAdmin->ul_get_config();
      $result = $bulletAdmin->page_all_configure();
      break;
   case 'user':
      if ($option['subAction'] != null or $option['subAction'] != '') {
         switch ($option['subAction']) {
            case 'access':
               $result = $bulletAdmin->page_access_user();
               break;
            case 'access_editor':
               $result = $bulletAdmin->page_access_editor_user();
               break;
            case 'param_group_update':
               $result = $bulletAdmin->page_param_group_update();
               break;
            case 'moderator':
               $result = $bulletAdmin->moderator();
               break;
            case 'add_moderator':
               $result = $bulletAdmin->add_moderator();
               break;
            case 'add_moderator_db':
               $result = $bulletAdmin->add_moderator_db();
               break;
         }
      } else {
         $result = $bulletAdmin->page_user();
      }
      $option['user'] = $bulletAdmin->ul_get_user();
      break;
   case 'service':
      if ($_POST['save'] == 'all_router' and is_array($_POST['router']) and $_POST['submit'] == "") {
         if ($bulletAdmin->saveRouter()) {
            @header("Location: {$_SERVER['HTTP_REFERER']}");
         }
      }
      if ($option['subAction'] != null or $option['subAction'] != '') {
         switch ($option['subAction']) {
            case 'category':
               $result = $bulletAdmin->page_category();
               break;
            case 'captcha':
               $result = $bulletAdmin->questionsViewPage();
               break;
            case 'question_edit':
               $result = $bulletAdmin->questionsEdit();
               break;
            case 'add_question_db':
               $result = $bulletAdmin->questionAddDb();
               break;
            case 'advertising':
               $result = $bulletAdmin->advertising();
               break;
            case 'add_advertising_db':
               $result = $bulletAdmin->advertisingAddDb();
               break;
            case 'router':
               $result = $bulletAdmin->router();
               break;
            case 'share':
               $result = $bulletAdmin->share();
               break;
            case 'add_advertising_update':
               $result = $bulletAdmin->advertisingUpdate();
               break;
            case 'advertising_add':
               $result = $bulletAdmin->advertisingAddPage();
               break;
            case 'advertising_edit':
               if ($_REQUEST['id']) {
                  $result = $bulletAdmin->advertisingEdit();
               } else {
                  die('no param');
               }
               break;
            case 'update_question':
               $result = $bulletAdmin->questionUpdate();
               break;
            case 'add_question':
               $result = $bulletAdmin->add_question();
               break;
            case 'add_category':
               $result = $bulletAdmin->page_add_cat();
               break;
            case 'add_tree':
               $result = $bulletAdmin->treeAddDb();
               break;
            case 'update_tree':
               $result = $bulletAdmin->page_update_tree();
               break;
            case 'cash':
               $result = $bulletAdmin->cashe_param();
               break;
            case 'complaint':
               $result = $bulletAdmin->complaint();
               break;
            case 'template':
               $result = $bulletAdmin->template();
               break;
            case 'add_template_db':
               $result = $bulletAdmin->updateTamplate();
               break;
            case 'trophies':
               $result = $bulletAdmin->trophies(false);
               break;
            case 'trophies_add':
               $result = $bulletAdmin->trophies(true);
               break;
            case 'sortable':
               $result = $bulletAdmin->sortTree();
               break;
            case 'add_trophies_db':
               $result = $bulletAdmin->trophiesAdDb();
               break;
            case 'add_trophies_update':
               $result = $bulletAdmin->trophiesUpdate();
               break;
            case 'trophies_edit':
               if (isset($_REQUEST['id_trophies'])) {
                  $result = $bulletAdmin->editTrophies();
               } else {
                  die('ERROR');
               }
               break;
            case 'edit_category':
               if (isset($_REQUEST['id_category'])) {
                  $result = $bulletAdmin->page_edit_tree();
               } else {
                  die('ERROR');
               }
               break;
            case 'rank':
               $result = $bulletAdmin->rank(false);
               break;
            case 'update_rank':
               $result = $bulletAdmin->rankUpdate();
               break;
            case 'rank_edit':
               if (isset($_REQUEST['id_rank'])) {
                  $result = $bulletAdmin->rankEdit();
               } else {
                  die('ERROR');
               }
               break;
            case 'rank_add':
               $result = $bulletAdmin->rank(true);
               break;
            case 'add_rank':
               $result = $bulletAdmin->rankAdd();
               break;
         }
      } else {
         $result = $bulletAdmin->page_servise();
      }
      $option['service'] = $bulletAdmin->ul_get_servise();
      break;
   default:
      $result = $bulletAdmin->page_main();
      break;
}
echo <<< HTML
<!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" xml:lang="ru" lang="ru">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={$config['charset']}" />
<title>{$be_lang['AC_tiil']}</title>
<meta name="description" content="{$be_lang['AC_descr']}" />
<meta name="keywords" content="{$be_lang['AC_key']}" />
<meta name="generator" content="Bullet Energy" /> 

<link media="screen" href="/engine/bullet_energy/library/jquery/jquery-ui.css" type="text/css" rel="stylesheet" />
<link media="screen" href="/engine/bullet_energy/library/bbcode/bbcode.css" type="text/css" rel="stylesheet" />
<link media="screen" href="/engine/bullet_energy/library/colorpicker/colorpicker.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/engine/bullet_energy/library/jquery/jquery.js"></script>
<script type="text/javascript" src="/engine/bullet_energy/library/jquery/jqueryui.js"></script>
<script type="text/javascript" src="/engine/bullet_energy/library/jquery/jquery.ui.draggable.js"></script>
<script type="text/javascript" src="/engine/bullet_energy/library/jquery/jquery.ui.sortable.js"></script>
<script type="text/javascript" src="/engine/bullet_energy/library/bbcode/bbcodes.js"></script>
<script type="text/javascript" src="/engine/bullet_energy/library/colorpicker/colorpicker.js"></script>
<script type="text/javascript" src="/engine/bullet_energy/library/colorpicker/eye.js"></script>
<script type="text/javascript" src="/engine/bullet_energy/library/colorpicker/utils.js"></script>
<script type="text/javascript" src="/engine/bullet_energy/admin_skins/black/js/base_forum_admin.js"></script>
<link media="screen" href="/engine/bullet_energy/admin_skins/black/css/style.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
 $(document).ready(function () {
   $("#sortTbl").sortable({
    placeholder: "ui-state-highlight",
    cursor: 'pointer',
    start: function (e, ui) {
        startPos = ui.item.prevAll().length + 1;
    },
    update: function (event, ui) {
        $.post(be_root + 'engine/bullet_energy/ajax/site.php', {
            be_action: 'share_update',
            element: ui.item.attr('id'),
            position: ui.item.prevAll().length + 1,
            position_old : startPos,
            list: $(this).sortable('toArray'),
            hash: login_hash
        }, function (data) {
            if (data.param == 1) {
                //ok
            } else {
                //no ok
            }
        }, "json");
    },
  });
     $('#colorSelectorLi , #colorSelectorLi1').ColorPicker({
         color: '#0000ff',
         onShow: function (colpkr) {
             $(colpkr).fadeIn(50);
             return false;
         },
         onHide: function (colpkr) {
             $(colpkr).fadeOut(50);
             return false;
         },
         onSubmit: function (hsb, hex, rgb, el) {
             $('#' + $(el).next().attr('id')).css('color', '#' + hex);
             $('#i_' + $(el).next().attr('id')).val('#' + hex);
             $(".colorpicker").fadeOut(50);
         },
         onChange: function (hsb, hex, rgb) {
             $('#colorSelector div').css('backgroundColor', '#' + hex);
         }
     });
 });
</script>
<script type="text/javascript">
var be_root       = '{$config['http_home_url']}';
var login_hash = '{$dle_login_hash}';
var titl_popup = '{$be_lang['admin_error_titl']}';
var error_message = '{$be_lang['admin_error_text']}';
var popup_yes = '{$be_lang['yes']}';
var popup_no = '{$be_lang['no']}';
</script>
</head>
<body>
<div style="display:none" id="loading-layer"><div id="loading-layer-text">{$be_lang['admin_add_tree_47']}</div></div>
<div id="main">
  <div id="top">
 <!--<div class="innnert_main"></div>-->
  </div>
  <div id="menu">
    <div class="innnert_main">
      <ul>
        <li class="active"><a href="$PHP_SELF?mod=bullet_energy">{$be_lang['admin_be_ac']}</a></li>
        <li><a href="$PHP_SELF?mod=options&action=options">{$be_lang['admin_all_ac']}</a></li>
        <li><a target="_blank" href="{$config['http_home_url']}">{$be_lang['admin_to_site']}</a></li>
        <li><a target="_blank" href="{$config['http_home_url']}forum">{$be_lang['admin_to_forum']}</a></li>
      </ul>
    </div>
  </div>
  <div id="content">
    <div class="innnert_main">
      <div id="left_block">
        <ul>
          <li><a class="active main" href="{$PHP_SELF}?mod=bullet_energy">{$be_lang['admin_main']}</a></li>
          <li><a class="configure" href="{$PHP_SELF}?mod=bullet_energy&be_action=configure">{$be_lang['admin_configure']}</a>
            {$option['config']} 
          </li>
          <li><a class="restore" href="{$PHP_SELF}?mod=bullet_energy&be_action=service&sub_action=category">{$be_lang['admin_optimize']}</a>
             {$option['service']}
          </li>
          <li><a class="users" href="{$PHP_SELF}?mod=bullet_energy&be_action=user&sub_action=access">{$be_lang['admin_user']}</a>
           {$option['user']}
          </li>
           <li><a class="activate" href="{$PHP_SELF}?mod=bullet_energy&be_action=activate">{$be_lang['activate']}</a></li>
        </ul>
      </div>
      <div id="right_block">
        <div class="block_content">{$result}</div>
      </div>
    </div>
  </div>
  <div id="footer">
    <div class="innnert_main">
      <ul>
        <li><a title="Перейти на сайт разработчика" target="_blank" href="http://white-master.ru/">Bullet Energy 1.2</a></li>
        <li class="cupy_info"><a title="Система управления форумом" target="_blank" href="http://white-master.ru/">Powered by White-Master</a></li>
      </ul>
    </div>
  </div>
</div>
</body>
</html>
HTML;

?>