<?php
/*
=================================================================
Bullet Energy - by White-Master 
-----------------------------------------------------------------
http://white-master.ru/
-----------------------------------------------------------------
Copyright (c) 2011 White-Master
=================================================================
Данный код защищен авторскими правами
=================================================================
Файл: main.class.php
=================================================================
*/
class BulletEnergy
{
  protected static $id_member = array();
  protected static $config_dle = array();
  protected static $modules_lang = array();
  protected static $group_user = array();
  protected static $modules_config = array();
  protected static $groups_config = array();
  protected static $sys_cashe = array();
  protected static $meta = array();
  protected static $lang_local = array();
  protected static $tree = array();
  protected static $treePermanent = array();
  protected static $translit_local = array();
  protected static $question = array();
  protected static $moderator = array();
  protected static $advertising = array();
  protected static $stats = array();
  protected static $handler = null;
  protected static $view = null;
  protected static $logged_is = null;
  protected static $debug = null;
  // protected static $debugBlock = false;
  protected static $action = '';
  protected static $sub_action = '';
  protected static $hash_login = '';
  public function __construct()
  {
    require_once (ENGINE_DIR . '/bullet_energy/data/forum_config.php');
    require_once (ENGINE_DIR . '/bullet_energy/classes/main_viewer.class.php');
    //:TODO: view class remove handler include
    //:TODO: class name no standart, new versaion rename
    //:TODO: method setMeta need refrect
    require_once (ENGINE_DIR . '/bullet_energy/classes/main_handler.class.php');
    //require_once (ENGINE_DIR . '/bullet_energy/classes/linck.class.php');
    global $config, $member_id, $user_group, $dle_login_hash, $is_logged;
    self::$logged_is = $is_logged;
    self::$config_dle = $config;
    self::$hash_login = $dle_login_hash;
    self::$id_member = $member_id;
    self::$group_user = $user_group;
    self::$modules_config = $bullet_energy_config;
    require_once (ENGINE_DIR . '/bullet_energy/library/language/' . self::$config_dle['langs'] . '/site.lng');
    self::$modules_lang = $bullet_energy_lang;
    self::$lang_local = $langdates;
    self::$translit_local = $langtranslit;
    self::$action = strip_tags(totranslit($_REQUEST['action'], true, true));
    self::$sub_action = strip_tags(totranslit($_REQUEST['sub_action'], true, true));
    self::$handler = new BulletEnergyHandler;
    self::$view = new BulletEnergyView;
    self::$handler->_checkValidCashe();
    self::$groups_config = self::$handler->set_group_cashe();
    self::$stats = self::$handler->setStatCashe();
    self::$sys_cashe = self::$handler->setSystemCasheGroup();
    self::$treePermanent = self::$handler->setSystemTreePermanent();
    self::$moderator = self::$handler->setModeratorCashe();
    self::$advertising = self::$handler->setAdvertising();
    if (self::$action == 'categories') {
      self::$tree = self::$handler->setSystemTreeDirect();
    }
    self::$question = self::$handler->setQuestionCashe();
    //    require_once (ENGINE_DIR . '/bullet_energy/classes/debug.class.php');
    //    self::$debug = new BulletEnergyDebug;
  }
  public function Init()
  {
    if (self::$modules_config['forum_status']) {
      if (!self::$groups_config[self::$id_member['user_group']]['be_access_view_forum_off']) {
        return self::$view->error_set(self::$modules_lang['information'], self::$modules_config['off_line_status'], array(self::$modules_lang['information']));
      }
    }
    switch (self::$action) {
      case 'main':
        $result = self::$handler->_home();
        break;
      case 'categories':
        $result = self::$handler->_pageTree();
        break;
      case 'showtopic':
        $result = self::$handler->_viewTopic();
        break;
      case 'moderation':
        $result = self::$handler->_moderation();
        break;
      case 'moderation_update':
        $result = self::$handler->_moderationProcess();
        break;
      case 'add_message':
        if (self::$handler->getInt('reply_full')) {
          $result = self::$handler->_replyFull();
        } else {
          $result = self::$handler->_addMessageDB();
        }
        break;
      case 'findpost':
        $result = self::$handler->_findPost();
        break;
      case 'new_post':
        $result = self::$handler->_topicUnread();
        break;
      case 'message_user':
        $result = self::$handler->_messageUser();
        break;
      case 'newtopic':
        $result = self::$handler->_newTopic();
        break;
      case 'watched':
        $result = self::$handler->_watchedContent();
        break;
      case 'add_topic':
        $result = self::$handler->_addTopicDB();
        break;
      case 'topic_user':
        $result = self::$handler->_topicUser();
        break;
      case 'search':
        $result = self::$handler->_searchPage();
        break;
      default:
        $result = self::$handler->_home();
        break;
    }
    //Имей совесть! Заплати за снятие копирайта.
    return $result . '<div class="copyInfo"><div class="innertBox">Povered by <a href="http://white-master.ru/">Bullet Energy 1.0</a></div></div>';
  }
  public function SetMetaTag()
  {
    global $metatags;
    $metatags['title'] = self::$meta['title'];
    $metatags['description'] = self::$meta['description'];
    $metatags['keywords'] = self::$meta['keywords'];
    return $metatags;
  }
}

?>