<?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 $modul_config = 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';
    $this->modul_config = $bullet_energy_config;
    $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 trophies()
  {
    $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() . '</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></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']));
    $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) 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}')");
    $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";
    $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['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>
       
      </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) {
      $value = $this->db->safesql(trim(strtr(strip_tags($value), $this->_cleanString)));
      $sql[] = $key . " = " . "'" . $value . "'";
    }
    $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']));
    $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) {
    }
    if (intval($row['tree_type']) == 2) {
      $option['categoryLinck'] = ' style="display:none" ';
    }
    $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><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 ' . $option['category'] . $option['categoryLinck'] . '><span>Текст информационного сообщения:</span><br><textarea name="update_tree[tree_info_text]" style="width:969px;height:150px;" class="edit">' . 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&be_action=user&sub_action=access">"' . $this->lang_be['admin_add_tree_18'] . '"</a></span></li></ul><input type="hidden" value="update_tree" name="sub_action"><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)));
  }
  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);
    if ($option['name'] and $option['type'] != 10) {
      foreach ($_POST['save_tree'] 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']}', '{$option['rules']}', '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>{$group_name[group_name]}</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('ERROE');
  }
  private function get_table_access()
  {
    if (count($this->group_user)) {
      foreach ($this->group_user as $group) {
        $param .= '<tr class="list">
      <td>' . $group['group_name'] . '</td>
      
      <td class="param_input"><input type="checkbox" value="' . $group['id'] . '" class="access_new_topic" name="access_new_topic[' . $group['id'] . ']"></td>
      <td class="param_input"><input type="checkbox" value="' . $group['id'] . '" class="access_replic_topic" name="access_replic_topic[' . $group['id'] . ']"></td>
      <td class="param_input"><input type="checkbox" value="' . $group['id'] . '" class="access_read_topic" name="access_read_topic[' . $group['id'] . ']"></td>
      <td class="param_input"><input type="checkbox" value="' . $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 = 'Модераторов нет.<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'] = 'Супер-модератор';
          $row['moderator_tree_id'] = 'Все';
        } else {
          $row['moderator_super'] = 'Модератор раздела';
          $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=\"Удалить\" onclick=\"doDelete('moderator','" . $row['id'] . "'); return false;\" class=\"deleteElementA\"><b>Удалить</b></a></td></tr>";
      }
      $table = '<table cellspacing="0" cellpadding="0" border="0" class="table_tree" id="table"><thead><tr><th><div>Имя</div></th><th style="width:150px"><div>Ранг</div></th><th class="w300"><div>Раздел</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">Вернуться назад</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">Вернуться назад</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">Вернуться назад</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">Вернуться назад</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 onclick="moderatorSelect('super')" value="1">Супер-модератор</option><option onclick="moderatorSelect('tree')"selected="" value="0">Модератор раздела</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" onclick="CatSelection('cat')">{$this->lang_be['admin_add_tree_type_0']}</option>
          <option value="1" onclick="CatSelection('sub_cat')">{$this->lang_be['admin_add_tree_type_1']}</option>
          <option value="2" onclick="CatSelection('linck_cat')">{$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>Пароль:</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>Счётчик сообщений и тем:</span><span class="info">Если 'Да' то пользователю будут засчитываться темы и сообщения (Настройка пригодится в разделе 'Курилка')</span>
         <select name="save_tree[counts]">
          <option value="1">Да</option>
          <option value="0">Нет</option>
        </select>
        </li>
        
        
        
        
        <li id="rules_titl" style="display:none"><span>Заголовок информационного сообщения:</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>Текст информационного сообщения:</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" => 'Да', "0" => 'Нет'), "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">Нет</option>
          <option selected="" value="1">Да</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>Название блока: </span> <span class="info">Например: реклама от google</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">Нет</option><option value="display" selected="">Да</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>Название блока: </span> <span class="info">Например: реклама от google</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">Нет</option><option value="display" selected="">Да</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>В темах</strong>: случайный образом между сообщениями';
        } elseif ($row['advertising_topic'] == 'none') {
          $row['viewParam'] = '<strong>В темах</strong>: не выводится';
        } elseif ($row['advertising_topic'] == 'top') {
          $row['viewParam'] = '<strong>В темах</strong>: наверху';
        } elseif ($row['advertising_topic'] == 'footer') {
          $row['viewParam'] = '<strong>В темах</strong>: внизу';
        }
        $row['viewGroup'] = explode('.', $row['advertising_group']);
        foreach ($row['viewGroup'] as $key => $val) {
          $row['viewGroupSet'][] = $group[$val]['group_name'];
        }
        $row['viewGroup'] = '<strong>Выводится группам</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('Везде') : $row['viewTreeSet'];
        $row['viewTree'] = '<strong>Выводится в узлах</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="Редактировать" 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="Удалить"><b>Удалить</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">Добавить блок рекламы</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>Название блока</div></th><th class="w300"><div>Где, кому и как выводится блок</div></th><th class="w25" style="text-align:center"><div>Статус</div></th><th class="w25 last"><div>&nbsp;</div></th></tr></thead><tbody>' . $ret . '  </tbody></table>';
    }
    return $ret;
  }
  public function advertisingAddDb()
  {
    $data = is_array($_POST['advertising']) ? $_POST['advertising'] : die('die');
    $data['name'] = strip_tags($data['name']);
    $option['advertising_name'] = trim($data['name']) ? "'" . substr($data['name'], 0, 255) . "'" : die('no name block');
    $option['advertising_group'] = count($data['group']) ? "'" . implode('.', $data['group']) . "'" : '0';
    $option['advertising_tree'] = count($data['tree']) ? "'" . implode('.', $data['tree']) . "'" : '0';
    $option['advertising_topic'] = "'" . $data['topic_view'] . "'";
    $option['advertising_display'] = "'" . $data['display'] . "'";
    $option['advertising_content'] = trim($data['content']) ? "'" . $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']) ? "'" . substr($data['name'], 0, 255) . "'" : die('no name block');
    $option['advertising_group'] = count($data['group']) ? "'" . implode('.', $data['group']) . "'" : '0';
    $option['advertising_tree'] = count($data['tree']) ? "'" . implode('.', $data['tree']) . "'" : '0';
    $option['advertising_topic'] = "'" . $data['topic_view'] . "'";
    $option['advertising_display'] = "'" . $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" => 'Нет', "display" => 'Да'), "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->_selectedItem(explode('.', $row['advertising_tree']), $this->_getTree(), 'tree');
    $ret = '<form method="post" name="advertising" action=""><div class="content"><h1>' . $this->lang_be['setting_184'] . '</h1><ul><li><span>Название блока: </span> <span class="info">Например: реклама от google</span><input type="text" class="edit" name="advertising[name]" value="' . stripcslashes(htmlspecialchars($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]">' . $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 get_list_tree()
  {
    $this->db->query("SELECT * FROM " . PREFIX . "_be_tree ORDER BY tree_parent_id DESC");
    while ($row = $this->db->get_row()) {
      $tree_info[] = $row;
    }
    //var_dump($tree_info);
    if (count($tree_info)) {
      foreach ($tree_info as $category) {
        if (intval($category['tree_parent_id']) > 0) {
          $type = intval($category['tree_type']);
          if ($type == 0) {
            $type = 'Категория';
          } elseif ($type == 1) {
            $type = 'Раздел (Подфорум)';
          } elseif ($type == 2) {
            $type = 'Раздел-ссылка';
          }
          $a[$category['tree_parent_id']] .= '<tr id="' . $category['tree_id'] . '" class="parents_child_tree"><td><input type="radio" name="tree" uid="sub_tree" value="' . $category['tree_id'] . '"></td><td class="tree_info"><a style="padding-left:' . $category['tree_parent_id'] / 2 . 'px" id="tree_' . $category['tree_id'] . '" rel="' . $category['tree_title'] . '" href="' . $this->php_self . '?mod=bullet_energy&amp;be_action=service&amp;sub_action=edit_category&amp;id_category=' . $category['tree_id'] . '" title="Редактировать">' . $category['tree_title'] . '</a><span class="tree_type">' . $type . '</span></td><td>' . $category['tree_description'] . '</td> <td>' . $category['tree_topic'] . '</td><td>' . $category['tree_answer'] . '</td></tr>' . $a[$category['tree_id']];
        }
        continue;
      }
      foreach ($tree_info as $category) {
        if (intval($category['tree_parent_id']) == 0) {
          $type = intval($category['tree_type']);
          if ($type == 0) {
            $type = 'Категория';
          } elseif ($type == 1) {
            $type = 'Раздел (Подфорум)';
          } elseif ($type == 2) {
            $type = 'Раздел-ссылка';
          }
          $ret .= '<tr id="' . $category['tree_id'] . '" class="list"><td><input type="radio" name="tree"  uid="main_tree"  value="' . $category['tree_id'] . '"></td><td class="tree_info"><a style="padding-left:' . $category['tree_parent_id'] / 2 . 'px" id="tree_' . $category['tree_id'] . '" rel="' . $category['tree_title'] . '" href="' . $this->php_self . '?mod=bullet_energy&amp;be_action=service&amp;sub_action=edit_category&amp;id_category=' . $category['tree_id'] . '" title="Редактировать">' . $category['tree_title'] . '</a><span class="tree_type">' . $type . '</span></td><td>' . $category['tree_description'] . '</td> <td>' . $category['tree_topic'] . '</td><td>' . $category['tree_answer'] . '</td></tr>' . $a[$category['tree_id']];
        }
      }
    }
    $sel = $this->tree_selectDubl();
    $rets .= <<< HTML
<form action="" id="add_tree" name="add_tree" method="post">
    <div id="tree" style="display:none"><select id="treeRemove" name="treeRemove">
        {$sel}</select></div>
 <div id="general" class="content">
    <h1>Дерево узлов</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">Добавить узел</a></span></div>
                </div> 
                <div class="fbutton" style="display:none">
                  <div><span class="del" onclick="TreeDell()">Удалить узел</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>Имя</div></th>
      <th class="w300"><div>Описание</div></th> 
      <th class="w50"><div>Тем</div></th>
      <th class="w90 last"><div>Сообщений</div></th>
    </tr>
  </thead>
  <tbody>
{$ret}
  </tbody>
</table></div></form>
HTML;
    $rets .= '<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></ul></div>';
    return $rets;
  }
  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';
      $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// Bullet Energy config\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()
  {
    if (intval($this->modul_config['captha_type']) == 0 or 1) {
      $sel_captha_type = $this->makeDropDown(array("1" => 'reСaptcha', "0" => 'Вопрос-Ответ'), "save_param[captha_type]", "{$this->modul_config['captha_type']}");
    } else {
      $sel_captha_type = '<select name="save_param[captha_type]">
          <option value="1">reСaptcha</option>
          <option value="0">Вопрос-Ответ</option>
        </select>';
    }
    if (intval($this->modul_config['forum_status']) == 0 or 1) {
      $sel_status = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[forum_status]", "{$this->modul_config['forum_status']}");
    } else {
      $sel_status = '<select name="save_param[forum_status]">
          <option value="1">Да</option>
          <option value="0">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['dowload_count']) == 0 or 1) {
      $sel_dowl = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[dowload_count]", "{$this->modul_config['dowload_count']}");
    } else {
      $sel_dowl = '<select name="save_param[dowload_count]">
          <option value="1">Да</option>
          <option value="0">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['reg_linck_5']) == 0 or 1) {
      $sel_reg = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[reg_linck_5]", "{$this->modul_config['reg_linck_5']}");
    } else {
      $sel_reg = '<select name="save_param[reg_linck_5]">
          <option value="1">Да</option>
          <option value="0">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['online_block']) == 0 or 1) {
      $sel_online = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[online_block]", "{$this->modul_config['online_block']}");
    } else {
      $sel_online = '<select name="save_param[online_block]">
          <option value="1">Да</option>
          <option value="0">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['cpu']) == 0 or 1) {
      $sel_cpu = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[cpu]", "{$this->modul_config['cpu']}");
    } else {
      $sel_cpu = '<select name="save_param[cpu]">
          <option value="1">Да</option>
          <option value="0">Нет</option>
        </select>';
    }
    /*if (intval($this->modul_config['toogle_block']) == 0 or 1) {
    $sel_cook = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[toogle_block]", "{$this->modul_config['toogle_block']}");
    } else {
    $sel_cook = '<select name="save_param[toogle_block]">
    <option value="1">Да</option>
    <option value="0">Нет</option>
    </select>';
    }
    <li><span>{$this->lang_be['setting_19']}:</span><span class="info">{$this->lang_be['setting_20']}</span>{$sel_cook}</li>
    */
    if (intval($this->modul_config['mass_upload']) == 0 or 1) {
      $sel_mass = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[mass_upload]", "{$this->modul_config['mass_upload']}");
    } else {
      $sel_mass = '<select name="save_param[mass_upload]">
          <option value="1">Да</option>
          <option value="0">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['topic_view']) == 0 or 1) {
      $topic_view = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[topic_view]", "{$this->modul_config['topic_view']}");
    } else {
      $topic_view = '<select name="save_param[topic_view]">
          <option value="1">Да</option>
          <option value="0">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['images_marck']) == 0 or 1) {
      $images_marck = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[images_marck]", "{$this->modul_config['images_marck']}");
    } else {
      $images_marck = '<select name="save_param[images_marck]">
          <option value="1">Да</option>
          <option value="0">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['wh_images']) == 0 or 1) {
      $image_gen = $this->makeDropDown(array("2" => 'По высоте', "1" => 'По ширине', "0" => 'По наибольшей стороне'), "save_param[wh_images]", "{$this->modul_config['wh_images']}");
    } else {
      $image_gen = '<select name="save_param[wh_images]">
<option selected="" value="0">По наибольшей стороне</option>
<option value="1">По ширине</option>
<option value="2">По высоте</option>
        </select>';
    }
    if (intval($this->modul_config['msg_combine']) == 0 or 1) {
      $sel_combine = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[msg_combine]", "{$this->modul_config['msg_combine']}");
    } else {
      $sel_combine = '<select name="save_param[msg_combine]">
<option selected="" value="0">Нет</option>
<option value="1">Да</option>
        </select>';
    }
    if (intval($this->modul_config['play']) == 0 or 1) {
      $sel_start_auto = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[play]", "{$this->modul_config['play']}");
    } else {
      $sel_start_auto = '<select name="save_param[play]">
<option selected="" value="0">Нет</option>
<option value="1">Да</option>
        </select>';
    }
    if (intval($this->modul_config['flv_watermark']) == 0 or 1) {
      $sel_water = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[flv_watermark]", "{$this->modul_config['flv_watermark']}");
    } else {
      $sel_water = '<select name="save_param[flv_watermark]">
<option selected="" value="0">Нет</option>
<option value="1">Да</option>
        </select>';
    }
    if (intval($this->modul_config['flv_watermark_pos']) == 0 or 1) {
      $sel_position = $this->makeDropDown(array("left" => 'По левому краю', "center" => 'По центру', "right" => 'По правому краю'), "save_param[flv_watermark_pos]", "{$this->modul_config['flv_watermark_pos']}");
    } else {
      $sel_position = '<select name="save_param[flv_watermark_pos]">
<option selected="" value="left">По левому краю</option>
<option value="center">По центру</option><option value="right">По правому краю</option>
        </select>';
    }
    if (intval($this->modul_config['tube_related']) == 0 or 1) {
      $sel_releted = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[tube_related]", "{$this->modul_config['tube_related']}");
    } else {
      $sel_releted = '<select name="save_param[tube_related]">
<option selected="" value="0">Нет</option>
<option value="1">Да</option>
        </select>';
    }
    if (intval($this->modul_config['tube_dle']) == 0 or 1) {
      $sel_dle_style = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[tube_dle]", "{$this->modul_config['tube_dle']}");
    } else {
      $sel_dle_style = '<select name="save_param[tube_dle]">
<option selected="" value="0">Нет</option>
<option value="1">Да</option>
        </select>';
    }
    if (intval($this->modul_config['youtube_q']) == 0 or 1) {
      $sel_yq = $this->makeDropDown(array("small" => 'Низкое', "medium" => 'Среднее', "large" => 'Высокое', "hd720" => 'HD 720p'), "save_param[youtube_q]", "{$this->modul_config['youtube_q']}");
    } else {
      $sel_yq = '<select name="save_param[youtube_q]">
<option selected="" value="small">Низкое</option>
<option value="medium">Среднее</option>
<option value="large">Высокое</option>
<option value="hd720">HD 720p</option>
        </select>';
    }
    if (intval($this->modul_config['startframe']) == 0 or 1) {
      $sel_cadre = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[startframe]", "{$this->modul_config['startframe']}");
    } else {
      $sel_cadre = '<select name="save_param[startframe]">
<option selected="" value="0">Нет</option>
<option value="1">Да</option>
        </select>';
    }
    if (intval($this->modul_config['preview']) == 0 or 1) {
      $sel_cover = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[preview]", "{$this->modul_config['preview']}");
    } else {
      $sel_cover = '<select name="save_param[preview]">
<option selected="" value="0">Нет</option>
<option value="1">Да</option>
        </select>';
    }
    if (intval($this->modul_config['autohide']) == 0 or 1) {
      $sel_control = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[autohide]", "{$this->modul_config['autohide']}");
    } else {
      $sel_control = '<select name="save_param[autohide]">
<option selected="" value="0">Нет</option>
<option value="1">Да</option>
        </select>';
    }
    if (intval($this->modul_config['images_prev_insert']) == 0 or 1) {
      $image_pv = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[images_prev_insert]", "{$this->modul_config['images_prev_insert']}");
    } else {
      $image_pv = '<select name="save_param[images_prev_insert]">
<option selected="" value="0">Нет</option>
<option value="1">Да</option>
        </select>';
    }
    if (intval($this->modul_config['reputations']) == 0 or 1) {
      $sel_repa = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[reputations]", "{$this->modul_config['reputations']}");
    } else {
      $sel_repa = '<select name="save_param[reputations]">
<option  selected="" value="0">Нет</option>
<option  value="1">Да</option>
        </select>';
    }
    if (intval($this->modul_config['reputations_type']) == 0 or 1) {
      $sel_repa_type = $this->makeDropDown(array("2" => 'Подробный', "1" => 'Расширенный', "0" => 'Стандартный'), "save_param[reputations_type]", "{$this->modul_config['reputations_type']}");
    } else {
      $sel_repa_type = '<select name="save_param[reputations_type]">
<option selected="" value="0">Стандартный</option>
<option value="1">Расширенный</option>
<option value="2">Подробный</option>
        </select>';
    }
    if (intval($this->modul_config['view_post_search']) == 0 or 1) {
      $sel_view_post = $this->makeDropDown(array("1" => 'Сообщение на странице темы', "0" => 'Искомое сообщение'), "save_param[view_post_search]", "{$this->modul_config['view_post_search']}");
    } else {
      $sel_view_post = '<select name="save_param[view_post_search]">
<option  selected="" value="0">Искомое сообщение</option>
<option  value="1">Сообщение на странице темы</option>
        </select>';
    }
    if (intval($this->modul_config['url_click']) == 0 or 1) {
      $sel_url_refresch = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[url_click]", "{$this->modul_config['url_click']}");
    } else {
      $sel_url_refresch = '<select name="save_param[url_click]">
<option  selected="" value="0">Да</option>
<option  value="1">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['title_case']) == 0 or 1) {
      $topic_auto_ren = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[title_case]", "{$this->modul_config['title_case']}");
    } else {
      $topic_auto_ren = '<select name="save_param[title_case]">
<option  selected="" value="0">Да</option>
<option  value="1">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['adv']) == 0 or 1) {
      $sel_adviser = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[adv]", "{$this->modul_config['adv']}");
    } else {
      $sel_adviser = '<select name="save_param[adv]">
<option  selected="" value="0">Да</option>
<option  value="1">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['widget_last_post']) == 0 or 1) {
      $sel_post_last = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[widget_last_post]", "{$this->modul_config['widget_last_post']}");
    } else {
      $sel_post_last = '<select name="save_param[widget_last_post]">
<option  selected="" value="0">Да</option>
<option  value="1">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['session']) == 0 or 1) {
      $sel_session = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[session_check]", "{$this->modul_config['session_check']}");
    } else {
      $sel_session = '<select name="save_param[session_check]">
<option  selected="" value="0">Да</option>
<option  value="1">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['online']) == 0 or 1) {
      $sel_onlines = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[online]", "{$this->modul_config['online']}");
    } else {
      $sel_onlines = '<select name="save_param[online]">
<option  selected="" value="0">Да</option>
<option  value="1">Нет</option>
        </select>';
    }
    if (intval($this->modul_config['is_like']) == 0 or 1) {
      $sel_thanks = $this->makeDropDown(array("1" => 'Да', "0" => 'Нет'), "save_param[is_like]", "{$this->modul_config['is_like']}");
    } else {
      $sel_thanks = '<select name="save_param[is_like]">
<option  selected="" value="0">Да</option>
<option  value="1">Нет</option>
        </select>';
    }
    $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_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_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">{$this->lang_be['setting_202']}</span>
      <span id="colorSelectorLi1">Подобрать цвет</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">{$this->lang_be['setting_202']}</span>
      <span id="colorSelectorLi">Подобрать цвет</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 style="display:none"><span>{$this->lang_be['setting_41']}:</span><span class="info">{$this->lang_be['setting_42']}</span>
        <input type="text" size="40" value="{$this->modul_config['preview_count']}" name="save_param[preview_count]"  class="edit">
      </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_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>
     
    </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_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>         
  </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>    
  </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>Включить поддержку модуля Репутация 6.5:</span><span class="info">Если у вас установлен модуль репутация пользователей 6.5 то вы можете активировать эту настройку и форум будет обрабатывать тег {reputation} в шаблоне short_message.tpl</span>{$sel_repa}</li>
      
      <li id="repa_type"><span>Выбирите тип вывода репутации:</span><span class="info">Данная опция позволит изменить вид вывода репутации у пользователей.<br>Стандартный - вывод репутации вида: - 10 +<br>Расширенный - вывод репутации вида: - (<font color="green">13</font>|<font color="red">3</font>) +<br>Подробный - вывод репутации вида: - (<font color="green">13</font>|<b>10</b>|<font color="red">3</font>) +</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>  
      
      
      
 </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 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']}'>Перейти к сообщению</a>";
      $option['linck'] .= "<a style=\"padding-left:15px\" href=\"#\" onclick=\"deleteComplain('{$row['ct_id']}'); return false;\">Удалить жалобу</a>";
      $option['linck'] .= "<a style=\"padding-left:15px\" href=\"#\" onclick=\"deletePost('{$row['ct_msg_id']}'); return false;\">Удалить сообщение</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");
    $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>
    </ul>
  </div>
  <script language="javascript" type="text/javascript">
  var total = {$row['count']};
  $(function() {
      $("#progress").ajaxError(function(event, request, settings) {
          $(this).html('<font color="red">Ошибка отправки</font>');
          $('#recount_buttonn_topic').attr("disabled", false);
      });
      $("#progressbar").progressbar({
          value: 0
      });
      $('#recount_buttonn_topic').click(function() {
          if($('#topic_count').text()== 0 ){
          $('#progress').html('Идет обработка, ждите...');
          $('#recount_buttonn_topic').attr("disabled", "disabled");
          $('#recount_buttonn_topic').html("Идет обработка данных");
          sendenTopic($('#count').val());
          return false;}
      });

  });
  
</script>
<input type="hidden" value="0" name="count" id="count">
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> 
              
            </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(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) {
          //var_dump($root_category);
          $returnstring .= "<option disabled 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;
  }
  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">Список модераторов</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>
    
    <li><a class="trophies" href="{$this->php_self}?mod=bullet_energy&be_action=service&sub_action=trophies">{$this->lang_be['setting_227']}</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>
     </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');
    }
    $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'));
  }
}

?>