Ejemplo n.º 1
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.º 2
0
 /**
  * Получение сообщения
  * @return string сообщение
  */
 public function getEMessage()
 {
     // Ибо getMessage - final
     $m = lang::o()->if_exists($this->message);
     $v = $this->vars;
     return $v ? vsprintf($m, $v) : $m;
 }
Ejemplo n.º 3
0
 /**
  * Инициализация управления категориями
  * @return null
  */
 public function init()
 {
     $admin_file = globals::g('admin_file');
     lang::o()->get('admin/cats');
     $act = $_GET['act'];
     $type = $_GET['type'];
     if (!$type || !$this->cats->change_type($type)) {
         $type = 'content';
     }
     tpl::o()->assign('oldadmin_file', $admin_file);
     $admin_file .= '&type=' . $type;
     globals::s('admin_file', $admin_file);
     tpl::o()->assign('admin_file', $admin_file);
     tpl::o()->assign('cat_type', $type);
     switch ($act) {
         case "add":
         case "edit":
             try {
                 $this->add((int) $_GET['id'], $act == "add");
             } catch (EngineException $e) {
                 $e->defaultCatch(true);
             }
             break;
         case "save":
             $this->save($type, $_POST);
             break;
         default:
             $this->show();
             break;
     }
 }
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
 /**
  * Получение нового ID группы
  * @param int $group старый ID группы
  * @return int новый ID группы
  */
 public function get_group($group)
 {
     $group = (int) $group;
     if (!$this->groups || !is_array($this->groups) || !$this->groups[$group]) {
         printf(lang::o()->v('convert_cant_find_group'), $group);
         die;
     }
     return $this->groups[$group];
 }
Ejemplo n.º 6
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.º 7
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.º 8
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.º 9
0
 /**
  * Инициализация блока контента
  * @return null
  */
 public function init()
 {
     lang::o()->get("content");
     if (!users::o()->perm('content')) {
         return;
     }
     /* @var $content content */
     $content = plugins::o()->get_module("content");
     if (!is_callable(array($content, "show"))) {
         return;
     }
     tpl::o()->assign('content_in_block', true);
     $content->show();
 }
Ejemplo n.º 10
0
 /**
  * Вывод селектора параметров
  * @param array $row массив группы
  * @param int $v значение параметра
  * @return string HTML код
  */
 public function show_selector($row, $v)
 {
     $m = $row['allowed'];
     $n = $row['perm'];
     $s = "";
     if (strpos($n, "edit_") === 0 || strpos($n, "del_") === 0) {
         $a = "_e";
     }
     for ($i = $m; $i >= 0; $i--) {
         $l = lang::o()->visset("groups_rule_" . $n . "_value_" . $i) ? lang::o()->v("groups_rule_" . $n . "_value_" . $i) : lang::o()->v("groups_value_" . $i . ($i ? $a : ""));
         $s .= "<input type='radio' name='can_" . $n . "'\n                value='" . $i . "'" . ($v == $i ? " checked='checked'" : "") . ">&nbsp;" . $l . " ";
     }
     return $s;
 }
Ejemplo n.º 11
0
 /**
  * Инициализация блока календаря
  * @return null
  */
 public function init()
 {
     $day_of_week = implode(',', array_map(array(db::o(), 'esc'), array_map('trim', explode(",", lang::o()->v('calendar_day_of_week')))));
     $months = input::$months;
     $monthes = array();
     // lol'd
     foreach ($months as $month) {
         $monthes[] = db::o()->esc(lang::o()->v('month_' . $month));
     }
     $content = $this->count_content();
     tpl::o()->assign("content_count", $content);
     tpl::o()->assign('day_of_week', $day_of_week);
     tpl::o()->assign("months", implode(",", $monthes));
     tpl::o()->display("blocks/contents/calendar.tpl");
 }
