<?php

if(!defined('DATALIFEENGINE')) {
   die("Hacking attempt!");
}
class bullet_energy_admin
{
   private $dle_config = array();
   private $id_member = array();
   private $group_user = array();
   private $lang_be = array();
   private $router = array();
   private $modul_config = array();
   private $share = array();
   private $login_hash = '';
   private $config_dir = '';
   private $php_self = '';
   private $db = null;
   private $filter = null;
   private $casheSySPath = '';
   private $_cleanString = array("\r" => '', "\n" => '', "\0" => '', "\xC2\xA0" => ' ');
   public function bullet_energy_admin()
   {
      //:TODO: need full refrect!
      global $config, $member_id, $user_group, $dle_login_hash, $be_lang, $PHP_SELF;
      $this->dle_config = $config;
      $this->php_self = $PHP_SELF;
      $this->group_user = $user_group;
      $this->id_member = $member_id;
      $this->login_hash = $dle_login_hash;
      $this->casheSySPath = ENGINE_DIR . '/bullet_energy/cache/system/';
      $this->config_dir = ENGINE_DIR . '/bullet_energy/data/';
      require_once ENGINE_DIR . '/bullet_energy/data/forum_config.php';
      require_once ENGINE_DIR . '/bullet_energy/data/forum_share.php';
      $this->share = $share;
      $bullet_energy_config['is_cpu_type'] = (int)$bullet_energy_config['is_cpu_type'];
      require_once ENGINE_DIR . '/bullet_energy/data/router_param_type_' . $bullet_energy_config['is_cpu_type'] . '.php';
      $this->modul_config = $bullet_energy_config;
      $this->router = $bulletRouter;
      $this->lang_be = $be_lang;
      if(!class_exists('db')) {
         require_once ENGINE_DIR . '/classes/mysql.class.php';
      }
      $this->db = new db;
      if(!class_exists('BulletFilter')) {
         require_once ENGINE_DIR . '/bullet_energy/classes/filter.class.php';
      }
      $this->filter = new BulletFilter;
   }
   public function sortTree()
   {
      foreach ($_POST["position"] as $id => $position) {
         $position = intval($position) > 0 ? intval($position) : 0;
         $id = intval($id);
         if(!$id) {
            continue;
         }
         $this->db->query("UPDATE " . PREFIX . "_be_tree SET tree_display = {$position} WHERE tree_id = {$id} LIMIT 1");
      }
      $this->casheRefresh();
      header("Location:" . $this->php_self . "?mod=bullet_energy&be_action=service&sub_action=category");
   }
   public function trophies($add = false)
   {
      $row = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_honor");
      if($row['count'] == 0 or $add) {
         $ret = '<form action="" name="trophies" method="post"><div class="content" id="general"><h1>' . $this->lang_be['setting_228'] . '</h1><ul><li><span>' . $this->lang_be['setting_229'] . '</span> <span class="info">' . $this->lang_be['setting_230'] . '</span><input type="text" size="66" value="" name="trophies[name]" class="edit"></li><li><span>' . $this->lang_be['setting_238'] . '</span> <span class="info">' . $this->lang_be['setting_239'] . '</span><input type="text" class="edit" name="trophies[bals]" value="" size="66"></li><li><span>' . $this->lang_be['setting_231'] . '</span><span class="info">' . $this->lang_be['setting_232'] . '</span>' . $this->_getSelectGroup(false, 'trophies') . '</li><li><span>' . $this->lang_be['setting_233'] . '</span><br><textarea class="edit" style="width:969px;height:100px;" name="trophies[desc]"></textarea></li><li><span>' . $this->lang_be['setting_234'] . '</span> <span class="info">' . $this->lang_be['setting_237'] . '</span><input type="text" class="edit" name="trophies[day]" value="" size="66"></li><li><span>' . $this->lang_be['setting_235'] . '</span> <span class="info">' . $this->lang_be['setting_237'] . '</span><input type="text" class="edit" name="trophies[post]" value="" size="66"></li><li><span>' . $this->lang_be['setting_236'] . '</span> <span class="info">' . $this->lang_be['setting_237'] . '</span><input type="text" class="edit" name="trophies[like]" value="" size="66"></li><input type="hidden" name="sub_action" value="add_trophies_db"><button class="be_button" name="add_sub" type="submit">' . $this->lang_be['add'] . '</button></ul>' . $this->lang_be['setting_288'] . '</div></form>';
      } else {
         $this->db->query("SELECT * FROM " . PREFIX . "_be_honor");
         while ($row = $this->db->get_row()) {
            $row['criteria'] = unserialize($row['criteria']);
            $ret .= '<tr class="list"><td><input type="radio" value="' . $row['id'] . '" uid="sub_tree" name="tree"></td><td class="tree_info"><a style="padding-left:0px" href="' . $this->php_self . '?mod=bullet_energy&amp;be_action=service&amp;sub_action=trophies_edit&amp;id_trophies=' . $row['id'] . '" title="Редактировать">' . $row['criteria']['name'] . '</a></td><td>' . $row['criteria']['desc'] . '</td><td>' . $row['bals'] . '</td></tr>';
         }
         $ret = '<h1>' . $this->lang_be['setting_269'] . '</h1><div class="button_table_param"><div class="parent_child"><div class="fbutton"><div><span class="add"><a href="' . $this->php_self . '?mod=bullet_energy&amp;be_action=service&amp;sub_action=trophies_add">' . $this->lang_be['setting_265'] . '</a></span></div></div><div class="fbutton"><div><span onclick="TroofDell()" class="del">' . $this->lang_be['setting_266'] . '</span></div></div></div></div><table cellspacing="0" cellpadding="0" border="0" class="table_tree" id="table"><thead><tr><th class="w25"><div>&nbsp;</div></th><th><div>' . $this->lang_be['setting_262'] . '</div></th><th class="w300"><div>' . $this->lang_be['setting_263'] . '</div></th><th class="w90 last"><div>' . $this->lang_be['setting_264'] . '</div></th></tr></thead><tbody>' . $ret . '</tbody></table>';
      }
      return $ret;
   }
   public function editTrophies()
   {
      $optipn = array('id' => $this->getInt('id_trophies'));
      $this->db->query("SELECT id,group_name FROM " . PREFIX . "_usergroups");
      $group = array();
      while ($row = $this->db->get_row()) {
         $group[$row['id']] = array();
         foreach ($row as $key => $value) {
            $group[$row['id']][$key] = stripslashes($value);
         }
      }
      $this->db->query("SELECT * FROM " . PREFIX . "_be_honor WHERE id = {$optipn['id']} LIMIT 1");
      $row = $this->db->num_rows() ? $this->db->get_row() : die('Error');
      $row['data'] = unserialize($row['criteria']);
      foreach ($group as $key => $value) {
         $value['sels'] = in_array($value['id'], $row['data']['group']) ? ' selected="selected" ' : '';
         $optipn['retG'] .= '<option ' . $value['sels'] . ' value="' . $value['id'] . '">' . $value['group_name'] . '</option>';
      }
      $optipn['retG'] = '<select multiple="" id="trophies" name="trophies[group][]">' . $optipn['retG'] . '</select>';
      $ret = '<form action="" name="trophies" method="post"><input type="hidden" name="id" value="' . $optipn['id'] . '" /><div class="content" id="general"><h1>' . $this->lang_be['setting_268'] . '</h1><ul><li><span>' . $this->lang_be['setting_229'] . '</span> <span class="info">' . $this->lang_be['setting_230'] . '</span><input type="text" size="66" value="' . $row['data']['name'] . '" name="trophies[name]" class="edit"></li><li><span>' . $this->lang_be['setting_238'] . '</span> <span class="info">' . $this->lang_be['setting_239'] . '</span><input type="text" class="edit" name="trophies[bals]" value="' . $row['bals'] . '" size="66"></li><li><span>' . $this->lang_be['setting_231'] . '</span><span class="info">' . $this->lang_be['setting_232'] . '</span>' . $optipn['retG'] . '</li><li><span>' . $this->lang_be['setting_233'] . '</span><br><textarea class="edit" style="width:969px;height:100px;" name="trophies[desc]">' . $row['data']['desc'] . '</textarea></li><li><span>' . $this->lang_be['setting_234'] . '</span> <span class="info">' . $this->lang_be['setting_237'] . '</span><input type="text" class="edit" name="trophies[day]" value="' . $row['data']['day'] . '" size="66"></li><li><span>' . $this->lang_be['setting_235'] . '</span> <span class="info">' . $this->lang_be['setting_237'] . '</span><input type="text" class="edit" name="trophies[post]" value="' . $row['data']['post'] . '" size="66"></li><li><span>' . $this->lang_be['setting_236'] . '</span> <span class="info">' . $this->lang_be['setting_237'] . '</span><input type="text" class="edit" name="trophies[like]" value="' . $row['data']['like'] . '" size="66"></li><input type="hidden" name="sub_action" value="add_trophies_update"><button class="be_button" name="add_sub" type="submit">' . $this->lang_be['refresh'] . '</button></ul></div></form>';
      return $ret;
   }
   private function get_bb()
   {
      $i = 0;
      $smiles = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\"><tr>";
      $smilies = explode(",", $this->dle_config['smilies']);
      foreach ($smilies as $smile) {
         $i++;
         $smile = trim($smile);
         $smiles .= "<td style=\"padding:2px;\" align=\"center\"><a href=\"#\" onClick=\"dle_smiley(':$smile:'); return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"" . $this->dle_config['http_home_url'] . "engine/data/emoticons/$smile.gif\" /></a></td>";
         if($i % 4 == 0)
            $smiles .= "</tr><tr>";
      }
      $smiles .= "</tr></table>";
      $ret = <<< HTML
<ul class="bbcode_forum">
  <li onclick="simpletag('b')"><span id="b_b"></span></li>
  <li onclick="simpletag('i')"><span id="b_i"></span></li>
  <li onclick="simpletag('u')"><span id="b_u"></span></li>
  <li onclick="simpletag('s')"><span id="b_s"></span></li>
  <li onclick="ins_emo(this);"><span id="b_emo"></span></li>
  <li onclick="tag_url()"><span id="b_tag_url"></span></li>
  <li onclick="tag_leech()"><span id="b_tag_leech"></span></li>
  <li onclick="tag_email()"><span id="b_tag_email"></span></li>
  <li onclick="tag_video()"><span id="b_tag_video"></span></li>
  <li onclick="tag_audio()"><span id="b_tag_audio"></span></li>
  <li class="b_hide" onclick="simpletag('hide')"><span id="b_hide"></span></li>
  <li class="b_hide" onclick="tag_hide_post()"><span id="b_hide"></span></li>
  <li onclick="simpletag('quote')"><span id="b_quote"></span></li>
  <li class="b_code"  onclick="simpletag('code')"><span id="b_code"></span></li>
  <li onclick="simpletag('left')"><span id="b_left"></span></li>
  <li onclick="simpletag('center')"><span id="b_center"></span></li>
  <li onclick="simpletag('right')"><span id="b_right"></span></li> 
  <li onclick="simpletag('spoiler')"><span id="b_spoiler"></span></li>
  <li class="b_youtube" onclick="tag_youtube()"><span id="b_youtube"></span></li>
  <li onclick="tag_list('list')"><span id="b_list"></span></li>
  <li onclick="tag_list('ol')"><span id="b_ol"></span></li>
  <li onclick="tag_flash()"><span id="b_flash"></span></li>
  <li><div id="colorSelector">&nbsp;<div></div></div></li>
  <li class="bbfont"><select name="bbfont" onchange="insert_font(this.options[this.selectedIndex].value, 'font')">
      <option value='0'>{$this->lang_be['rules_2']}</option>
      <option value='Arial'>Arial</option>
      <option value='Arial Black'>Arial Black</option>
      <option value='Century Gothic'>Century Gothic</option>
      <option value='Courier New'>Courier New</option>
      <option value='Georgia'>Georgia</option>
      <option value='Impact'>Impact</option>
      <option value='System'>System</option>
      <option value='Tahoma'>Tahoma</option>
      <option value='Times New Roman'>Times New Roman</option>
      <option value='Verdana'>Verdana</option>
    </select></li>    <li class="bbsize"><select name="bbsize" onchange="insert_font(this.options[this.selectedIndex].value, 'size')">
      <option value='0'>{$this->lang_be['rules_3']}</option>
      <option value='1'>1</option>
      <option value='2'>2</option>
      <option value='3'>3</option>
      <option value='4'>4</option>
      <option value='5'>5</option>
      <option value='6'>6</option>
      <option value='7'>7</option>
    </select></li> 
</ul>
<div id="bullet_energy_emos" style="display: none;">
  <div style="overflow: auto;">{$smiles}</div>
</div>
<div id="colorpickerHolder"></div>
HTML;
      return $ret;
   }
   private function get_form($name = '', $data = '')
   {
      return '<textarea id="' . $name . '" name="' . $name . '" onclick="setFieldName(this.name)" rows="15" class="edit admin_form">' . $data . '</textarea>';
   }
   public function page_param_group_update()
   {
      $id_group = $this->db->safesql($this->getInt('group_access'));
      $access = $_REQUEST['access'];
      $moderation = $_REQUEST['moderation'];
      $style = $_REQUEST['style'];
      if(!$id_group) {
         die('Hacking attempt / No group_access');
      }
      if($_REQUEST['login_hash'] == "" or $_REQUEST['login_hash'] != $this->login_hash) {
         die("Hacking attempt / User not found");
      }
      $be_style_group_css = $this->db->safesql(strip_tags($style['css_param_group']));
      $be_style_name_css = $this->db->safesql(strip_tags($style['css_param_name']));
      $be_access_view_forum = $this->db->safesql(intval($access['view_forum']));
      $be_access_view_forum_off = $this->db->safesql(intval($access['view_forum_ofline']));
      $be_access_thanks = $this->db->safesql(intval($access['thanks']));
      $be_upload = $this->db->safesql(intval($access['upload']));
      $be_upload_img = $this->db->safesql(intval($access['upload_img']));
      $be_access_topic_new_private = $this->db->safesql(intval($access['topic_new_private']));
      $be_access_search = $this->db->safesql(intval($access['search']));
      $be_access_del_my_post = $this->db->safesql(intval($access['del_my_post']));
      $be_access_edit_my_post = $this->db->safesql(intval($access['edit_my_post']));
      $be_access_del_my_topic = $this->db->safesql(intval($access['del_my_topic']));
      $be_captna_param = $this->db->safesql(intval($access['captna_param']));
      $be_access_hide = $this->db->safesql(intval($access['hide']));
      $be_access_download = $this->db->safesql(intval($access['download']));
      $be_access_mat_check = $this->db->safesql(intval($access['mat_check']));
      $be_moder_topic_wanted = $this->db->safesql(intval($moderation['topic_wanted']));
      $be_moder_topic_moder_param = $this->db->safesql(intval($moderation['topic_moder_param']));
      $be_moder_edit_message_user = $this->db->safesql(intval($moderation['edit_message_user']));
      $be_moder_del_message_user = $this->db->safesql(intval($moderation['del_message_user']));
      $be_moder_moder_access = $this->db->safesql(intval($moderation['moder_access']));
      $be_moder_moder_view = $this->db->safesql(intval($moderation['moder_view']));
      $be_moder_del_user_topic = $this->db->safesql(intval($moderation['del_user_topic']));
      $be_close_to_open_topic = $this->db->safesql(intval($moderation['close_to_open_topic']));
      $be_moder_ip_view = $this->db->safesql(intval($moderation['ip_view']));
      $be_be_moder_top_rename = $this->db->safesql(intval($moderation['top_rename']));
      $be_moder_top_view_private = $this->db->safesql(intval($moderation['top_view_private']));
      $be_complaint = $this->db->safesql(intval($access['stuck']));
      $be_status = $this->db->safesql(intval($access['status']));
      $be_time_step_msg = $this->db->safesql(intval($access['time_msg_check']));
      $be_fix = $this->db->safesql(intval($moderation['be_fix']));
      $be_rc = $this->db->safesql(intval($access['cloze_topic_an']));
      $be_vote_tn = $this->db->safesql(intval($access['vote_tn']));
      $be_vote_re = $this->db->safesql(intval($access['vote_re']));
      $be_pre_view = $this->db->safesql(intval($access['pre_view_topic']));
      $be_loadTopic = $this->db->safesql(intval($access['ajax_load_topic']));
      $be_sort = $this->db->safesql(intval($access['sort']));
      $be_warn = $this->db->safesql(intval($access['warning']));
      $be_warnd = $this->db->safesql(intval($access['warning_del']));
      $be_warnl = $this->db->safesql(intval($access['warning_log']));
      $this->db->query("DELETE FROM " . PREFIX . "_be_groups WHERE be_groups_id = {$id_group} LIMIT 1");
      $this->db->query("INSERT INTO " . PREFIX . "_be_groups (be_groups_id, be_style_name_css, be_style_group_css, be_access_view_forum, be_access_view_forum_off, be_access_thanks, be_upload, be_upload_img, be_access_topic_new_private, be_access_search, be_access_del_my_post, be_access_edit_my_post, be_access_del_my_topic, be_access_hide, be_access_download, be_access_mat_check, be_moder_topic_wanted, be_moder_topic_moder_param, be_moder_edit_message_user, be_moder_del_message_user, be_moder_moder_access, be_moder_moder_view, be_moder_del_user_topic, be_moder_close_to_open_topic, be_moder_ip_view, be_moder_top_rename, be_moder_top_view_private, be_complaint, be_status, be_time_step_msg, be_captha_status,be_fix,be_replic_is_cloze,be_create_vote,be_replic_vote,be_preview_topic,be_load_ajax_topic,be_sort,be_warning,be_warning_delete,be_view_warning_log) VALUES ('{$id_group}', '{$be_style_name_css}', '{$be_style_group_css}', '{$be_access_view_forum}', '{$be_access_view_forum_off}', '{$be_access_thanks}', '{$be_upload}', '{$be_upload_img}', '{$be_access_topic_new_private}', '{$be_access_search}', '{$be_access_del_my_post}', '{$be_access_edit_my_post}', '{$be_access_del_my_topic}', '{$be_access_hide}', '{$be_access_download}', '{$be_access_mat_check}', '{$be_moder_topic_wanted}', '{$be_moder_topic_moder_param}', '{$be_moder_edit_message_user}', '{$be_moder_del_message_user}', '{$be_moder_moder_access}', '{$be_moder_moder_view}', '{$be_moder_del_user_topic}', '{$be_close_to_open_topic}', '{$be_moder_ip_view}', '{$be_be_moder_top_rename}', '{$be_moder_top_view_private}', '{$be_complaint}', '{$be_status}', '{$be_time_step_msg}', '{$be_captna_param}', '{$be_fix}', '{$be_rc}' , '{$be_vote_tn}', '{$be_vote_re}','{$be_pre_view}','{$be_loadTopic}','{$be_sort}','{$be_warn}','{$be_warnd}','{$be_warnl}')");
      $this->casheRefresh();
      return '<div class="ok_save"><h1>' . $this->lang_be['information'] . '</h1><div class="coul">' . $this->lang_be['admin_user_access_35'] . '</div><a class="be_button" href="' . $this->php_self . '?mod=bullet_energy&be_action=user&sub_action=access">' . $this->lang_be['admin_error_text_3'] . '</a></div>';
   }
   public function page_access_editor_user()
   {
      $id = $this->db->safesql($this->getInt('id_group'));
      if(!$id) {
         die('Hacking attempt / No id_group');
      }
      $this->db->query("SELECT * FROM " . PREFIX . "_be_groups WHERE be_groups_id = {$id} LIMIT 1");
      $row = $this->db->get_row();
      $name_css = htmlspecialchars(stripslashes($row['be_style_name_css']));
      $group_css = htmlspecialchars(stripslashes($row['be_style_group_css']));
      $time_step_msg = intval($row['be_time_step_msg']);
      if(intval($row['be_groups_id']) == 1) {
         $admingroup = "disabled";
         $time_step_msg = '0';
      }
      if(intval($row['be_groups_id']) == 5)
         $gastgroup = "disabled";
      if($row['be_access_view_forum'])
         $view_forum_yes = "checked";
      else
         $view_forum_no = "checked";
      if($row['be_access_view_forum_off'])
         $view_forum_off_yes = "checked";
      else
         $view_forum_off_no = "checked";
      if($row['be_access_thanks'])
         $thanks_yes = "checked";
      else
         $thanks_no = "checked";
      if($row['be_upload'])
         $upload_yes = "checked";
      else
         $upload_no = "checked";
      if($row['be_upload_img'])
         $upload_img_yes = "checked";
      else
         $upload_img_no = "checked";
      if($row['be_access_topic_new_private'])
         $topic_new_private_yes = "checked";
      else
         $topic_new_private_no = "checked";
      if($row['be_access_search'])
         $search_yes = "checked";
      else
         $search_no = "checked";
      if($row['be_access_del_my_post'])
         $del_my_post_yes = "checked";
      else
         $del_my_post_no = "checked";
      if($row['be_access_edit_my_post'])
         $edit_my_post_yes = "checked";
      else
         $edit_my_post_no = "checked";
      if($row['be_access_del_my_topic'])
         $del_my_topic_yes = "checked";
      else
         $del_my_topic_no = "checked";
      if($row['be_access_hide'])
         $hide_yes = "checked";
      else
         $hide_no = "checked";
      if($row['be_access_download'])
         $download_yes = "checked";
      else
         $download_no = "checked";
      if($row['be_access_mat_check'])
         $mat_check_yes = "checked";
      else
         $mat_check_no = "checked";
      if($row['be_moder_topic_wanted'])
         $topic_wanted_yes = "checked";
      else
         $topic_wanted_no = "checked";
      if($row['be_moder_topic_moder_param'])
         $topic_moder_param_yes = "checked";
      else
         $topic_moder_param_no = "checked";
      if($row['be_moder_edit_message_user'])
         $edit_message_user_yes = "checked";
      else
         $edit_message_user_no = "checked";
      if($row['be_moder_del_message_user'])
         $del_message_user_yes = "checked";
      else
         $del_message_user_no = "checked";
      if($row['be_moder_moder_access'])
         $moder_access_yes = "checked";
      else
         $moder_access_no = "checked";
      if($row['be_moder_moder_view'])
         $moder_view_yes = "checked";
      else
         $moder_view_no = "checked";
      if($row['be_moder_del_user_topic'])
         $del_user_topic_yes = "checked";
      else
         $del_user_topic_no = "checked";
      if($row['be_moder_close_to_open_topic'])
         $close_to_open_topic_yes = "checked";
      else
         $close_to_open_topic_no = "checked";
      if($row['be_moder_ip_view'])
         $ip_view_yes = "checked";
      else
         $ip_view_no = "checked";
      if($row['be_moder_top_rename'])
         $top_rename_yes = "checked";
      else
         $top_rename_no = "checked";
      if($row['be_moder_top_view_private'])
         $top_view_private_yes = "checked";
      else
         $top_view_private_no = "checked";
      if($row['be_complaint'])
         $complaint_yes = "checked";
      else
         $complaint_no = "checked";
      if($row['be_status'])
         $status_yes = "checked";
      else
         $status_no = "checked";
      if($row['be_captha_status'])
         $captha_status_yes = "checked";
      else
         $captha_status_no = "checked";
      if($row['be_fix'])
         $fixpost_yes = "checked";
      else
         $fixpost_no = "checked";
      if($row['be_replic_is_cloze'])
         $clo_to_yes = "checked";
      else
         $clo_to_no = "checked";
      if($row['be_create_vote'])
         $vote_yes = "checked";
      else
         $vote_no = "checked";
      if($row['be_replic_vote'])
         $vote_re_yes = "checked";
      else
         $vote_re_no = "checked";
      if($row['be_preview_topic'])
         $pre_view_topic_yes = "checked";
      else
         $pre_view_topic_no = "checked";
      if($row['be_load_ajax_topic'])
         $load_topic_ajax_yes = "checked";
      else
         $load_topic_ajax_no = "checked";
      if($row['be_sort'])
         $sort_yes = "checked";
      else
         $sort_no = "checked";
      if($row['be_warning'])
         $warning_yes = "checked";
      else
         $warning_no = "checked";
      if($row['be_warning_delete'])
         $warningd_yes = "checked";
      else
         $warningd_no = "checked";
      if($row['be_view_warning_log'])
         $warningl_yes = "checked";
      else
         $warningl_no = "checked";
      $ret = <<< HTML
<form method="post" name="add_answer" id="add_answer" action="">
  <div class="content" id="general">
    <h1>{$this->lang_be['admin_user_access_3']} "{$this->group_user[$_REQUEST['id_group']]['group_name']}"</h1>
    <table cellspacing="0" cellpadding="0" border="0" id="table" class="table_tree">
      <thead>
        <tr>
          <th class="head"><div>{$this->lang_be['admin_user_access_4']}</div></th>
          <th class="text_center cp" width="175px"> <div>{$this->lang_be['admin_user_access_5']}</div>
          </th>
          <th class="text_center cp last" width="175px"> <div>{$this->lang_be['admin_user_access_6']}</div>
          </th>
        </tr>
      </thead>
      <tbody>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_7']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$view_forum_no} name="access[view_forum]"{$admingroup}></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$view_forum_yes} name="access[view_forum]"></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_8']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$view_forum_off_no} name="access[view_forum_ofline]"{$admingroup}></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$view_forum_off_yes} name="access[view_forum_ofline]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_10']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$thanks_no} name="access[thanks]" {$admingroup}></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$thanks_yes} name="access[thanks]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_34']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$topic_new_private_no} name="access[topic_new_private]"></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$topic_new_private_yes} name="access[topic_new_private]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_13']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$del_my_post_no} name="access[del_my_post]"></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$del_my_post_yes} name="access[del_my_post]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_14']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$edit_my_post_no} name="access[edit_my_post]"></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$edit_my_post_yes} name="access[edit_my_post]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_15']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$del_my_topic_no} name="access[del_my_topic]"></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$del_my_topic_yes} name="access[del_my_topic]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_38']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$hide_no} name="access[hide]"></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$hide_yes} name="access[hide]"></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_17']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$download_no} name="access[download]"></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$download_yes} name="access[download]"></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_18']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$mat_check_no} name="access[mat_check]"></td>
          <td class="param_input access_yes"><input type="radio" {$gastgroup} value="1" {$mat_check_yes} name="access[mat_check]"></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_36']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$upload_no} name="access[upload]"></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$upload_yes} name="access[upload]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_41']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$upload_img_no} name="access[upload_img]"></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$upload_img_yes} name="access[upload_img]" {$gastgroup}></td>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_42']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$complaint_no} name="access[stuck]"></td>
          <td class="param_input access_yes"><input type="radio" {$gastgroup} value="1" {$complaint_yes} name="access[stuck]"></td>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_28']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$moder_view_no} name="moderation[moder_view]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$moder_view_yes} name="moderation[moder_view]"></td>
        </tr><tr class="list" style="display:none">
          <td> {$this->lang_be['admin_user_access_43']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$status_no} name="access[status]"></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$status_yes} name="access[status]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_37']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup} value="0" {$search_no} name="access[search]"></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$search_yes} name="access[search]"></td>
        </tr>
                <tr class="list">
          <td> {$this->lang_be['admin_user_access_31']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$ip_view_no} name="moderation[ip_view]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$ip_view_yes} name="moderation[ip_view]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_40']} </td>
          <td class="param_input access_no"><input type="radio" {$admingroup}  value="0" {$captha_status_no} name="access[captna_param]"></td>
          <td class="param_input access_yes"><input type="radio" {$gastgroup}  value="1" {$captha_status_yes} name="access[captna_param]"></td>
        </tr>
          <tr class="list">
          <td> {$this->lang_be['admin_user_access_33']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$top_view_private_no} name="moderation[top_view_private]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$top_view_private_yes} name="moderation[top_view_private]" {$gastgroup}></td>
        </tr>
        
        <tr class="list">
          <td> {$this->lang_be['setting_290']} </td>
          <td class="param_input access_no"><input type="radio" value="0"  {$clo_to_no}  name="access[cloze_topic_an]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$clo_to_yes}  name="access[cloze_topic_an]" {$gastgroup}></td>
        </tr>
        
        
        <tr class="list">
          <td> {$this->lang_be['setting_291']} </td>
          <td class="param_input access_no"><input type="radio" value="0"  {$vote_no}  name="access[vote_tn]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$vote_yes}  name="access[vote_tn]" {$gastgroup}></td>
        </tr>
        
        
        <tr class="list">
          <td> {$this->lang_be['setting_292']} </td>
          <td class="param_input access_no"><input type="radio" value="0"  {$vote_re_no}  name="access[vote_re]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$vote_re_yes}  name="access[vote_re]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['setting_331']} </td>
          <td class="param_input access_no"><input type="radio" value="0"  {$pre_view_topic_no}  name="access[pre_view_topic]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$pre_view_topic_yes}  name="access[pre_view_topic]"></td>
        </tr>
        
        
        <tr class="list">
          <td> {$this->lang_be['setting_333']} </td>
          <td class="param_input access_no"><input type="radio" value="0"  {$load_topic_ajax_no}  name="access[ajax_load_topic]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$load_topic_ajax_yes}  name="access[ajax_load_topic]"></td>
        </tr>
        
        <tr class="list"  style="display:none">
          <td> {$this->lang_be['setting_367']} </td>
          <td class="param_input access_no"><input type="radio" value="0"  {$sort_no}  name="access[sort]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$sort_yes}  name="access[sort]"></td>
        </tr>
        
        <tr class="list">
          <td> {$this->lang_be['setting_368']} </td>
          <td class="param_input access_no"><input type="radio" value="0"  {$warning_no}  name="access[warning]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$warning_yes}  name="access[warning]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['setting_369']} </td>
          <td class="param_input access_no"><input type="radio" value="0"  {$warningd_no}  name="access[warning_del]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$warningd_yes}  name="access[warning_del]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['setting_372']} </td>
          <td class="param_input access_no"><input type="radio" value="0"  {$warningl_no}  name="access[warning_log]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$warningl_yes}  name="access[warning_log]" {$gastgroup}></td>
        </tr>
        
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_39']} </td>
          <td class="param_input access_no"></td>
          <td class="param_input access_yes"><input {$gastgroup} {$admingroup} type="text" style="width:100px!important;margin-bottom:2px" value="{$time_step_msg}" name="access[time_msg_check]" class="edit"></td>
        </tr>
                
      </tbody>
    </table>
    <div style="height:15px"></div>
    <table cellspacing="0" cellpadding="0" border="0" id="table" class="table_tree">
      <thead>
        <tr>
          <th class="head"><div>{$this->lang_be['admin_user_access_22']}</div></th>
          <th class="text_center cp" width="175px"> <div>{$this->lang_be['admin_user_access_5']}</div>
          </th>
          <th class="text_center cp last" width="175px"> <div>{$this->lang_be['admin_user_access_6']}</div>
          </th>
        </tr>
      </thead>
      <tbody>        <tr class="list">
          <td> {$this->lang_be['admin_user_access_24']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$topic_moder_param_no} name="moderation[topic_moder_param]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$topic_moder_param_yes} name="moderation[topic_moder_param]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_23']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$topic_wanted_no} name="moderation[topic_wanted]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$topic_wanted_yes} name="moderation[topic_wanted]" {$gastgroup}></td>
        </tr>

        <tr class="list">
          <td> {$this->lang_be['admin_user_access_25']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$edit_message_user_no} name="moderation[edit_message_user]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$edit_message_user_yes} name="moderation[edit_message_user]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_26']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$del_message_user_no} name="moderation[del_message_user]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$del_message_user_yes} name="moderation[del_message_user]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_27']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$moder_access_no} name="moderation[moder_access]"{$admingroup}></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$moder_access_yes} name="moderation[moder_access]" {$gastgroup}></td>
        </tr>

        <tr class="list">
          <td> {$this->lang_be['admin_user_access_29']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$del_user_topic_no} name="moderation[del_user_topic]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$del_user_topic_yes} name="moderation[del_user_topic]" {$gastgroup}></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_30']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$close_to_open_topic_no} name="moderation[close_to_open_topic]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$close_to_open_topic_yes} name="moderation[close_to_open_topic]" {$gastgroup}></td>
        </tr>

        <tr class="list">
          <td> {$this->lang_be['admin_user_access_32']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$top_rename_no} name="moderation[top_rename]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$top_rename_yes} name="moderation[top_rename]" {$gastgroup}></td>
        </tr>
       
       
       <tr class="list">
          <td> {$this->lang_be['setting_289']} </td>
          <td class="param_input access_no"><input type="radio" value="0" {$fixpost_no} name="moderation[be_fix]"{$admingroup} ></td>
          <td class="param_input access_yes"><input type="radio" value="1" {$fixpost_yes} name="moderation[be_fix]" {$gastgroup}></td>
        </tr>
        
        
      </tbody>
    </table>
    <div style="height:15px"></div>
    <table cellspacing="0" cellpadding="0" border="0" id="table" class="table_tree">
      <thead>
        <tr>
          <th class="head"><div>{$this->lang_be['admin_user_access_20']}</div></th>
          <th class="last" width="350px"> </th>
        </tr>
      </thead>
      <tbody>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_19']} </td>
          <td class="param_input"><input type="text" class="edit" name="style[css_param_name]" value="{$name_css}" size="58"></td>
        </tr>
        <tr class="list">
          <td> {$this->lang_be['admin_user_access_21']} </td>
          <td class="param_input"><input type="text" class="edit" name="style[css_param_group]" value="{$group_css}" size="58"></td>
        </tr>
      </tbody>
    </table>
    <div style="height:10px"></div>
    <input type="hidden" value="{$this->group_user[$id]['id']}" name="group_access">
    <input type="hidden" value="{$this->login_hash}" name="login_hash">    
    <input type="hidden" value="param_group_update" name="sub_action">
    <button type="submit" name="answer_updates" class="be_button">{$this->lang_be['refresh_access']}</button>
  </div>
