<?php

/*
=================================================================
Bullet Energy - by White-Master 
-----------------------------------------------------------------
http://white-master.ru/
-----------------------------------------------------------------
Copyright (c) 2011 White-Master
=================================================================
Данный код защищен авторскими правами
=================================================================
Файл: site.php
=================================================================
*/
if ($_SERVER['HTTP_X_REQUESTED_WITH'] != "XMLHttpRequest") {
   die('die');
}
@session_start();
@error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);
@ini_set('display_errors', true);
@ini_set('html_errors', false);
@ini_set('error_reporting', E_ALL ^ E_WARNING ^ E_NOTICE);
define('DATALIFEENGINE', true);
define('ROOT_DIR', substr(dirname(__file__), 0, -26));
define('ENGINE_DIR', ROOT_DIR . '/engine');
include ENGINE_DIR . '/data/config.php';
if ($config['http_home_url'] == "") {
   $config['http_home_url'] = explode("engine/bullet_energy/ajax/site.php", $_SERVER['PHP_SELF']);
   $config['http_home_url'] = reset($config['http_home_url']);
   $config['http_home_url'] = "http://" . $_SERVER['HTTP_HOST'] . $config['http_home_url'];
}
require_once ENGINE_DIR . '/classes/mysql.php';
require_once ENGINE_DIR . '/data/dbconfig.php';
require_once ENGINE_DIR . '/modules/functions.php';
require_once ENGINE_DIR . '/modules/sitelogin.php';
$user_group = get_vars("usergroup");
if (!$user_group) {
   $user_group = array();
   $db->query("SELECT * FROM " . USERPREFIX . "_usergroups ORDER BY id ASC");
   while ($row = $db->get_row()) {
      $user_group[$row['id']] = array();
      foreach ($row as $key => $value) {
         $user_group[$row['id']][$key] = stripslashes($value);
      }
   }
   set_vars("usergroup", $user_group);
   $db->free();
}
$action = totranslit($_REQUEST['be_action'], true, true);
require_once ENGINE_DIR . '/bullet_energy/classes/ajax.class.php';
$ajax = new BulletAjax;
switch ($action) {
   case 'refresh_list':
      $result = $ajax->ajax_handler->refreshAttachmentListProcess(); //
      break;
   case 'refresh_list_do_upload':
      $result = $ajax->ajax_handler->refreshAttachmentListEditorProcess(); //
      break;
   case 'delete_attach':
      $result = $ajax->ajax_handler->deleteAttachmentProcess(); //
      break;
   case 'delete_msg':
      $result = $ajax->ajax_handler->deleteMsgTopicProcess(); //
      break;
   case 'save_msg_ajax_edit':
      $result = $ajax->ajax_handler->EditSaveMsgProcess(); //
      break;
   case 'add_msg_ajax':
      $result = $ajax->ajax_handler->messageAddAjaxProcess();
      break;
   case 'read_tree':
      $result = $ajax->ajax_handler->readTreeProcess();
      break;
   case 'edit_msg_ajax':
      $result = $ajax->ajax_handler->msgEditAjaxProcess();
      break;
   case 'get_profile_card':
      $result = $ajax->ajax_handler->getProfileCardProcess(); //
      break;
   case 'complaint':
      $result = $ajax->ajax_handler->ComplaintPostProcess(); //
      break;
   case 'topic_edit':
      $result = $ajax->ajax_handler->TopicEditProcess();
      break;
   case 'update_topic':
      $result = $ajax->ajax_handler->TopicUpdateProcess();
      break;
   case 'tree_delete':
      $result = $ajax->ajax_handler->deleteTree(); //
      break;
   case 'delete_questions':
      $result = $ajax->ajax_handler->questionsDelete();
      break;
   case 'delete_moderator':
      $result = $ajax->ajax_handler->moderatorDelete();
      break;
   case 'delete_advertising':
      $result = $ajax->ajax_handler->advertisingDelete();
      break;
   case 'recount_tree':
      $result = $ajax->ajax_handler->recountTree(); //
      break;
   case 'recount_topic_last':
      $result = $ajax->ajax_handler->recountTopicLast();
      break;
   case 'recount_tree_last':
      $result = $ajax->ajax_handler->recountTreeLast();
      break;
   case 'topic_option':
      $result = $ajax->ajax_handler->topicOptionEdit();
      break;
   case 'like':
      $result = $ajax->ajax_handler->like(); //
      break;
   case 'like_all':
      $result = $ajax->ajax_handler->likeAll(); //
      break;
   case 'feed':
      $result = $ajax->ajax_handler->feed();
      break;
   case 'delete_all_cashe':
      $result = $ajax->ajax_handler->deleteCache();
      break;
   case 'delete_complain':
      $result = $ajax->ajax_handler->deleteComplain(); //
      break;
   case 'delete_post':
      $result = $ajax->ajax_handler->deleteMessageOnlyAdmin();
      break;
   case 'delete_trof':
      $result = $ajax->ajax_handler->deleteTrophies();
      break;
   case 'delete_rank':
      $result = $ajax->ajax_handler->deleteRank();
      break;
   case 'redirect':
      $result = $ajax->ajax_handler->redirect();
      break;
   case 'user_trophies':
      $result = $ajax->ajax_handler->userTrophiesAll();
      break;
   case 'recount_user':
      $result = $ajax->ajax_handler->recountUser();
      break;
   case 'un_feed':
      $result = $ajax->ajax_handler->unFeed();
      break;
   case 'lock':
      $result = $ajax->ajax_handler->lockMessage();
      break;
   case 'unlock':
      $result = $ajax->ajax_handler->unLockMessage();
      break;
   case 'vote':
      $result = $ajax->ajax_handler->vote();
      break;
   case 'result':
      $result = $ajax->ajax_handler->voteResult();
      break;
   case 'all_answer':
      $result = $ajax->ajax_handler->voteAll();
      break;
   case 'get_topic_preview':
      $result = $ajax->ajax_handler->getPreview();
      break;
   case 'warning':
      $result = $ajax->ajax_handler->warning();
      break;
   case 'set_warning':
      $result = $ajax->ajax_handler->setWarning();
      break;
   case 'warning_delete':
      $result = $ajax->ajax_handler->deleteWarning();
      break;
   case 'get_editor_vote':
      $result = $ajax->ajax_handler->getEditorVote();
      break;
   case 'save_editor_vote':
      $result = $ajax->ajax_handler->updateVote();
      break;
   case 'delete_answer_vote':
      $result = $ajax->ajax_handler->deleteAnswerVote();
      break;
   case 'delete_vote':
      $result = $ajax->ajax_handler->deleteVote();
      break;
   case 'share':
      $result = $ajax->ajax_handler->share();
      break;
   case 'share_update':
      $result = $ajax->ajax_handler->shareUpdatePosition();
      break;
   case 'mass_configure':
      $result = $ajax->ajax_handler->massConfigure();
      break;
   case 'activate':
      $result = $ajax->ajax_handler->activate();
      break;
   default:
      die('die');
      break;
}
header("Content-type: text/html; charset=" . $config['charset']);
echo $result;

?>