<?php

/*
=================================================================
Bullet Energy - by White-Master 
-----------------------------------------------------------------
http://white-master.ru/
-----------------------------------------------------------------
Copyright (c) 2011 White-Master
=================================================================
Данный код защищен авторскими правами
=================================================================
Файл: main.class.php
=================================================================
*/
class BulletEnergy
{
   public $ajax = false;
   protected static $transcred = false;
   protected static $unline = false;
   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 $honor = array();
   protected static $title = array();
   protected static $translit_local = array();
   protected static $question = array();
   protected static $moderator = array();
   protected static $advertising = array();
   protected static $router = array();
   protected static $stats = array();
   protected static $share = array();
   protected static $type_action = array();
   protected static $handler = null;
   protected static $view = null;
   protected static $logged_is = null;
   protected static $debug = null;
   protected static $action = '';
   protected static $sub_action = '';
   protected static $hash_login = '';
   protected static $unsigneds = '';
   public function __construct()
   {
      global $config, $member_id, $user_group, $dle_login_hash, $is_logged, $bullet_energy_config, $bulletRouter, $bullet_energy_lang, $langdates, $langtranslit;
    //  var_dump($langtranslit);
      require_once (ENGINE_DIR . '/bullet_energy/classes/main_handler.class.php');
      if(!$bullet_energy_config['version']) {
         require_once (ENGINE_DIR . '/bullet_energy/data/forum_config.php');
      }
      if(!$bulletRouter['main']) {
         require_once (ENGINE_DIR . '/bullet_energy/data/router_param_type_' . $bullet_energy_config['is_cpu_type'] . '.php');
      }
      require_once (ENGINE_DIR . '/bullet_energy/classes/main_viewer.class.php');
      require_once (ENGINE_DIR . '/bullet_energy/data/forum_share.php');
      if(file_exists(ENGINE_DIR . '/bullet_energy/cache/system/types.tmp')) {
         require_once (ENGINE_DIR . '/bullet_energy/cache/system/types.tmp');
      }
      self::$type_action = $types;
      self::$share = $share;
      self::$logged_is = $is_logged;
      self::$config_dle = $config;
      self::$hash_login = $dle_login_hash;
      self::$id_member = $member_id;
      if(!self::$logged_is) {
         self::$id_member['user_group'] = 5;
      }
      self::$group_user = $user_group;
      self::$modules_config = $bullet_energy_config;
      self::$router = $bulletRouter;
      if(!$bullet_energy_lang) {
         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::$transcred = self::$handler->_transcred();
      self::$unline = self::$handler->_unline();
      self::$handler->_syntaxUrlCheck();
      self::$handler->_checkValidCashe();
      $this->ajax = self::$handler->_isAjax();
      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();
      self::$honor = self::$handler->setHonor();
      self::$title = self::$handler->setTitle();
      if(self::$action == 'categories') {
         self::$tree = self::$handler->setSystemTreeDirect();
      }
      self::$question = self::$handler->setQuestionCashe();
      self::$view = new BulletEnergyView;
      //   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(false);
            break;
         case 'watched_all':
            $result = self::$handler->_watchedContent(true);
            break;
         case 'add_topic':
            $result = self::$handler->_addTopicDB();
            break;
         case 'topic_user':
            $result = self::$handler->_topicUser();
            break;
         case 'search':
            $result = self::$handler->_searchPage();
            break;
         case 'unread':
            $result = self::$handler->_unreadPostTopic();
            break;
         case 'search_proccess':
            $result = self::$handler->_searchProcess();
            break;
         case 'trophies':
            $result = self::$handler->_userTrophies();
            break;
         case 'vote':
            $result = self::$handler->_vote();
            break;
         case 'discussion':
            $result = self::$handler->_discussion();
            break;
         default:
            $result = self::$handler->_home();
            break;
      }
      return $result /*. self::$debug->getDebug()*/;
   }
   public function SetMetaTag()
   {
      global $metatags;
      $metatags['title'] = self::$meta['title'];
      $metatags['description'] = self::$meta['description'];
      $metatags['keywords'] = self::$meta['keywords'];
      return $metatags;
   }
}

?>