/** * Вывод списка 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"); }
/** * Получение сообщения * @return string сообщение */ public function getEMessage() { // Ибо getMessage - final $m = lang::o()->if_exists($this->message); $v = $this->vars; return $v ? vsprintf($m, $v) : $m; }
/** * Инициализация управления категориями * @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; } }
/** * Инициализация нижнего блока * @return null */ public function init() { if (!config::o()->mstate('downm')) { return; } lang::o()->get("blocks/downm"); print "Down block inited"; }
/** * Получение нового 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]; }
/** * Инициализация чата * @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'); }
/** * Инициализация блока новостей * @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'); }
/** * Функция проверки кода 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; }
/** * Инициализация блока контента * @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(); }
/** * Вывод селектора параметров * @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'" : "") . "> " . $l . " "; } return $s; }
/** * Инициализация блока календаря * @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"); }
/** * Функция проверки кода 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; } }
/** * Построение плагина * @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'); }
/** * Инициализация блока-торрентов * @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)); }
/** * Инициализация модуля обратной связи * @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; } }
/** * Инициализация управления блоками * @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; } }
/** * Инициализация модуля стат. страниц * @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; } }
/** * Инициализация управления шаблонами * @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; } }
/** * Функция инициализации 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; } }
/** * Инициализация модуля смайлов * @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; } }
/** * Проверка, является ли сайт 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; } }
/** * Выборка и вставка значений из таблицы * @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; }
/** * Клонирование языкового пакета * @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)); }
<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>
/** * Получение объекта класса * @return lang $this */ public static function o() { if (!self::$o) { self::$o = new self(); self::$o->change_folder(DEFAULT_LANG); } return self::$o; }
/** * Вход для конвертированного пользователя * @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); }
/** * Инициализация 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; }
/** * Осуществление подтверждения пользователя * @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; }
<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>
/** * Генератор пароля для шаблонов 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) . '\');">'; }