Ejemplo n.º 12
0
 /**
  * Функция проверки кода captcha
  * @param array $error массив ошибок
  * @param string $var $_POST переменная для проверки введённого кода
  * @return null
  */
 public function check(&$error, $var = "captcha_code")
 {
     $posted_code = $_POST[$var];
     if (!$posted_code) {
         $error[] = lang::o()->v('captcha_false_captcha');
         return;
     }
     $code = (array) $_SESSION['captcha_key'];
     if (in_array(mb_strtoupper($posted_code), $code)) {
         return true;
     } else {
         $error[] = lang::o()->v('captcha_false_captcha');
         return;
     }
 }
Ejemplo n.º 13
0
 /**
  * Построение плагина
  * @param array $data массив данных
  * @return null 
  * @throws EngineException
  */
 public function build($data)
 {
     lang::o()->get('admin/plugins');
     $data_params = array("plugin", "version", "author", "name", "descr", "comp", "comp_min", "comp_max");
     extract(rex($data, $data_params));
     if (!validword($plugin)) {
         throw new EngineException("plugins_invalid_name");
     }
     $settings = modsettings::o()->make($data);
     $defaults = modsettings::o()->save(modsettings::nocache_id, $data);
     $vars = array($plugin, var_export((string) $version, true), var_export((string) $author, true), var_export((string) $name, true), var_export((string) $descr, true), var_export((string) $comp, true), var_export((string) $comp_min, true), var_export((string) $comp_max, true), var_export((array) $settings, true), $plugin, var_export((array) $defaults, true));
     $contents = @file_get_contents(ROOT . self::plugin_template);
     $contents = vsprintf($contents, $vars);
     /* @var $uploader uploader */
     $uploader = n("uploader");
     $uploader->download_headers($contents, 'plugin.' . $plugin . '.php', 'text/plain');
 }
Ejemplo n.º 14
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.º 15
0
 /**
  * Инициализация модуля обратной связи
  * @return null
  */
 public function init()
 {
     $admin_file = globals::g('admin_file');
     lang::o()->get('admin/feedback');
     $act = $_GET["act"];
     switch ($act) {
         case "clear":
             /* @var $o feedback_man_ajax */
             $o = plugins::o()->get_module('feedback', 1, true);
             $o->clear();
             furl::o()->location($admin_file);
             break;
         default:
             $this->show($_GET['sort'], $_GET['type']);
             break;
     }
 }
Ejemplo n.º 16
0
 /**
  * Инициализация управления блоками
  * @return null
  */
 public function init()
 {
     lang::o()->get('admin/blocks');
     $act = $_GET['act'];
     switch ($act) {
         case "add":
         case "edit":
             $this->add((int) $_GET['id']);
             break;
         case "save":
             $this->save($_POST);
             break;
         default:
             $this->show();
             break;
     }
 }
Ejemplo n.º 17
0
 /**
  * Инициализация модуля стат. страниц
  * @return null
  */
 public function init()
 {
     $POST = globals::g('POST');
     lang::o()->get('admin/static');
     $act = $_GET["act"];
     switch ($act) {
         case "save":
             $_POST['html'] = $POST['html'];
             $this->save($_POST);
             break;
         case "add":
         case "edit":
             $this->add($_GET['id']);
             break;
         default:
             $this->show();
             break;
     }
 }
Ejemplo n.º 18
0
 /**
  * Инициализация управления шаблонами
  * @return null
  */
 public function init()
 {
     $POST = globals::g('POST');
     lang::o()->get('admin/patterns');
     $act = $_GET['act'];
     switch ($act) {
         case "add":
         case "edit":
             $this->add((int) $_GET['id'], $act == "add");
             break;
         case "save":
             $_POST['html'] = $POST['html'];
             $_POST['descr'] = $POST['descr'];
             $this->save($_POST);
             break;
         default:
             $this->show();
             break;
     }
 }
