/** * Отображение списка логов * @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'); }
/** * Функция получения возраста пользователя * @param int $birthdate дата рождения * @return int возраст пользователя */ public function get_age($birthdate) { display::o()->time_diff($birthdate); $age = explode('.', date('Y.m.d', $birthdate)); $current = explode('.', date('Y.m.d', time())); return $current[0] - $age[0] - ($age[1] > $current[1] || $age[1] == $current[1] && $age[2] > $current[2] ? 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'); }
/** * Функция для инициализации блока * @return null */ public function init() { $content = $this->settings['content']; if ($this->settings['type'] == 'bbcode') { $content = bbcodes::o()->format_text($content); } else { $content = display::o()->html_decode($content); } print $content; }
/** * Добавление/редактирование доп. полей * @param string $id имя поля * @return null */ protected function add($id = null) { if ($id) { $r = db::o()->p($id)->query('SELECT * FROM users_fields WHERE field=? LIMIT 1'); $row = db::o()->fetch_assoc($r); if ($row['allowed']) { $values = @unserialize($row['allowed']); } tpl::o()->assign('row', $row); } if (!$values) { $values = array('', ''); } /* @var $uf userfields */ $uf = n("userfields"); tpl::o()->assign('types', array_keys($uf->get_var('types'))); tpl::o()->assign('types_array', display::o()->array_export_to_js($uf->get_var('types'))); tpl::o()->assign('values', $values); tpl::o()->display('admin/userfields/add.tpl'); }
/** * Результат поиска * @param array $data массив данных для поиска * @return null */ protected function users_results($data) { $unco = (bool) $_GET['unco']; $parent = (bool) $_GET['parent']; $inadmin = users::o()->check_inadmin("users"); if (!$inadmin) { users::o()->check_perms('usearch', 1, 2); $unco = false; } list($where, $orderby, $subupdate) = $this->users_data_prepare($data); $count = db::o()->no_parse()->count_rows('users', $where); list($pages, $limit) = display::o()->pages($count, config::o()->v('table_perpage'), 'submit_search_form', 'page', '', true); $rows = db::o()->no_parse()->query('SELECT * FROM ' . db::table('users') . ($where ? ' WHERE ' . $where : "") . ($orderby ? ' ORDER BY ' . $orderby : "") . ($limit ? ' LIMIT ' . $limit : "")); tpl::o()->assign('unco', $unco); tpl::o()->assign('rows', db::o()->fetch2array($rows)); tpl::o()->assign('pages', $pages); if ($parent) { tpl::o()->assign('parented_window', true); } else { tpl::o()->assign('parented_window', false); } tpl::o()->assign('subupdate', (int) $subupdate); tpl::o()->display('profile/search_result.tpl'); }
/** * Выбор файла темы * @param string $name тема * @param string $folder выбранная дирректория * @return null */ protected function files($name, $folder = null) { display::o()->filechooser(THEMES_PATH, $name, $folder, self::$spaths); }
/** * Создание условия для выборки всего из данной категории и всех подкатегорий * @param integer|string $cur имя или ID данной категории * @param array $cat_row массив верхней категории * @return string условие, если есть данные */ public function condition($cur, &$cat_row = null) { if (!$cur) { return null; } if (is_numeric($cur)) { $cat = (int) $cur; } else { $cat = mb_strtolower(display::o()->strip_subpath($cur)); if (preg_match('/^(.*?)\\//siu', $cat, $matches)) { $cat = $matches[1]; } } $c = $this->get($cat); if (!$c) { return; } $cat_row = array($c['name'], $c['descr'], $c['transl_name'], $c['id']); $ids = array(); $this->get_children_ids($c['id'], $ids); $ids[] = $c['id']; $where = $this->cat_where($ids, true); return $where; }
/** * Построение паттерна * @param array $pattern массив данных * @return array массив паттерна * @throws EngineException */ protected function build_pattern($pattern) { $c = count($pattern['name']); $obj = array(); foreach ($pattern as $type => $e) { if (!is_array($e) || count($e) != $c) { throw new EngineException('patterns_invalid_data'); } for ($i = 0; $i < $c; $i++) { $obj[$i][$type] = $e[$i]; } } $pattern = array(); foreach ($obj as $i => $e) { $type = $e['type']; if (!$type || !in_array($type, $this->types)) { continue; } if (!$e['name']) { continue; } if ((!$e['rname'] || !validword($e['rname'])) && $type != 'html') { $e['rname'] = display::o()->translite($e['name']); } if (!$e['formdata']) { continue; } $c = false; $size = (int) $e['size']; unset($e['size']); switch ($type) { case 'select': case 'radio': if (!$e['values']) { $c = true; break; } unset($e['html']); break; case 'html': if (!$e['html']) { $c = true; break; } unset($e['rname']); unset($e['descr']); unset($e['values']); break; case "input": if ($size) { $e['size'] = $size; } default: unset($e['html']); unset($e['values']); break; } if (!$c) { $pattern[] = $e; } } return $pattern; }
/** * Анти-флуд проверка * @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); } }
/** * Метод обработки параметров для ЧПУ контента * @param string $param имя параметра * @param mixed $value значение параметра * @return string часть ЧПУ */ protected function content_furl_rules($param, $value) { switch ($param) { //case "attr" : // return $value; case "year": case "month": case "day": return (preg_match('/^\\$([1-3])$/siu', $value) ? $value : longval($value)) . '/'; case "act": return $value; case "id": return "-id" . longval($value); break; case "cid": return "-cid" . longval($value); break; case "title": return display::o()->translite($value, 100); break; case "cat": return $value . "/"; case "comments_page": case "page": return "page" . $value; default: return; break; } }
/** * Обрезаем XSS "примочки" у массивов * @param string|array $arr "обрезаемый" массив * @return string|array "обрезанный" массив */ function xss_array_protect($arr) { if (!$arr) { return $arr; } if (!is_array($arr) && !is_numeric($arr)) { return display::o()->html_encode($arr); } else { foreach ($arr as $key => $value) { if (is_array($value)) { $arr[$key] = xss_array_protect($value); } elseif (!is_numeric($value)) { $arr[$key] = display::o()->html_encode($value); } } return $arr; } }
/** * Форма ввода текста с BB-кодами * @param string $name имя формы * @param string $text текст * @return string HTML код формы */ public function input_form($name, $text = '') { if (is_array($name)) { $text = $name['text']; $name = $name['name']; } $this->init_smilies(); lang::o()->get('bbcodes'); $c = ''; try { plugins::o()->pass_data(array('name' => $name, 'text' => $text, 'html' => &$c), true)->run_hook('bbcodes_input_form'); } catch (PReturn $e) { return $e->r(); } tpl::o()->assign("textarea_rname", $name); tpl::o()->assign("textarea_name", 'formid' . time() . $this->id++); tpl::o()->assign("textarea_text", $text); tpl::o()->assign("smilies", $this->smilies[1]); tpl::o()->assign("inited_bbcodes", $this->inited_js); if (!$this->inited_js) { $this->inited_js = true; $fs = array_merge($this->smilies[0], $this->smilies[1]); tpl::o()->assign('smilies_array', display::o()->array_export_to_js($fs)); } $c .= tpl::o()->fetch('init_textinput.tpl'); return $c; }
/** * Переход по степеням в регистрации * @param integer|string $step текущая стадия регистрации * @param array $data массив данных * @return null * @throws EngineException */ protected function step_by_step($step, $data) { $error = array(); /* @var $uf userfields */ $uf = n("userfields")->change_type('register'); // для input_userfields и метода save if ($data['to_check'] && is_numeric($step)) { $this->check_steps($error, $step, $data); if ($step >= 3) { try { $uf->save($data); } catch (EngineException $e) { $error[] = $e->getEMessage(); } } if (!$error) { ok(); } else { $error = implode("<br>", $error); } throw new EngineException($error); } elseif ($step == "last") { if (!config::o()->v('allowed_register') && !config::o()->v('allowed_invite')) { die("ERROR!"); } $refered_by = 0; /* @var $etc etc */ $etc = n("etc"); $this->check_steps($error, $step, $data, $refered_by); if ($error) { throw new EngineException(implode("<br>", $error)); } $salt = users::o()->generate_salt(); display::o()->remove_time_fields("his", "birthday"); $birthday = display::o()->make_time("birthday", "ymd"); $cols = array('username', 'password', 'email', 'gender', 'timezone', 'admin_email', 'user_email', 'use_dst', 'invite'); extract(rex($data, $cols)); $password = users::o()->generate_pwd_hash($password, $salt); $update = array("username" => $username, "username_lower" => mb_strtolower($username), "passkey" => users::o()->generate_salt(), "password" => $password, "salt" => $salt, "registered" => time(), "birthday" => $birthday, "email" => $email, "confirmed" => longval($etc->confirm_user(0, 0)), "group" => users::o()->find_group('default'), "refered_by" => (int) $refered_by, "confirm_key" => config::o()->v('confirm_email') ? $etc->confirm_request($email, "confirm_register") : ""); if (config::o()->v('bonus_by_default')) { $update['bonus_count'] = config::o()->v('bonus_by_default'); } $update["gender"] = $gender == "f" ? "f" : "m"; $update["admin_email"] = (bool) $admin_email; $update["user_email"] = (bool) $user_email; $update["dst"] = (bool) $use_dst; $update["timezone"] = (int) $timezone; $cols = array("name_surname" => 'name'); $settings = rex($data, $cols); $settings["show_age"] = (bool) $data['show_age']; $settings = array_merge($settings, $uf->save($data)); try { plugins::o()->pass_data(array('update' => &$update, 'settings' => &$settings), true)->run_hook('register_user'); $update['settings'] = users::o()->make_settings($settings); $id = db::o()->insert($update, "users"); plugins::o()->pass_data(array('id' => $id))->run_hook('register_user_finish'); } catch (PReturn $e) { return $e->r(); } if ($invite) { db::o()->p($invite)->update(array("to_userid" => $id), "invites", 'WHERE invite_id=? LIMIT 1'); } elseif (!config::o()->v('confirm_email') && !config::o()->v('confirm_admin')) { users::o()->write_cookies($username, $password); } ok(); } tpl::o()->display("register/main_step.tpl"); }
tpl::o()->assign('curlang', users::o()->get_lang()); tpl::o()->assign('curtheme', users::o()->get_theme()); tpl::o()->assign('curtheme_color', users::o()->get_theme(true)); tpl::o()->assign('curuser', users::o()->v('username')); tpl::o()->assign('curgroup', users::o()->v('group')); } if (!defined('DELAYED_UINIT')) { users_init(); } tpl::o()->assign('URL_PATTERN', display::url_pattern); tpl::o()->assign('slbox_mbinited', false); // Кой-чаво для Smarty // Для модификаторов нет описания, ибо проще посмотреть сами функции. $bbcodes = bbcodes::o(); $input = input::o(); $display = display::o(); if (config::o()->v('torrents_on')) { lang::o()->get('torrents', null, true, true); } /* @var $blocks blocks */ $blocks = n("blocks"); /* @var $message message */ $message = n("message"); tpl::o()->register_modifier('unserialize', 'unserialize'); tpl::o()->register_modifier('arr_current', 'current'); tpl::o()->register_modifier('arr_key', 'key'); tpl::o()->register_modifier('l2ip', 'long2ip'); tpl::o()->register_modifier('long', 'longval'); tpl::o()->register_modifier('is', 'is'); tpl::o()->register_modifier('sl', 'slashes_smarty'); tpl::o()->register_modifier('uamp', 'w3c_amp_replace');
/** * Сохранение настроек и данных пользователя * @param array $data данные юзера * @return null * @throws EngineException */ protected function save_main($data) { $inadmin = users::o()->check_inadmin("users"); /* @var $etc etc */ $etc = n("etc"); if ($inadmin) { $id = (int) $data['uid']; users::o()->set_tmpvars($etc->select_user($id)); $sadmin = users::o()->perm("system"); $gr = users::o()->get_group(users::o()->v('group')); $suser = $gr['system']; if ($suser && !$sadmin) { throw new EngineException("access_denied"); } } else { $id = users::o()->v('id'); users::o()->check_perms(); check_formkey(); } //$register = plugins::o()->get_module('registration'); display::o()->remove_time_fields("his", "birthday"); $birthday = display::o()->make_time("birthday", "ymd"); $this->check_areas($data, $error, $inadmin); if ($error) { throw new EngineException(implode("<br>", $error)); } extract(rex($data, array("email", "gid" => "group", "gender", "admin_email", "user_email", "use_dst", "timezone", "interval", "password", "email", "avatar_url", "username"))); $update = array(); if ($password) { $salt = users::o()->v('salt'); $update["password"] = users::o()->generate_pwd_hash($password, $salt); if (!$inadmin) { users::o()->write_cookies(users::o()->v('username'), $update["password"]); } } if ($email != users::o()->v('email')) { if (config::o()->v('confirm_email') && !$inadmin) { $update["new_email"] = $email; $update["confirm_key"] = $etc->confirm_request($email, "confirm_email"); } else { $update["email"] = $email; } } $settings = rex($data, array("name_surname", "signature", 'hidden', 'announce_pk' => 'passkey', 'show_age')); $settings["show_age"] = (bool) $settings["show_age"]; $settings["hidden"] = users::o()->perm("behidden") || $inadmin ? (bool) $settings["hidden"] : 0; if (config::o()->v("torrents_on")) { $settings['announce_pk'] = serialize($settings['announce_pk']); } /* @var $uf userfields */ $uf = n("userfields"); $settings = array_merge($settings, $uf->change_type('profile')->save($data)); if ($inadmin) { $gid = (int) $gid; if ($etc->change_group($id, $gid, true)) { $update['group'] = $gid; /* @var $groups groups_man */ $groups = plugins::o()->get_module('groups', 1); $group = users::o()->get_group(users::o()->v('group')); $update["add_permissions"] = $groups->save($data, $group); } $update['username'] = $username; $update['username_lower'] = mb_strtolower($username); } $update["gender"] = $gender == "f" ? "f" : "m"; $update["admin_email"] = (bool) $admin_email; $update["user_email"] = (bool) $user_email; $update["timezone"] = (int) $timezone; $update["dst"] = (bool) $use_dst; $update["mailer_interval"] = (int) $interval; //print_r($update); if ($birthday) { $update["birthday"] = $birthday; } if ($avatar_url && is(config::o()->v('allowed_avatar'), ALLOWED_AVATAR_URL)) { $this->clear_avatar(true); /* @var $uploader uploader */ $uploader = n("uploader")->upload_via_url(); $avatar_name = display::avatar_prefix . users::o()->v('id'); $uploader->upload($avatar_url, config::o()->v('avatars_folder'), $tmp = 'avatars', $avatar_name); //$uploader->upload_via_url(true)->check($avatar_url, /* ссылка */ $tmp = 'avatars'); $update["avatar"] = $avatar_name; } try { plugins::o()->pass_data(array('update' => &$update, 'settings' => &$settings), true)->run_hook('usercp_save_main'); } catch (PReturn $e) { return $e->r(); } $update["settings"] = users::o()->make_settings($settings); users::o()->remove_tmpvars(); db::o()->p($id)->update($update, "users", 'WHERE id=? LIMIT 1'); if (!$inadmin) { users::o()->setcookie("theme", $data['theme']); users::o()->setcookie("lang", $data['lang']); users::o()->setcookie("theme_color", $data['theme_color']); } else { log_add("changed_user", 'admin', null, $id); } }
/** * Поиск/замена в файлах * @param string|array $dir путь к дирректории или массив файлов * @param string $what что ищем? (рег. выражение без делимиттеров) * @param bool $regexp регулярное выражение? * @param int $where где ищем?(для массива, 0 - в значениях, 1 - в ключах, 2 - и там, и там) * если указать -1, то не будет проверяться, слово ли ключ, а поиск будет по значению * @param callback $callback callback функция для получения контента файла * единственный параметр функции - путь к файлу * @param string $was пред. путь(для рекурсии) * @return array массив файлов(ключи) и подсвеченных результатов(значения) */ public function search_infiles($dir, $what, $regexp = false, $where = null, $callback = null, $was = '') { if (!$dir || !$what) { return; } if (!is_array($dir) && is_dir(ROOT . $dir)) { $files = file::o()->open_folder($dir); } else { $dir = $files = (array) $dir; } $r = array(); if (!$regexp) { $what = mpc($what); $regexp = true; } elseif (!$was) { $what = str_replace('/', '\\/', $what); } $owhat = $what; if (is_null($this->infiles_replace)) { $what = display::o()->html_encode($what); } $what = '/(' . $what . ')/siu'; $where = (int) $where; foreach ($files as $f) { if (!is_array($dir)) { $nf = $dir . '/' . $f; $wf = ($was ? $was . '/' : '') . $f; } else { $wf = $nf = $f; } if (!$f) { return; } $fr = ROOT . $nf; if (is_dir($fr)) { if (!is_array($dir)) { $r = array_merge($r, $this->search_infiles($nf, $owhat, $regexp, $where, $callback, $wf)); } continue; } if ($callback) { $c = call_user_func($callback, $nf); } else { $c = file_get_contents($fr); } if (!$c) { continue; } if (!is_array($c)) { $this->search_infiles_na($r, $fr, $what, $nf, $wf); continue; } if (!is_null($this->infiles_replace) && !$this->infiles_replace_cb) { continue; } $this->search_infiles_a($r, $c, $what, $where, $nf, $wf); } if (!$was) { $this->replace_infiles(null, null); } return $r; }
/** * Проверка и сборка шаблона для формы * @param int $id ID шаблона * @return null */ protected function check_pattern($id) { lang::o()->get('admin/patterns'); $row = $this->parse_pattern($id); $arr = array(); foreach ($row['pattern'] as $e) { foreach ($e['formdata'] as $key => $val) { $this->pattern_filled = true; $val = preg_replace_callback('/\\{this\\.([a-z0-9\\_\\-]+)\\}/siu', array($this, 'pattern_pcre_callback'), $val); if (!$this->pattern_filled) { if ($e['name'][0] == '*') { throw new EngineException('patterns_necessary_fields_not_filled'); } else { continue; } } $oval = $val = rtrim($val); if ($oval == ($val = preg_replace('/^\\{nobr\\}/siu', '', $val)) && $arr[$key] && $key != 'title') { // в заголовки заранее не пишем $val = "\n" . $val; } $val = preg_replace('/\\{br\\}/siu', "\n", $val); $arr[$key] .= $val; } } ok(true); die(display::o()->array_export_to_js($arr)); }
/** * Замена переменных %time% и %time_after% в Anti-Double Comment тексте * @param string $dc_text текст для парсинга * @param int $fromtime время постинга пред. комментария * @return string спарсенный текст */ public function parse_dc_text($dc_text, $fromtime) { $dc_text = str_replace('%time%', display::o()->date(time(), 'ymdhis'), $dc_text); if ($fromtime) { $dc_text = str_replace('%time_after%', display::o()->estimated_time($fromtime, time()), $dc_text); } return $dc_text; }
/** * Получение имени ЧПУ для категории * @param int $id ID категории * @param string $name имя категории * @param string $sname имя категории для подкатегории * @return string транслитерованное имя */ public function get_catname($id, $name, $sname = '') { return display::o()->translite($id . '-' . $name . ($sname ? "-" . $sname : "")); }
/** * Обработка записи торрента * @param content $content объект контента * @param array $row данные торрента * @param int $max_title_symb макс. кол-во символов в заголовке * @return null */ protected function show_row($content, &$row, $max_title_symb) { $row['screenshots'] = $content->show_image($row['screenshots'], true, false, "center"); if (preg_match('/^(.+?)(?:\\/(.+?))?\\(([0-9]+)\\).*?$/siu', $row['title'], $matches)) { $row['name'] = display::o()->cut_text($matches[1], $max_title_symb); $row['orig_name'] = display::o()->cut_text($matches[2], $max_title_symb); $row['year'] = $matches[3]; } foreach ($this->patterns as $patt) { $lv = 'btorrents_pattern_' . $patt; if (!lang::o()->visset($lv)) { continue; } @preg_match(sprintf($this->patterns_pattern, lang::o()->v($lv)), $row['content'], $matches); if (!$matches) { continue; } $row[$patt] = $matches[1]; } if (!$row['name']) { $row['name'] = display::o()->cut_text($row['title'], $max_title_symb); } if (!$row['orig_name']) { $row['orig_name'] = $row['name']; } }
/** * Скачивание вложения * @param int $id ID вложения * @return null * @throws EngineException */ public function download($id) { if (!$this->state) { return; } users::o()->check_perms('attach', 1, 2); $id = (int) $id; $q = db::o()->p($id)->query("SELECT * FROM attachments WHERE id=? LIMIT 1"); $row = db::o()->fetch_assoc($q); if (!$row) { throw new EngineException('file_not_exists'); } $file = config::o()->v("attachments_folder") . "/" . self::attach_prefix . default_filename($row['time'], $row['user']); try { plugins::o()->pass_data(array("row" => &$row))->run_hook('attachments_download'); } catch (PReturn $e) { return $e->r(); } db::o()->p($id)->update(array("_cb_downloaded" => 'downloaded+1'), "attachments", 'WHERE id = ? LIMIT 1'); /* @var $uploader uploader */ $uploader = n("uploader"); $uploader->download($file, display::o()->html_decode($row["filename"])); }
/** * Функция для превращения имени пользователя в ссылку * @param string $text имя пользователя либо HTML текст * @param string $subtext имя пользователя * @param bool $bbcode BBCode? * @return string HTML код ссылки */ function smarty_user_link($text, $subtext = "", $bbcode = false) { if (!$subtext) { if (!users::o()->check_login($text)) { $gr = users::o()->get_group(users::o()->find_group('guest')); $subtext = $gr["name"]; } } $quote = display::o()->html_encode('"'); $aopen = $bbcode ? '[url=' . $quote : "<a class='profile_link' href='"; $aopen2 = $bbcode ? $quote . ']' : "'>"; $aclose = $bbcode ? '[/url]' : '</a>'; return (users::o()->perm('profile') ? $aopen . furl::o()->construct("users", array("user" => !$subtext ? $text : $subtext)) . $aopen2 : "") . $text . (users::o()->perm('profile') ? $aclose : ""); }
/** * Выбор смайлов * @param string $folder выбранная дирректория * @return null */ protected function files($folder = null) { display::o()->filechooser(null, config::o()->v('smilies_folder'), $folder, null, true); }
/** * Вывод поля конфигурации для данного типа * @param array $row массив параметров * @return string html код поля */ public function show_type($row) { if (!is_array($row) || !$row) { return null; } $type = $row['type']; $allowed = $row['allowed']; $name = $row['name']; $value = display::o()->html_encode($row['value']); if ($type == 'other') { $f = self::method_show_prefix . $name; return $this->call_method($f, array($value)); } elseif ($type == 'radio' || $type == 'select') { $a = explode(";", $allowed); $allowed = array(); $c = count($a); for ($i = 0; $i < $c; $i++) { if (lang::o()->visset("config_field_" . $name . "_" . $a[$i])) { $l = lang::o()->v("config_field_" . $name . "_" . $a[$i]); } else { $l = lang::o()->v("config_value_" . $a[$i]); } $allowed[$a[$i]] = $l; } } else { input::o()->ssize(35); } return input::o()->stype($type)->scurrent($value)->skeyed()->standart_types(config_man::config_prefix . $name, $allowed); }
/** * Отображение значения в зависимости от типа поля * Параметры: type,current,keyed * @param array $allowed допустимые значения * @return mixed преобразованное значени */ public function standart_types_display($allowed = null) { if ($this->params) { $this->join_params($allowed, array('allowed' => $allowed)); } $type = $allowed['type']; $value = $allowed['current']; $keyed = $allowed['keyed']; $allowed = $allowed['allowed']; switch ($type) { case "int": case "text": case "string": return $value; case "date": return display::o()->date($value, $allowed); case "folder": return ($allowed ? $allowed . '/' : '') . $value; case "radio": case "select": if (!is_array($allowed)) { $allowed = unserialize($allowed); } return $keyed ? $allowed[$value] : $value; case "checkbox": // не отображаем return ""; } }
/** * Выбор языкового файла * @param string $name языковой пакет * @param string $folder выбранная дирректория * @return null */ protected function files($name, $folder = null) { display::o()->filechooser(LANGUAGES_PATH, $name, $folder); }
/** * Начало инициализации пользователя * @return null */ protected function init_begin() { display::o()->site_autoon(); $this->lang = validfolder($_COOKIE["lang"], LANGUAGES_PATH) ? $_COOKIE["lang"] : config::o()->v('default_lang'); $this->theme = validfolder($_COOKIE["theme"]) ? $_COOKIE["theme"] : config::o()->v('default_style'); init_spaths(); $this->theme_color = tpl::o()->set_color($_COOKIE["theme_color"]); lang::o()->change_folder($this->lang); $this->init_ipbans(); $this->get_groups(); try { plugins::o()->run_hook('user_init_begin'); } catch (PReturn $e) { return $e->r(); } }
/** * Получение объекта класса * @return display $this */ public static function o() { if (!self::$o) { $cn = __CLASS__; $c = n($cn, true); self::$o = new $c(); } return self::$o; }
tpl::o()->assign('from_ajax', $ajax); tpl::o()->assign('module_loaded', $module); if ($module) { if (!allowed::o()->is($module)) { die(lang::o()->v('module_not_exists')); } $mod = plugins::o()->get_module($module, false, $ajax && !$nno); if (!$mod) { die(lang::o()->v('module_not_exists')); } plugins::o()->call_init($mod, 'pre_init'); } users_init(); // ...доседова if ($module != "login") { display::o()->siteoffline_check(); } $content = ""; try { if ($mod) { if (!$ajax) { ob_start(); if ($mod instanceof empty_class) { disabled(false); } plugins::o()->call_init($mod); $content = ob_get_contents(); ob_end_clean(); if (isset($mod->title)) { tpl::o()->assign("overall_title", $mod->title); }