</form>
HTML;
      return $ret;
   }
   public function page_access_user()
   {
      foreach ($this->group_user as $id => $group_name) {
         $param .= '<tr class="list">
      <td><a href="' . $this->php_self . '?mod=bullet_energy&be_action=user&sub_action=access_editor&id_group=' . $id . '">' . $group_name['group_name'] . '</a></td>
      <td class="param_input"><a href="' . $this->php_self . '?mod=usergroup&action=edit&id=' . $id . '">' . $this->lang_be['admin_user_access_info'] . '</a></td></tr>';
      }
      $top = '<div class="content" id="general">
    <h1>' . $this->lang_be['admin_user_access'] . '</h1><table cellspacing="0" cellpadding="0" border="0" class="table_tree" id="table"><thead><tr><th class="head"><div>' . $this->lang_be['admin_add_tree_1'] . '</div></th><th width="175px" class="head"></th></tr></thead><tbody>';
      $bot = '</tbody></table></div><div class="infoBoxTree"><p>' . $this->lang_be['setting_148'] . ':</p><ul><li>' . $this->lang_be['admin_user_access_2'] . '</li><li>' . $this->lang_be['setting_157'] . '</li><li>' . $this->lang_be['setting_158'] . '</li></ul></div>';
      return $top . $param . $bot;
   }
   public function page_edit_captha()
   {
      if(is_numeric($_REQUEST['captcha_id'])) {
         $count = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_answer WHERE answer_id = " . $this->db->safesql($_REQUEST['captcha_id']) . " LIMIT 1");
         if(intval($count['count']) != 0) {
            $this->db->query("SELECT * FROM " . PREFIX . "_be_answer WHERE answer_id = " . $this->db->safesql($_REQUEST['captcha_id']) . " LIMIT 1");
            $row = $this->db->get_row();
            $ans = stripcslashes($row['answer']);
            $question = stripcslashes($row['question']);
            if(intval($row['answer_flag']) == 0) {
               $answer_flag = '';
            } elseif(intval($row['answer_flag']) == 1) {
               $answer_flag = 'checked="checked"';
            }
            $ret = <<< HTML
  <form method="post" name="add_answer" id="add_answer" action="">
    <div class="content" id="general">
      <h1>{$this->lang_be['admin_add_answer_14']}: {$ans}</h1>
    <ul>
        <li><span>{$this->lang_be['admin_add_answer_11']}: </span>
          <input type="text" size="66" value="{$ans}" name="answer_update[name]"  class="edit">
        </li>
        <li><span>{$this->lang_be['admin_add_answer_7']}:</span>
        <span class="info">{$this->lang_be['admin_add_answer_8']}</span>
          <textarea name="answer_update[replic]" style="width:370px;height:50px;" class="edit">{$question}</textarea>
        </li> 
        <li><span>{$this->lang_be['admin_add_answer_9']}: </span>
    <input type="checkbox" {$answer_flag} value="1" name="answer_update[active]">
        </li>
        </ul>
       <input type="hidden" value="update_answer" name="sub_action">
      <button type="submit" name="answer_updates" class="be_button">{$this->lang_be['refresh']}</button>
    </div>
  </form>
HTML;
            return $ret;
         } else {
            die('ERROR');
         }
      } else {
         die('ERROR');
      }
   }
   public function page_update_tree()
   {
      $data = is_array($_POST['update_tree']) ? $_POST['update_tree'] : die('die');
      $id = $this->getInt('id_category') ? $this->db->safesql($this->getInt('id_category')) : die('die');
      $name = $data['tree_title'] ? substr($data['tree_title'], 0, 255) : die('no title tree!');
      $sql = array();
      foreach ($data as $key => $value) {
         if($key == 'tree_info_text') {
            continue;
         }
         $value = $this->db->safesql(trim(strtr(strip_tags($value), $this->_cleanString)));
         $sql[] = $key . " = " . "'" . $value . "'";
      }
      $_POST['update_tree']['tree_info_text'] = str_replace("\r", "", $_POST['update_tree']['tree_info_text']);
      $_POST['update_tree']['tree_info_text'] = str_replace("\n", "<br />", $_POST['update_tree']['tree_info_text']);
      $sql[] = 'tree_info_text' . ' = \'' . $this->db->safesql(substr(strip_tags(stripcslashes($_POST['update_tree']['tree_info_text']), '<br /><br><ol><li><p><b><a>'), 0, 60000)) . ' \'';
      $sql[] = 'tree_access_topic_new = \'' . substr(implode(',', $_POST['access_new_topic']), 0, 255) . '\'';
      $sql[] = 'tree_access_topic_read = \'' . substr(implode(',', $_POST['access_read_topic']), 0, 255) . '\'';
      $sql[] = 'tree_access_topic_replic = \'' . substr(implode(',', $_POST['access_replic_topic']), 0, 255) . '\'';
      $sql[] = 'tree_access_view = \'' . substr(implode(',', $_POST['access_download']), 0, 255) . '\'';
      $data = implode(', ', $sql);
      $this->db->query("UPDATE " . PREFIX . "_be_tree SET {$data} WHERE tree_id = {$id} LIMIT 1");
      $referer = explode('sub_action', $_SERVER['HTTP_REFERER']);
      $goto = $referer[0] . 'sub_action=category';
      $this->casheRefresh();
      return '<div class="ok_save"><h1>' . $this->lang_be['information'] . '</h1><div class="coul">' . $this->lang_be['admin_save_tree'] . '</div><a class="be_button" href="' . $goto . '">' . $this->lang_be['admin_error_text_3'] . '</a></div>';
   }
   public function page_edit_tree()
   {
      $id = $this->getInt('id_category') ? $this->db->safesql($this->getInt('id_category')) : die('die');
      $table = $this->get_table_access_edit($id);
      $row = $this->db->super_query("SELECT * FROM " . PREFIX . "_be_tree WHERE tree_id = {$id} LIMIT 1");
      $option = array('infoTitle' => stripslashes($row['tree_info_titl']), 'password' => stripslashes($row['tree_pass']), 'type' => intval($row['tree_type']), 'description' => stripcslashes($row['tree_description']), 'typeSubParam' => stripcslashes($row['tree_type_sub']), 'title' => stripcslashes($row['tree_title']), 'idParent' => intval($row['tree_parent_id']));
      $row['treeSelect'] = '<select name="update_tree[tree_parent_id]">' . $this->tree_select($option['idParent'], 0, false) . '</select>';
      $option['aproveSelection'] = $this->makeDropDown(array("1" => $this->lang_be['visible'], "0" => $this->lang_be['visible_not']), "update_tree[tree_approve]", "{$row['tree_approve']}");
      if(intval($row['tree_type']) == 2) {
         $option['linck'] = '<li><span>' . $this->lang_be['admin_add_tree_6'] . ':</span><span class="info">' . $this->lang_be['admin_add_tree_7'] . '</span><input type="text"  value="' . $option['typeSubParam'] . '" name="update_tree[tree_type_sub]"  class="edit"></li>';
      }
      if(intval($row['tree_type']) == 0) {
         $option['category'] = ' style="display:none" ';
      }
      if(intval($row['tree_type']) == 1) {
         $option['countIs'] = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "update_tree[tree_count]", "{$row['tree_count']}");
      }
      if(intval($row['tree_type']) == 2) {
         $option['categoryLinck'] = ' style="display:none" ';
      }
      if(intval($row['tree_type']) > 0) {
         $option['parentChild'] = '<li id="parent"><span>' . $this->lang_be['admin_add_tree_21'] . ': </span>' . $row['treeSelect'] . '</li>';
      }
      $row['tree_info_text'] = str_replace("<br />", "\n", $row['tree_info_text']);
      $ret = '<form method="post" name="add_tree" id="add_tree" action=""><div class="content" id="general"><h1>' . $this->lang_be['admin_add_tree_9'] . ' "' . $option['title'] . '"</h1><ul><li><span>' . $this->lang_be['admin_add_tree_10'] . ': </span><span class="info">' . $this->lang_be['admin_add_tree_28'] . '</span><input type="text" size="66" value="' . $option['title'] . '" name="update_tree[tree_title]"  class="edit"></li><li><span>' . $this->lang_be['admin_add_tree_11'] . ':</span><span class="info">' . $this->lang_be['admin_add_tree_29'] . '</span><textarea name="update_tree[tree_description]" rows="5" class="edit">' . $option['description'] . '</textarea></li>' . $option['linck'] . '<li' . $option['category'] . '><span>' . $this->lang_be['admin_add_tree_12'] . ':</span><span class="info">' . $this->lang_be['admin_add_tree_13'] . '</span>' . $option['aproveSelection'] . '</li><li style="display:none" ' . $option['category'] . $option['categoryLinck'] . ' ><span>' . $this->lang_be['passwword'] . ':</span><span class="info">' . $this->lang_be['admin_add_tree_14'] . '</span><input type="text" size="66" value="' . $option['password'] . '" name="update_tree[tree_pass]"  class="edit"></li>' . $option['parentChild'] . '<li id="rules_titl" ' . $option['category'] . $option['categoryLinck'] . '><span>' . $this->lang_be['setting_180'] . ':</span> <input style="width:969px;margin-top:2px" name="update_tree[tree_info_titl]" type="text" class="edit" value="' . $option['infoTitle'] . '" /></li><li style="display: block;" id="counts"><span>' . $this->lang_be['admin_add_tree_43'] . '</span><span class="info">' . $this->lang_be['admin_add_tree_44'] . '</span>' . $option['countIs'] . '</li>