Ejemplo n.º 19
0
 /**
  * Функция инициализации Ajax-части ЛС
  * @return null
  */
 public function init()
 {
     users::o()->check_perms('pm');
     lang::o()->get('messages');
     $act = $_GET['act'];
     switch ($act) {
         case "send_ok":
             $to_unames = $_POST['to_usernames'];
             $to_groups = $_POST['to_groups'];
             $title = $_POST['title'];
             $descr = $_POST['body'];
             $this->confirm_send($to_unames, $to_groups, $title, $descr);
             ok();
             break;
         case "send":
             $to = $_GET['to'];
             $id = longval($_GET['id']);
             $this->send($to, $id);
             break;
         case "read":
             $id = (int) $_POST['id'];
             $this->show_simple($id);
             break;
         case "s_read":
             $ids = $_POST['item'];
             $this->read($ids);
             ok();
             break;
         case "delete":
             $ids = $_POST['item'];
             $this->delete($ids);
             ok();
             break;
         default:
             $out = (bool) $_GET['out'];
             $sended = (bool) $_GET['sended'];
             $this->show($out, $sended);
             break;
     }
 }
Ejemplo n.º 20
0
 /**
  * Инициализация модуля смайлов
  * @return null
  */
 public function init()
 {
     lang::o()->get('admin/smilies');
     $act = $_GET["act"];
     switch ($act) {
         case "save":
             $this->save($_POST);
             break;
         case "edit":
         case "add":
             try {
                 $this->add($_GET['file']);
             } catch (EngineException $e) {
                 $e->defaultCatch(true);
             }
             break;
         case "files":
             $this->files($_REQUEST['folder']);
             break;
         default:
             $this->show();
             break;
     }
 }
Ejemplo n.º 21
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.º 22
0
 /**
  * Выборка и вставка значений из таблицы
  * @param string $table имя таблицы вставки
  * @param string $orderby сортировка таблицы выборки
  * @param string $ftable имя таблицы выборки
  * @param string $cond условие для выборки
  * @param int $limit ограничение
  * @param bool $noerr без ошибок?
  * @return bool статус выбокри/вставки
  */
 private function select4insert($table, $orderby, $ftable, $cond, $limit, $noerr = false)
 {
     $query = "SELECT ";
     $c = count($this->columns);
     for ($i = 0; $i < $c; $i++) {
         $query .= ($i ? ', ' : '') . $this->columns[$i];
     }
     $orderby = '`' . implode('`, `', array_map('trim', explode(',', $orderby))) . '`';
     $query .= " FROM `" . $this->db . "`.`" . $this->prefix . $ftable . "`" . ($cond ? " WHERE " . $cond : "") . "\n            ORDER BY " . $orderby . "\n            LIMIT " . $limit . ',' . $this->peronce;
     $r = db::o()->no_error()->no_parse()->query($query);
     if (db::o()->errno()) {
         printf(lang::o()->v('convert_select_error'), $ftable, db::o()->errno(), db::o()->errtext());
         if ($noerr) {
             return false;
         } else {
             die;
         }
     }
     while ($row = db::o()->fetch_assoc($r)) {
         db::o()->ignore()->insert($this->insert($row), $table, true);
     }
     db::o()->no_error()->save_last_table();
     if (db::o()->errno()) {
         printf(lang::o()->v('convert_insert_error'), $table, db::o()->errno(), db::o()->errtext());
         if ($noerr) {
             return false;
         } else {
             die;
         }
     }
     printf(lang::o()->v('convert_inserted_table'), $limit, $limit + $this->peronce - 1, $table, $ftable);
     return true;
 }
Ejemplo n.º 23
0
 /**
  * Клонирование языкового пакета
  * @param string $name имя языка
  * @param string $newname новое имя языка
  * @return null
  * @throws EngineException
  */
 public function copy($name, $newname)
 {
     lang::o()->get('admin/languages');
     if (!validword($newname)) {
         throw new EngineException('languages_invalid_new_name');
     }
     file::o()->copy_folder(LANGUAGES_PATH . '/' . $name, LANGUAGES_PATH . '/' . $newname);
     log_add('copied_language', 'admin', array($newname, $name));
 }
Ejemplo n.º 24
0
<div align="center" class='m_message margin_auto'>
    <div class="info m_message_table margin_auto">
        <div align="left" class='content'>
            <div class='tr'>
                <div class="m_message_image info_image td"></div>
                <div class='td'>
                    <div class='m_message_content'>
                        <?php 
