Ejemplo n.º 1
0
 /**
  * Отображение списка обратной связи
  * @param string $sort сортировка
  * @param string $type тип
  * @return null
  */
 protected function show($sort = null, $type = '')
 {
     $orderby = '';
     if ($sort) {
         $sort = explode(",", $sort);
         $c = count($sort);
         for ($i = 0; $i < $c; $i += 2) {
             if (!$this->orderby[$sort[$i]]) {
                 continue;
             }
             $orderby .= ($orderby ? ', ' : '') . "`" . $this->orderby[$sort[$i]] . "` " . ($sort[$i + 1] ? "asc" : "desc");
         }
     }
     if (!$orderby) {
         $orderby = 'f.`time` DESC';
     }
     $where = $type ? 'f.type=?' : "";
     $count = db::o()->p($type)->as_table('f')->count_rows("feedback", $where);
     list($pages, $limit) = display::o()->pages($count, config::o()->v('table_perpage'), 'switch_feedback_page', 'page', 5, true);
     $r = db::o()->p($type)->query('SELECT f.*, u.username, u.group
         FROM feedback AS f LEFT JOIN users AS u ON u.id=f.uid
         ' . ($where ? ' WHERE ' . $where : "") . '
         ' . ($orderby ? ' ORDER BY ' . $orderby : "") . '
         ' . ($limit ? ' LIMIT ' . $limit : ""));
     tpl::o()->assign('res', db::o()->fetch2array($r));
     tpl::o()->assign('pages', $pages);
     tpl::o()->assign('type', $type);
     tpl::o()->display('admin/feedback/index.tpl');
 }
Ejemplo n.º 2
0
 /**
  * Вывод списка online-пользователей
  * @return null
  */
 public function show_online()
 {
     $i = (int) config::o()->v('online_interval');
     if (!$i) {
         $i = 15;
     }
     $time = time() - $i;
     $res = db::o()->p($time)->query('SELECT userdata FROM sessions
             WHERE time > ? GROUP BY IF(uid>0,uid,ip)');
     $res = db::o()->fetch2array($res);
     tpl::o()->assign("res", $res);
     $c = count($res);
     $mo = stats::o()->read("max_online");
     if (!intval($mo) || $mo < $c) {
         $mo = $c;
         stats::o()->write("max_online", $c);
         stats::o()->write("max_online_time", time());
     }
     $mot = stats::o()->read("max_online_time");
     tpl::o()->assign("record_total", $mo);
     tpl::o()->assign("record_time", $mot);
     /* @var $user user */
     $user = plugins::o()->get_module("user");
     lang::o()->get("profile");
     tpl::o()->register_modifier("gau", array($user, "get_age"));
     tpl::o()->assign("bdl", $this->bd_list());
     tpl::o()->display("blocks/contents/online.tpl");
 }
Ejemplo n.º 3
0
 /**
  * Отображение списка логов
  * @param string $type тип логов
  * @param string $sort сортировка
  * @return null
  */
 protected function show($type = null, $sort = null)
 {
     tpl::o()->assign('curtype', $type);
     $orderby = '';
     if ($sort) {
         $sort = explode(",", $sort);
         $c = count($sort);
         for ($i = 0; $i < $c; $i += 2) {
             if (!$this->orderby[$sort[$i]]) {
                 continue;
             }
             $orderby .= ($orderby ? ', ' : '') . "`" . $this->orderby[$sort[$i]] . "` " . ($sort[$i + 1] ? "asc" : "desc");
         }
     }
     if (!$orderby) {
         $orderby = 'l.`time` DESC';
     }
     $count = db::o()->p($type)->count_rows("logs", $type ? 'type=?' : "");
     list($pages, $limit) = display::o()->pages($count, config::o()->v('table_perpage'), 'switch_logs_page', 'page', 5, true);
     $r = db::o()->p($type)->query('SELECT l.*, u.username, u.group, u2.username AS tusername, u2.group AS tgroup
         FROM logs AS l LEFT JOIN users AS u ON u.id=l.byuid LEFT JOIN users AS u2 ON u2.id=l.touid
         ' . ($type ? ' WHERE l.type=?' : "") . '
         ' . ($orderby ? ' ORDER BY ' . $orderby : "") . '
         ' . ($limit ? ' LIMIT ' . $limit : ""));
     tpl::o()->assign('res', db::o()->fetch2array($r));
     tpl::o()->assign('log_types', $this->types);
     tpl::o()->assign('pages', $pages);
     tpl::o()->display('admin/logs/index.tpl');
 }
Ejemplo n.º 4
0
 /**
  * Инициализация нижнего блока
  * @return null
  */
 public function init()
 {
     if (!config::o()->mstate('downm')) {
         return;
     }
     lang::o()->get("blocks/downm");
     print "Down block inited";
 }
Ejemplo n.º 5
0
 /**
  * Инициализация чата
  * @return null
  */
 public function init()
 {
     if (!users::o()->perm('chat')) {
         return;
     }
     if (!config::o()->mstate('chat')) {
         return;
     }
     lang::o()->get("blocks/chat");
     tpl::o()->display('chat/index.tpl');
 }
Ejemplo n.º 6
0
 /**
  * Инициализация блока новостей
  * @return null
  */
 public function init()
 {
     if (!config::o()->mstate('news')) {
         return;
     }
     lang::o()->get('news');
     $l = (int) config::o()->v('news_max');
     $a = db::o()->cname('news')->query('SELECT n.*, u.username, u.group FROM news AS n
         LEFT JOIN users AS u ON u.id=n.poster_id
         ORDER BY n.posted_time DESC' . ($l ? ' LIMIT ' . $l : ""));
     tpl::o()->assign('rows', $a);
     tpl::o()->display('news/index.tpl');
 }
Ejemplo n.º 7
0
 /**
  * Функция проверки кода recaptcha
  * @param array $error массив ошибок
  * @param string $var $_POST переменная для проверки введённого кода
  * @return null
  */
 public function check(&$error, $var = "recaptcha_challenge_field")
 {
     $posted_code = $_POST[$var];
     if (!$posted_code) {
         $error[] = lang::o()->v('captcha_false_captcha');
         return;
     }
     $r = recaptcha_check_answer(config::o()->v('recaptcha_private_key'), $_SERVER["REMOTE_ADDR"], $posted_code, $_POST["recaptcha_response_field"]);
     if (!$r || !is_object($r) || !$r->is_valid) {
         $error[] = lang::o()->v('captcha_false_captcha');
         return;
     }
     return true;
 }
Ejemplo n.º 8
0
 /**
  * Инициализация блока-торрентов
  * @return null
  */
 public function init()
 {
     if (!config::o()->v('torrents_on')) {
         return;
     }
     lang::o()->get("blocks/content");
     if (!users::o()->perm('content')) {
         return;
     }
     $curcats = $this->settings['cats'];
     if (!$curcats) {
         return;
     }
     print "Torrents block inited";
     $this->get_children($curcats);
     tpl::o()->assign('curcats', array_reverse($curcats));
 }
Ejemplo n.º 9
0
 /**
  * Конструктор класса
  * @return null 
  */
 protected function plugin_construct()
 {
     $this->state = (bool) config::o()->mstate('rating_manage');
     $this->access_var('allowed_types', PVAR_ADD);
     $this->access_var('allowed_stypes', PVAR_ADD);
     $this->access_var('max', PVAR_ADD);
     $this->access_var('min', PVAR_ADD);
     $this->access_var('part', PVAR_ADD);
     /**
      * @note Отображение рейтинга(display_rating)
      * int toid ID ресурса
      * string type тип ресурса
      * int owner владелец ресурса
      * array res массив ресурса
      * int stoid доп. ID ресурса(для уникальности)
      * string stype доп. тип ресурса(для уникальности)
      */
     tpl::o()->register_function("display_rating", array($this, 'display'));
 }
Ejemplo n.º 10
0
globals::s('start', timer());
// Start time
require_once ROOT . 'include/smarty/Smarty.class.php';
require_once ROOT . 'include/functions_smarty.php';
@set_error_handler("myerror_report");
// Присваиваем функцию myerror_report, вместо стандартной, помогает избежать раскрытия путей.
db::o()->connect();
init_baseurl();
lang::o()->change_folder(config::o()->v('default_lang'));
init_spaths();
tpl::o()->register_modifier('lang', array(lang::o(), 'v'));
// языковая переменная
tpl::o()->register_modifier('getlang', array(lang::o(), 'get'));
// подключение языка прямо в шаблоне
tpl::o()->register_modifier('islang', array(lang::o(), 'visset'));
// языковая переменная
tpl::o()->register_modifier('config', array(config::o(), 'v'));
// конфиг. переменная
tpl::o()->register_modifier('mstate', array(config::o(), 'mstate'));
// разрешён ли модуль
tpl::o()->register_modifier('perm', array(users::o(), "perm"));
// проверка на права
tpl::o()->register_modifier('user', array(users::o(), "v"));
// поле юзера
/**
 * Не смей удалять копирайт ниже, а то дядя Ваня тебя покарает своим большим чёрным банхаммером.
 */
tpl::o()->assign("copyright", "Powered by <a href=\"http://ctrev.cyber-tm.ru/\" title=\"Go to the official site of CTRev\">CTRev v." . ENGINE_VERSION . ' ' . ENGINE_STAGE . "</a> &copy; <a href=\"http://cyber-tm.ru\" title=\"Go to the official site of Cyber-Team\">Cyber-Team</a> 2008-2012");
tpl::o()->assign("designed_by", "Дизайн сайта разработал <u>А. Воробей</u>. All Rights Reserved.");
//tpl::o()->assign_by_ref('config', $CONFIG);
require_once ROOT . 'include/init.php';
Ejemplo n.º 11
0
 /**
  * Очистка старых сообщений чата
  * @return null
  */
 protected function clear_chat()
 {
     if (!config::o()->v('chat_autoclear')) {
         return;
     }
     $hour = 3600;
     // Секунд в час
     $when = time() - config::o()->v('chat_autoclear') * $hour;
     db::o()->p($when)->delete('chat', 'WHERE posted_time <= ?');
 }
Ejemplo n.º 12
0
 /**
  * Инициализация AJAX части конвертации
  * @return null 
  */
 public function init()
 {
     lang::o()->get('install/convert');
     if ($_GET['check']) {
         if (INSTALL_PAGE == "database") {
             $this->check_settings();
         }
         ok();
     } else {
         tpl::o()->assign("config", config::o());
         switch (INSTALL_PAGE) {
             case "database":
                 $this->show_database();
                 break;
             case "convert":
                 $this->show_convert();
                 break;
             case "notice":
                 cache::o()->clear();
                 break;
         }
         tpl::o()->display("convert/" . INSTALL_PAGE);
     }
 }
Ejemplo n.º 13
0
 /**
  * Конструктор? А где конструктор? А нет его.
  * @return null 
  */
 private function __construct()
 {
     $this->state = (bool) config::o()->v('plugins_on');
     if (!$this->state) {
         return;
     }
     $this->manager = new plugins_manager($this, $this->current_plugin);
 }
Ejemplo n.º 14
0
 /**
  * Инициализация AJAX-части модуля
  * @return null
  */
 public function init()
 {
     $POST = globals::g('POST');
     lang::o()->get('admin/config');
     $cprefix = config_man::config_prefix;
     $cprefix_length = strlen($cprefix);
     $keys = array();
     $newcfg = array();
     $i = 0;
     $sort = array();
     foreach ($POST as $key => $value) {
         if (strpos($key, $cprefix) !== 0) {
             continue;
         }
         $key = substr($key, $cprefix_length);
         if (!config::o()->visset($key)) {
             continue;
         }
         $keys[] = $key;
         $newcfg[$key] = $value;
         $sort[$key] = ++$i;
     }
     if (!$keys) {
         return;
     }
     try {
         plugins::o()->pass_data(array("newcfg" => &$newcfg, "sort" => &$sort), true)->run_hook('admin_config_save');
     } catch (PReturn $e) {
         return $e->r();
     }
     $r = db::o()->p($keys)->query('SELECT name,type,allowed FROM config WHERE name IN(@' . count($keys) . '?)');
     $c = 0;
     while (list($name, $type, $allowed) = db::o()->fetch_row($r)) {
         if (!$this->check_type($type, $newcfg[$name], $allowed, $name)) {
             continue;
         }
         $c++;
         config::o()->set($name, $newcfg[$name], $sort[$name]);
     }
     db::o()->query('ALTER TABLE `config` ORDER BY `cat`, `sort`');
     log_add('changed_config', 'admin');
     print $c;
     die;
 }
Ejemplo n.º 15
0
/**
 * Вывод статистики по запросам
 * @return string HTML код
 */
function query_stat()
{
    if (!config::o()->v('show_process') || !users::o()->perm('acp', 2)) {
        return;
    }
    $r = "";
    foreach (db::o()->query_stat as $n => $stat) {
        $r .= "[" . ($n + 1) . "] => \n            <b><font color='" . ($stat['seconds'] > 0.01 ? "red" : "green") . "'>\n                " . $stat["seconds"] . "</font></b> [" . $stat["query"] . "]<br>";
    }
    return "<div class='query_stat'>" . $r . "</div>";
}
Ejemplo n.º 16
0
 /**
  * Создание превью для загружаемого изображения
  * @param bool|array $minimized массив данных для ресайза
  * @param array $file массив данных файла(дирректория,имя,тип,загруженное изображение)
  * @return null
  */
 protected function upload_minimize($minimized, $file)
 {
     list($to_folder, $name, $nt, $to) = $file;
     $preview = "";
     $this->preview =& $preview;
     if (!$minimized || !is_array($minimized)) {
         return;
     }
     list($maxwidth, $maxheight, $width, $height) = $minimized;
     if ($this->make_preview) {
         $preview_postfix = !is_null($this->preview_postfix) ? $this->preview_postfix : config::o()->v('preview_postfix');
         $preview = $name . $preview_postfix . $nt;
         // Всегда добавляем тип для превью
         $topr = ($this->preview_folder ? $this->preview_folder : $to_folder) . "/" . $preview;
         try {
             if ($this->preview_always && $width <= $maxwidth && $height <= $maxheight) {
                 @copy($to, $topr);
             } else {
                 $this->resize(array($to, $nt), $maxwidth, $maxheight, $width, $height, $topr, $this->preview_cut);
             }
         } catch (EngineException $e) {
             $preview = '';
         }
     } else {
         $this->resize(array($to, $nt), $maxwidth, $maxheight, $width, $height, null, $this->preview_cut);
     }
 }
Ejemplo n.º 17
0
 /**
  * Отображение комментариев пользователя/пользователей
  * @param int $id ID пользователя
  * @param string $where доп. условие
  * @return null
  */
 public function usertable($id = null, $where = null)
 {
     lang::o()->get('profile');
     if (!$this->state) {
         disabled(false);
         return false;
     }
     if (!users::o()->perm('comment')) {
         n("message")->stype("error")->info('comment_you_cannt_view');
         return;
     }
     $id = (int) $id;
     $select = "c.id,c.posted_time,c.type,c.toid";
     if (!$id) {
         $select .= ",c.poster_id";
     }
     $where = $id ? 'c.poster_id=' . $id : ($where ? $where : '');
     $comm_row = db::o()->no_parse()->query('SELECT ' . $select . (!$id ? ",u.username,u.group" : "") . '
         FROM ' . db::table('comments') . ' AS c
         ' . (!$id ? 'LEFT JOIN ' . db::table('users') . ' AS u ON c.poster_id=u.id' : '') . '
         ' . ($where ? " WHERE " . $where : "") . '
         ORDER BY c.posted_time DESC
         LIMIT ' . config::o()->v('last_profile_comments'));
     $cr = array();
     while ($rows = db::o()->fetch_assoc($comm_row)) {
         $res = db::o()->p($rows["toid"])->query('SELECT ' . $this->title_cols[$rows["type"]] . ' AS title
             FROM ' . $rows["type"] . ' WHERE id=? LIMIT 1');
         $res = db::o()->fetch_assoc($res);
         $rows["title"] = $res["title"];
         $cr[] = $rows;
     }
     tpl::o()->assign("comm_row", $cr);
     tpl::o()->display("profile/last_comments.tpl");
 }
Ejemplo n.º 18
0
 /**
  * Функция вывода списка стран
  * Параметры: current, null
  * @param string $name имя для списка стран
  * @return string HTML код выборки списка стран
  */
 public function select_countries($name = 'country')
 {
     if (!is_array($name)) {
         $this->join_params($name);
     }
     $country = $name['country'];
     $current = $name['current'];
     $null = $name['null'];
     $name = $name['name'];
     $name = $name ? $name : 'country';
     $select = "";
     $show_flag = "show_flag_image('" . addslashes(config::o()->v('countries_folder') . "/") . "',\n\t\t\t'#" . addslashes("country_" . $name) . "',\n\t\t\t'" . addslashes("flag_image_" . $name) . "');";
     $select .= "<script type=\"text/javascript\">\n\t\t\t\tjQuery(document).ready(function () {\n\t\t\t\t\t" . $show_flag . "\n\t\t\t\t});\n\t\t\t\t</script>";
     $res = $this->get_countries();
     $select .= "<select name=\"" . $name . "\" id=\"country_" . $name . "\" onchange=\"" . $show_flag . "\">";
     if ($null) {
         $select .= $this->get_null_text();
     }
     foreach ($res as $row) {
         $id = $row['id'];
         $cname = $row['name'];
         $image = $row['image'];
         if ($current == $id) {
             $this_i = $image;
         }
         $select .= "<option value=\"" . $id . "\"\n                rel=\"" . $image . "\"" . ($current == $id ? " selected=\"selected\"\n                    id=\"cselected_" . $name . "\"" : "") . ">" . $cname . "</option>";
     }
     $select .= "</select>";
     $select = "<span id=\"flag_image_" . $name . "\" style=\"display:none;\">\n            <img src=\"" . config::o()->v('countries_folder') . "/" . ($this_i ? $this_i : $image) . "\"\n                height=\"20\" alt=\"\" align=\"left\"></span>" . $select;
     return $select;
 }
Ejemplo n.º 19
0
 /**
  * Удаление скриншотов, постера и торрента
  * @param int $posted_time время создания
  * @param int $poster_id ID залившего
  * @param string $screenshots массив скриншотов
  * @return null
  */
 protected function delete_files($posted_time, $poster_id, $screenshots)
 {
     if (!$this->tstate) {
         return;
     }
     $f = default_filename($posted_time, $poster_id);
     @unlink(ROOT . config::o()->v('torrents_folder') . '/' . bittorrent::torrent_prefix . $f . ".torrent");
     $screenshots = unserialize($screenshots);
     if (!$screenshots) {
         return;
     }
     foreach ($screenshots as $screenshot) {
         if (is_array($screenshot)) {
             if ($screenshot[0]) {
                 @unlink(ROOT . config::o()->v('screenshots_folder') . '/' . $screenshot[0]);
             }
             if ($screenshot[1]) {
                 @unlink(ROOT . config::o()->v('screenshots_folder') . '/' . $screenshot[1]);
             }
         }
     }
 }
Ejemplo n.º 20
0
 /**
  * Вывод сообщений чата
  * @param int $time время последней проверки или ID сообщения
  * @param bool $prev показать пред. сообщения, до этого ID
  * @return null
  */
 public function show($time, $prev = false)
 {
     $time = (int) $time;
     users::o()->check_perms('chat', 2, 2);
     if ($time && !$prev) {
         $r = db::o()->p($time)->query('SELECT id FROM chat_deleted WHERE time>=?');
         $del = "";
         while (list($i) = db::o()->fetch_row($r)) {
             $del .= ($del ? "," : "") . $i;
         }
         tpl::o()->assign('deleted', $del);
     }
     $orderby = " ORDER BY c.posted_time DESC ";
     $limit = $orderby . (config::o()->v('chat_maxmess') ? " LIMIT " . config::o()->v('chat_maxmess') : "");
     if ($prev) {
         $where = ' WHERE c.id < ?' . $limit;
         tpl::o()->assign('prev', true);
     } else {
         $where = $time ? ' WHERE c.edited_time>=?' . $orderby : $limit;
     }
     $r = db::o()->p($time)->query('SELECT c.*, u.username, u.group FROM chat AS c
             LEFT JOIN users AS u ON u.id=c.poster_id ' . $where);
     tpl::o()->assign('rows', array_reverse(db::o()->fetch2array($r)));
     tpl::o()->register_modifier('chat_mf', array($this, 'chat_mf'));
     tpl::o()->display('chat/chat.tpl');
 }
Ejemplo n.º 21
0
 /**
  * Замена смайликов
  * @param string $input входящий текст
  * @return null
  */
 protected function smilies_replace(&$input)
 {
     if (!$this->smilies) {
         return;
     }
     foreach ($this->smilies as $smilies_pack) {
         if ($smilies_pack) {
             foreach ($smilies_pack as $smilie) {
                 $code = display::o()->html_encode($smilie['code']);
                 $image = $smilie['image'];
                 $name = $smilie['name'];
                 // preg_replace с модификатором i намного быстрее str_ireplace
                 $input = preg_replace('/(\\s|\\&nbsp\\;|^)' . mpc($code) . '(\\s|\\&nbsp\\;|$)/siu', " <img src=\"" . config::o()->v('smilies_folder') . "/" . $image . "\" \n                                alt=\"" . $name . "\" \n                                title=\"" . $name . "\"> ", $input);
             }
         }
     }
 }
Ejemplo n.º 22
0
 /**
  * Инициализация сессии пользователя
  * @return null
  */
 public function write_session()
 {
     if (!cache::o()->query_delay('usessions', config::o()->v('delay_userupdates'))) {
         return;
     }
     $ip = $this->get_ip();
     $url = $_SERVER['REQUEST_URI'];
     $ctime = time();
     $agent = $_SERVER["HTTP_USER_AGENT"];
     if (!$this->vars) {
         $uid = 0;
         $userdata = '';
     } else {
         $uid = $this->vars['id'];
         $userdata = array('username' => $this->vars['username'], 'group' => $this->vars['group'], 'hidden' => $this->vars['hidden'], 'useragent' => $agent, 'url' => $url);
         if ($this->vars['bot']) {
             $userdata['bot'] = true;
             $this->vars = array();
         }
         $userdata = serialize($userdata);
     }
     //$past = time() - 300;
     $sid = session_id();
     $updateset = array("sid" => $sid, "uid" => $uid, "userdata" => $userdata, "ip" => $ip, "time" => $ctime);
     $users_updateset = array("ip" => $ip, "last_visited" => time());
     try {
         plugins::o()->pass_data(array('update_sess' => &$updateset, 'update_user' => &$users_updateset), true)->run_hook('users_sessions');
     } catch (PReturn $e) {
         return $e->r();
     }
     if ($this->vars) {
         db::o()->p($uid)->update($users_updateset, "users", "WHERE id=? LIMIT 1");
     }
     db::o()->p($sid)->update($updateset, "sessions", "WHERE sid=? LIMIT 1");
     if (db::o()->affected_rows() < 1) {
         db::o()->insert($updateset, "sessions");
     }
 }
Ejemplo n.º 23
0
 /**
  * Анти-флуд проверка
  * @param string $table таблица
  * @param string $where условие
  * @param array $columns столбецы автора и времени постинга соотв.
  * @return null
  * @throws EngineException 
  */
 public function anti_flood($table, $where, $columns = array("poster_id", "posted_time"))
 {
     if (!is_array($columns) || !config::o()->v('antispam_time')) {
         return;
     }
     list($author, $time_var) = $columns;
     $time = time() - config::o()->v('antispam_time');
     $lang_var = 'anti_flood_subj';
     $uid = users::o()->v('id') ? users::o()->v('id') : -1;
     $c = db::o()->no_parse()->query('SELECT `' . $time_var . '` FROM `' . db::table($table) . '` WHERE ' . ($where ? $where . " AND " : "") . '`' . $author . "`=" . $uid . "\n                AND `" . $time_var . "` >= " . $time . '
             ORDER BY `' . $time_var . '` DESC LIMIT 1');
     $c = db::o()->fetch_assoc($c);
     if ($c) {
         $intrvl_time = display::o()->estimated_time(config::o()->v('antispam_time') + 1, time() - $c[$time_var]);
         throw new EngineException($lang_var, $intrvl_time);
     }
 }
Ejemplo n.º 24
0
 /**
  * Удаление плагина
  * @param bool $replaced было ли успешно ВСЁ замененённое сохранено?
  * @return bool статус удаления
  * @note метод может возвращать false или 0, в случае, если была какая-то
  * критическая ошибка при удалении
  */
 public function uninstall($replaced = false)
 {
     config::o()->remove('recaptcha_public_key');
     config::o()->remove('recaptcha_private_key');
     return $replaced;
 }
Ejemplo n.º 25
0
 /**
  * Функция создания Человекопонятного URL, исходя из заданных параметров, 
  * по предустановленным правилам
  * @param string $module имя модуля
  * @param array $params массив параметров, например:
  * array('id' => 1, 'name' => 'CTRev', 'cat' => 'demo')
  * ключ slashes экранирует результат для JavaScript, иначе & заменяется на &amp;
  * @param bool $page является ли указанный модуль ссылкой на документ?
  * @param bool $no_end нужно ли в конец добавлять .html/index.html?
  * @param bool $nobaseurl не добавлять в начало $baseurl
  * @return string ЧПУ
  */
 public function construct($module, $params = array(), $page = false, $no_end = false, $nobaseurl = false)
 {
     $baseurl = globals::g('baseurl');
     $burl = true;
     $assign = false;
     if (is_array($module)) {
         $module_t = $module['module'];
         if ($module['no_end']) {
             $no_end = $module['no_end'];
         }
         if ($module['assign']) {
             $assign = (string) $module['assign'];
         }
         if (!$module_t && $module['page']) {
             $module = $module['page'];
             $page = true;
         } elseif (!$module_t) {
             return;
         } else {
             unset($module['module']);
             $params = $module;
             $module = $module_t;
         }
     } elseif ($nobaseurl) {
         $burl = false;
     }
     if (!is_array($params)) {
         $params = array();
     }
     if ($params["_filetype"]) {
         $filetype = '.' . file::o()->get_filetype($params["_filetype"]);
     } else {
         $filetype = ".html";
     }
     $url = $burl ? $baseurl : "";
     if (config::o()->v('furl')) {
         $url .= $this->module_name($module) . ($page ? '' : "/");
         $function = $module . '_furl_rules';
     } else {
         $url .= 'index.php?module=' . ($this->rmodules[$module] ? $this->rmodules[$module] : $module);
         $function = $module . '_nfurl_rules';
     }
     $slashes = $params['slashes'];
     $noencode = $params['noencode'];
     $b = $this->is_callable($function);
     if ($b) {
         $params = $this->resort($module, $params);
     }
     $postfix = "";
     $surl = '';
     $ourl = $url;
     if ($params && !$page) {
         foreach ($params as $param => $value) {
             if ($this->postfixes[$module][$param]) {
                 $postfix .= $this->postfixes[$module][$param] . $value;
             }
             if ($b) {
                 $r = $this->call_method($function, array($param, $value, !$slashes && !$noencode));
             } elseif (!config::o()->v('furl')) {
                 $r = $param . "=" . $value;
             } else {
                 $r = $param . "-" . $value . "/";
             }
             if (!config::o()->v('furl') && $r) {
                 $surl .= '&' . $r;
                 $r = ($slashes || $noencode ? '&' : '&amp;') . $r;
             }
             $url .= $r;
         }
     }
     if (!$surl) {
         $surl = $url;
     } else {
         $surl = $ourl . $surl;
     }
     $add = '';
     if (config::o()->v('furl')) {
         if (!$no_end && !$page && (!$params || !$b || preg_match('/\\/$/siu', $url))) {
             $add .= "index";
         }
         if (!$no_end) {
             $add .= $filetype;
         }
     }
     $add .= $postfix;
     $url = $url . $add;
     $surl = $surl . $add;
     $this->forlocation = array($surl, $url);
     if ($slashes) {
         $url = slashes_smarty($url);
     }
     if ($assign) {
         tpl::o()->assign($assign, $url);
     } else {
         return $url;
     }
 }
Ejemplo n.º 26
0
 /**
  * Получение объекта класса
  * @param string|array $cat категория конфига
  * @return config $this
  */
 public static function o($cat = '')
 {
     if (!self::$o) {
         self::$o = new self($cat);
     }
     return self::$o;
 }
Ejemplo n.º 27
0
 /**
  * Присвоение языкового пакета по-умолчанию
  * @param string $name имя языка
  * @return null
  */
 public function bydefault($name)
 {
     if (config::o()->v('default_lang') == $name) {
         return;
     }
     config::o()->set('default_lang', $name);
     log_add('changed_config', 'admin');
 }
Ejemplo n.º 28
0
define('INSITE', true);
define('INANNOUNCE', true);
require_once 'system/php_config.php';
require_once ROOT . 'include/classes/class.db.php';
require_once ROOT . 'include/classes/class.file.php';
// для кеша
require_once ROOT . 'include/classes/class.cache.php';
// для кеша конфига
require_once ROOT . 'include/classes/class.config.php';
require_once ROOT . 'include/classes/class.fbenc.php';
require_once ROOT . 'include/functions.php';
@set_error_handler("myerror_report");
// Присваиваем функцию myerror_report, вместо стандартной, помогает избежать раскрытия путей.
/**
 * Вывод ошибки последнего запроса к БД
 * @param string $query строка запрос
 * @return null
 */
function db_errhandler($query = null)
{
    $bt = new fbenc();
    $bt->err(mysql_error());
}
db::o()->errhandler('db_errhandler');
$bt = new fbenc();
db::o()->connect();
db::o()->no_reset();
config::o(array('content', 'announce', 'other'));
if (!config::o()->v('torrents_on')) {
    die('Module turned off');
}
Ejemplo n.º 29
0
 /**
  * Проверка, является ли сайт offline на данный момент
  * @return null
  */
 public function siteoffline_check()
 {
     if (users::o()->perm('acp', 2)) {
         return;
     } elseif (!config::o()->v('site_online')) {
         lang::o()->get("site_offline");
         $offline_reason = config::o()->v('siteoffline_reason');
         tpl::o()->assign("reason", $offline_reason);
         tpl::o()->display("site_offline.tpl");
         die;
     }
 }
Ejemplo n.º 30
0
 /**
  * Отображение последнего контента пользователя
  * @param int $id ID пользователя
  * @param string $where доп. условие
  * @return null
  */
 public function show_last_content($id = null, $where = null)
 {
     $id = (int) $id;
     $select = "t.id,t.category_id,t.posted_time,t.title";
     if (!$id) {
         $select .= ",t.poster_id";
     }
     $where = $id ? 'poster_id=' . $id : $where;
     $tr = db::o()->no_parse()->query('SELECT ' . $select . (!$id ? ',u.username,u.group' : '') . ' 
         FROM ' . db::table('content') . ' AS t
         ' . (!$id ? 'LEFT JOIN ' . db::table('users') . ' AS u ON u.id=t.poster_id' : '') . '
         ' . ($where ? ' WHERE ' . $where : "") . '
         ORDER BY t.posted_time DESC
         ' . (config::o()->v('last_profile_content') ? "LIMIT " . config::o()->v('last_profile_content') : ""));
     $trs = array();
     /* @var $cats categories */
     $cats = n("categories");
     $cats->change_type("content");
     while ($rows = db::o()->fetch_assoc($tr)) {
         $categs = $cats->cid2arr($rows["category_id"]);
         $rows["category_id"] = $categs[1];
         $trs[] = $rows;
     }
     tpl::o()->assign("content_row", $trs);
     tpl::o()->display("profile/last_content.tpl");
 }