<li ' . $option['category'] . $option['categoryLinck'] . '><span>' . $this->lang_be['admin_add_tree_41'] . '</span><br><textarea name="update_tree[tree_info_text]" style="width:969px;height:150px;" class="edit">' . htmlspecialchars(stripslashes($row['tree_info_text'])) . '</textarea></li><li> ' . $table . '<span style="margin-top:5px;width: 70%;margin-bottom:5px">' . $this->lang_be['admin_add_tree_17'] . ' <a href="' . $this->php_self . '?mod=bullet_energy&amp;be_action=user&amp;sub_action=access">"' . $this->lang_be['admin_add_tree_18'] . '"</a></span></li></ul><input type="hidden" value="update_tree" name="sub_action"><select style="display:none" name="save_tree[type]"><option value="' . $row['tree_type'] . '">sels</option></select><button type="submit" name="add_sub" class="be_button">' . $this->lang_be['refresh'] . '</button></div></form>';
      $this->casheRefresh();
      return $ret;
   }
   private function delSysCashe()
   {
      $this->db->query("SELECT id FROM " . PREFIX . "_usergroups ORDER BY id ASC");
      while ($row = $this->db->get_row()) {
         foreach ($row as $key => $value) {
            @unlink($this->casheSySPath . 'sys_cashe_group_' . $row['id'] . '.tmp');
         }
      }
   }
   private function _singleFilter($object = '')
   {
      return $this->db->safesql(strip_tags(stripcslashes($object)));
   }
   private function _arrayCheck(array $data = array(), array $type = array())
   {
      $return = array();
      if(!is_array($data) or empty($data)) {
         return;
      }
      if($type['setType'] == 'int') {
         foreach ($data as $key => $value) {
            $value = intval($value);
            if($type['setTypeNull'] == 'unset' and $value <= 0) {
               continue;
            }
            $return[] = $value;
         }
      } elseif($type['setType'] == 'string') {
      }
      return empty($return) ? false : $return;
   }
   public function treeAddDb()
   {
      $option = is_array($_POST['save_tree']) ? $_POST['save_tree'] : die('no array');
      $option['newTopic'] = substr(implode(',', $_POST['access_new_topic']), 0, 255);
      $option['readTopic'] = substr(implode(',', $_POST['access_read_topic']), 0, 255);
      $option['replicTopic'] = substr(implode(',', $_POST['access_replic_topic']), 0, 255);
      $option['viewTopic'] = substr(implode(',', $_POST['access_download']), 0, 255);
      $option['name'] = substr(strip_tags($option['name']), 0, 255);
      $option['rules_titl'] = substr($option['rules_titl'], 0, 255);
      $option['rules'] = str_replace("\r", "", $option['rules']);
      $option['rules'] = str_replace("\n", "<br />", $option['rules']);
      $i = $this->db->safesql(substr(strip_tags(stripcslashes($option['rules']), '<ol><li><p><b><a><br /><br>'), 0, 60000));
      if($option['name'] and $option['type'] != 10) {
         foreach ($option as $key => $value) {
            $value = $this->_singleFilter($value);
         }
         $this->db->query("INSERT INTO " . PREFIX . "_be_tree (tree_id, tree_title, tree_description, tree_parent_id, tree_display, tree_type, tree_type_sub, tree_approve, tree_count, tree_pass, tree_info_titl, tree_info_text, tree_last_date, tree_last_info, tree_topic, tree_answer, tree_access_topic_new, tree_access_topic_read, tree_access_topic_replic, tree_access_view, tree_is_pass_no) VALUES (NULL, '{$option['name']}', '{$option['descr']}', '{$option['tree_parent']}', '1', '{$option['type']}', '{$option['type_sub']}', '{$option['aprove']}', '{$option['counts']}', '', '{$option['rules_titl']}', '{$i}', '0', '', '0', '0', '{$option['newTopic']}', '{$option['readTopic']}', '{$option['replicTopic']}', '{$option['viewTopic']}', '')");
         $this->casheRefresh();
         header('Location: ' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=category');
      } else {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['admin_error_text_1'] . '</div><a class="be_button" href="' . $_SERVER['HTTP_REFERER'] . '">' . $this->lang_be['admin_error_text_3'] . '</a></div>';
      }
   }
   private function set_tree_cashe()
   {
      $tree = array();
      $this->db->query("SELECT * FROM " . PREFIX . "_be_tree ORDER BY tree_id ASC");
      while ($row = $this->db->get_row()) {
         $tree[$row['tree_id']] = array();
         foreach ($row as $key => $value) {
            $tree[$row['tree_id']][$key] = stripslashes($value);
         }
      }
   }
   private function cashe_groups()
   {
      $tree = array();
      $this->db->query("SELECT * FROM " . PREFIX . "_be_groups ORDER BY be_groups_id ASC");
      while ($row = $this->db->get_row()) {
         $tree[$row['be_groups_id']] = array();
         foreach ($row as $key => $value) {
            $tree[$row['be_groups_id']][$key] = stripslashes($value);
         }
      }
      $this->set_vars_cashe('groups_config', $tree);
   }
   private function tree_select($categoryid = 0, $parentid = 0, $nocat = true, $sublevelmarker = '', $returnstring = '')
   {
      $tree = array();
      $this->db->query("SELECT * FROM " . PREFIX . "_be_tree ORDER BY tree_id ASC");
      while ($row = $this->db->get_row()) {
         $tree[$row['tree_id']] = array();
         foreach ($row as $key => $value) {
            $tree[$row['tree_id']][$key] = stripslashes($value);
         }
      }
      $tree_info = $tree;
      $root_category = array();
      if($parentid == 0) {
         if($nocat)
            $returnstring .= '<option  value="0"></option>';
      } else {
         $sublevelmarker .= '&nbsp;&nbsp;&nbsp;';
      }
      if(count($tree_info)) {
         foreach ($tree_info as $cats) {
            if($cats['tree_parent_id'] == $parentid)
               $root_category[] = $cats['tree_id'];
         }
         if(count($root_category)) {
            foreach ($root_category as $id) {
               $returnstring .= "<option value=\"" . $id . '" ';
               if(is_array($categoryid)) {
                  foreach ($categoryid as $element) {
                     if($element == $id)
                        $returnstring .= 'SELECTED';
                  }
               } elseif($categoryid == $id)
                  $returnstring .= 'SELECTED';
               $returnstring .= '>' . $sublevelmarker . $tree_info[$id]['tree_title'] . '</option>';
               $returnstring = $this->tree_select($categoryid, $id, $nocat, $sublevelmarker, $returnstring);
            }
         }
      }
      return $returnstring;
   }
   private function get_table_access_edit($id_category)
   {
      $access_result = $this->db->query("SELECT * FROM " . PREFIX . "_be_tree WHERE tree_id = {$id_category} LIMIT 1");
      if($this->db->num_rows()) {
         $row = $this->db->get_row($access_result);
         if(intval($row['tree_type']) == 0) {
            $catInfo = $this->lang_be['admin_add_tree_32'];
         } else {
            $catInfo = '';
         }
         foreach ($this->group_user as $id => $group_name) {
            if(in_array($id, explode(",", $row['tree_access_topic_new']))) {
               $checked1 = "checked";
            } else {
               if(intval($row['tree_type']) == 2 or intval($row['tree_type']) == 0 or intval($row['tree_type']) == 1 and $id == 5) {
                  $checked1 = "disabled";
               } else {
                  $checked1 = "";
               }
            }
            if(in_array($id, explode(",", $row['tree_access_topic_read']))) {
               $checked2 = "checked";
            } else {
               if(intval($row['tree_type']) == 2 or intval($row['tree_type']) == 0) {
                  $checked2 = "disabled";
               } else {
                  $checked2 = "";
               }
            }
            if(in_array($id, explode(",", $row['tree_access_topic_replic']))) {
               $checked3 = "checked";
            } else {
               if(intval($row['tree_type']) == 2 or intval($row['tree_type']) == 0) {
                  $checked3 = "disabled";
               } elseif($id == 5) {
                  $checked3 = "disabled";
               } else {
                  $checked3 = "";
               }
            }
            if(in_array($id, explode(",", $row['tree_access_view']))) {
               $checked4 = "checked";
            } else {
               $checked4 = "";
            }
            $param .= "<tr class=\"list\">
     
      
       <td class=\"groupUnsep\"><a class=\"addRulGroup\" onclick=\"group_permission('{$id}',true); return false;\"  href=\"#\" title=\"{$this->lang_be['setting_249']}\"></a><a class=\"delRulGroup\" onclick=\"group_permission('{$id}',false); return false;\"  href=\"#\" title=\"{$this->lang_be['setting_250']}\"></a><b>{$group_name[group_name]}</b></td>
       
       
<td class=\"param_input\"><input type=\"checkbox\" name=\"access_new_topic[" . $id . "]\" id=\"access_new_topic_" . $id . "\" value=\"" . $id . "\"{$checked1}></td>
<td class=\"param_input\"><input type=\"checkbox\" name=\"access_replic_topic[" . $id . "]\" id=\"access_replic_topic_" . $id . "\" value=\"" . $id . "\"{$checked3}></td>
<td class=\"param_input\"><input type=\"checkbox\" name=\"access_read_topic[" . $id . "]\" id=\"access_read_topic_" . $id . "\" value=\"" . $id . "\"{$checked2}></td>
<td class=\"param_input\"><input type=\"checkbox\" name=\"access_download[" . $id . "]\" id=\"access_download_" . $id . "\" value=\"" . $id . "\"{$checked4}></td>
</tr>";
         }
         $ret .= <<< HTML
 <table cellspacing="0" cellpadding="0" border="0" id="table" class="table_tree">
  <thead>
    <tr>
      <th><div>{$this->lang_be['admin_add_tree_1']}</div></th> 
      <th class="text_center"><div>{$this->lang_be['admin_add_tree_3']}</div></th>
      <th class="text_center"><div>{$this->lang_be['admin_add_tree_4']}</div></th>
      <th class="text_center"><div>{$this->lang_be['admin_add_tree_5']}</div></th>
      <th class="last text_center"><div>{$this->lang_be['admin_add_tree_2']}</div></th>
    </tr>
  </thead>{$catInfo}
  <tbody>
  {$param}
    </tbody>
</table>
HTML;
         return $ret;
      } else
         die('ERROR');
   }
   private function get_table_access()
   {
      if(count($this->group_user)) {
         foreach ($this->group_user as $group) {
            $param .= '<tr class="list">
      <td class="groupUnsep"><a class="addRulGroup" onclick="group_permission(\'' . $group['id'] . '\',true); return false;"  href="#" title="' . $this->lang_be['setting_249'] . '"></a><a class="delRulGroup" onclick="group_permission(\'' . $group['id'] . '\',false); return false;"  href="#" title="' . $this->lang_be['setting_250'] . '"></a><b>' . $group['group_name'] . '</b></td>
      
      <td class="param_input"><input type="checkbox" value="' . $group['id'] . '" id="access_new_topic_' . $group['id'] . '" class="access_new_topic" name="access_new_topic[' . $group['id'] . ']"></td>
      <td class="param_input"><input type="checkbox" value="' . $group['id'] . '" id="access_replic_topic_' . $group['id'] . '" class="access_replic_topic" name="access_replic_topic[' . $group['id'] . ']"></td>
      <td class="param_input"><input type="checkbox" value="' . $group['id'] . '" id="access_read_topic_' . $group['id'] . '" class="access_read_topic" name="access_read_topic[' . $group['id'] . ']"></td>
      <td class="param_input"><input type="checkbox" value="' . $group['id'] . '" id="access_download_' . $group['id'] . '" class="access_download" name="access_download[' . $group['id'] . ']"></td>
   
    </tr>';
         }
         $ret .= <<< HTML
 <table cellspacing="0" cellpadding="0" border="0" class="table_tree">
  <thead>
    <tr>
      <th><div>{$this->lang_be['admin_add_tree_1']}</div></th> 
      <th class="text_center"><div>{$this->lang_be['admin_add_tree_3']}</div></th>
      <th class="text_center"><div>{$this->lang_be['admin_add_tree_4']}</div></th>
      <th class="text_center"><div>{$this->lang_be['admin_add_tree_5']}</div></th>
      <th class="last text_center"><div>{$this->lang_be['admin_add_tree_2']}</div></th>
    </tr>
  </thead>
  <tbody>
  {$param}
    </tbody>
</table>

HTML;
         return $ret;
      }
   }
   public function moderator()
   {
      $tree = array();
      $this->db->query("SELECT tree_id,tree_parent_id,tree_type,tree_title,tree_approve,tree_count,tree_description,tree_access_topic_new,tree_access_topic_read,tree_access_topic_replic,tree_access_view FROM " . PREFIX . "_be_tree ORDER BY tree_id ASC");
      while ($row = $this->db->get_row()) {
         $tree[$row['tree_id']] = array();
         foreach ($row as $key => $value) {
            $tree[$row['tree_id']][$key] = stripslashes($value);
         }
      }
      $table = $this->lang_be['setting_431'] . '<br><br>';
      $this->db->query("SELECT * FROM " . PREFIX . "_be_moderator AS moder                     
                      ORDER BY moder.moderator_name ASC");
      if($this->db->num_rows()) {
         while ($row = $this->db->get_row()) {
            $treeI = array();
            if($row['moderator_super']) {
               $row['moderator_super'] = $this->lang_be['setting_416'];
               $row['moderator_tree_id'] = $this->lang_be['setting_417'];
            } else {
               $row['moderator_super'] = $this->lang_be['setting_415'];
               $row['moderator_tree_id'] = explode(',', $row['moderator_tree_id']);
               foreach ($row['moderator_tree_id'] as $key => $val) {
                  $treeI[] = $tree[$val]['tree_title'];
               }
               $row['moderator_tree_id'] = implode(', ', $treeI);
            }
            $rett .= "<tr id=\"" . $row['id'] . "\" class=\"list\"><td>{$row['moderator_name']}</td><td>{$row['moderator_super']}</td><td>{$row['moderator_tree_id']}</td><td><a title=\"{$this->lang_be['setting_418']}\" onclick=\"doDelete('moderator','" . $row['id'] . "'); return false;\" class=\"deleteElementA\"><b>{$this->lang_be['setting_418']}</b></a></td></tr>";
         }
         $table = '<table cellspacing="0" cellpadding="0" border="0" class="table_tree" id="table"><thead><tr><th><div>' . $this->lang_be['setting_412'] . '</div></th><th style="width:150px"><div>' . $this->lang_be['setting_414'] . '</div></th><th class="w300"><div>' . $this->lang_be['setting_413'] . '</div></th><th class="w25 last"><div>&nbsp;</div></th></tr></thead><tbody>' . $rett . '</tbody></table><br>';
      }
      $ret .= <<< HTML
  <form method="post" name="add_tree" id="add_tree" action="">
    <div class="content" id="general">
      <h1>{$this->lang_be['moderator']}</h1>
{$table}
      <input type="hidden" value="add_moderator" name="sub_action">
      <button type="submit" name="add_sub" class="be_button">{$this->lang_be['moderatorAdd']}</button>
    </div>
    <div class="infoBoxTree"><p>{$this->lang_be['setting_148']}:</p><ul><li>{$this->lang_be['setting_154']}</li>
    <li>{$this->lang_be['setting_155']}</li><li>{$this->lang_be['setting_156']}</li></ul></div>
  </form>
HTML;
      return $ret;
   }
   public function add_moderator_db()
   {
      $name = $this->db->safesql(strip_tags(str_replace('/', '', $_POST['moder']['name'])));
      $row = $this->db->super_query("SELECT user_id FROM " . PREFIX . "_users WHERE name LIKE '{$name}' LIMIT 1");
      if(intval($_POST['moder']['type']) == 0) {
         $type = 0;
      } else {
         $type = 1;
      }
      if(!$row['user_id']) {
         $back = ' href="' . $this->php_self . '?mod=bullet_energy&be_action=user&sub_action=moderator" ';
         $ret .= <<< HTML
  <form method="post" name="add_tree" id="add_tree" action="">
    <div class="content" id="general">
     <div class="ok_save"> <h1>{$this->lang_be['information_error']}</h1>
      <div class="coul"> {$this->lang_be['moderator_8']}</div>
      <a {$back} class="be_button">{$this->lang_be['setting_411']}</a>
      
    </div>   
    </div>
  </form>
HTML;
         return $ret;
      }
      $rows = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_moderator WHERE moderator_name LIKE '{$name}' LIMIT 1");
      if(intval($rows['count']) > 0) {
         $back = ' href="' . $this->php_self . '?mod=bullet_energy&be_action=user&sub_action=moderator" ';
         $ret .= <<< HTML
  <form method="post" name="add_tree" id="add_tree" action="">
    <div class="content" id="general">
     <div class="ok_save"> <h1>{$this->lang_be['information_error']}</h1>
      <div class="coul"> {$this->lang_be['setting_179']}</div>
      <a {$back} class="be_button">{$this->lang_be['setting_411']}</a>
      
    </div>   
    </div>
  </form>
HTML;
         return $ret;
      }
      if(!count($_POST['moder']['tree']) and $type == 0) {
         $back = ' href="' . $this->php_self . '?mod=bullet_energy&be_action=user&sub_action=moderator" ';
         $ret .= <<< HTML
  <form method="post" name="add_tree" id="add_tree" action="">
    <div class="content" id="general">
     <div class="ok_save"> <h1>{$this->lang_be['information_error']}</h1>
      <div class="coul"> {$this->lang_be['moderator_9']}</div>
      <a {$back} class="be_button">{$this->lang_be['setting_411']}</a>
      
    </div>   
    </div>
  </form>
HTML;
         return $ret;
      }
      $tree = $this->db->safesql(implode(',', $_POST['moder']['tree']));
      $this->db->query("INSERT INTO " . PREFIX . "_be_moderator (id,moderator_id,moderator_name,moderator_super,moderator_tree_id) VALUES (NULL,'{$row['user_id']}','{$name}','{$type}','{$tree}')");
      $back = ' href="' . $this->php_self . '?mod=bullet_energy&be_action=user&sub_action=moderator" ';
      $ret .= <<< HTML
  <form method="post" name="add_tree" id="add_tree" action="">
    <div class="content" id="general">
     <div class="ok_save"> <h1>{$this->lang_be['moderatorAddPage']}</h1>
      <div class="coul"> {$this->lang_be['moderator_7']}</div>
      <a {$back} class="be_button">{$this->lang_be['setting_411']}</a>
    </div>   
    </div>
  </form>
HTML;
      $this->casheRefresh();
      return $ret;
   }
   public function add_moderator()
   {
      $tree = $this->tree_selectDubl(0, 0);
      $ret .= <<< HTML
  <form method="post" name="add_tree" id="add_tree" action="">
    <div class="content" id="general">
      <h1>{$this->lang_be['moderatorAddPage']}</h1>
       <ul>
      <li><span>{$this->lang_be['moderator_2']}:</span> <span class="info">{$this->lang_be['moderator_3']}</span>
        <input type="text" class="edit" name="moder[name]" value="" size="40">
      </li>
      <li><span>{$this->lang_be['moderator_4']}:</span><span class="info">{$this->lang_be['moderator_5']}</span>
      <select name="moder[type]"><option value="1">{$this->lang_be['setting_409']}</option><option selected="" value="0">{$this->lang_be['setting_410']}</option></select></li>
      <li><span>{$this->lang_be['moderator_6']}:</span><span class="info">{$this->lang_be['moderator_10']}</span><select multiple=""  id="tree" name="moder[tree][]">{$tree}</select></li>   
    </ul>
      <input type="hidden" value="add_moderator_db" name="sub_action">
      <button type="submit" name="add_sub" class="be_button">{$this->lang_be['moderatorAdd']}</button>
    </div>
  </form>
HTML;
      return $ret;
   }
   public function page_add_cat()
   {
      $table_access_thered = $this->get_table_access();
      $cat_select = $this->tree_select(0, 0);
      $ret .= <<< HTML
  <form method="post" name="add_tree" id="add_tree" action="">
    <div class="content" id="general">
      <h1>{$this->lang_be['admin_add_tree_19']}</h1>
      <ul>
        <li><span>{$this->lang_be['admin_add_tree_10']}: </span>
        <span class="info">{$this->lang_be['admin_add_tree_28']}</span>
          <input type="text" size="66" value="" name="save_tree[name]"  class="edit">
        </li>
        <li><span>{$this->lang_be['admin_add_tree_11']}:</span>
        <span class="info">{$this->lang_be['admin_add_tree_29']}</span>
          <textarea name="save_tree[descr]" rows="5" class="edit"></textarea>
        </li>
         <li><span>{$this->lang_be['admin_add_tree_20']}:</span><span class="info">{$this->lang_be['admin_add_tree_30']}</span>
       <select name="save_tree[type]">
          <option value="10"></option>
          <option value="0">{$this->lang_be['admin_add_tree_type_0']}</option>
          <option value="1">{$this->lang_be['admin_add_tree_type_1']}</option>
          <option value="2">{$this->lang_be['admin_add_tree_type_2']}</option>
        </select>
        </li>  
         
        
          <li id="parent" style="display:none"><span>{$this->lang_be['admin_add_tree_21']}: </span>
       <select name="save_tree[tree_parent]" >{$cat_select}</select>
        </li>      
         <li id="typed" style="display:none"><span>{$this->lang_be['admin_add_tree_22']}:</span><span class="info">{$this->lang_be['admin_add_tree_7']}</span>
          <input type="text" size="40" value="" name="save_tree[type_sub]"  class="edit">
        </li>
         <li id="aprove" style="display:none"><span>{$this->lang_be['admin_add_tree_12']}:</span><span class="info">{$this->lang_be['admin_add_tree_13']}</span>
         <select name="save_tree[aprove]">
          <option value="1">{$this->lang_be['visible']}</option>
          <option value="0">{$this->lang_be['visible_not']}</option>
        </select>
        </li> 
          <li id="passworld" style="display:none"><span>{$this->lang_be['setting_408']}</span><span class="info">{$this->lang_be['admin_add_tree_14']}</span>
          <input type="text" size="66" value="" name="save_tree[passworld]"  class="edit">
        </li>
        
        
        <li id="counts" style="display:none"><span>{$this->lang_be['setting_407']}</span>
         <select name="save_tree[counts]">
          <option value="1">{$this->lang_be['yes']}</option>
          <option value="0">{$this->lang_be['no']}</option>
        </select>
        </li>    
        <li id="rules_titl" style="display:none"><span>{$this->lang_be['setting_406']}</span> 
  <input style="width:969px;margin-top:2px" name="save_tree[rules_titl]" type="text" class="edit" value="" />
</li>
        <li id="rules" style="display:none"><span>{$this->lang_be['setting_405']}</span><br>
        <textarea name="save_tree[rules]" style="width:969px;height:150px;" class="edit"></textarea>
        </li>
         <li id="table_access" style="display:none">
         {$this->lang_be['admin_add_tree_32']}
        {$table_access_thered}
        <span style="margin-top:5px;width: 70%;margin-bottom:5px">{$this->lang_be['admin_add_tree_17']} <a href="{$this->php_self}?mod=bullet_energy&be_action=user&sub_action=access">"{$this->lang_be['admin_add_tree_18']}"</a></span>
        </li>  
      </ul>
      <input type="hidden" value="add_tree" name="sub_action"><button type="submit" name="add_sub" class="be_button">{$this->lang_be['add']}</button>
    </div>
  </form>
HTML;
      return $ret;
   }
   public function questionsViewPage()
   {
      if($this->modul_config['captha_type']) {
         return '<div class="ok_save"><h1>' . $this->lang_be['setting_135'] . '</h1><div class="coul">' . $this->lang_be['setting_136'] . '</div></div>';
      }
      $row = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_question");
      if($row['count'] == 0) {
         return '<form method="post" name="add_question" id="add_tree" action=""><div class="ok_save"><h1>' . $this->lang_be['setting_135'] . '</h1><div class="coul">' . $this->lang_be['setting_137'] . '</div></div><input type="hidden" value="add_question" name="sub_action"><button type="submit" name="add_sub" class="be_button">' . $this->lang_be['add'] . '</button></form>';
      } elseif($row['count'] > 0) {
         $row = $this->db->query("SELECT * FROM " . PREFIX . "_be_question");
         $fetch = '<form method="post" name="add_question" id="add_tree" action=""><table cellspacing="0" cellpadding="0" border="0" class="table_tree" id="table"><thead><tr><th><div>' . $this->lang_be['setting_147'] . '</div></th><th class="w25 last">&nbsp;</th></tr></thead><tbody>';
         while ($row = $this->db->get_row()) {
            $row['question'] = $row['is_active'] ? stripcslashes(htmlspecialchars($row['question'])) : '<s>' . stripcslashes(htmlspecialchars($row['question'])) . '</s>';
            $fetch .= '<tr class="list" id="' . $row['id'] . '"><td class="tree_info"><a href="' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=question_edit&id=' . $row['id'] . '">' . $row['question'] . '</a><span class="tree_type">' . stripcslashes(implode(', ', explode('<sep>', $row['answers']))) . '</span></td><td><a class="deleteElementA" onclick="doDelete(\'questions\',\'' . $row['id'] . '\'); return false;" title="Удалить"><b>Удалить</b></a></td></tr>';
         }
         $fetch .= '</tbody></table><input type="hidden" value="add_question" name="sub_action"><br><button type="submit" name="add_sub" class="be_button">' . $this->lang_be['add'] . '</button><div class="infoBoxTree"><p>' . $this->lang_be['setting_148'] . ':</p><ul><li>' . $this->lang_be['setting_149'] . '</li><li>' . $this->lang_be['setting_150'] . '</li><li>' . $this->lang_be['setting_151'] . '</li><li>' . $this->lang_be['setting_152'] . '</li></ul></div></form>';
         return $fetch;
      }
   }
   public function questionsEdit()
   {
      $id = !$this->getInt('id') ? die('die no id') : $this->db->safesql($this->getInt('id'));
      $this->db->query("SELECT * FROM " . PREFIX . "_be_question WHERE id = {$id} LIMIT 1");
      $row = !$this->db->num_rows() ? die('no question') : $this->db->get_row();
      $isActive = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "update[active]", $row['is_active']);
      return '<form method="post" name="update_question" action=""><div class="content"><h1>' . $this->lang_be['setting_153'] . '</h1><ul><li><span>' . $this->lang_be['setting_139'] . ':</span><span class="info">' . $this->lang_be['setting_140'] . '</span><input type="text" class="edit" name="update[question]" value="' . htmlspecialchars(stripcslashes($row['question'])) . '" size="66"></li><li><span>' . $this->lang_be['setting_141'] . ':</span><span class="info">' . $this->lang_be['setting_142'] . '</span><textarea name="update[answer]" rows="5" class="edit">' . stripcslashes(implode(', ', explode('<sep>', $row['answers']))) . '</textarea></li><li><span>' . $this->lang_be['setting_143'] . ':</span><span class="info">' . $this->lang_be['setting_144'] . '</span>' . $isActive . '</li></ul><input type="hidden" value="' . $id . '" name="id_questions"><input type="hidden" value="update_question" name="sub_action"><button type="submit" name="add_sub" class="be_button">' . $this->lang_be['refresh'] . '</button></div></form>';
   }
   public function add_question()
   {
      $ret .= <<< HTML
<form method="post" name="add_question" action="">
  <div class="content">
    <h1>{$this->lang_be['setting_138']}</h1>
    <ul>
      <li><span>{$this->lang_be['setting_139']}:</span><span class="info">{$this->lang_be['setting_140']}</span>
        <input type="text" class="edit" name="captcha[question]" value="" size="66">
      </li>
      <li><span>{$this->lang_be['setting_141']}:</span><span class="info">{$this->lang_be['setting_142']}</span>
       <textarea name="captcha[answer]" rows="5" class="edit"></textarea>
      </li>
      <li><span>{$this->lang_be['setting_143']}:</span><span class="info">{$this->lang_be['setting_144']}</span>
        <select name="captcha[active]">
          <option value="0">{$this->lang_be['no']}</option>
          <option selected="" value="1">{$this->lang_be['yes']}</option>
        </select>
      </li>
    </ul>
    <input type="hidden" value="add_question_db" name="sub_action">
    <button type="submit" name="add_sub" class="be_button">{$this->lang_be['add']}</button>
  </div>
</form>
HTML;
      return $ret;
   }
   public function questionUpdate()
   {
      $id = !$this->getInt('id_questions') ? die('die no questions') : $this->db->safesql($this->getInt('id_questions'));
      $this->db->query("SELECT * FROM " . PREFIX . "_be_question WHERE id = {$id} LIMIT 1");
      $row = !$this->db->num_rows() ? die('no question') : true;
      if(!trim(strtr($_POST['update']['question'], $this->_cleanString))) {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['setting_145'] . '</div></div>';
      }
      if(!trim(strtr($_POST['update']['answer'], $this->_cleanString))) {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['setting_146'] . '</div></div>';
      }
      $option['status'] = intval($_POST['update']['active']);
      $option['question'] = $this->db->safesql(substr(trim(strtr(strip_tags($_POST['update']['question']), $this->_cleanString)), 0, 255));
      $option['arrayAnswerPost'] = explode(',', $_POST['update']['answer']);
      foreach ($option['arrayAnswerPost'] as $key => &$answer) {
         $answer = $this->db->safesql(trim(strtr($answer, $this->_cleanString)));
         $answer = htmlspecialchars($answer);
         if($answer === '') {
            unset($option['arrayAnswerPost'][$key]);
         }
      }
      if(empty($option['arrayAnswerPost'])) {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['setting_146'] . '</div></div>';
      }
      $option['arrayAnswerPost'] = implode('<sep>', $option['arrayAnswerPost']);
      $this->db->query("UPDATE " . PREFIX . "_be_question 
                      SET question = '{$option['question']}', 
                      answers = '{$option['arrayAnswerPost']}',
                      is_active = '{$option['status']}' 
                      WHERE id = '{$id}' LIMIT 1");
      $this->casheRefresh();
      header('Location: ' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=captcha');
   }
   private function _getGroup()
   {
      $group = array();
      $this->db->query("SELECT id,group_name FROM " . PREFIX . "_usergroups ORDER BY id ASC");
      while ($row = $this->db->get_row()) {
         $group[$row['id']] = array();
         foreach ($row as $key => $value) {
            $group[$row['id']][$key] = stripslashes($value);
         }
      }
      return $group;
   }
   private function _getTree()
   {
      $group = array();
      $this->db->query("SELECT tree_id,tree_title,tree_type FROM " . PREFIX . "_be_tree ORDER BY tree_id ASC");
      while ($row = $this->db->get_row()) {
         $group[$row['tree_id']] = array();
         foreach ($row as $key => $value) {
            $group[$row['tree_id']][$key] = stripslashes($value);
         }
      }
      return $group;
   }
   public function advertisingAddPage()
   {
      $ret = '<form method="post" name="advertising" action=""><div class="content"><h1>' . $this->lang_be['setting_184'] . '</h1><ul><li><span>' . $this->lang_be['setting_388'] . '</span> <span class="info">' . $this->lang_be['setting_389'] . '</span><input type="text" class="edit" name="advertising[name]" value="" size="66"></li><li><span>' . $this->lang_be['setting_185'] . ':</span><span class="info">' . $this->lang_be['setting_186'] . '</span>' . $this->_getSelectGroup(false, 'advertising', '') . '</li><li><span>' . $this->lang_be['setting_187'] . ':</span><span class="info">' . $this->lang_be['setting_188'] . '</span><select name="advertising[tree][]" multiple=""> ' . $this->tree_selectDubl(0, 0) . '  </select></li><li><span>' . $this->lang_be['setting_189'] . ':</span><select name="advertising[topic_view]"><option selected="" value="none">' . $this->lang_be['setting_195'] . '</option><option value="top">' . $this->lang_be['setting_190'] . '</option><option value="random">' . $this->lang_be['setting_191'] . '</option><option value="footer">' . $this->lang_be['setting_196'] . '</option></select></li><li><span>' . $this->lang_be['setting_192'] . ':</span><br><textarea class="edit" style="width:969px;height:100px;" name="advertising[content]"></textarea></li><li><span>' . $this->lang_be['setting_193'] . ':</span><span class="info">' . $this->lang_be['setting_197'] . '</span><select name="advertising[display]"><option value="none">' . $this->lang_be['no'] . '</option><option value="display" selected="">' . $this->lang_be['yes'] . '</option></select></li></ul><input type="hidden" value="add_advertising_db" name="sub_action"><button type="submit" name="add_sub" class="be_button">' . $this->lang_be['add'] . '</button></div></form>';
      return $ret;
   }
   public function advertising()
   {
      $group = $this->_getGroup();
      $tree = $this->_getTree();
      $row = $this->db->query("SELECT * FROM " . PREFIX . "_be_advertising");
      if(!$this->db->num_rows()) {
         $ret = '<form method="post" name="advertising" action=""><div class="content"><h1>' . $this->lang_be['setting_184'] . '</h1><ul><li><span>' . $this->lang_be['setting_388'] . '</span> <span class="info">' . $this->lang_be['setting_389'] . '</span><input type="text" class="edit" name="advertising[name]" value="" size="66"></li><li><span>' . $this->lang_be['setting_185'] . ':</span><span class="info">' . $this->lang_be['setting_186'] . '</span>' . $this->_getSelectGroup(false, 'advertising', '') . '</li><li><span>' . $this->lang_be['setting_187'] . ':</span><span class="info">' . $this->lang_be['setting_188'] . '</span><select name="advertising[tree][]" multiple=""> ' . $this->tree_selectDubl(0, 0) . '  </select></li><li><span>' . $this->lang_be['setting_189'] . ':</span><select name="advertising[topic_view]"><option selected="" value="none">' . $this->lang_be['setting_195'] . '</option><option value="top">' . $this->lang_be['setting_190'] . '</option><option value="random">' . $this->lang_be['setting_191'] . '</option><option value="footer">' . $this->lang_be['setting_196'] . '</option></select></li><li><span>' . $this->lang_be['setting_192'] . ':</span><br><textarea class="edit" style="width:969px;height:100px;" name="advertising[content]"></textarea></li><li><span>' . $this->lang_be['setting_193'] . ':</span><span class="info">' . $this->lang_be['setting_197'] . '</span><select name="advertising[display]"><option value="none">' . $this->lang_be['no'] . '</option><option value="display" selected="">' . $this->lang_be['yes'] . '</option></select></li></ul><input type="hidden" value="add_advertising_db" name="sub_action"><button type="submit" name="add_sub" class="be_button">' . $this->lang_be['add'] . '</button></div></form>';
      } else {
         while ($row = $this->db->get_row()) {
            if($row['advertising_topic'] == 'random') {
               $row['viewParam'] = '<strong>' . $this->lang_be['setting_399'] . '</strong>' . $this->lang_be['setting_404'];
            } elseif($row['advertising_topic'] == 'none') {
               $row['viewParam'] = '<strong>' . $this->lang_be['setting_399'] . '</strong>' . $this->lang_be['setting_403'];
            } elseif($row['advertising_topic'] == 'top') {
               $row['viewParam'] = '<strong>' . $this->lang_be['setting_399'] . '</strong>' . $this->lang_be['setting_402'];
            } elseif($row['advertising_topic'] == 'footer') {
               $row['viewParam'] = '<strong>' . $this->lang_be['setting_399'] . '</strong>' . $this->lang_be['setting_401'];
            }
            $row['viewGroup'] = explode('.', $row['advertising_group']);
            foreach ($row['viewGroup'] as $key => $val) {
               $row['viewGroupSet'][] = $group[$val]['group_name'];
            }
            $row['viewGroup'] = '<strong>' . $this->lang_be['setting_398'] . '</strong>: ' . implode(', ', $row['viewGroupSet']);
            $row['viewTree'] = explode('.', $row['advertising_tree']);
            foreach ($row['viewTree'] as $key => $val) {
               $row['viewTreeSet'][] = $tree[$val]['tree_title'];
            }
            $row['viewTreeSet'] = $row['viewTreeSet'][0] == null ? array($this->lang_be['setting_396']) : $row['viewTreeSet'];
            $row['viewTree'] = '<strong>' . $this->lang_be['setting_396'] . '</strong>: ' . implode(', ', $row['viewTreeSet']);
            if($row['advertising_display'] == 'display') {
               $row['advertising_display'] = 'enable_advertising';
            } else {
               $row['advertising_display'] = 'disble_advertising';
            }
            $ret .= '<tr class="list" id="' . $row['advertising_id'] . '"><td class="tree_info"><a title="' . $this->lang_be['setting_395'] . '" href="' . $this->php_self . '?mod=bullet_energy&amp;be_action=service&amp;sub_action=advertising_edit&amp;id=' . $row['advertising_id'] . '" rel="' . $row['advertising_name'] . '" style="padding-left:0px">' . $row['advertising_name'] . '</a></td><td><p>' . $row['viewParam'] . '</p><p>' . $row['viewGroup'] . '</p><p>' . $row['viewTree'] . '</p></td>   <td class="' . $row['advertising_display'] . '">' . $row['advertising_display'] . '</td><td><a class="deleteElementA" onclick="doDelete(\'advertising\',\'' . $row['advertising_id'] . '\'); return false;" title="' . $this->lang_be['setting_394'] . '"><b>' . $this->lang_be['setting_394'] . '</b></a></td></tr>';
         }
         $ret = '<div class="button_table_param"><div class="parent_child"><div class="fbutton"><div><span class="add"><a href="' . $this->php_self . '?mod=bullet_energy&amp;be_action=service&amp;sub_action=advertising_add">' . $this->lang_be['setting_393'] . '</a></span></div></div></div></div><table cellspacing="0" cellpadding="0" border="0" class="table_tree" id="table"><thead><tr><th style="width:30%"><div>' . $this->lang_be['setting_392'] . '</div></th><th class="w300"><div>' . $this->lang_be['setting_391'] . '</div></th><th class="w25" style="text-align:center"><div>' . $this->lang_be['setting_390'] . '</div></th><th class="w25 last"><div>&nbsp;</div></th></tr></thead><tbody>' . $ret . '  </tbody></table>';
      }
      return $ret;
   }
   public function saveRouter()
   {
      if(intval($this->id_member['user_group']) == 1) {
         $save_con = $_POST['router'];
         $find[] = "'\r'";
         $replace[] = "";
         $find[] = "'\n'";
         $replace[] = "";
         $handler = fopen(ENGINE_DIR . '/bullet_energy/data/router_param_type_' . $this->modul_config['is_cpu_type'] . '.php', "w");
         fwrite($handler, "<?PHP \n// Bullet Energy Router Param\n\$bulletRouter = array (\n");
         foreach ($save_con as $name => $value) {
            $value = trim(stripslashes($value));
            $value = htmlspecialchars($value, ENT_QUOTES);
            $value = preg_replace($find, $replace, $value);
            $name = trim(stripslashes($name));
            $name = htmlspecialchars($name, ENT_QUOTES);
            $name = preg_replace($find, $replace, $name);
            $value = str_replace("$", "&#036;", $value);
            $value = str_replace("{", "&#123;", $value);
            $value = str_replace("}", "&#125;", $value);
            $name = str_replace("$", "&#036;", $name);
            $name = str_replace("{", "&#123;", $name);
            $name = str_replace("}", "&#125;", $name);
            fwrite($handler, "'{$name}' => \"{$value}\",\n");
         }
         fwrite($handler, ");\n?>");
         fclose($handler);
         return true;
      } else {
         die('Hacking attempt! User not found');
      }
   }
   public function router()
   {
      $option = array();
      $option['isNotRewrite'] = '';
      if(function_exists('apache_get_modules')) {
         if(array_search('mod_rewrite', apache_get_modules())) {
            $option['mod_rewrite'] = '';
         } else {
            $option['mod_rewrite'] = "<font color=\"red\">" . $this->lang_be['setting_361'] . "</font>";
            $option['isNotRewrite'] = ' disabled ';
         }
      } else {
         $option['mod_rewrite'] = "<font color=\"red\">" . $this->lang_be['setting_362'] . "</font>";
         $option['isNotRewrite'] = ' disabled ';
      }
      $rewRulle = array();
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '(/?)+$ index.php?do=forum&action=main [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['moderation'] . '(/?)+$ index.php?do=forum&action=moderation [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['moderation'] . '/' . $this->router['page'] . '([0-9]+)(/?)+$ index.php?do=forum&action=moderation&page=$1 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['tree'] . '([0-9]+)(/?)+$ index.php?do=forum&action=categories&id=$1 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['tree'] . '([0-9]+)/' . $this->router['page'] . '([0-9]+)(/?)+$ index.php?do=forum&action=categories&id=$1&page=$2 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['topic'] . '([0-9]+)(/?)+$ index.php?do=forum&action=showtopic&id=$1 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['topic'] . '([0-9]+)/' . $this->router['page'] . '([0-9]+)(/?)+$ index.php?do=forum&action=showtopic&id=$1&page=$2 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['topic'] . '([0-9]+)/findpost-([0-9]+)(/?)+$ index.php?do=forum&action=findpost&id=$1&findpost=$2 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['new_topic'] . '([0-9]+)(/?)+$ index.php?do=forum&action=newtopic&id=$1 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['search'] . '(/?)+$ index.php?do=forum&action=search [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['new_post'] . '(/?)+$ index.php?do=forum&action=new_post [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['new_post'] . '/' . $this->router['page'] . '([0-9]+)(/?)+$ index.php?do=forum&action=new_post&page=$1 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['rss_tree'] . '([0-9]+).xml(/?)+$ engine/bullet_energy/modules/rss.php?action=tree_rss&id=$1  [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['attachment'] . '([0-9]+)(/?)+$ engine/bullet_energy/modules/download.php?id=$1 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['watched'] . '(/?)+$ index.php?do=forum&action=watched [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['watched'] . '/' . $this->router['page'] . '([0-9]+)(/?)+$ index.php?do=forum&action=watched&page=$1 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['watched'] . '/all(/?)+$ index.php?do=forum&action=watched_all [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['rss_topic'] . '([0-9]+).xml(/?)+$ engine/bullet_energy/modules/rss.php?action=topic_rss&id=$1  [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/discussion-([0-9]+)(/?)+$ index.php?do=forum&action=discussion&id=$1 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['tree'] . '/([0-9]+)-([^/]*)(/?)+$ index.php?do=forum&action=categories&id=$1&name=$2 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['tree'] . '/([0-9]+)-([^/]*)/' . $this->router['page'] . '([0-9]+)(/?)+$ index.php?do=forum&action=categories&id=$1&name=$2&page=$3 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['topic'] . '/([0-9]+)-([^/]*)(/?)+$ index.php?do=forum&action=showtopic&id=$1&name=$2 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['topic'] . '/([0-9]+)-([^/]*)/' . $this->router['page'] . '([0-9]+)(/?)+$ index.php?do=forum&action=showtopic&id=$1&name=$2&page=$3 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/' . $this->router['topic'] . '/([0-9]+)-([^/]*)/findpost-([0-9]+)(/?)+$ index.php?do=forum&action=findpost&id=$1&name=$2&findpost=$3 [L]';
      $rewRulle[] = 'RewriteRule ^' . $this->router['main'] . '/unread/([0-9]+)(/?)+$ index.php?do=forum&action=unread&id=$1 [L]';
      $rewRulle = implode("\n", $rewRulle);
      $ret = <<< HTML
<form method="post" name="configure" id="configure" action="">
  <div class="content" id="general">
    <h1>{$this->lang_be['setting_363']}</h1>
    <div>{$option['mod_rewrite']}</div>
     <div style="margin-bottom:10px;color:red">{$this->lang_be['setting_366']}</div>
    <ul>
      <li style="display:none"><span>{$this->lang_be['setting_335']}</span><span class="info">{$this->lang_be['setting_336']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[main]" value="{$this->router['main']}" size="40">
      </li>
      <li><span>{$this->lang_be['setting_337']}</span><span class="info">{$this->lang_be['setting_338']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[tree]" value="{$this->router['tree']}" size="40">
      </li>
      <li><span>{$this->lang_be['setting_339']}</span><span class="info">{$this->lang_be['setting_340']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[topic]" value="{$this->router['topic']}" size="40">
      </li>
      <li><span>{$this->lang_be['setting_344']}</span><span class="info">{$this->lang_be['setting_345']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[search]" value="{$this->router['search']}" size="40">
      </li> 
      <li><span>{$this->lang_be['setting_346']}</span><span class="info">{$this->lang_be['setting_347']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[new_topic]" value="{$this->router['new_topic']}" size="40">
      </li>
      <li><span>{$this->lang_be['setting_348']}</span><span class="info">{$this->lang_be['setting_349']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[new_post]" value="{$this->router['new_post']}" size="40">
      </li>
      <li><span>{$this->lang_be['setting_350']}</span><span class="info">{$this->lang_be['setting_354']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[watched]" value="{$this->router['watched']}" size="40">
      </li>
      <li><span>{$this->lang_be['setting_352']}</span><span class="info">{$this->lang_be['setting_353']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[attachment]" value="{$this->router['attachment']}" size="40">
      </li>
      <li><span>{$this->lang_be['setting_355']}</span><span class="info">{$this->lang_be['setting_356']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[rss_tree]" value="{$this->router['rss_tree']}" size="40">
      </li>
      <li><span>{$this->lang_be['setting_357']}</span><span class="info">{$this->lang_be['setting_358']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[rss_topic]" value="{$this->router['rss_topic']}" size="40">
      </li>
      <li><span>{$this->lang_be['setting_359']}</span><span class="info">{$this->lang_be['setting_360']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[moderation]" value="{$this->router['moderation']}" size="40">
      </li>
      <li><span>{$this->lang_be['setting_341']}</span><span class="info">{$this->lang_be['setting_342']}</span>
        <input {$option['isNotRewrite']} type="text" class="edit" name="router[page]" value="{$this->router['page']}" size="40">
      </li>
    </ul>
    <button type="submit" name="submit" class="be_button">{$this->lang_be['refresh']}</button>
    <div>{$this->lang_be['setting_365']}</div>
    <textarea style="width:969px;height:100px;margin-top:5px" class="edit">{$rewRulle}</textarea>
  </div>
  <input type="hidden" name="save" value="all_router">
</form>
HTML;
      return $ret;
   }
   public function share()
   {
      $option = array();
      foreach ($this->share as $key => $value) {
         $option['status'] = '';
         $option['statusBotton'] = '';
         $option['img'] = $this->lang_be['setting_428'];
         if($key != 'google') {
            $option['img'] = '<img src="' . $this->dle_config['http_home_url'] . 'templates/' . $this->dle_config['skin'] . '/bullet_energy/images/social/' . $key . '.png" alt="">';
         }
         $option['statusBotton'] = $value['type'] ? '<a id="' . $key . '" title="' . $this->lang_be['setting_426'] . '" onclick="doShare(\'' . $key . '\',\'disabled\'); return false;" class="deleteElementA"><b>' . $this->lang_be['setting_426'] . '</b></a>' : '<a id="' . $key . '" title="' . $this->lang_be['setting_427'] . '" onclick="doShare(\'' . $key . '\',\'enable\'); return false;" class="enableElementA"><b>' . $this->lang_be['setting_426'] . '</b></a>';
         $option['return'][$value['position']] = '<tr id="' . $key . '" class="list"><td class="tree_info">' . $value['name'] . '</td><td>' . $option['img'] . '</td> <td>' . $option['statusBotton'] . '</td></tr>';

      }
      ksort($option['return']);
      $option['return'] = '<table cellspacing="0" cellpadding="0" border="0" class="table_tree" id="table"><thead><tr><th><div>' . $this->lang_be['setting_423'] . '</div></th><th class="w300"><div>' . $this->lang_be['setting_424'] . '</div></th> <th class="w25"><div></div></th></tr></thead><tbody id="sortTbl">' . implode('', $option['return']) . '</tbody></table>';
      return '<div id="general" class="content"><h1>' . $this->lang_be['setting_422'] . '</h1><div>' . $option['return'] . '</div></div>';
   }
   public function advertisingAddDb()
   {
      $data = is_array($_POST['advertising']) ? $_POST['advertising'] : die('die');
      $data['name'] = strip_tags($data['name']);
      $option['advertising_name'] = trim($data['name']) ? "'" . $this->db->safesql(substr($data['name'], 0, 255)) . "'" : die('no name block');
      $option['advertising_group'] = count($data['group']) ? "'" . $this->db->safesql(implode('.', $data['group'])) . "'" : '0';
      $option['advertising_tree'] = count($data['tree']) ? "'" . $this->db->safesql(implode('.', $data['tree'])) . "'" : '0';
      $option['advertising_topic'] = "'" . $this->db->safesql($data['topic_view']) . "'";
      $option['advertising_display'] = "'" . $this->db->safesql($data['display']) . "'";
      $option['advertising_content'] = trim($data['content']) ? "'" . $this->db->safesql($data['content']) . "'" : die('no content');
      $option = implode(',', $option);
      $this->db->query("INSERT INTO " . PREFIX . "_be_advertising (advertising_id, advertising_name, advertising_group, advertising_tree, advertising_topic, advertising_display, advertising_content) VALUES (NULL, {$option})");
      $this->casheRefresh();
      header('Location: ' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=advertising');
   }
   public function advertisingUpdate()
   {
      $data = is_array($_POST['advertising']) ? $_POST['advertising'] : die('die');
      $id = $this->getInt('id') ? $this->db->safesql($this->getInt('id')) : die('die');
      $data['name'] = strip_tags($data['name']);
      $option['advertising_name'] = trim($data['name']) ? "'" . $this->db->safesql(substr($data['name'], 0, 255)) . "'" : die('no name block');
      $option['advertising_group'] = count($data['group']) ? "'" . $this->db->safesql(implode('.', $data['group'])) . "'" : '0';
      $option['advertising_tree'] = count($data['tree']) ? "'" . $this->db->safesql(implode('.', $data['tree'])) . "'" : '0';
      $option['advertising_topic'] = "'" . $this->db->safesql($data['topic_view']) . "'";
      $option['advertising_display'] = "'" . $this->db->safesql($data['display']) . "'";
      $option['advertising_content'] = trim($data['content']) ? "'" . $this->db->safesql(stripslashes($data['content'])) . "'" : die('no content');
      foreach ($option as $key => $val) {
         $ret[] = "{$key} = {$val}";
      }
      $option = implode(', ', $ret);
      $this->db->query("UPDATE " . PREFIX . "_be_advertising SET {$option} WHERE advertising_id = {$id} LIMIT 1 ");
      $this->casheRefresh();
      header('Location: ' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=advertising');
   }
   public function advertisingEdit()
   {
      $id = $this->getInt('id') ? $this->db->safesql($this->getInt('id')) : die('no param');
      $this->db->query("SELECT * FROM " . PREFIX . "_be_advertising WHERE advertising_id = {$id} LIMIT 1");
      $row = $this->db->num_rows() ? $this->db->get_row() : die('die');
      $row['selectDisplay'] = $this->makeDropDown(array("none" => $this->lang_be['no'], "display" => $this->lang_be['yes']), "advertising[display]", "{$row['advertising_display']}");
      $row['topicViewSelect'] = $this->makeDropDown(array("none" => $this->lang_be['setting_195'], "top" => $this->lang_be['setting_190'], "random" => $this->lang_be['setting_191'], "footer" => $this->lang_be['setting_196']), "advertising[topic_view]", "{$row['advertising_topic']}");
      $row['groupSelect'] = $this->_selectedItem(explode('.', $row['advertising_group']), $this->_getGroup(), 'group');
      $row['treeSelect'] = $this->tree_selectDubl(explode('.', $row['advertising_tree']), 0, false);
      $ret = '<form method="post" name="advertising" action=""><div class="content"><h1>' . $this->lang_be['setting_184'] . '</h1><ul><li><span>' . $this->lang_be['setting_388'] . '</span> <span class="info">' . $this->lang_be['setting_389'] . '</span><input type="text" class="edit" name="advertising[name]" value="' . htmlspecialchars(stripcslashes($row['advertising_name'])) . '" size="66"></li><li><span>' . $this->lang_be['setting_185'] . ':</span><span class="info">' . $this->lang_be['setting_186'] . '</span><select multiple="" id="advertising" name="advertising[group][]">' . $row['groupSelect'] . '</select></li><li><span>' . $this->lang_be['setting_187'] . ':</span><span class="info">' . $this->lang_be['setting_188'] . '</span><select name="advertising[tree][]" multiple=""> ' . $row['treeSelect'] . '  </select></li><li><span>' . $this->lang_be['setting_189'] . ':</span>' . $row['topicViewSelect'] . '</li><li><span>' . $this->lang_be['setting_192'] . ':</span><br><textarea class="edit" style="width:969px;height:100px;" name="advertising[content]">' . htmlspecialchars(stripcslashes($row['advertising_content'])) . '</textarea></li><li><span>' . $this->lang_be['setting_193'] . ':</span><span class="info">' . $this->lang_be['setting_197'] . '</span>' . $row['selectDisplay'] . '</li></ul><input type="hidden" value="add_advertising_update" name="sub_action"><button type="submit" name="add_sub" class="be_button">' . $this->lang_be['refresh'] . '</button></div></form>';
      return $ret;
   }
   public function _selectedItem($selected = 0, $arrParam = array(), $type = '')
   {
      foreach ($arrParam as $key => $val) {
         $sel = in_array($key, $selected) ? ' selected ' : '';
         $name = $type == 'tree' ? $val['tree_title'] : $val['group_name'];
         $id = $type == 'tree' ? $val['tree_id'] : $val['id'];
         $sels = $val['tree_type'] == '0' ? 'disabled' : '';
         $ret .= "<option {$sel} {$sels} value=\"" . $id . '" >' . $name . '</option>';
      }
      return $ret;
   }
   private function _getSelectGroup($select = false, $name = '', $data = '')
   {
      $this->db->query("SELECT id,group_name FROM " . PREFIX . "_usergroups ORDER BY id ASC");
      if($select) {
      } else {
         while ($row = $this->db->get_row()) {
            if($row['id'] == 1) {
               $fetch .= '<option selected="" value="' . $row['id'] . '">' . $row['group_name'] . '</option>';
            } else {
               $fetch .= '<option value="' . $row['id'] . '">' . $row['group_name'] . '</option>';
            }
         }
         $fetch = '<select name="' . $name . '[group][]" id="' . $name . '" multiple="">' . $fetch . '</select>';
      }
      return $fetch;
   }
   public function questionAddDb()
   {
      if(!trim(strtr($_POST['captcha']['question'], $this->_cleanString))) {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['setting_145'] . '</div></div>';
      }
      if(!trim(strtr($_POST['captcha']['answer'], $this->_cleanString))) {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['setting_146'] . '</div></div>';
      }
      $option['status'] = intval($_POST['captcha']['active']);
      $option['question'] = $this->db->safesql(substr(trim(strtr($_POST['captcha']['question'], $this->_cleanString)), 0, 255));
      $option['arrayAnswerPost'] = explode(',', $_POST['captcha']['answer']);
      foreach ($option['arrayAnswerPost'] as $key => &$answer) {
         $answer = $this->db->safesql(trim(strip_tags(strtr($answer, $this->_cleanString))));
         if($answer === '') {
            unset($option['arrayAnswerPost'][$key]);
         }
      }
      if(empty($option['arrayAnswerPost'])) {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['setting_146'] . '</div></div>';
      }
      //var_dump($option['arrayAnswerPost']);
      $option['arrayAnswerPost'] = implode('<sep>', $option['arrayAnswerPost']); //var_dump($option);
      $this->db->query("INSERT INTO " . PREFIX . "_be_question 
                      (id,question,answers,is_active) 
                      VALUES (NULL,'{$option['question']}','{$option['arrayAnswerPost']}','{$option['status']}')");
      $this->casheRefresh();
      header('Location: ' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=captcha');
   }
   public function page_category()
   {
      $count = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_tree");
      if(intval($count['count']) == 0) {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['admin_tree_no'] . '</div><a class="be_button" href="' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=add_category">' . $this->lang_be['admin_add_tree_31'] . '</a></div>';
      } else {
         return $this->get_list_tree();
      }
   }
   private function _setSelectTreeGel($categoryid = 0, $parentid = 0, $nocat = true, $sublevelmarker = '', $returnstring = '')
   {
      $this->db->query("SELECT * FROM " . PREFIX . "_be_tree");
      while ($row = $this->db->get_row()) {
         $tree_info[$row['tree_id']] = array();
         foreach ($row as $key => $value) {
            $tree_info[$row['tree_id']][$key] = stripslashes($value);
         }
      }
      $root_category = array();
      $option = array();
      if($parentid == 0) {
         if($nocat)
            $returnstring .= '';
      } else {
         $sublevelmarker .= '&nbsp;&nbsp;&nbsp;';
      }
      if(count($tree_info)) {
         foreach ($tree_info as $cats) {
            if($cats['tree_parent_id'] == $parentid)
               $root_category[] = $cats['tree_id'];
         }
         if(count($root_category)) {
            foreach ($root_category as $id) {
               if($tree_info[$id]['tree_type'] == 0) {
                  $option['typeView'] = $this->lang_be['setting_432'];
                  $option['typeJs'] = 'main_tree';
                  $option['typeCss'] = 'list';
               } elseif($tree_info[$id]['tree_type'] == 1) {
                  $option['typeView'] = $this->lang_be['setting_433'];
                  $option['typeJs'] = 'sub_tree';
                  $option['typeCss'] = 'parents_child_tree';
               } elseif($tree_info[$id]['tree_type'] == 2) {
                  $option['typeView'] = $this->lang_be['setting_434'];
                  $option['typeJs'] = 'sub_tree';
                  $option['typeCss'] = 'parents_child_tree';
               }
               $returnstring .= '<tr id="' . $id . '" class="' . $option['typeCss'] . '"><td><input type="radio" name="tree" date-type="' . $tree_info[$id]['tree_type'] . '" uid="' . $option['typeJs'] . '" value="' . $id . '"></td><td class="tree_info"><a id="tree_' . $id . '" rel="' . $tree_info[$id]['tree_title'] . '" href="' . $this->php_self . '?mod=bullet_energy&amp;be_action=service&amp;sub_action=edit_category&amp;id_category=' . $id . '" title="' . $this->lang_be['edit'] . '">' . $sublevelmarker . $tree_info[$id]['tree_title'] . '</a><span class="tree_type">' . $option['typeView'] . '</span></td><td>' . $tree_info[$id]['tree_description'] . '</td> <td>' . $tree_info[$id]['tree_topic'] . '</td><td>' . $tree_info[$id]['tree_answer'] . '</td><td>' . $tree_info[$id]['tree_id'] . '</td><td><input type="text" value="' . $tree_info[$id]['tree_display'] . '" maxlength="5" name="position[' . $id . ']" size="5" class="edit MiniImputArea"></td></tr>';
               $returnstring = $this->_setSelectTreeGel($categoryid, $id, $nocat, $sublevelmarker, $returnstring);
            }
         }
      }
      return $returnstring;
   }
   private function get_list_tree()
   {
      $sel = $this->tree_selectDubl2();
      return '<form action="" id="sort_tree" name="sort_tree" method="post"><div id="tree" style="display:none"><select id="treeRemove" name="treeRemove">' . $sel . '</select></div><div id="general" class="content"><h1>' . $this->lang_be['admin_drevo'] . '</h1><div class="button_table_param"><div class="parent_child"><div class="fbutton"><div><span class="add"><a href="' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=add_category">' . $this->lang_be['admin_add_tree_31'] . '</a></span></div></div><div class="fbutton"><div><span class="del" onclick="TreeDell()">' . $this->lang_be['admin_add_tree_33'] . '</span></div></div></div></div><table cellspacing="0" cellpadding="0" border="0" id="table" class="table_tree"><thead><tr><th class="w25"><div>&nbsp;</div></th><th><div>' . $this->lang_be['admin_add_tree_23'] . '</div></th><th class="w300"><div>' . $this->lang_be['admin_add_tree_11'] . '</div></th> <th class="w50"><div>' . $this->lang_be['admin_add_tree_34'] . '</div></th><th class="w90"><div>' . $this->lang_be['admin_add_tree_35'] . '</div></th><th class="w50"><div>' . $this->lang_be['admin_add_tree_36'] . '</div></th><th class="w50 last"><div>' . $this->lang_be['admin_add_tree_37'] . '</div></th></tr></thead><tbody>' . $this->_setSelectTreeGel() . '</tbody></table></div><input type="hidden" name="sub_action" value="sortable"><button class="be_button" name="add_sub" type="submit">' . $this->lang_be['admin_add_tree_40'] . '</button></form><div class="infoBoxTree"><p>' . $this->lang_be['setting_148'] . ':</p><ul><li>' . $this->lang_be['setting_162'] . '</li><li>' . $this->lang_be['setting_159'] . '</li><li>' . $this->lang_be['setting_160'] . '</li><li>' . $this->lang_be['setting_161'] . '</li><li>' . $this->lang_be['setting_252'] . '</li></ul></div>';
   }
   public function trophiesUpdate()
   {
      $option['data'] = $_POST['trophies'];
      if(!$this->getInt('id')) {
         die('Error');
      }
      if(!trim(strtr($option['data']['name'], $this->_cleanString)) or !trim(strtr($option['data']['desc'], $this->_cleanString)) or !intval($option['data']['bals']) > 0) {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['setting_261'] . '</div></div>';
      }
      if(intval($option['data']['bals']) > 0) {
         $option['insert']['bals'] = intval($option['data']['bals']);
      }
      if(intval($option['data']['post']) > 0) {
         $option['insert']['post'] = intval($option['data']['post']);
      }
      if(intval($option['data']['like']) > 0) {
         $option['insert']['like'] = intval($option['data']['like']);
      }
      if(intval($option['data']['day']) > 0) {
         $option['insert']['day'] = intval($option['data']['day']);
      }
      $option['insert']['name'] = $this->db->safesql(htmlspecialchars(trim(strtr(strip_tags(stripcslashes($option['data']['name'])), $this->_cleanString))));
      $option['insert']['desc'] = $this->db->safesql(htmlspecialchars(trim(strtr(strip_tags(stripcslashes($option['data']['desc'])), $this->_cleanString))));
      foreach ($option['data']['group'] as $key => $value) {
         $value = intval($value);
         if($value <= 0) {
            unset($option['data']['group'][$key]);
         }
      }
      $option['insert']['group'] = $option['data']['group'];
      $option['insertDb'] = $this->db->safesql(serialize($option['insert']));
      $this->db->query("UPDATE " . PREFIX . "_be_honor SET bals = '{$option['insert']['bals']}', criteria = '{$option['insertDb']}' WHERE id = " . $this->getInt('id') . " LIMIT 1");
      $this->casheRefresh();
      header('Location: ' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=trophies');
   }
   public function rankAdd()
   {
      $option['data'] = $_POST['rank'];
      if(!trim(strtr($option['data']['name'], $this->_cleanString)) or !intval($option['data']['bals']) > 0) {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['setting_275'] . '</div></div>';
      }
      $option['insert']['name'] = $this->db->safesql(htmlspecialchars(trim(strtr(strip_tags(stripcslashes($option['data']['name'])), $this->_cleanString))));
      $this->db->query("INSERT INTO " . PREFIX . "_be_user_title (id, bals, title) VALUES (NULL, '" . intval($option['data']['bals']) . "', '{$option['insert']['name']}')");
      $this->casheRefresh();
      header('Location: ' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=rank');
   }
   public function rankUpdate()
   {
      $option['data'] = $_POST['rank'];
      if(!trim(strtr($option['data']['name'], $this->_cleanString)) or !intval($option['data']['bals']) > 0) {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['setting_275'] . '</div></div>';
      }
      $option['insert']['name'] = $this->db->safesql(htmlspecialchars(trim(strtr(strip_tags(stripcslashes($option['data']['name'])), $this->_cleanString))));
      $this->db->query("UPDATE " . PREFIX . "_be_user_title SET title = '{$option['insert']['name']}', bals=" . intval($option['data']['bals']) . " WHERE id = " . $this->getInt('id') . " LIMIT 1");
      $this->casheRefresh();
      header('Location: ' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=rank');
   }
   public function rank($act = false)
   {
      $row = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_user_title");
      if($row['count'] == 0 or $act) {
         $ret = '<form method="post" name="trophies" action=""><div id="general" class="content"><h1>' . $this->lang_be['setting_270'] . '</h1><ul><li><span>' . $this->lang_be['setting_271'] . '</span> <span class="info">' . $this->lang_be['setting_272'] . '</span><input type="text" class="edit" name="rank[name]" value="" size="66"></li><li><span>' . $this->lang_be['setting_273'] . '</span> <span class="info">' . $this->lang_be['setting_274'] . '</span><input type="text" size="66" value="" name="rank[bals]" class="edit"></li><input type="hidden" value="add_rank" name="sub_action"><button type="submit" name="add_sub" class="be_button">' . $this->lang_be['add'] . '</button></ul></div></form>';
      } else {
         $this->db->query("SELECT * FROM " . PREFIX . "_be_user_title ORDER BY bals ASC");
         while ($row = $this->db->get_row()) {
            $ret .= '<tr class="list"><td><input type="radio" name="tree" uid="sub_tree" value="' . $row['id'] . '"></td><td class="tree_info"><a title="Редактировать" href="' . $this->php_self . '?mod=bullet_energy&amp;be_action=service&amp;sub_action=rank_edit&amp;id_rank=' . $row['id'] . '" style="padding-left:0px">' . stripcslashes($row['title']) . '</a></td><td>' . $row['bals'] . '</td></tr>';
         }
         $ret = '<h1>' . $this->lang_be['setting_281'] . '</h1><div class="button_table_param"><div class="parent_child"><div class="fbutton"><div><span class="add"><a href="' . $this->php_self . '?mod=bullet_energy&amp;be_action=service&amp;sub_action=rank_add">' . $this->lang_be['setting_278'] . '</a></span></div></div><div class="fbutton"><div><span class="del" onclick="RankDell()">' . $this->lang_be['setting_279'] . '</span></div></div></div></div><table cellspacing="0" cellpadding="0" border="0" id="table" class="table_tree"><thead><tr><th class="w25"><div>&nbsp;</div></th><th><div>' . $this->lang_be['setting_277'] . '</div></th><th style="width:150px" class="w90 last"><div>' . $this->lang_be['setting_276'] . '</div></th></tr></thead>' . $ret . '<tbody></tbody></table>';
      }
      return $ret;
   }
   public function rankEdit()
   {
      $this->db->query("SELECT * FROM " . PREFIX . "_be_user_title WHERE id = " . $this->getInt('id_rank') . " LIMIT 1");
      $row = $this->db->num_rows() ? $this->db->get_row() : die('Error');
      return '<form action="" name="trophies" method="post"><div class="content" id="general"><h1>' . $this->lang_be['setting_280'] . '</h1><ul><li><span>' . $this->lang_be['setting_384'] . '</span> <span class="info">' . $this->lang_be['setting_385'] . '</span><input type="text" size="66" value="' . stripcslashes($row['title']) . '" name="rank[name]" class="edit"></li><li><span>' . $this->lang_be['setting_386'] . '</span> <span class="info">' . $this->lang_be['setting_387'] . '</span><input type="text" class="edit" name="rank[bals]" value="' . $row['bals'] . '" size="66"></li><input type="hidden" name="sub_action" value="update_rank"><input type="hidden" name="id" value="' . $row['id'] . '"><button class="be_button" name="add_sub" type="submit">' . $this->lang_be['refresh'] . '</button></ul></div></form>';
   }
   public function trophiesAdDb()
   {
      $option['data'] = $_POST['trophies'];
      if(!trim(strtr($option['data']['name'], $this->_cleanString)) or !trim(strtr($option['data']['desc'], $this->_cleanString)) or !intval($option['data']['bals']) > 0) {
         return '<div class="ok_save"><h1>' . $this->lang_be['information_error'] . '</h1><div class="coul">' . $this->lang_be['setting_261'] . '</div></div>';
      }
      if(intval($option['data']['bals']) > 0) {
         $option['insert']['bals'] = intval($option['data']['bals']);
      }
      if(intval($option['data']['post']) > 0) {
         $option['insert']['post'] = intval($option['data']['post']);
      }
      if(intval($option['data']['like']) > 0) {
         $option['insert']['like'] = intval($option['data']['like']);
      }
      if(intval($option['data']['day']) > 0) {
         $option['insert']['day'] = intval($option['data']['day']);
      }
      $option['insert']['name'] = $this->db->safesql(htmlspecialchars(trim(strtr(strip_tags(stripcslashes($option['data']['name'])), $this->_cleanString))));
      $option['insert']['desc'] = $this->db->safesql(htmlspecialchars(trim(strtr(strip_tags(stripcslashes($option['data']['desc'])), $this->_cleanString))));
      foreach ($option['data']['group'] as $key => $value) {
         $value = intval($value);
         if($value <= 0) {
            unset($option['data']['group'][$key]);
         }
      }
      $option['insert']['group'] = $option['data']['group'];
      $option['insertDb'] = $this->db->safesql(serialize($option['insert']));
      $this->db->query("INSERT INTO " . PREFIX . "_be_honor (id ,bals ,criteria) VALUES (NULL , '{$option['insert']['bals']}', '{$option['insertDb']}')");
      $this->casheRefresh();
      header('Location: ' . $this->php_self . '?mod=bullet_energy&be_action=service&sub_action=trophies');
   }
   public function save_config()
   {
      if(strip_tags($_POST['hash']) == $this->login_hash and intval($this->id_member['user_group']) == 1) {
         $_POST['save_param']['version'] = '1.2';
         $save_con = $_POST['save_param'];
         $find[] = "'\r'";
         $replace[] = "";
         $find[] = "'\n'";
         $replace[] = "";
         $handler = fopen(ENGINE_DIR . '/bullet_energy/data/forum_config.php', "w");
         fwrite($handler, "<?PHP \n// " . $this->lang_be['setting_383'] . "\n\$bullet_energy_config = array (\n");
         foreach ($save_con as $name => $value) {
            $value = trim(stripslashes($value));
            $value = htmlspecialchars($value, ENT_QUOTES);
            $value = preg_replace($find, $replace, $value);
            $name = trim(stripslashes($name));
            $name = htmlspecialchars($name, ENT_QUOTES);
            $name = preg_replace($find, $replace, $name);
            $value = str_replace("$", "&#036;", $value);
            $value = str_replace("{", "&#123;", $value);
            $value = str_replace("}", "&#125;", $value);
            $name = str_replace("$", "&#036;", $name);
            $name = str_replace("{", "&#123;", $name);
            $name = str_replace("}", "&#125;", $name);
            fwrite($handler, "'{$name}' => \"{$value}\",\n");
         }
         fwrite($handler, ");\n?>");
         fclose($handler);
         return true;
      } else {
         die('Hacking attempt! User not found');
      }
   }
   public function page_main()
   {
      $option = array();
      $this->db->query("SHOW TABLE STATUS FROM `" . DBNAME . "`");
      $option['size'] = 0;
      while ($row = $this->db->get_array()) {
         if(strpos($row['Name'], PREFIX . "_be_") !== false)
            $option['size'] += $row['Data_length'] + $row['Index_length'];
      }
      $option['size'] = formatsize($option['size']);
      $option['topic'] = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_topic");
      $option['topicAprove'] = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_topic WHERE topic_approve = 0");
      $option['message'] = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_message");
      $option['messageAprove'] = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_message WHERE message_approve = 0");
      $option['complain'] = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_complaint");
      $option['block'] = '<div class="mainPageBox"><div class="titleMain"><h1>' . $this->lang_be['setting_163'] . '</h1></div>';
      $option['block'] .= '<dl><dt>' . $this->lang_be['setting_217'] . '</dt>';
      $option['block'] .= '<dd>' . $option['topic']['count'] . '</dd></dl>';
      /**/
      $option['block'] .= '<dl><dt>' . $this->lang_be['setting_218'] . '</dt>';
      $option['block'] .= '<dd>' . $option['topicAprove']['count'] . '</dd></dl>';
      /**/
      $option['block'] .= '<dl><dt>' . $this->lang_be['setting_220'] . '</dt>';
      $option['block'] .= '<dd>' . $option['message']['count'] . '</dd></dl>';
      /**/
      $option['block'] .= '<dl><dt>' . $this->lang_be['setting_221'] . '</dt>';
      $option['block'] .= '<dd>' . $option['messageAprove']['count'] . '</dd></dl>';
      /**/
      $option['block'] .= '<dl><dt>' . $this->lang_be['setting_219'] . '</dt>';
      $option['block'] .= '<dd>' . $option['complain']['count'] . '</dd></dl>';
      /**/
      $option['block'] .= '<dl><dt>' . $this->lang_be['setting_222'] . '</dt>';
      $option['block'] .= '<dd>' . $option['size'] . '</dd></dl>';
      /**/
      $option['block'] .= '</div><button type="submit" name="submit" onclick="clearCache(); return false;" class="be_button">' . $this->lang_be['setting_223'] . '</button>';
      return $option['block'];
   }
   public function page_all_configure()
   {
      $sel_captha_type = $this->makeDropDown(array("1" => $this->lang_be['setting_313'], "0" => $this->lang_be['setting_314']), "save_param[captha_type]", "{$this->modul_config['captha_type']}");
      $sel_status = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[forum_status]", "{$this->modul_config['forum_status']}");
      $sel_dowl = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[dowload_count]", "{$this->modul_config['dowload_count']}");
      $sel_reg = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[reg_linck_5]", "{$this->modul_config['reg_linck_5']}");
      $sel_online = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[online_block]", "{$this->modul_config['online_block']}");
      $sel_cpu = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[cpu]", "{$this->modul_config['cpu']}");
      $sel_mass = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[mass_upload]", "{$this->modul_config['mass_upload']}");
      $topic_view = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[topic_view]", "{$this->modul_config['topic_view']}");
      $images_marck = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[images_marck]", "{$this->modul_config['images_marck']}");
      $image_gen = $this->makeDropDown(array("2" => $this->lang_be['setting_315'], "1" => $this->lang_be['setting_316'], "0" => $this->lang_be['setting_317']), "save_param[wh_images]", "{$this->modul_config['wh_images']}");
      $sel_combine = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[msg_combine]", "{$this->modul_config['msg_combine']}");
      $sel_start_auto = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[play]", "{$this->modul_config['play']}");
      $sel_water = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[flv_watermark]", "{$this->modul_config['flv_watermark']}");
      $sel_position = $this->makeDropDown(array("left" => $this->lang_be['setting_318'], "center" => $this->lang_be['setting_319'], "right" => $this->lang_be['setting_320']), "save_param[flv_watermark_pos]", "{$this->modul_config['flv_watermark_pos']}");
      $sel_releted = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[tube_related]", "{$this->modul_config['tube_related']}");
      $sel_dle_style = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[tube_dle]", "{$this->modul_config['tube_dle']}");
      $sel_yq = $this->makeDropDown(array("small" => $this->lang_be['setting_321'], "medium" => $this->lang_be['setting_322'], "large" => $this->lang_be['setting_323'], "hd720" => 'HD 720p'), "save_param[youtube_q]", "{$this->modul_config['youtube_q']}");
      $sel_cadre = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[startframe]", "{$this->modul_config['startframe']}");
      $sel_cover = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[preview]", "{$this->modul_config['preview']}");
      $sel_control = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[autohide]", "{$this->modul_config['autohide']}");
      $image_pv = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[images_prev_insert]", "{$this->modul_config['images_prev_insert']}");
      $sel_repa = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[reputations]", "{$this->modul_config['reputations']}");
      $sel_repa_type = $this->makeDropDown(array("2" => $this->lang_be['setting_324'], "1" => $this->lang_be['setting_325'], "0" => $this->lang_be['setting_326']), "save_param[reputations_type]", "{$this->modul_config['reputations_type']}");
      $sel_view_post = $this->makeDropDown(array("1" => $this->lang_be['setting_327'], "0" => $this->lang_be['setting_328']), "save_param[view_post_search]", "{$this->modul_config['view_post_search']}");
      $sel_url_refresch = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[url_click]", "{$this->modul_config['url_click']}");
      $topic_auto_ren = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[title_case]", "{$this->modul_config['title_case']}");
      $sel_adviser = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[adv]", "{$this->modul_config['adv']}");
      $sel_post_last = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[widget_last_post]", "{$this->modul_config['widget_last_post']}");
      $sel_session = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[session_check]", "{$this->modul_config['session_check']}");
      $sel_onlines = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[online]", "{$this->modul_config['online']}");
      $sel_thanks = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[is_like]", "{$this->modul_config['is_like']}");
      $sel_ае = $this->makeDropDown(array("1" => $this->lang_be['setting_243'], "0" => $this->lang_be['setting_244']), "save_param[format_rss_tree]", "{$this->modul_config['format_rss_tree']}");
      $sel_rss_en = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[enable_rss]", "{$this->modul_config['enable_rss']}");
      $sel_rss_en_to = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[enable_rss_topic]", "{$this->modul_config['enable_rss_topic']}");
      $selModD = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[moder_disable]", "{$this->modul_config['moder_disable']}");
      $top_pag_m = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[mini_pag]", "{$this->modul_config['mini_pag']}");
      $image_float = $this->makeDropDown(array("none" => $this->lang_be['setting_283'], "left" => $this->lang_be['setting_284'], "right" => $this->lang_be['setting_285'], "center" => $this->lang_be['setting_286']), "save_param[float_img]", "{$this->modul_config['float_img']}");
      $wpewviewTopic = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[widget_preview]", "{$this->modul_config['widget_preview']}");
      $warningWidget = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[widget_warning]", "{$this->modul_config['widget_warning']}");
      $sel_cpu_mod = $this->makeDropDown(array("1" => $this->lang_be['setting_376'], "0" => $this->lang_be['setting_377']), "save_param[is_cpu_type]", "{$this->modul_config['is_cpu_type']}");
      $sel_cpu_mod_red = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[handler_cpu]", "{$this->modul_config['handler_cpu']}");
      $sel_slash = $this->makeDropDown(array("1" => $this->lang_be['yes'], "0" => $this->lang_be['no']), "save_param[slash]", "{$this->modul_config['slash']}");
      $ret .= <<< HTML
<form action="" id="configure" name="configure" method="post">
  <div id="general" class="content">
    <h1>{$this->lang_be['setting_0']}</h1>
    <ul>
      <li><span>{$this->lang_be['setting_1']}:</span><span class="info">{$this->lang_be['setting_2']}</span>
        <input type="text" size="40" value="{$this->modul_config['meta_titl']}" name="save_param[meta_titl]" class="edit">
      </li>
      <li><span>{$this->lang_be['setting_3']}:</span><span class="info">{$this->lang_be['setting_4']}</span>
        <input type="text" size="40" value="{$this->modul_config['speedbar_titl']}" name="save_param[speedbar_titl]" class="edit">
      </li>
      <li><span>{$this->lang_be['setting_5']}:</span><span class="info">{$this->lang_be['setting_6']}</span>
        <input type="text" size="40" value="{$this->modul_config['url_site']}" name="save_param[url_site]" class="edit">
      </li>
      <li><span>{$this->lang_be['setting_7']}:</span><span class="info">{$this->lang_be['setting_8']}</span>
        <input type="text" size="40" value="{$this->modul_config['meta_descr']}" name="save_param[meta_descr]" class="edit">
      </li>
      <li><span>{$this->lang_be['setting_9']}:</span><span class="info">{$this->lang_be['setting_10']}</span>
        <textarea name="save_param[meta_keywords]" rows="5" class="edit">{$this->modul_config['meta_keywords']}</textarea>
      </li>
       
     <li><span>{$this->lang_be['setting_240']}:</span><span class="info">{$this->lang_be['setting_241']}</span>
        <input type="text" size="40" value="{$this->modul_config['time_cashe']}" name="save_param[time_cashe]" class="edit">
      </li>
        
      
      <li><span>{$this->lang_be['setting_15']}:</span><span class="info">{$this->lang_be['setting_16']}</span>{$sel_reg}</li>
      <li><span>{$this->lang_be['setting_17']}:</span><span class="info">{$this->lang_be['setting_18']}</span>{$sel_cpu}</li>
      <li><span>{$this->lang_be['setting_375']}</span><span class="info" style="width:75%">{$this->lang_be['setting_380']}</span>{$sel_cpu_mod}</li>
      <li><span>{$this->lang_be['setting_378']}</span><span class="info">{$this->lang_be['setting_381']}</span>{$sel_cpu_mod_red}</li>
      <li><span>{$this->lang_be['setting_379']}</span><span class="info">{$this->lang_be['setting_382']}</span>{$sel_slash}</li>
      
      <li><span>{$this->lang_be['setting_253']}:</span><span class="info">{$this->lang_be['setting_254']}</span>{$selModD}</li>
     
      
<li><span>{$this->lang_be['setting_198']}:</span><span class="info">{$this->lang_be['setting_199']}</span>{$sel_adviser}</li>
      <li><span>{$this->lang_be['setting_206']}:</span><span class="info">{$this->lang_be['setting_207']}</span>{$sel_session}</li>
      
      
      <li><span>{$this->lang_be['setting_67']}:</span><span class="info">{$this->lang_be['setting_68']}</span><input type="text" size="40" value="{$this->modul_config['count_pagination_rez']}" name="save_param[count_pagination_rez]" class="edit"></li>
      
     
      
      <li><span>{$this->lang_be['setting_21']}:</span><span class="info">{$this->lang_be['setting_22']}</span>{$sel_status}</li>
      <li><span>{$this->lang_be['setting_23']}:</span><span class="info">{$this->lang_be['setting_24']}</span>
        <textarea name="save_param[off_line_status]" rows="5" class="edit">{$this->modul_config['off_line_status']}</textarea>
      </li>
    </ul>
    <button class="be_button" name="submit" type="submit">{$this->lang_be['save']}</button>
    
    {$this->lang_be['setting_225']}
  </div>
  <div id="upload" class="content" style="display:none">
    <h1>{$this->lang_be['setting_25']}</h1>
    <ul>
      <li><span>{$this->lang_be['setting_26']}:</span> <span class="info">{$this->lang_be['setting_27']}</span>
        <input type="text" size="40" value="{$this->modul_config['upload_max_size']}" name="save_param[upload_max_size]"  class="edit">
      </li>
      <li><span>{$this->lang_be['setting_28']}:</span> <span class="info">{$this->lang_be['setting_29']}</span>
        <textarea name="save_param[upload_file_type]" rows="5" class="edit">{$this->modul_config['upload_file_type']}</textarea>
      </li>
     
     
      <li><span>{$this->lang_be['setting_34']}:</span><span class="info">{$this->lang_be['setting_35']}</span>{$sel_dowl} </li>
      
      <li><span>{$this->lang_be['setting_36']}:</span><span class="info">{$this->lang_be['setting_37']}</span>{$sel_mass} </li>
       <li><span>{$this->lang_be['setting_30']}:</span><span class="info">{$this->lang_be['setting_31']}</span>
        <input type="text" size="40" value="{$this->modul_config['upload_count_file']}" name="save_param[upload_count_file]"  class="edit">
      </li>
    </ul>
    <button class="be_button" name="submit" type="submit">{$this->lang_be['save']}</button>
  </div>
  <div id="topic" class="content" style="display:none">
    <h1>{$this->lang_be['setting_38']}</h1>
    <ul>
      <li><span>{$this->lang_be['setting_39']}:</span><span class="info">{$this->lang_be['setting_40']}</span>
        <input type="text" size="40" value="{$this->modul_config['topic_count']}" name="save_param[topic_count]"  class="edit">
      </li>
      
      
      <li><span>{$this->lang_be['setting_200']}:</span> <span class="info"> </span>
      <span id="colorSelectorLi1">{$this->lang_be['setting_312']}</span>
     
        <input style="color:{$this->modul_config['color_prefixwan']}" id="prefixwan" type="text" size="40" value="{$this->modul_config['prefix_wan']}" name="save_param[prefix_wan]"  class="edit">
       <input type="hidden" id="i_prefixwan" name="save_param[color_prefixwan]" value="{$this->modul_config['color_prefixwan']}" /></li>
      
      <li><span>{$this->lang_be['setting_201']}:</span> <span class="info"> </span>
      <span id="colorSelectorLi">{$this->lang_be['setting_312']}</span>
     
        <input style="color:{$this->modul_config['color_prefixcloze']}" id="prefixcloze" type="text" size="40" value="{$this->modul_config['prefix_cloze']}" name="save_param[prefix_cloze]"  class="edit">
      <input type="hidden" id="i_prefixcloze" name="save_param[color_prefixcloze]" value="{$this->modul_config['color_prefixcloze']}" /> </li>
      
      
      <li><span>{$this->lang_be['setting_332']}:</span> 
      <span id="colorSelectorLi">{$this->lang_be['setting_312']}</span>
     
        <input style="color:{$this->modul_config['color_prefixvote']}" id="prefixvote" type="text" size="40" value="{$this->modul_config['prefix_vote']}" name="save_param[prefix_vote]"  class="edit">
      <input type="hidden" id="i_prefixvote" name="save_param[color_prefixvote]" value="{$this->modul_config['color_prefixvote']}" /> </li>
      
      
      
      
      <li><span>{$this->lang_be['setting_420']}</span> 
      <span id="colorSelectorLi">{$this->lang_be['setting_312']}</span>
     
        <input style="color:{$this->modul_config['color_prefixfire']}" id="prefix_fire" type="text" size="40" value="{$this->modul_config['prefix_fire']}" name="save_param[prefix_fire]"  class="edit">
      <input type="hidden" id="i_prefix_fire" name="save_param[color_prefixfire]" value="{$this->modul_config['color_prefixfire']}" /> </li>
      
      
      
      
      
      
       
       
      <li><span>{$this->lang_be['setting_70']}:</span> <span class="info">{$this->lang_be['setting_71']}</span> {$topic_view} </li>
      
      
      <li><span>{$this->lang_be['setting_258']}:</span> <span class="info">{$this->lang_be['setting_259']}</span> {$top_pag_m} </li>
      
      
<li><span>{$this->lang_be['setting_181']}:</span> <span class="info">{$this->lang_be['setting_182']}</span> {$topic_auto_ren} </li>
       
      <li><span>{$this->lang_be['setting_92']}:</span><span class="info">{$this->lang_be['setting_93']}</span><input type="text" size="40" value="{$this->modul_config['topic_day']}" name="save_param[topic_day]" class="edit"></li>
      <li><span>{$this->lang_be['setting_419']}:</span><input type="text" size="40" value="{$this->modul_config['fire_topic']}" name="save_param[fire_topic]" class="edit"></li>
     
    </ul>
    <button class="be_button" name="submit" type="submit">{$this->lang_be['save']}</button>
  </div>
  <div id="message" class="content" style="display:none">
    <h1>{$this->lang_be['setting_53']}</h1>
    <ul>
      <li><span>{$this->lang_be['setting_54']}:</span> <span class="info">{$this->lang_be['setting_55']}</span>
        <input type="text" size="40" value="{$this->modul_config['message_count']}" name="save_param[message_count]"  class="edit">
      </li>
      <li><span>{$this->lang_be['setting_56']}:</span> <span class="info">{$this->lang_be['setting_57']}</span>
        <input type="text" size="40" value="{$this->modul_config['message_count_mini']}" name="save_param[message_count_mini]"  class="edit">
      </li>
      
      
      <li><span>{$this->lang_be['setting_58']}: </span> <span class="info">{$this->lang_be['setting_59']}</span>
        <input type="text" size="40" value="{$this->modul_config['message_count_page']}" name="save_param[message_count_page]"  class="edit">
      </li>
      
    <li><span>{$this->lang_be['setting_255']}: </span> <span class="info">{$this->lang_be['setting_256']}</span>
        <input type="text" size="40" value="{$this->modul_config['edit_time_post']}" name="save_param[edit_time_post]"  class="edit">
      </li>
      
      
      
      
      
      
      
      
      
      <li><span>{$this->lang_be['setting_91']}:</span> <span class="info">{$this->lang_be['setting_134']}</span> {$sel_combine} </li>  
      <li><span>{$this->lang_be['setting_89']}:</span><span class="info">{$this->lang_be['setting_90']}</span><input type="text" size="40" value="{$this->modul_config['wrap_count_msg']}" name="save_param[wrap_count_msg]" class="edit"></li> 
      <li><span>{$this->lang_be['setting_175']}:</span> <span class="info">{$this->lang_be['setting_176']}</span> {$sel_view_post} </li>  
    <li><span>{$this->lang_be['setting_177']}:</span> <span class="info">{$this->lang_be['setting_178']}</span> {$sel_url_refresch} </li>  
      
    </ul>
    <button class="be_button" name="submit" type="submit">{$this->lang_be['save']}</button>
     {$this->lang_be['setting_225']}
  </div>
  <div id="time_step" class="content" style="display:none">
    <h1>{$this->lang_be['setting_60']}</h1>
    <ul>
      <li><span>{$this->lang_be['setting_61']}</span> <span class="info">{$this->lang_be['setting_62']}</span>
        <input type="text" size="40" value="{$this->modul_config['time_step_last_message']}" name="save_param[time_step_last_message]"  class="edit">
      </li>
      <li><span>{$this->lang_be['setting_61']}</span> <span class="info">{$this->lang_be['setting_69']}</span>
        <input type="text" size="40" value="{$this->modul_config['time_step_last_message_cat']}" name="save_param[time_step_last_message_cat]"  class="edit">
      </li>
      <li><span>{$this->lang_be['setting_63']}:</span> <span class="info">{$this->lang_be['setting_64']}</span>
        <input type="text" size="40" value="{$this->modul_config['time_step_message']}" name="save_param[time_step_message]"  class="edit">
      </li>
      <li><span>{$this->lang_be['setting_65']}:</span> <span class="info">{$this->lang_be['setting_66']}</span>
        <input type="text" size="40" value="{$this->modul_config['time_step_autor']}" name="save_param[time_step_autor]"  class="edit">
      </li>
      
      <li><span>{$this->lang_be['setting_88']}:</span> <span class="info">{$this->lang_be['setting_62']}</span>
        <input type="text" size="40" value="{$this->modul_config['time_step_topic_new']}" name="save_param[time_step_topic_new]"  class="edit">
      </li>
      
    </ul>
    <button class="be_button" name="submit" type="submit">{$this->lang_be['save']}</button>
  </div>
  
  
  <div id="video" class="content" style="display:none">
  <h1>{$this->lang_be['setting_99']}</h1>
  <ul>
    <li><span>{$this->lang_be['setting_100']}:</span> <span class="info">{$this->lang_be['setting_101']}</span>
      <input type="text" size="40" value="{$this->modul_config['width']}" name="save_param[width]"  class="edit">
    </li>
    <li><span>{$this->lang_be['setting_103']}:</span> <span class="info">{$this->lang_be['setting_104']}</span>
      <input type="text" size="40" value="{$this->modul_config['height']}" name="save_param[height]"  class="edit">
    </li>
    <li><span>{$this->lang_be['setting_104']}:</span> <span class="info">{$this->lang_be['setting_105']}</span> {$sel_start_auto} </li>
    <li><span>{$this->lang_be['setting_106']}:</span> <span class="info">{$this->lang_be['setting_107']}</span> {$sel_water} </li>
    <li><span>{$this->lang_be['setting_108']}:</span> <span class="info">{$this->lang_be['setting_109']}</span> {$sel_position} </li>
    <li><span>{$this->lang_be['setting_110']}:</span> <span class="info">{$this->lang_be['setting_111']}</span>
      <input type="text" size="40" value="{$this->modul_config['flv_watermark_al']}" name="save_param[flv_watermark_al]"  class="edit">
    </li>
    <li><span>{$this->lang_be['setting_112']}:</span> <span class="info">{$this->lang_be['setting_113']}</span> {$sel_releted} </li>
    <li><span>{$this->lang_be['setting_114']}:</span> <span class="info">{$this->lang_be['setting_115']}</span> {$sel_dle_style} </li>
   
     <h1>{$this->lang_be['setting_128']}</h1>
    <li><span>{$this->lang_be['setting_116']}:</span> <span class="info">{$this->lang_be['setting_117']}</span> {$sel_yq} </li>
    <li><span>{$this->lang_be['setting_118']}:</span> <span class="info">{$this->lang_be['setting_119']}</span> {$sel_cadre} </li>
    <li><span>{$this->lang_be['setting_120']}:</span> <span class="info">{$this->lang_be['setting_121']}</span> {$sel_cover} </li>
    <li><span>{$this->lang_be['setting_122']}:</span> <span class="info">{$this->lang_be['setting_122']}</span> {$sel_control} </li>
<li><span>{$this->lang_be['setting_124']}:</span> <span class="info">{$this->lang_be['setting_125']}</span>
      <input type="text" size="40" value="{$this->modul_config['buffer']}" name="save_param[buffer]"  class="edit">
    </li>  
<li><span>{$this->lang_be['setting_126']}:</span> <span class="info">{$this->lang_be['setting_127']}</span>
      <input type="text" size="40" value="{$this->modul_config['progressBarColor']}" name="save_param[progressBarColor]"  class="edit">
    </li>   
  </ul>
  <button class="be_button" name="submit" type="submit">{$this->lang_be['save']}</button>
</div>
 <div id="images" class="content" style="display:none">
  <h1>{$this->lang_be['setting_129']}</h1>
  <ul> 
     <li><span>{$this->lang_be['setting_76']}:</span><span class="info">{$this->lang_be['setting_77']}</span>
        <input type="text" size="40" value="{$this->modul_config['max_images_upload']}" name="save_param[max_images_upload]"  class="edit">
      </li>   
      <li><span>{$this->lang_be['setting_78']}:</span><span class="info">{$this->lang_be['setting_79']}</span>
        <input type="text" size="40" value="{$this->modul_config['size_image_th']}" name="save_param[size_image_th]"  class="edit">
      </li>
      <li><span>{$this->lang_be['setting_80']}:</span><span class="info">{$this->lang_be['setting_81']}</span>
       {$image_gen}
      </li>   
       <li><span>{$this->lang_be['setting_130']}</span><span class="info">{$this->lang_be['setting_131']}</span>
        <input type="text" size="40" value="{$this->modul_config['size_img_noupload']}" name="save_param[size_img_noupload]"  class="edit">
      </li>    
<li><span>{$this->lang_be['setting_132']}:</span><span class="info">{$this->lang_be['setting_133']}</span>
       {$image_pv}
      </li>    
      
      
      
      <li><span>{$this->lang_be['setting_282']}:</span>{$image_float}</li>       
  </ul>
  <button class="be_button" name="submit" type="submit">{$this->lang_be['save']}</button>
</div>

<div id="security" class="content" style="display:none">
  <h1>{$this->lang_be['security']}</h1>
  <ul> 
      <li><span>{$this->lang_be['setting_13']}:</span><span class="info">{$this->lang_be['setting_14']}</span>{$sel_captha_type}</li>
 
      <li><span>{$this->lang_be['setting_95']}:</span><span class="info">{$this->lang_be['setting_97']}</span>
        <input type="text" size="40" value="{$this->modul_config['republic']}" name="save_param[republic]" class="edit">
      </li>
      <li><span>{$this->lang_be['setting_96']}:</span><span class="info">{$this->lang_be['setting_97']}</span>
        <input type="text" size="40" value="{$this->modul_config['reprivate']}" name="save_param[reprivate]" class="edit">
      </li> 
      
      <li><span>{$this->lang_be['setting_257']}:</span><span class="info">{$this->lang_be['setting_260']}</span> 
        <input type="text" size="40" value="{$this->modul_config['anti_no']}" name="save_param[anti_no]" class="edit">
      </li>    
  </ul>
  <button class="be_button" name="submit" type="submit">{$this->lang_be['save']}</button>
</div>

<div id="intergration" class="content" style="display:none">
  <h1>{$this->lang_be['intergration_0']}</h1>
  <ul> 
      <li><span>{$this->lang_be['setting_311']}</span><span class="info">{$this->lang_be['setting_310']}</span>{$sel_repa}</li>
      
      <li id="repa_type"><span>{$this->lang_be['setting_309']}</span><span class="info">{$this->lang_be['setting_308']}</span>{$sel_repa_type}</li>
      
        
  </ul>
  <button class="be_button" name="submit" type="submit">{$this->lang_be['save']}</button>
   {$this->lang_be['setting_226']}
</div>




<div id="widget" class="content" style="display:none">
  <h1>{$this->lang_be['setting_211']}</h1>
  <ul>
  <li><span>{$this->lang_be['setting_210']}:</span><span class="info">{$this->lang_be['setting_212']}</span>{$sel_onlines}</li>
  <li><span>{$this->lang_be['setting_208']}:</span><span class="info">{$this->lang_be['setting_209']}</span>
        <input type="text" size="40" value="{$this->modul_config['session_time']}" name="save_param[session_time]" class="edit">
      </li>
      
   <li style="display:none"><span>{$this->lang_be['setting_203']}:</span> <span class="info">{$this->lang_be['setting_204']}</span> {$sel_post_last} </li>  
    
 <li style="display:none"><span>{$this->lang_be['setting_205']}: </span>
        <input type="text" size="40" value="{$this->modul_config['widget_last_post_count']}" name="save_param[widget_last_post_count]"  class="edit">
</li>           
  <li><span>{$this->lang_be['setting_216']}:</span> {$sel_thanks} </li>   
    <li><span>{$this->lang_be['setting_329']}</span> <span class="info">{$this->lang_be['setting_330']}</span>{$wpewviewTopic}</li>
    
    <li><span>{$this->lang_be['setting_370']}</span> <span class="info">{$this->lang_be['setting_429']}</span>{$warningWidget}</li>    
    <li><span>{$this->lang_be['setting_371']}</span><span class="info">{$this->lang_be['setting_430']}</span>
        <input type="text" size="40" value="{$this->modul_config['widget_warning_bann']}" name="save_param[widget_warning_bann]" class="edit">
      </li>
    
    <li><span>{$this->lang_be['setting_373']}</span><span class="info">{$this->lang_be['setting_374']}</span>
        <input type="text" size="40" value="{$this->modul_config['widget_warning_count']}" name="save_param[widget_warning_count]" class="edit">
      </li>
      
 </ul>
  <button class="be_button" name="submit" type="submit">{$this->lang_be['save']}</button>
</div>

<div id="rss" class="content" style="display:none">
  <h1>{$this->lang_be['rssTitlAct']}</h1>
  <ul> <li><span>{$this->lang_be['setting_248']}:</span> {$sel_rss_en}</li>
  <li><span>{$this->lang_be['setting_251']}:</span> {$sel_rss_en_to}</li>
  <li><span>{$this->lang_be['setting_242']}:</span><span class="info">{$this->lang_be['setting_241']}</span>
        <input type="text" size="40" value="{$this->modul_config['time_cashe_rss']}" name="save_param[time_cashe_rss]" class="edit">
      </li> 
      
      <li><span>{$this->lang_be['setting_246']}</span><span class="info">{$this->lang_be['setting_247']}</span>
        <input type="text" size="40" value="{$this->modul_config['count_feed']}" name="save_param[count_feed]" class="edit">
      </li> 
    
  <li><span>{$this->lang_be['setting_245']}:</span> {$sel_ае}</li>
  
  
      
   
 </ul>
  <button class="be_button" name="submit" type="submit">{$this->lang_be['save']}</button>
</div>



  <input type="hidden" value="all_configure" name="save">
  <input type="hidden" value="{$this->id_member['name']}" id="name" name="name">
  <input type="hidden" value="{$this->login_hash}" id="hash" name="hash">
  <input type="hidden" value="{$this->id_member['user_id']}" id="user_id" name="user_id">
</form>
HTML;
      return $ret;
   }
   public function updateTamplate()
   {
      $option = $_POST['template'];
      $insert['prefix'] = $this->db->safesql(strip_tags(stripcslashes($option['prefix'])));
      $insert['content'] = $this->db->safesql(trim(strip_tags(stripcslashes($option['content']))));
      $insert['tree'] = (int)$option['tree'];
      $insert = serialize($insert);
      $this->db->query("DELETE FROM " . PREFIX . "_be_sub_template WHERE action = 'discussion' LIMIT 1");
      $this->db->query("INSERT INTO " . PREFIX . "_be_sub_template (action, param) VALUES ('discussion', '{$insert}')");
      header("Location:" . $this->php_self . "?mod=bullet_energy&be_action=service&sub_action=template");
   }
   public function template()
   {
      $row = $this->db->super_query("SELECT * FROM " . PREFIX . "_be_sub_template WHERE action = 'discussion' LIMIT 1");
      $row['param'] = unserialize($row['param']);
      return '<form action="" name="advertising" method="post">
  <div class="content">
    <h1>' . $this->lang_be['setting_293'] . '</h1>
    <ul>
      <li><span>' . $this->lang_be['setting_294'] . '</span><span class="info">' . $this->lang_be['setting_295'] . '</span>
        <select name="template[tree]"> ' . $this->tree_selectDubl($row['param']['tree'], 0) . '  </select>
      </li>
      <li><span>' . $this->lang_be['setting_297'] . '</span><span class="info">' . $this->lang_be['setting_299'] . '</span> 
      <input type="text" size="66" value="' . htmlspecialchars($row['param']['prefix']) . '" name="template[prefix]" class="edit"></li>
      <li><span>' . $this->lang_be['setting_296'] . '</span>
      <span class="info">' . $this->lang_be['setting_298'] . '</span> 
        <textarea name="template[content]" style="width:969px;height:100px;" class="edit">' . htmlspecialchars($row['param']['content']) . '</textarea>
      </li>
    </ul>
    <input type="hidden" name="sub_action" value="add_template_db">
    <button type="submit" name="add_sub" class="be_button">' . $this->lang_be['refresh'] . '</button></div></form>';
   }
   public function activate()
   {
      if(file_exists(ENGINE_DIR . '/bullet_energy/cache/system/types.tmp')) {
         require_once ENGINE_DIR . '/bullet_energy/cache/system/types.tmp';
         return '<div id="general" class="content"><h1>' . $this->lang_be['activate_0'] . '</h1>' . $this->lang_be['activate_6'] . '</div>';
      } else {
         return '<div id="general" class="content"><h1>' . $this->lang_be['activate_0'] . '</h1><ul><li><span>' . $this->lang_be['activate_2'] . '</span><span class="info">' . $this->lang_be['activate_3'] . '<a href="http://white-master.ru/buy-license.html" target="_blank">' . $this->lang_be['activate_4'] . '</a>.</span><input type="text" class="edit" name="key" value="" size="40"></li></ul><button onclick="Activate(); return false;" type="submit" name="submit" class="be_button">' . $this->lang_be['activate_5'] . '</button></div>';
      }
   }
   public function complaint()
   {
      $option = array();
      $row = $this->db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_be_complaint");
      if(!$row['count']) {
         $option['return'] = $this->lang_be['complaint_6'];
      }
      $this->db->query("SELECT " . PREFIX . "_be_complaint.ct_id," . PREFIX . "_be_complaint.ct_msg_id," . PREFIX . "_be_complaint.ct_date," . PREFIX . "_be_complaint.ct_text," . PREFIX . "_be_complaint.ct_from," . PREFIX . "_be_message.id," . PREFIX . "_be_message.id_topic," . PREFIX . "_be_message.message_autor," . PREFIX . "_be_message.message_text," . PREFIX . "_be_topic.title FROM " . PREFIX . "_be_complaint LEFT JOIN " . PREFIX . "_be_message ON " . PREFIX . "_be_complaint.ct_msg_id=" . PREFIX . "_be_message.id LEFT JOIN " . PREFIX . "_be_topic ON " . PREFIX . "_be_message.id_topic=" . PREFIX . "_be_topic.id");
      while ($row = $this->db->get_row()) {
         $option['linckTopic'] .= "<a target=\"_blank\" href='" . $this->dle_config['http_home_url'] . "forum/showtopic-{$row['id_topic']}'>" . stripslashes($row['title']) . '</a>';
         $option['linck'] .= "<a target=\"_blank\" href='" . $this->dle_config['http_home_url'] . "forum/showtopic-{$row['id_topic']}/findpost-{$row['ct_msg_id']}'>" . $this->lang_be['setting_307'] . "</a>";
         $option['linck'] .= "<a style=\"padding-left:15px\" href=\"#\" onclick=\"deleteComplain('{$row['ct_id']}'); return false;\">" . $this->lang_be['setting_306'] . "</a>";
         $option['linck'] .= "<a style=\"padding-left:15px\" href=\"#\" onclick=\"deletePost('{$row['ct_msg_id']}'); return false;\">" . $this->lang_be['setting_305'] . "</a>";
         $option['return'] .= "<li><span>" . $this->lang_be['complaint_1'] . $option['linckTopic'] . "</span><div class=\"fw\">" . $this->lang_be['complaint_2'] . "</div><div class=\"fw\"><div class=\"blockq\">" . stripcslashes($row['message_text']) . "</div></div><div class=\"fw\">" . $this->lang_be['complaint_4'] . "</div><div class=\"fw\"><div class=\"blockq\">" . stripcslashes($row['ct_text']) . "</div></div><div class=\"fw\">" . $option['linck'] . "</div></li>";
      }
      return '<div id="complaint" class="content"><h1>' . $this->lang_be['complaint'] . '</h1><ul>' . $option['return'] . '</ul></div>';
   }
   public function cashe_param()
   {
      $row = $this->db->super_query("SELECT COUNT(*) AS count FROM " . PREFIX . "_be_topic");
      $rows = $this->db->super_query("SELECT COUNT(*) AS count FROM " . PREFIX . "_users");
      $ret = <<< HTML
 <div id="cash" class="content">
    <h1>{$this->lang_be['setting_72']}</h1>
    <ul>
      <li><span>{$this->lang_be['setting_74']}:</span><span class="info">{$this->lang_be['setting_75']}</span>
         <button onclick="Recount('tree','#recount_buttonn_tree'); return false;" id="recount_buttonn_tree" class="fr be_button" name="submit" type="submit">{$this->lang_be['recount']}</button>
      </li>
    <li><span>{$this->lang_be['setting_213']}:</span><span class="info">{$this->lang_be['setting_214']}</span> <span id="paramTopicCount" style="display:none;margin-top:5px;position: relative;"><b style="font-weight:normal;color:black;left:10px;position:absolute;font-size: 10px;top:4px;" id="progress"></b>
  <div id="progressbar"></div>
  </span>
  <button id="recount_buttonn_topic" class="fr be_button" name="submit" type="submit">{$this->lang_be['refresh']}</button>
   </li>
<li><span>{$this->lang_be['setting_215']}:</span><span class="info">{$this->lang_be['setting_214']}</span>
         <button onclick="Recount('tree_last','#recount_buttonn_tree_last'); return false;" id="recount_buttonn_tree_last" class="fr be_button" name="submit" type="submit">{$this->lang_be['refresh']}</button>
      </li>
      
      
      <li><span>{$this->lang_be['setting_287']}:</span><span class="info">{$this->lang_be['setting_214']}</span> <span id="paramUserCount" style="display:none;margin-top:5px;position: relative;"><b style="font-weight:normal;color:black;left:10px;position:absolute;font-size: 10px;top:4px;" id="progress1"></b>
  <div id="progressbar1"></div>
  </span>
  <button onclick="RecountUser(); return false;" id="recount_buttonn_user" class="fr be_button" name="submit" type="submit">{$this->lang_be['refresh']}</button>
   </li>
   
   
    </ul>
  </div>
  <script language="javascript" type="text/javascript">
  var total = {$row['count']};
  var total_user = {$rows['count']};
$(document).ready(function () {
      $("#progress").ajaxError(function(event, request, settings) {
          $(this).html('<font color="red">{$this->lang_be['setting_304']}<br><br>' + request.responseText + '</font>');
          $('#recount_buttonn_topic').attr("disabled", false);
      });
      $("#progressbar").progressbar({
          value: 0
      });
      $('#recount_buttonn_topic').click(function() {
          
              $('#progress').html('{$this->lang_be['setting_302']}');
              $('#recount_buttonn_topic').attr("disabled", "disabled");
              $('#recount_buttonn_topic').html("{$this->lang_be['setting_303']}");
              sendenTopic($('#count').val());
              return false;
           
      });
      
  });
</script>
<input type="hidden" value="0" name="count" id="count">
<input type="hidden" value="0" name="count_user" id="count_user">
HTML;
      return $ret;
   }
   private function makeDropDown($options, $name, $selected)
   {
      $output = "<select name=\"$name\">\r\n";
      foreach ($options as $value => $description) {
         $output .= "<option value=\"$value\"";
         if($selected == $value) {
            $output .= " selected ";
         }
         $output .= ">$description</option>\n";
      }
      $output .= "</select>";
      return $output;
   }
   public function ul_get_config()
   {
      $ret = <<< HTML
    
            <ul class="sub_menu">
              <li><a class="all_configure" href="javascript:ChangeBlock('general');">{$this->lang_be['admin_configure_all']}</a></li>
              <li><a class="upload" href="javascript:ChangeBlock('upload');">{$this->lang_be['admin_configure_upload']}</a></li>
              <li><a class="thread" href="javascript:ChangeBlock('topic');">{$this->lang_be['admin_configure_thred']}</a></li>
              <li><a class="msg" href="javascript:ChangeBlock('message');">{$this->lang_be['admin_configure_message']}</a></li>
             <li><a class="security" href="javascript:ChangeBlock('security');">{$this->lang_be['security']}</a></li> 
             <li><a class="date" href="javascript:ChangeBlock('time_step');">{$this->lang_be['time_step']}</a></li>              
             <li><a class="video" href="javascript:ChangeBlock('video');">{$this->lang_be['setting_98']}</a></li>     
             <li><a class="images" href="javascript:ChangeBlock('images');">{$this->lang_be['setimg']}</a></li>
             <li><a class="widget" href="javascript:ChangeBlock('widget');">{$this->lang_be['setting_211']}</a></li>
             <li><a class="intergration" href="javascript:ChangeBlock('intergration');">{$this->lang_be['intergration']}</a></li> 
             <li><a class="rss" href="javascript:ChangeBlock('rss');">{$this->lang_be['rssTitl']}</a></li> 
              
            </ul>
       
<script language='JavaScript' type="text/javascript">
        function ChangeBlock(selectedOption) {
                document.getElementById('general').style.display = "none";
                document.getElementById('upload').style.display = "none";
                document.getElementById('topic').style.display = "none";
                document.getElementById('message').style.display = "none"; 
                document.getElementById('time_step').style.display = "none";
                document.getElementById('video').style.display = "none";  
                document.getElementById('images').style.display = "none";      
                document.getElementById('security').style.display = "none";   
                document.getElementById('intergration').style.display = "none";  
                document.getElementById('widget').style.display = "none";  
                document.getElementById('rss').style.display = "none";                
                document.getElementById(selectedOption).style.display = "";
       }
</script>
HTML;
      return $ret;
   }
   private function tree_selectDubl($categoryid = 0, $parentid = 0, $nocat = true, $sublevelmarker = '', $returnstring = '')
   {
      $tree = array();
      $this->db->query("SELECT * FROM " . PREFIX . "_be_tree ORDER BY tree_id ASC");
      while ($row = $this->db->get_row()) {
         $tree[$row['tree_id']] = array();
         foreach ($row as $key => $value) {
            $tree[$row['tree_id']][$key] = stripslashes($value);
         }
      }
      $tree_info = $tree;
      $root_category = array();
      if($parentid == 0) {
         if($nocat)
            $returnstring .= '<option value="0"></option>';
      } else {
         $sublevelmarker .= '&nbsp;&nbsp;&nbsp;';
      }
      if(count($tree_info)) {
         foreach ($tree_info as $cats) {
            if($cats['tree_parent_id'] == $parentid)
               $root_category[] = $cats['tree_id'];
         }
         if(count($root_category)) {
            foreach ($root_category as $id) {
               $mark = ' ';
               if($tree_info[$id]['tree_type'] == 0) {
                  $mark = ' disabled ';
               }
               $returnstring .= "<option {$mark} value=\"" . $id . '" ';
               if(is_array($categoryid)) {
                  foreach ($categoryid as $element) {
                     if($element == $id) {
                        $returnstring .= 'SELECTED';
                     }
                  }
               } elseif($categoryid == $id)
                  $returnstring .= 'SELECTED';
               $returnstring .= '>' . $sublevelmarker . $tree_info[$id]['tree_title'] . '</option>';
               $returnstring = $this->tree_selectDubl($categoryid, $id, $nocat, $sublevelmarker, $returnstring);
            }
         }
      }
      return $returnstring;
   }
   private function tree_selectDubl2($categoryid = 0, $parentid = 0, $nocat = true, $sublevelmarker = '', $returnstring = '')
   {
      $tree = array();
      $this->db->query("SELECT * FROM " . PREFIX . "_be_tree where tree_type !=2 ORDER BY tree_id ASC ");
      while ($row = $this->db->get_row()) {
         $tree[$row['tree_id']] = array();
         foreach ($row as $key => $value) {
            $tree[$row['tree_id']][$key] = stripslashes($value);
         }
      }
      $tree_info = $tree; // var_dump($tree_info);
      $root_category = array();
      if($parentid == 0) {
         if($nocat)
            $returnstring .= '<option value="0"></option>';
         $ri = 'disabled';
      } else {
         $sublevelmarker .= '&nbsp;&nbsp;&nbsp;';
         $ri = '';
      }
      if(count($tree_info)) {
         foreach ($tree_info as $cats) {
            if($cats['tree_parent_id'] == $parentid)
               $root_category[] = $cats['tree_id'];
         }
         if(count($root_category)) {
            foreach ($root_category as $id) {
               //var_dump($root_category);
               $returnstring .= "<option {$ri} value=\"" . $id . '" ';
               if(is_array($categoryid)) {
                  foreach ($categoryid as $element) {
                     if($element == $id)
                        $returnstring .= 'SELECTED';
                  }
               } elseif($categoryid == $id)
                  $returnstring .= 'SELECTED';
               $returnstring .= '>' . $sublevelmarker . $tree_info[$id]['tree_title'] . '</option>';
               $returnstring = $this->tree_selectDubl2($categoryid, $id, $nocat, $sublevelmarker, $returnstring);
            }
         }
      }
      return $returnstring;
   }
   public function ul_get_user()
   {
      $ret = <<< HTML
<ul class="sub_menu">
    <li><a class="users_groups" href="{$this->php_self}?mod=bullet_energy&be_action=user&sub_action=access">{$this->lang_be['admin_user_access']}</a></li>
    <li><a class="moderator" href="{$this->php_self}?mod=bullet_energy&be_action=user&sub_action=moderator">{$this->lang_be['setting_301']}</a></li>   
  </ul>
HTML;
      return $ret;
   }
   public function ul_get_servise()
   {
      /*

      <a class="bb" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=bbcode">{$this->lang_be['admin_configure_construct']}</a></li>  <li><a class="rules" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=rules">{$this->lang_be['rules']}</a></li>
      */
      $ret = <<< HTML
    <ul class="sub_menu">
    <li><a class="cash" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=cash">{$this->lang_be['admin_cash_refresh']}</a></li>
    <li><a class="tree" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=category">{$this->lang_be['admin_drevo']}</a></li>   
    <li><a class="complaint" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=complaint">{$this->lang_be['complaint']}</a></li>
    <li><a class="answer" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=captcha">{$this->lang_be['admin_cash_captcha']}</a></li>
    <li><a class="advertising" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=advertising">{$this->lang_be['setting_183']}</a></li>
    <li><a class="trophies" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=trophies">{$this->lang_be['setting_227']}</a></li>
    <li><a class="rank" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=rank">{$this->lang_be['setting_267']}</a></li>
    <li><a class="template" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=template">{$this->lang_be['setting_300']}</a></li>
    <li><a class="cpu" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=router">{$this->lang_be['setting_364']}</a></li>
    <li><a class="share" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=share">{$this->lang_be['setting_421']}</a></li>
 
     </ul>
HTML;
      return $ret;
   }
   /**
    * bullet_energy_admin::del_vars_cashe()
    * Метод удаления системного кеша.
    * @param mixed $file - имя файла.
    * @return void
    */
   private function del_vars_cashe($file)
   {
      @unlink(ENGINE_DIR . '/bullet_energy/cache/system/' . $file . '.tmp');
   }
   /**
    * bullet_energy_admin::get_vars_cashe()
    * Метод получения системного кеша.
    * @param mixed $file - имя файла.
    * @return
    */
   private function get_vars_cashe($file)
   {
      return unserialize(@file_get_contents(ENGINE_DIR . '/bullet_energy/cache/system/' . $file . '.tmp'));
   }
   public function casheRefresh()
   {
      if(file_exists($this->casheSySPath . 'groups_config.tmp')) {
         @unlink($this->casheSySPath . 'groups_config.tmp');
      }
      if(file_exists($this->casheSySPath . 'question.tmp')) {
         @unlink($this->casheSySPath . 'question.tmp');
      }
      if(file_exists($this->casheSySPath . 'moderator.tmp')) {
         @unlink($this->casheSySPath . 'moderator.tmp');
      }
      if(file_exists($this->casheSySPath . 'tree_permanent.tmp')) {
         @unlink($this->casheSySPath . 'tree_permanent.tmp');
      }
      if(file_exists($this->casheSySPath . 'advertising.tmp')) {
         @unlink($this->casheSySPath . 'advertising.tmp');
      }
      if(file_exists($this->casheSySPath . 'honor.tmp')) {
         @unlink($this->casheSySPath . 'honor.tmp');
      }
      if(file_exists($this->casheSySPath . 'title.tmp')) {
         @unlink($this->casheSySPath . 'title.tmp');
      }
      $this->db->query("SELECT be_groups_id FROM " . PREFIX . "_be_groups ORDER BY be_groups_id ASC");
      while ($row = $this->db->get_row()) {
         @unlink($this->casheSySPath . 'sys_cashe_group_' . $row['be_groups_id'] . '.tmp');
      }
   }
   private function set_vars_cashe($file, $data)
   {
      $fp = fopen(ENGINE_DIR . '/bullet_energy/cache/system/' . $file . '.tmp', 'wb+');
      fwrite($fp, serialize($data));
      fclose($fp);
      @chmod(ENGINE_DIR . '/bullet_energy/cache/system/' . $file . '.tmp', 0666);
   }
   private function data_strip($data)
   {
      $data = strip_tags($data);
      $data = str_replace("$", "&#036;", $data);
      $data = str_replace("{", "&#123;", $data);
      $data = str_replace("}", "&#125;", $data);
      if(trim($data)) {
         return $data;
      } else {
         return false;
      }
   }
   public function get($name, $default, $type = 'mixed')
   {
      if(self::defined($name)) {
         $mixRes = $_REQUEST[$name];
      } else {
         if(null === $default) {
            return false;
         }
         $mixRes = $default;
      }
      if($type != 'mixed') {
         if($type == 'float') {
            $mixRes = str_replace(",", ".", $mixRes);
         }
         settype($mixRes, $type);
      }
      return $mixRes;
   }
   public function getInt($name, $default = 0)
   {
      return self::get($name, $default, 'int');
   }
   public function defined($name)
   {
      if(isset($_REQUEST[$name])) {
         return true;
      }
      return false;
   }
   private function deleteMQR($mixValue)
   {
      if(get_magic_quotes_gpc()) {
         if(is_array($mixValue)) {
            foreach ($mixValue as $k => $v) {
               $mixValue[$k] = self::deleteMQR($v);
            }
         } else {
            return stripslashes($mixValue);
         }
      }
      return $mixValue;
   }
   public function getString($name, $default = "")
   {
      return self::deleteMQR(self::get($name, $default, 'string'));
   }
}

?>