echo lang::o()->v('convert_finished');
?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
Ejemplo n.º 25
0
 /**
  * Получение объекта класса
  * @return lang $this
  */
 public static function o()
 {
     if (!self::$o) {
         self::$o = new self();
         self::$o->change_folder(DEFAULT_LANG);
     }
     return self::$o;
 }
Ejemplo n.º 26
0
 /**
  * Вход для конвертированного пользователя
  * @param array $data массив переменных
  * @return null
  * @throws PReturn
  */
 public function converted_login($data)
 {
     $login = $data['login'];
     $password = $data['password'];
     $error =& $data['error'];
     $id =& $data['id'];
     /* @var $etc etc */
     $etc = n("etc");
     $u = $etc->select_user(null, $login, 'id,password,salt,converted');
     if (!$u['converted']) {
         return;
     }
     $salt = $u['salt'];
     if ($u['password'] != md5($salt . $password . $salt)) {
         $error = lang::o()->v('login_false_signin');
         return;
     }
     $id = $u['id'];
     $salt = users::o()->generate_salt(32);
     $password = users::o()->generate_pwd_hash($password, $salt);
     db::o()->p($id)->update(array('salt' => $salt, 'password' => $password, 'converted' => '0'), 'users', 'WHERE id = ? LIMIT 1');
     throw new PReturn($password);
 }
Ejemplo n.º 27
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.º 28
0
 /**
  * Осуществление подтверждения пользователя
  * @param int $act степень подтверждения
  * @param int $now_conf степень подтверждения на данный момент
  * @param int $id ID пользователя
  * @return int степень подтверждения
  */
 public function confirm_user($act, $now_conf, $id = null)
 {
     $now_conf = (int) $now_conf;
     if ($now_conf < 0 || $now_conf > 2) {
         return $now_conf;
     }
     $id = (int) $id;
     switch ($act) {
         case 3:
             $confirm = 3;
             break;
         case 2:
             if ($now_conf < 1) {
                 return lang::o()->v('not_confirmed_email');
             }
             if (!config::o()->v('confirm_admin')) {
                 $confirm = 3;
             } else {
                 $confirm = 2;
             }
             break;
         default:
             if (config::o()->v('confirm_email')) {
                 $confirm = 0;
                 break;
             }
         case 1:
             if (!config::o()->v('confirm_admin') && (config::o()->v('allowed_register') || !config::o()->v('allowed_invite'))) {
                 $confirm = 3;
             } elseif (config::o()->v('allowed_register') || !config::o()->v('allowed_invite')) {
                 $confirm = 2;
             } else {
                 $confirm = 1;
             }
             break;
     }
     if ($now_conf >= $confirm) {
         return $now_conf;
     }
     if ($id) {
         db::o()->p($id)->update(array("confirmed" => $confirm), "users", 'WHERE id=? LIMIT 1');
     }
     return $confirm;
 }
Ejemplo n.º 29
0
<div align="center" class='m_message margin_auto'>
    <div class="info m_message_table margin_auto">
        <div align="left" class='content'>
            <div class='tr'>
                <div class="m_message_image info_image td"></div>
                <div class='td'>
                    <div class='m_message_content'>
                        <?php 
echo sprintf(lang::o()->v('convert_notice'), $data['config']->v('avatars_folder'), $data['config']->v('torrents_folder'), $data['config']->v('screenshots_folder'));
?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
Ejemplo n.º 30
0
/**
 * Генератор пароля для шаблонов Smarty
 * @param array $params массив параметров(pname - имя поля пароля, paname - имя поля повтора пароля)
 * @return string HTML код генератора
 */
function smarty_passgen($params)
{
    $theme_path = globals::g('theme_path');
    $name = $params["pname"];
    $name2 = $params["paname"];
    return '<img src="' . $theme_path . 'engine_images/passgen.png" alt="' . lang::o()->v('passgen') . '" class="passgen clickable"
        title="' . lang::o()->v('passgen') . '" onclick="passgen(\'' . addslashes($name) . '\', \'' . addslashes($name2) . '\');">';
}