function IndexPollsViewPolls() { $polls = System::database()->Select('polls', GetWhereByAccess('view', "`active`='1'")); if (count($polls) > 0) { System::site()->AddTemplatedBox('Опросы', 'module/polls_main.html'); System::site()->AddBlock('polls_title', true, false, 'ptitle'); System::site()->Blocks['polls_title']['vars'] = array('public' => 'Добавлен', 'title' => 'Опрос', 'comments' => 'Комментарий', 'voices' => 'Всего ответов'); System::site()->AddBlock('polls', true, true, 'poll'); SortArray($polls, 'date', true); foreach ($polls as $poll) { $answers = unserialize($poll['answers']); $c = count($answers); $num_voices = 0; for ($i = 0; $i < $c; $i++) { $num_voices += SafeDB($answers[$i][2], 11, int); } $vars = array(); $vars['title'] = SafeDB($poll['question'], 255, str); $vars['url'] = Ufu('index.php?name=polls&op=viewpoll&poll_id=' . SafeDB($poll['id'], 11, int), 'polls/{poll_id}/'); $vars['public'] = TimeRender($poll['date'], false, false); $vars['num_voices'] = $num_voices; $vars['allow_comments'] = SafeDB($poll['allow_comments'], 1, int); $vars['comments'] = SafeDB($poll['com_counter'], 11, int); System::site()->AddSubBlock('polls', true, $vars); } } else { System::site()->AddTextBox('', '<p align="center">Опросов пока нет.</p>'); } }
function IndexForumEditTopic() { global $forum_lang; if (!System::user()->Auth) { System::site()->AddTextBox($forum_lang['forum'], '<p align="center">' . $forum_lang['error_auth'] . '</p>'); return; } $topic = SafeEnv($_GET['topic'], 11, int); $post = System::database()->Select('forum_posts', "`object`='{$topic}' and `delete`='0'"); SortArray($post, 'id', false); System::database()->Select('forum_topics', "`id`='{$topic}'"); $topic = System::database()->FetchRow(); if ($topic['delete'] == 0 || System::config('forum/basket') == false) { $title = ''; if (SafeDB($topic['starter_id'], 11, str) == System::user()->Get('u_id') or System::user()->IsAdmin()) { $title = SafeDB($topic['title'], 0, str); } if (System::user()->Get('u_id') == $post[0]['user_id'] || System::user()->isAdmin()) { ForumRenderPostForm(true, 0, SafeEnv($_GET['topic'], 11, int), SafeDB($post[0]['id'], 11, int), SafeDB($post[0]['message'], 0, str, false, true), $title); } else { System::site()->AddTextBox($forum_lang['forum'], '<p align="center">' . $forum_lang['no_right_comment_edit'] . '</p>'); return; } } else { System::site()->AddTextBox($forum_lang['topic_basket_current_post'], '<p align="center">' . $forum_lang['topic_basket_post'] . '<br><input type="button" value="' . $forum_lang['back'] . '"onclick="history.back();"></p>'); } }
public function ActiveTopicAuthors() { $this->topic_authors_count = count(array_unique($this->_author_count)); $this->active_topic_authors = ' '; if (count($this->_author_name) > 0) { SortArray($this->_author_name, 'count', true); $i = 0; foreach ($this->_author_name as $author) { $i++; $author_link = Ufu('index.php?name=user&op=userinfo&user='******'id'], 'user/{user}/info/'); $usertopics_link = Ufu('index.php?name=forum&op=usertopics&user='******'id'], 'forum/usertopics/{user}/'); $this->active_topic_authors .= '<a href="' . $author_link . '">' . $author['name'] . '</a> <font size="1">[<a href="' . $usertopics_link . '">' . $author['count'] . '</a>]</font>'; if ($i == 20 || count($this->_author_name) == $i) { $this->active_topic_authors .= '.'; } else { $this->active_topic_authors .= ', '; } if ($i == 20) { break; } } } return $this->active_topic_authors; }
function AdminArticlesMain() { global $editarticles; // Фильтр, дает возможность показывать статьи определенной категории. if (isset($_GET['cat']) && $_GET['cat'] > -1) { $cat = SafeEnv($_GET['cat'], 11, int); $where = "`cat_id`='{$cat}'"; } else { $cat = -1; $where = ""; } $data = array(); $data = AdminArticlesGetTree()->GetCatsData($cat, true); System::site()->DataAdd($data, -1, 'Все статьи', $cat == -1); // Получаем номер страницы if (isset($_GET['page'])) { $page = SafeEnv($_GET['page'], 10, int); } else { $page = 1; } AddCenterBox('Статьи'); // Форма фильтра по категориям System::admin()->AddJS(' ArticlesSelectCat = function(){ Admin.LoadPage("' . ADMIN_FILE . '?exe=articles&cat="+$("#article-cat").val()); } '); $text = '<div style="text-align: center; margin-bottom: 10px;">Категория: ' . System::site()->Select('cat', $data, false, 'id="article-cat" onchange="ArticlesSelectCat();"') . '</div>'; AddText($text); // Берем статьи из БД и включаем постраничную навигацию если нужно. $r = System::database()->Select('articles', $where); SortArray($r, 'public', true); // Сортируем по дате добавления if (count($r) > System::config('articles/articles_on_page')) { $navigator = new Navigation($page); $navigator->GenNavigationMenu($r, System::config('articles/articles_on_page'), ADMIN_FILE . '?exe=articles' . ($cat > 0 ? '&cat=' . $cat : '')); $nav = true; } else { $nav = false; } $text = '<table cellspacing="0" cellpadding="0" class="cfgtable">'; $text .= '<tr><th>Название</th><th>Прочитано</th><th>Оценки</th><th>Видят</th><th>Статус</th><th>Функции</th></tr>'; $back = SaveRefererUrl(); foreach ($r as $art) { $id = SafeDB($art['id'], 11, int); $cat_id = SafeDB($art['cat_id'], 11, int); $title = SafeDB($art['title'], 255, str); $hits = SafeDB($art['hits'], 11, int); $rating = '<img src="' . GetRatingImage(SafeDB($art['num_votes'], 11, int), SafeDB($art['all_votes'], 11, int)) . '" border="0" />'; $st = $art['active'] == '1' ? 'Вкл.' : 'Выкл.'; $link_go = Ufu("index.php?name=articles&op=read&art={$id}&cat={$cat_id}", 'articles/{cat}/{art}/'); $func = ''; $func .= System::admin()->SpeedButton('Перейти к странице на сайте', $link_go, 'images/link_go.png', false, false, 'target="_blank"'); if ($editarticles) { $title = '<b>' . System::admin()->Link($title, ADMIN_FILE . '?exe=articles&a=editor&id=' . $id . '&back=' . $back) . '</b>'; $hits .= ' ' . System::admin()->SpeedConfirm('Обнулить счётчик просмотров', ADMIN_FILE . '?exe=articles&a=resethits&id=' . $id . '&back=' . $back, 'images/admin/arrow_in.png', 'Сбросить счётчик просмотров?'); $rating .= ' ' . System::admin()->SpeedConfirm('Обнулить счётчик оценок (' . SafeDB($art['num_votes'], 11, int) . ' голосов)', ADMIN_FILE . '?exe=articles&a=resetrating&id=' . $id . '&back=' . $back, 'images/admin/arrow_in.png', 'Сбросить оценки?'); $st = System::admin()->SpeedStatus('Включена', 'Отключена', ADMIN_FILE . '?exe=articles&a=changestatus&id=' . $id, $art['active'] == '1'); $func .= System::admin()->SpeedButton('Редактировать', ADMIN_FILE . '?exe=articles&a=editor&id=' . $id . '&back=' . $back, 'images/admin/edit.png'); $func .= System::admin()->SpeedConfirm('Удалить', ADMIN_FILE . '?exe=articles&a=delete&id=' . $id . '&ok=1&back=' . $back, 'images/admin/delete.png', 'Удалить статью?'); } $text .= '<tr> <td>' . $title . '</td> <td>' . $hits . '</td> <td>' . ($art['allow_votes'] == '1' ? $rating : 'Запрещены') . '</td> <td>' . ViewLevelToStr(SafeDB($art['view'], 1, int)) . '</td> <td>' . $st . '</td> <td>' . $func . '</td> </tr>'; } $text .= '</table>'; AddText($text); if ($nav) { AddNavigation(); } }
function AdminUserRanks() { global $rankedit; TAddSubTitle('Ранги пользователей'); $users = System::database()->Select('users', "`type`='2'"); foreach ($users as $u) { $r = GetUserRank($u['points'], $u['type'], $u['access']); if (!isset($rcounts[$r[2]])) { $rcounts[$r[2]] = 0; } $rcounts[$r[2]]++; } $ranks = System::database()->Select('userranks', ''); SortArray($ranks, 'min'); $text = '<table cellspacing="0" cellpadding="0" class="cfgtable">'; $text .= '<tr><th>Ранг</th><th>Мин. пунктов</th><th>Участников</th><th>Изображение</th><th>Функции</th></tr>'; foreach ($ranks as $rank) { if (file_exists(System::config('general/ranks_dir') . $rank['image']) && is_file(System::config('general/ranks_dir') . $rank['image'])) { $image = '<img src="' . RealPath2(SafeDB(System::config('general/ranks_dir') . $rank['image'], 255, str)) . '" border="0" />'; } else { $image = ''; } $funcs = ''; if ($rankedit) { $funcs .= System::admin()->SpeedButton('Редактировать', ADMIN_FILE . '?exe=user&a=editrank&id=' . SafeDB($rank['id'], 11, int), 'images/admin/edit.png'); $funcs .= System::admin()->SpeedConfirm('Удалить', ADMIN_FILE . '?exe=user&a=delrank&id=' . SafeDB($rank['id'], 11, int), 'images/admin/delete.png', 'Удалить ранг?'); } else { $funcs .= ' '; } $text .= '<tr> <td>' . SafeDB($rank['title'], 250, str) . '</td> <td>' . SafeDB($rank['min'], 11, int) . '</td> <td>' . (isset($rcounts[$rank['id']]) ? $rcounts[$rank['id']] : '0') . '</td> <td>' . $image . '</td> <td>' . $funcs . '</td> </tr>'; } $text .= '</table>'; AddCenterBox('Ранги пользователей'); AddText($text); if ($rankedit) { System::admin()->FormTitleRow('Добавить ранг'); FormRow('Название ранга', System::site()->Edit('rankname', '', false, 'style="width:180px;"')); FormRow('Изображение', System::site()->Edit('rankimage', '', false, 'style="width:180px;"')); FormRow('Минимальное количество пунктов для вступления', System::site()->Edit('minpoints', '0', false, 'style="width:60px;"')); AddForm('<form name="addrang" method="post" action="' . ADMIN_FILE . '?exe=user&a=addrank">', System::site()->Submit('Добавить')); } }
function AdminFormsMain() { $forms = System::database()->Select('forms', ''); SortArray($forms, 'new_answ', true); $text = ''; $text .= '<table cellspacing="0" cellpadding="0" class="cfgtable">'; $text .= '<tr> <th>Название</th> <th>Новых ответов</th> <th>Всего ответов</th> <th>Полей</th> <th>Кто видит</th> <th>Статус</th> <th>Функции</th> </tr>'; foreach ($forms as $form) { $id = SafeDB($form['id'], 11, int); $vi = ViewLevelToStr(SafeDB($form['view'], 1, int)); $status = System::admin()->SpeedStatus('Выключить', 'Включить', ADMIN_FILE . '?exe=forms&a=changestatus&id=' . $id, $form['active'], 'images/bullet_green.png', 'images/bullet_red.png'); $answ = SafeDB($form['answ'], 11, int) > 0 ? '<b>' . SafeDB($form['answ'], 11, int) . '</b> / <a href="' . ADMIN_FILE . '?exe=forms&a=posts&id=' . $id . '">Просмотр</a>' : SafeDB($form['answ'], 11, int); $new_answ = SafeDB($form['new_answ'], 11, int) > 0 ? '<b>' . SafeDB($form['new_answ'], 11, int) . '</b> / <a href="' . ADMIN_FILE . '?exe=forms&a=newposts&id=' . $id . '">Просмотр</a>' : SafeDB($form['new_answ'], 11, int); $link_go = Ufu('index.php?name=forms&formlink=' . SafeDB($form['link'], 255, str), 'forms:form'); $func = ''; $func .= System::admin()->SpeedButton('Перейти к странице на сайте', $link_go, 'images/link_go.png', false, false, 'target="_blank"'); $func .= System::admin()->SpeedButton('Редактировать форму', ADMIN_FILE . '?exe=forms&a=edit&id=' . $id, 'images/admin/edit.png'); $func .= System::admin()->SpeedButton('Редактировать поля', ADMIN_FILE . '?exe=forms&a=fields&id=' . $id, 'images/admin/config.png'); $func .= System::admin()->SpeedConfirm('Удалить форму', ADMIN_FILE . '?exe=forms&a=del&id=' . $id, 'images/admin/delete.png', 'Удалить форму?'); $text .= '<tr> <td><b>' . System::admin()->Link(SafeDB($form['hname'], 255, str), ADMIN_FILE . '?exe=forms&a=edit&id=' . $id) . '</a></b></td> <td>' . $new_answ . '</td> <td>' . $answ . '</td> <td>' . SafeDB($form['numfields'], 11, int) . '</td> <td>' . $vi . '</td> <td>' . $status . '</td> <td>' . $func . '</td> </tr> '; } $text .= '</table><br />'; AddTextBox('Web-формы', $text); }
function AdminViewRetrofittingList() { if (!AdminConfigPlugins()) { $access_config = 'System::config('; } else { $access_config = 'System::plug_config('; } $back = SaveRefererUrl(); $groupid = 1; if (isset($_GET['group'])) { $groupid = SafeEnv($_GET['group'], 11, int); } $groups_data = array(); $groups = array(); System::admin()->DataAdd($groups_data, 0, 'Все группы', $groupid == 0); System::database()->Select(AdminConfigGroupTable()); SortArray(System::database()->QueryResult, 'hname'); while ($group = System::database()->FetchRow()) { $sel = false; if ($groupid != 0) { $sel = $group['id'] == $groupid; } System::admin()->DataAdd($groups_data, SafeDB($group['id'], 11, int), SafeDB($group['hname'], 255, str), $sel); $groups[$group['id']] = $group; } System::admin()->AddCenterBox('Все настройки'); System::admin()->AddJS(Indent(' RetrofittingSelectGroup = function(){ Admin.LoadPage("' . ADMIN_FILE . '?exe=config_admin' . (AdminConfigPlugins() ? '&a=view_all_plugins&plugins=1' : '') . '&group="+$("#retrofitting-group").val()); } ')); $text = '<div style="text-align: left; margin-bottom: 10px;">Группа: ' . System::site()->Select('group', $groups_data, false, 'id="retrofitting-group" onchange="RetrofittingSelectGroup();"') . '</div>'; System::admin()->AddText($text); System::database()->Select(AdminConfigConfigTable(), $groupid > 0 ? "`group_id`='{$groupid}'" : ''); SortArray(System::database()->QueryResult, 'name'); $text = '<table cellspacing="0" cellpadding="0" class="cfgtable">'; $text .= Indent(' <tr> <th>№</th> <th>Настройка</th> <th>PHP код</th> <th>Видимая</th> <th>Функции</th> </tr> '); $id = 0; while ($conf = System::database()->FetchRow()) { $id++; $confid = SafeDB($conf['id'], 11, int); $func = ''; $func .= System::admin()->SpeedButton('Редактировать', ADMIN_FILE . '?exe=config_admin&a=edit&id=' . $confid . (AdminConfigPlugins() ? '&plugins=1' : '') . '&back=' . $back, 'images/admin/edit.png'); $func .= System::admin()->SpeedConfirm('Удалить', ADMIN_FILE . '?exe=config_admin&a=delete&id=' . $confid . '&ok=0' . (AdminConfigPlugins() ? '&plugins=1' : '') . '&back=' . $back, 'images/admin/delete.png', 'Это может повлиять на работу системы. Нажмите отмена, если не уверены. Удалить настройку?'); $access = $access_config . "<span style=\"color: #008200\">'" . SafeDB($groups[$conf['group_id']]['name'], 255, str) . '/' . "" . SafeDB($conf['name'], 255, str) . "'</span>)"; // $install_vals = Values('', $conf['group_id'], $conf['name'], $conf['value'], // $conf['visible'], $conf['hname'], $conf['description'], $conf['kind'], // $conf['values'], $conf['savefunc'], $conf['type'], $conf['autoload']); // $install = 'System::database()->Insert("'.AdminConfigConfigTable().'","'.$install_vals.'");'; if ($conf['visible'] == '1') { $visible = '<font color="#008000">Да</font>'; } else { $visible = '<font color="#FF0000">Нет</font>'; } $text .= Indent(' <tr> <td>' . $id . '</td> <td style="text-align: left; padding-left: 10px; ' . ($conf['visible'] == '0' ? 'color: #888;' : '') . '">' . SafeDB($conf['hname'], 255, str) . '</td> <td style="text-align: left; padding-left: 10px;">' . $access . '</td> <td>' . $visible . '</td> <td>' . $func . '</td> </tr> '); } $text .= '</table>'; if (isset($_GET['saveok'])) { System::admin()->Highlight('Изменения сохранены.'); } elseif (isset($_GET['addok'])) { System::admin()->Highlight('Настройка добавлена.'); } elseif (isset($_GET['delok'])) { System::admin()->Highlight('Настройка удалена.'); } System::admin()->AddText($text); }
/** * Главная страница, список новостей * @return void */ function AdminNewsMain() { global $news_access_editnews; System::admin()->AddSubTitle('Главная'); $back = SaveRefererUrl(); // Количество новостей на странице if (isset($_REQUEST['onpage'])) { $num = intval($_REQUEST['onpage']); } else { $num = System::config('news/newsonpage'); } if (isset($_REQUEST['page'])) { $page = intval($_REQUEST['page']); } else { $page = 1; } $newsdb = System::database()->Select('news'); $columns = array('title', 'date', 'hit_counter', 'comments_counter', 'view', 'enabled'); $sortby = 'date'; $sortbyid = 1; $desc = true; if (isset($_REQUEST['sortby'])) { $sortby = $columns[$_REQUEST['sortby']]; $sortbyid = intval($_REQUEST['sortby']); $desc = $_REQUEST['desc'] == '1'; } SortArray($newsdb, $sortby, $desc); // Выводим новости UseScript('jquery_ui_table'); $table = new jQueryUiTable(); $table->listing = ADMIN_FILE . '?exe=news&ajax'; $table->del = ADMIN_FILE . '?exe=news&a=delete'; $table->total = count($newsdb); $table->onpage = $num; $table->page = $page; $table->sortby = $sortbyid; $table->sortdesc = $desc; $table->AddColumn('Заголовок'); $table->AddColumn('Дата', 'left', true, true); $table->AddColumn('Просмотров', 'right'); $table->AddColumn('Комментарий', 'right'); $table->AddColumn('Кто видит', 'center'); $table->AddColumn('Статус', 'center'); $table->AddColumn('Функции', 'center', false, true); $newsdb = ArrayPage($newsdb, $num, $page); // Берем только новости с текущей страницы foreach ($newsdb as $news) { $id = SafeDB($news['id'], 11, int); $status = System::admin()->SpeedStatus('Выключить', 'Включить', ADMIN_FILE . '?exe=news&a=changestatus&id=' . $id, $news['enabled'], 'images/bullet_green.png', 'images/bullet_red.png'); $view = ViewLevelToStr(SafeDB($news['view'], 1, int)); $allowComments = SafeDB($news['allow_comments'], 1, bool); $comments = SafeDB($news['comments_counter'], 11, int); // Количество комментарий $title = SafeDB($news['title'], 255, str); $func = ''; $link_go = Ufu('index.php?name=news&op=readfull&news=' . $id . '&topic=' . SafeDB($news['topic_id'], 11, int), 'news/{topic}/{news}/'); $func .= System::admin()->SpeedButton('Перейти к странице на сайте', $link_go, 'images/link_go.png', false, false, 'target="_blank"'); if ($news_access_editnews) { $func .= System::admin()->SpeedButton('Редактировать', ADMIN_FILE . '?exe=news&a=edit&id=' . $id . '&back=' . $back, 'images/admin/edit.png'); $func .= System::admin()->SpeedConfirmJs('Удалить', '$(\'#jqueryuitable\').table(\'deleteRow\', ' . $id . ');', 'images/admin/delete.png', 'Уверены, что хотите удалить эту новость?'); $title = '<b>' . System::admin()->Link($title, ADMIN_FILE . '?exe=news&a=edit&id=' . $id . '&back=' . $back) . '</b>'; } $table->AddRow($id, $title, TimeRender(SafeDB($news['date'], 11, int)), SafeDB($news['hit_counter'], 11, int), $allowComments ? $comments : 'Обсуждение закрыто', $view, $status, $func); } if (isset($_GET['ajax'])) { echo $table->GetOptions(); exit; } else { $table->AddTable('Новости'); } }
function ForumModerationMergePosts($posts, $begin) { global $forum_lang; if (!$begin) { return $forum_lang['merge_posts']; } $posts = System::database()->Select('forum_posts', '(`id`=\'' . implode('\' or `id`=\'', $posts) . '\') and `delete`=\'0\''); $merged_posts = count($posts); if ($merged_posts < 2) { return false; } SortArray($posts, 'public', false); $post = $posts[0]; // Тема $topic_id = SafeEnv($post['object'], 11, int); System::database()->Select('forum_topics', "`id`='{$topic_id}'"); if (System::database()->NumRows() == 0) { System::site()->AddTextBox($forum_lang['error'], $forum_lang['error_no_topic']); return false; } $topic = System::database()->FetchRow(); if ($topic['delete'] == '1') { // Тема на удалении System::site()->AddTextBox($forum_lang['error'], $forum_lang['topic_basket']); return false; } // Форум $forum_id = SafeEnv($topic['forum_id'], 11, int); System::database()->Select('forums', "`id`='{$forum_id}'"); if (System::database()->NumRows() == 0) { System::site()->AddTextBox($forum_lang['error'], $forum_lang['error_no_forum']); return false; } $forum = System::database()->FetchRow(); // Объединяем сообщения и удаляем старые $new_post_message = ''; $where = ''; foreach ($posts as $p) { if ($new_post_message != '') { $where .= "`id`='" . SafeEnv($p['id'], 11, int) . "' or "; } $new_post_message .= $p['message'] . "\r\n\r\n"; } $new_post_message = SafeEnv($new_post_message, 0, str); $post_id = SafeEnv($post['id'], 11, int); System::database()->Update('forum_posts', "`message`='{$new_post_message}'", "`id`='{$post_id}'"); $where = substr($where, 0, strlen($where) - 4); if ($where != '') { System::database()->Delete('forum_posts', $where); } if ($merged_posts >= 2) { // Обновляем тему $topic_posts = (int) $topic['posts'] - ($merged_posts - 1); if ($topic_posts < 0) { $topic_posts = 0; } $topic_set = "`posts`='{$topic_posts}'"; ForumSetLastPost($topic_id, $topic_set); // Обновляем форум $forum_posts = (int) $forum['posts'] - ($merged_posts - 1); if ($forum_posts < 0) { $forum_posts = 0; } $forum_set = "`posts`='{$forum_posts}'"; ForumSetLastTopic($forum_id, $forum_set); } ForumCacheClear(); return true; }
function IndexGBMain() { if (isset($_GET['page'])) { $page = SafeEnv($_GET['page'], 10, int); } else { $page = 1; } $msgs = System::database()->Select('guestbook', "`premoderate`='1'"); SortArray($msgs, 'date', true); $num = System::config('gb/msgonpage'); $navigation = new Navigation($page); $navigation->FrendlyUrl = System::config('general/ufu'); $navigation->GenNavigationMenu($msgs, $num, Ufu('index.php?name=guestbook', 'guestbook/page{page}/', true)); System::site()->AddBlock('guestbook', true, true, 'gb'); if (count($msgs) > 0) { foreach ($msgs as $message) { IndexGBAddMessage($message); } } else { System::site()->AddTextBox('', '<p align="center">Сообщений пока нет.</p>'); } System::site()->AddTemplatedBox('', 'module/guestbook.html'); IndexGBAddForm(System::config('gb/formposition') == 'top'); }
/** * Выбирает записи из таблицы. * @param $Name Имя таблицы * @param string $Where Условия выборки * @param null $Limit Ограничение выборки, число первых элментов, или массив array(start, length) * @param null $Order Сортировка результатов (имя колонки или массив колонок) * @param bool $OrderDesc Сортировать в обратном порядке (логическое значение или массив значений) * @return mixed */ public function &Select($Name, $Where = '', $Limit = null, $Order = null, $OrderDesc = false) { //echo "SELECT $name WHERE $where;\n"; $this->StartQ('Database->Select()'); $data = $this->GetTableData($Name); $info = $this->_GetTableInfo($Name); $result = array(); $i = 0; if ($Where != '') { foreach ($data as &$row) { if (Parser_ParseWhereStr($Where, $row, $info, $i)) { if (isset($row[0])) { foreach ($info["cols"] as $cid => $col) { $row[$col["name"]] =& $row[$cid]; unset($row[$cid]); } } $result[] =& $row; } $i++; } } else { foreach ($data as &$row) { if (isset($row[0])) { foreach ($info["cols"] as $cid => $col) { $row[$col["name"]] =& $row[$cid]; unset($row[$cid]); } } } $result =& $data; } if (isset($Order)) { SortArray($result, $Order, $OrderDesc); } if (isset($Limit)) { if (!is_array($Limit)) { $Limit = array(0, $Limit); } $result = array_slice($result, $Limit[0], $Limit[1]); } $this->Good(); return $this->SetResult($result); }
function AdminAdminMenuAjaxMove() { $table = 'adminmenu'; $itemId = SafeEnv($_POST['item_id'], 11, int); $parentId = SafeEnv($_POST['target_id'], 11, int); $position = SafeEnv($_POST['item_new_position'], 11, int); // Перемещаемый элемент System::database()->Select($table, "`id`='{$itemId}'"); if (System::database()->NumRows() == 0) { // Error exit; } $item = System::database()->FetchRow(); // Изменяем его родителя, если нужно if ($item['parent'] != $parentId) { System::database()->Update($table, "`parent`='{$parentId}'", "`id`='{$itemId}'"); } // Обноеление индексов элементов $indexes = array(); // соотвествие индексов и id элементов $items = System::database()->Select($table, "`parent`='{$parentId}'"); if ($position == -1) { $position = count($items); } SortArray($items, 'order'); $i = 0; foreach ($items as $p) { if ($p['id'] == $itemId) { $indexes[$p['id']] = $position; } else { if ($i == $position) { $i++; } $indexes[$p['id']] = $i; $i++; } } // Обновляем индексы foreach ($indexes as $id => $order) { System::database()->Update($table, "`order`='{$order}'", "`id`='{$id}'"); } Audit('Админ-меню: Перемещение элемента'); exit; }
<?php /** * Write a procedure SortArray(A, N) that sorts an array A of N real numbers in ascending order. * The array A is an input and output parameter. Using this procedure, sort three given arrays * A, B, C of size NA, NB, NC respectively. */ include 'helper.php'; function SortArray(&$A, $N = 0) { $N = sizeof($A); $min = 0; for ($i = 0; $i < $N; $i++) { for ($j = 0; $j < $N; $j++) { if ($A[$i] < $A[$j]) { $min = $A[$j]; $A[$j] = $A[$i]; $A[$i] = $min; } } } //asort($A); } $arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]; print_r($arr); echo '<br/>'; SortArray($arr); print_r($arr); echo '<br/>';
function AdminAuditReferers() { System::admin()->AddCenterBox('Переходы с сайтов (Рефералы)'); $query = System::database()->Select('referers', ''); SortArray($query, 'count', true); $allcount = 0; $count = count($query); if (isset($_GET['page'])) { $page = SafeEnv($_GET['page'], 10, int); } else { $page = 1; } $num = 50; if ($count > $num) { $navigator = new Navigation($page); $navigator->GenNavigationMenu($query, $num, ADMIN_FILE . '?exe=audit&a=referers'); $nav = true; } else { $nav = false; } if ($count == 0) { System::admin()->Highlight('Рефералов не было обнаружено.'); } elseif ($count >= 1) { $text = '<table cellspacing="0" cellpadding="0" class="cfgtable">'; $text .= Indent('<tr> <th>Реферал</th> <th>Переходов</th> </tr>'); foreach ($query as $q) { $referer = 'http://' . $q['referer']; $title = AdminAuditDecodeUrl($referer); $count = SafeDB($q['count'], 11, int); $allcount += $count; $text .= '<tr> <td><a href="' . $referer . '" target="_blank">' . $title . '</a></td> <td>' . $count . '</td> </tr>'; } $text .= '</table>'; $text .= 'Всего переходов на этой странице: <b>' . $allcount . '</b>. ' . System::admin()->SpeedConfirm('Очистить лог', ADMIN_FILE . '?exe=audit&a=clear_referers', '', 'Очистить лог рефералов?', true, true); AddText($text); if ($nav) { AddNavigation(); } } }
} } if (count($backup_files2) > 0) { $last_backup_name = SafeDB($backup_files2[0], 255, str); } else { $last_backup_name = ''; } $sort = 'name'; $sort_dec = false; if (isset($_GET['sort'])) { $sort = $_GET['sort']; } if (isset($_GET['dec'])) { $sort_dec = true; } SortArray($tables, $sort, $sort_dec); $top_text = ''; $top_text .= '<strong>БД:</strong> ' . System::database()->SelectDbName . '<br>'; if (System::database()->Name == 'FilesDB') { $mode = 'Файловая база данных'; } else { $mode = 'MySQL'; } $top_text .= '<strong>Режим</strong>: ' . $mode . '<br>'; $text = ''; $text .= '<table cellspacing="0" cellpadding="0" class="cfgtable">' . '<tr> <th>#</th> <th>' . System::admin()->Link('Таблица', ADMIN_FILE . '?exe=dbadmin&sort=name' . ($sort == 'name' && !$sort_dec ? '&dec=1' : ''), 'Сортировать') . '</th> <th>' . System::admin()->Link('Записей', ADMIN_FILE . '?exe=dbadmin&sort=num_rows' . ($sort == 'num_rows' && !$sort_dec ? '&dec=1' : ''), 'Сортировать') . '</th> <th>' . System::admin()->Link('Размер', ADMIN_FILE . '?exe=dbadmin&sort=size' . ($sort == 'size' && !$sort_dec ? '&dec=1' : ''), 'Сортировать') . '</th> <th>Тип</th>
function AdminForumMove() { $itemId = SafeEnv($_POST['item_id'], 11, int); $parentId = SafeEnv($_POST['target_id'], 11, int); $position = SafeEnv($_POST['item_new_position'], 11, int); // Перемещаемый элемент System::database()->Select('forums', "`id`='{$itemId}'"); if (System::database()->NumRows() == 0) { // Error exit("ERROR"); } $item = System::database()->FetchRow(); // Изменяем его родителя, если нужно if ($item['parent_id'] != $parentId) { System::database()->Update('forums', "`parent_id`='{$parentId}'", "`id`='{$itemId}'"); } // Обноеление индексов элементов $indexes = array(); // соотвествие индексов и id элементов $items = System::database()->Select('forums', "`parent_id`='{$parentId}'"); if ($position == -1) { $position = count($items); } SortArray($items, 'order'); $i = 0; foreach ($items as $p) { if ($p['id'] == $itemId) { $indexes[$p['id']] = $position; } else { if ($i == $position) { $i++; } $indexes[$p['id']] = $i; $i++; } } // Обновляем индексы foreach ($indexes as $id => $order) { System::database()->Update('forums', "`order`='{$order}'", "`id`='{$id}'"); } Audit('Форум: Перемещение форума "' . $item['title'] . '"'); ForumCacheClear(); exit("OK"); }
function IndexMailShowId() { if (isset($_GET['topic_id'])) { $topic_id = SafeEnv($_GET['topic_id'], 11, int); } else { GO(GetSiteUrl() . Ufu('index.php?name=mail&op=topics', 'mail/{op}/')); } if (isset($_GET['id'])) { $id = SafeEnv($_GET['id'], 11, int); } else { GO(GetSiteUrl() . Ufu('index.php?name=mail&op=topics', 'mail/{op}/')); } $mails = System::database()->Select('mail_history', "`topic_id`='{$topic_id}'"); SortArray($mails, 'date', false); $prev_id = false; $next_id = false; $find = false; for ($i = 0, $c = count($mails); $i < $c; $i++) { if ($mails[$i]['id'] == $id) { if ($i < $c - 1) { $next_id = $mails[$i + 1]['id']; } if ($i > 0) { $prev_id = $mails[$i - 1]['id']; } $mail = $mails[$i]; $find = true; break; } } if (!$find) { GO(GetSiteUrl() . Ufu('index.php?name=mail&op=topics', 'mail/{op}/')); } System::site()->AddTemplatedBox('', 'module/mail_showid_nav.html'); System::site()->AddBlock('mail_nav'); $vars['lprev'] = 'Предыдущий выпуск'; $vars['lnext'] = 'Следующий выпуск'; $vars['lback'] = 'Назад к списку'; $vars['prev_id'] = $prev_id; $vars['next_id'] = $next_id; $vars['back'] = true; $vars['prev_url'] = Ufu("index.php?name=mail&op=showid&topic_id={$topic_id}&id={$prev_id}", 'mail/show/topic{topic_id}/id{id}/'); $vars['back_url'] = Ufu("index.php?name=mail&op=history&topic_id={$topic_id}", 'mail/history/topic{topic_id}/'); $vars['next_url'] = Ufu("index.php?name=mail&op=showid&topic_id={$topic_id}&id='.{$next_id}", 'mail/show/topic{topic_id}/id{id}/'); System::site()->Blocks['mail_nav']['vars'] = $vars; System::site()->AddTemplatedBox('Архив рассылки ', 'module/mail_showid.html'); System::site()->AddBlock('mail'); $vars['subject'] = SafeDB($mail['subject'], 255, str); $vars['date'] = TimeRender(SafeDB($mail['date'], 11, int)); $vars['ldate'] = 'Дата выпуска'; $vars['text'] = nl2br(SafeDB($mail['plain_text'], 0, str)); // HTML //($mail[8]?nl2br(SafeDB($mail[7],0,str)):SafeDB($mail[7],0,str)); System::site()->Blocks['mail']['vars'] = $vars; System::site()->AddTemplatedBox('', 'module/mail_down_tab.html'); System::site()->AddBlock('mail_down_tab'); $vars['lsubscribe'] = 'Подписаться на эту рассылку.'; $vars['subscribe_url'] = Ufu("index.php?name=mail&op=subscribe&topic_id={$topic_id}", 'mail/subscribe/topic{topic_id}/'); System::site()->Blocks['mail_down_tab']['vars'] = $vars; }
function AdminGuestBookPremoderationMain() { System::admin()->AddCenterBox('Премодерация'); $premoderation = System::user()->CheckAccess2('guestbook', 'premoderation'); $premoderate = System::database()->Select('guestbook', "`premoderate`='0'"); if (System::database()->NumRows() == 0) { System::admin()->Highlight('В премодерации нет сообщений.'); return; } if (isset($_GET['page'])) { $page = SafeEnv($_GET['page'], 10, int); } else { $page = 1; } SortArray($premoderate, 'date', true); $num = System::config('gb/msgonpage'); if (count($premoderate) > $num) { $navigator = new Navigation($page); $navigator->GenNavigationMenu($premoderate, $num, ADMIN_FILE . '?exe=guestbook&a=premoderation'); $nav = true; } else { $nav = false; } $text = ''; $back = SaveRefererUrl(); foreach ($premoderate as $pre) { if ($pre['url'] == '') { $url = 'Нет'; } else { $url = '<a href="http://' . SafeDB($pre['url'], 250, str) . '" target="_blank">' . SafeDB($pre['url'], 250, str) . '</a>'; } if ($pre['email'] == '') { $name = SafeDB($pre['name'], 50, str); } else { $name = PrintEmail($pre['email'], $pre['name']); } $mid = SafeDB($pre['id'], 11, int); $del = System::admin()->SpeedConfirm('Удалить сообщение', ADMIN_FILE . '?exe=guestbook&a=delete&id=' . $mid . '&back=' . $back, 'images/admin/delete.png', 'Удалить сообщение?'); $func2 = ''; $func2 = System::admin()->Link('Разрешить', ADMIN_FILE . '?exe=guestbook&a=prem_yes&id=' . $mid . '&back=' . $back); $text .= '<table cellspacing="0" cellpadding="0" class="commtable" style="width:75%;">'; $text .= '<tr> <th style="text-align: left; width: 180px;">' . $name . '</th> <th style="width: 160px;">Сайт: ' . $url . '</th> <th style="width: 120px;">ICQ: ' . SafeDB($pre['icq'], 15, str) . '</th> <th style="width: 120px;">IP: ' . SafeDB($pre['user_ip'], 20, str) . '</th> <th> ' . $del . ' </th> </tr>'; $text .= '<tr><td colspan="5" style="text-align:left;padding:10px;" class="commtable_text">' . SafeDB($pre['message'], 0, str) . '</td></tr>'; $text .= '<tr><th>Дата: ' . TimeRender($pre['date']) . '</th><th colspan="4" style="text-align:right;">' . $func2 . '</th></tr>'; $text .= '</table>'; } AddText($text); if ($nav) { AddNavigation(); } AddText('<div style="text-align: center;">' . System::admin()->SpeedConfirm('Разрешить все', ADMIN_FILE . '?exe=guestbook&a=prem_yes_all&back=' . $back, 'images/admin/accept.png', 'Разрешить все сообщения?', true, true) . ' ' . System::admin()->SpeedConfirm('Удалить все', ADMIN_FILE . '?exe=guestbook&a=prem_del_all&back=' . $back, 'images/admin/delete.png', 'Удалить все сообщения?', true, true) . '</div>'); }
function IndexForumShowTopic($one_post = false) { global $forum_lang; $forums_tree = ForumTree::Instance(); // Вспомогательные переменные $user_auth = System::user()->Auth; $user_id = System::user()->Get('u_id'); $user_admin = System::user()->isAdmin(); $time = time(); $max_word_length = System::config('forum/max_word_length'); if (isset($_GET['topic'])) { $topic_id = SafeEnv($_GET['topic'], 11, int); } else { System::site()->AddTextBox($forum_lang['error'], $forum_lang['error_no_topic']); return; } // Берём тему и проверяем на доступ System::database()->Select('forum_topics', "`id`='" . $topic_id . "'"); if (System::database()->NumRows() == 0) { System::site()->AddTextBox($forum_lang['error'], $forum_lang['error_no_topic']); return; } $topic = System::database()->FetchRow(); if (!$user_admin && $topic['starter_id'] == $user_id && $topic['delete'] == '1') { // Тема удалена в корзину (только админы видят корзину и автор темы) System::site()->AddTextBox($forum_lang['topic_basket_current_post'], '<p align="center">' . $forum_lang['topic_basket_post'] . '.<br><input type="button" value="' . $forum_lang['back'] . '"onclick="history.back();"></p>'); return; } // Проверяем доступ к форуму $forum_id = SafeEnv($topic['forum_id'], 11, int); $forum_config = $forums_tree->GetForumConfigRecursive($forum_id); // Параметры доступа на форум if (!$forum_config['access']) { System::site()->AddTextBox($forum_lang['error'], $forum_config['access_reason']); // Нет доступа в этот форум return; } // $forum_config['add_post'] - право добавлять сообщения // $forum_config['add_post_reason'] - причина запрета добавления сообщений // $forum_config['no_link_guest'] - скрывать ссылки от гостей // $forum_config['new_message_email'] - разрешить подписку на новые сообщения // Определяем следующую и предыдущую темы $topics_data = ForumCacheGetTopics(); $topics_data = $topics_data[$forum_id]; $prev_topic = null; $next_topic = null; $find = false; foreach ($topics_data as $topic_row) { if ($topic_row['id'] == $topic_id) { $find = true; continue; } if ($find) { $next_topic = $topic_row; break; } $prev_topic = $topic_row; } // Параметры постраничной навигации if (isset($_GET['page'])) { $page = SafeEnv($_GET['page'], 11, int); } else { $page = 1; } if (isset($_GET['view']) && $_GET['view'] == 'lastpost') { $lastpost = true; } else { $lastpost = false; } $posts_on_page = System::config('forum/posts_on_page'); // Обновляем метку о прочтении темы, если пользователь авторизован if ($user_auth) { System::database()->Delete('forum_topics_read', "`tid`='{$topic_id}' and `mid`='{$user_id}'"); System::database()->Insert('forum_topics_read', "'{$user_id}','{$topic_id}','{$time}'"); } // Объект онлайн $online = ForumOnline::Instance($forum_id, $topic_id); // Устанавливаем заголовок страницы $topic_title = SafeDB($topic['title'], 255, str); System::site()->SetTitle($topic_title . ($page > 1 ? ' - Страница ' . $page : '')); // Хлебные крошки $forums_tree->BreadCrumbsF($forum_id); System::site()->BreadCrumbAdd(SafeDB($topic['title'], 255, str)); // Добавляем корзину (если тема удалена в корзину) if ($topic['delete'] == '1') { $basket_topics = ForumBasketGetData('forum_basket_topics'); if (isset($basket_topics[$topic['id']])) { System::site()->AddTextBox($forum_lang['topic_basket_red'], ForumBasketRender($topic['id'], $topic['title'], $basket_topics, true)); } } // Увеличиваем счётчик просмотров System::database()->Update('forum_topics', "`hits`='" . (SafeDB($topic['hits'], 11, int) + 1) . "'", "`id`='" . $topic_id . "'"); // Инициализируем постраничную навигацию $navigation = new Navigation($page); $navigation->FrendlyUrl = System::config('general/ufu'); // Загружаем сообщения из базы данных $basket_where = ''; // Администратор (подготавливаем запрос выборки т.к. нужно знать сколько всего сообщений для постр. навигации) if ($user_auth) { if (!$user_admin) { $basket_where = " and (`delete`='0' or `user_id`='{$user_id}')"; // Пользователь } } else { $basket_where = " and `delete`='0'"; // Гость } $posts = System::database()->Select('forum_posts', ($one_post !== false ? "`id`='{$one_post}'" : "`object`='{$topic_id}'") . $basket_where); SortArray($posts, 'public', false); //Сортируем по дате // Вывод постраничной навигации if (count($posts) > $posts_on_page) { if ($lastpost) { $page = ceil(count($posts) / $posts_on_page); } $navigation->GenNavigationMenu($posts, $posts_on_page, Ufu('index.php?name=forum&op=showtopic&topic=' . $topic_id, 'forum/topic' . $topic_id . '-{page}.html', true), $page); } else { $navigation->DisableNavigation(); } // Загружаем корзину для сообщений $basket = ForumBasketGetData('forum_basket_post'); // Блок с информацией о теме System::site()->AddBlock('topic', true, false); System::site()->SetVars('topic', ForumTopicFilterData($topic)); // Блок шаблонизатора для вывода сообщений System::site()->AddBlock('forum_posts', true, true, 'post'); $is_forum_member = AccessIsResolved(2); // Для определения первого и последнего сообщения $i = 1; // Выводим сообщения в шаблонизатор foreach ($posts as $post) { $post_user_id = SafeDB($post['user_id'], 11, int); if ($post_user_id == 0) { continue; } $vars = array(); // Обрабатываем текст сообщения if ($post['delete'] == '1') { // Сообщение удалено в корзину $vars['text'] = ForumBasketRender($post['id'], $post['message'], $basket); } else { $vars['text'] = HtmlChars($post['message']); if ($forum_config['no_link_guest']) { // Скрываем ссылки от гостей $replace = '<p class="notice">' . $forum_lang['hide_links_for_guests'] . '</p>'; $vars['text'] = preg_replace('/\\<a[^\\>]*?(http|https|ftp|www)(.*?)\\<\\/a\\>/is', $replace, $vars['text']); $vars['text'] = preg_replace('/(http:\\/\\/|https:\\/\\/|ftp:\\/\\/|www\\.)?([a-zA-Z0-9]+)\\.(ru|su|com|org|net|info|name|ws|cc|tv|tel|kz|biz|mobi|asia|me|tw|ua)+([а-яА-Яa-zA-Z0-9\'~;,@#%&_\\!\\$\\^\\*\\(\\)\\-\\=\\+\\?\\.\\:\\/\\\\]*)?/is', $replace, $vars['text']); } SmiliesReplace($vars['text']); $vars['text'] = nl2br($vars['text']); $vars['text'] = BbCodePrepare($vars['text']); if ($max_word_length > 0) { $vars['text'] = word_wrapped_string($vars['text'], $max_word_length); } } // Обрабатываем данные сообщения // Пользователь $user_info = GetUserInfo($post_user_id); $vars['usertopics'] = '<a href="' . Ufu('index.php?name=forum&op=usertopics&user='******'forum/usertopics/{user}/') . '">' . $forum_lang['allusertopics'] . '</a>'; if ($user_info['rank_name'] != '') { $vars['author'] = '<a href="' . Ufu('index.php?name=user&op=userinfo&user='******'user/{user}/info/') . '">' . $user_info['name'] . '</a>'; $vars['author_name'] = $user_info['name']; } else { $vars['author'] = $post['name']; $vars['author_name'] = $post['name']; } if ($user_info['hideemail'] == '0') { $vars['email'] = AntispamEmail($user_info['email']); } else { $vars['email'] = ' '; } if ($user_info['url'] != '') { $vars['homepage'] = '<a href="http://' . $user_info['url'] . '" target="_blank">' . $user_info['url'] . '</a>'; } else { $vars['homepage'] = ' '; } $vars['icq'] = $user_info['icq']; if ($user_info['online']) { $vars['status'] = $forum_lang['user_online']; } else { $vars['status'] = ''; } $vars['rank_image'] = $user_info['rank_image'] != '' ? $user_info['rank_image'] : ''; $vars['rank_name'] = $user_info['rank_name'] != '' ? $user_info['rank_name'] : ''; $vars['avatar'] = $user_info['avatar_file'] != '' ? $user_info['avatar_file'] : GetPersonalAvatar(0); $vars['regdate'] = TimeRender($user_info['regdate'], false, true); if (isset($user_info['data']['forum_counters'])) { $vars['user_posts_count'] = $user_info['data']['forum_counters']['posts']; $vars['user_topics_count'] = $user_info['data']['forum_counters']['topics']; } else { $vars['user_posts_count'] = '0'; $vars['user_topics_count'] = '0'; } // Сообщение $vars['public'] = $forum_lang['added'] . TimeRender($post['public']); $vars['public_date'] = TimeRender($post['public']); $vars['ip'] = SafeDB($post['user_ip'], 19, str); $vars['topic_id'] = $topic_id; $vars['id'] = SafeDB($post['id'], 11, int); $vars['nodelete'] = SafeDB($post['delete'], 1, int) == 1 ? false : true; $vars['is_admin_and_nodelete'] = $vars['nodelete'] && $user_admin; $vars['page'] = $page; // is_current_user Пользователь является владельцем сообщения (кнопки редактировать и удалить) if ($post['delete'] == '0') { $vars['is_current_user'] = $user_id == $post['user_id'] && $topic['close_topics'] == '0' || $user_admin; } else { $vars['is_current_user'] = false; } if ($one_post === false) { $vars['num'] = $page > 1 ? $page * $posts_on_page - $posts_on_page + $i : $i; $vars['url'] = "javascript:link_post('" . GetSiteUrl() . Ufu("index.php?name=forum&op=post&topic=" . $topic_id . "&post=" . $post['id'], 'forum/t{topic}/post{post}.html') . "')"; } else { $vars['num'] = ''; $vars['url'] = 'javascript:history.go(-1)'; } $vars['is_forum_member'] = $is_forum_member; System::site()->AddSubBlock('forum_posts', true, $vars, array(), 'module/forum_post.html'); $i++; } // Форма добавления сообщений System::site()->AddBlock('post_form', $forum_config['add_post'], false); ForumRenderPostForm(false, $forum_id, $topic_id, 0, '', '', $is_forum_member); // Подписка на тему System::site()->AddBlock('subscription', $forum_config['new_message_email'], false, 'subs'); $vars_subs = array(); $vars_subs['topic'] = $topic_id; $vars_subs['sub_status'] = Forum_Subscription_Status($topic_id); $vars_subs['status'] = $vars_subs['sub_status'] ? 'Отписаться от этой темы' : 'Подписаться на эту тему'; System::site()->SetVars('subscription', $vars_subs); System::site()->AddBlock('is_forum_member', $is_forum_member, false, 'marker'); System::site()->SetVars('is_forum_member', array('id' => $topic_id)); // Подключаем шаблон System::site()->AddTemplatedBox('', 'module/forum_showtopic.html'); // Выводим блок онлайн $online->Render($forum_id, $topic_id, $forum_lang['current_online'], 'forum_online'); // Предыдущая и следующая тема System::site()->AddBlock('forum_prev_topic', isset($prev_topic), false, 'topic'); if (isset($prev_topic)) { System::site()->SetVars('forum_prev_topic', array('url' => Ufu('index.php?name=forum&op=showtopic&topic=' . SafeDB($prev_topic['id'], 11, int), 'forum/topic{topic}.html'), 'title' => SafeDB($prev_topic['title'], 255, str), 'lang_prev_topic' => $forum_lang['prev_topic'])); } System::site()->AddBlock('forum_next_topic', isset($next_topic), false, 'topic'); if (isset($next_topic)) { System::site()->SetVars('forum_next_topic', array('url' => Ufu('index.php?name=forum&op=showtopic&topic=' . SafeDB($next_topic['id'], 11, int), 'forum/topic{topic}.html'), 'title' => SafeDB($next_topic['title'], 255, str), 'lang_next_topic' => $forum_lang['next_topic'])); } // Быстрый переход по форумам ForumQuickTransitionBox($forum_id, $forum_lang['quick_transition']); }
function AdminMailHistory() { System::admin()->AddCenterBox('История рассылки'); if (isset($_GET['topic_id'])) { $topic = SafeEnv($_GET['topic_id'], 11, int); } elseif (isset($_POST['topic'])) { $topic = SafeEnv($_POST['topic_id'], 11, int); } else { System::admin()->Highlight('Тема не указана.'); return; } $msgs = System::database()->Select('mail_history', ''); if (System::database()->NumRows() == 0) { System::admin()->Highlight('Рассылок по данной теме не проводилось.'); return; } if (isset($_GET['page'])) { $page = SafeEnv($_GET['page'], 10, int); } else { $page = 1; } SortArray($msgs, 'date', true); $num = 10; if (count($msgs) > $num) { $nav = new Navigation($page); $nav->GenNavigationMenu($msgs, $num, ADMIN_FILE . '?exe=mail&a=history&topic_id=' . $topic); $nav = true; } else { $nav = false; } $text = '<table cellspacing="0" cellpadding="0" align="center" class="commtable_header" style="width:80%;"> <tr> <th style="width: 120px;">Дата</th> <th style="width: 510px;">Тема</th> <th>Функции</th> </tr></table>'; foreach ($msgs as $msg) { $mid = SafeDB($msg['id'], 11, int); $subject = SafeDB($msg['subject'], 255, str); $date = SafeDB($msg['date'], 11, int); $from = SafeDB($msg['from'], 255, str); $from_email = SafeDB($msg['from_email'], 255, str); $mailtext = nl2br(SafeDB($msg['plain_text'], 0, str)); $func = ''; $func .= System::admin()->SpeedButton('Редактировать письмо', ADMIN_FILE . '?exe=mail&a=edit&id=' . $mid . '&topic_id=' . $topic, 'images/admin/edit.png'); $func .= System::admin()->SpeedConfirm('Удалить письмо', ADMIN_FILE . '?exe=mail&a=delete&id=' . $mid . '&topic_id=' . $topic . '&ok=0', 'images/admin/delete.png', 'Удалить письмо из истории?'); $text .= '<table cellspacing="0" cellpadding="0" class="commtable" style="width:80%;">'; $text .= '<tr> <th style="text-align: left; width: 120px;">' . TimeRender($date) . '</td> <th style="text-align: left; width: 510px;">' . $subject . '</td> <th>' . $func . '</td> </tr>'; $text .= '<tr><td colspan="3" class="commtable_text">' . $mailtext . '</td></tr>'; $text .= '</table>'; } AddText($text); if ($nav) { AddNavigation(); } }
/** * Генерирует регулярное выражение на основе шаблона и параметров. * @param $UfuTemplate Шаблон по которому генерировать регулярное выражение. * @param $Params Параметры, массив или строка вида "name=value&name2=val". * @param bool $PatternsInParams Использовать шаблоны значений из параметров. * @return array (RegExp, Replace) * @since 1.4.1 */ function UfuGeneratePattern($UfuTemplate, $Params, $PatternsInParams = false) { if (is_string($Params)) { parse_str($Params, $Params); } $r_patterns = array('{num}' => '([0-9]+)', '{ustr}' => '([\\pL_\\-\\.\\ 0-9]+)', '{str}' => '([a-zA-Z_\\-\\.\\ 0-9]+)'); // Определяем позиции параметров в шаблоне чтобы установить параметры замены в нужном месте $temp_pos = array(); foreach ($Params as $key => $val) { $p = strpos($UfuTemplate, '{' . $key . '}'); if ($p !== false) { $temp_pos[] = array($p, $key); } } SortArray($temp_pos, 0); $pos = array(); foreach ($temp_pos as $key => $val) { $pos[$val[1]] = $key + 1; } // Генерируем регулярное выражение и шаблон замены $replace = array(); $ReplacePattern = ''; foreach ($Params as $key => $val) { if (strpos($UfuTemplate, '{' . $key . '}') !== false) { $param_pattern = ''; if ($val != '') { if ($PatternsInParams) { if (isset($r_patterns[$val])) { $param_pattern = $r_patterns[$val]; } else { $param_pattern = '(' . $val . ')'; } } else { if (is_numeric($val)) { $param_pattern = '([0-9]+)'; } else { $param_pattern = '([\\pL_\\-\\.\\ 0-9]+)'; } } } $replace['\\{' . $key . '\\}'] = $param_pattern; $ReplacePattern .= "{$key}=\${$pos[$key]}&"; } else { $ReplacePattern .= "{$key}={$val}&"; } } if (substr($ReplacePattern, -1) == '&') { $ReplacePattern = substr($ReplacePattern, 0, -1); } $Pattern = strtr(preg_quote($UfuTemplate, '/'), $replace); return array($Pattern, $ReplacePattern); }
function IndexUserlist() { System::site()->SetTitle('Список пользователей'); System::site()->BreadCrumbAdd('Список пользователей'); $page = 0; if (isset($_GET['page'])) { $page = SafeEnv($_GET['page'], 11, int); } else { $page = 1; } $users = System::database()->Select('users', "`active`='1'"); SortArray($users, 'points', true); // regdate SortArray($users, 'type', false); // type $num = System::config('user/users_on_page'); $navigation = new Navigation($page); $navigation->FrendlyUrl = System::site()->Ufu; $navigation->GenNavigationMenu($users, $num, Ufu('index.php?name=user&op=userslist', 'user/users/page{page}/', true)); System::site()->AddTemplatedBox('Список пользователей', 'module/user_list.html'); System::site()->AddBlock('userlist_th', true, false, 'title'); System::site()->Blocks['userlist_th']['vars'] = array('name' => 'Имя', 'email' => 'E-mail', 'date' => 'Дата регистрации', 'last_visit' => 'Посл. посещение', 'last' => 'Посл. посещение', 'rank' => 'Ранг/статус'); System::site()->AddBlock('userlist', true, true, 'user'); foreach ($users as $usr) { $vars = array(); $rank_stat = GetUserRank($usr['points'], $usr['type'], $usr['access']); $rank_stat = $rank_stat[0]; $vars['avatar'] = GetUserAvatar($usr['id']); $vars['avatar_small'] = GetSmallUserAvatar($usr['id'], $vars['avatar']); $vars['avatar_smallest'] = GetSmallestUserAvatar($usr['id'], $vars['avatar']); $vars['user_id'] = SafeDB($usr['id'], 11, int); $vars['url'] = Ufu('index.php?name=user&op=userinfo&user='******'id'], 11, int), 'user/{user}/info/'); $vars['name'] = SafeDB($usr['name'], 50, str); if ($usr['hideemail'] == '1') { $vars['email'] = 'Скрывается'; } else { $vars['email'] = SafeDB($usr['email'], 50, str); } $vars['date'] = TimeRender($usr['regdate'], true); $vars['lastdate'] = TimeRender($usr['lastvisit'], true); $vars['rank'] = $rank_stat; System::site()->AddSubBlock('userlist', true, $vars); } }
function AdminGalleryMove() { global $edit_images; if (!$edit_images) { System::admin()->AccessDenied(); } $move = SafeEnv($_GET['to'], 4, str); // up, down $id = SafeEnv($_GET['id'], 11, int); System::database()->Select('gallery', "`id`='{$id}'"); if (System::database()->NumRows() > 0) { $img = System::database()->FetchRow(); $pid = SafeDB($img['cat_id'], 11, int); $images = System::database()->Select('gallery', "`cat_id`='{$pid}'"); SortArray($images, 'order'); $c = count($images); //Исходный индекс $cur_order = 0; for ($i = 0; $i < $c; $i++) { $images[$i]['order'] = $i; if ($images[$i]['id'] == $id) { $cur_order = $i; } } //Индекс перемещения if ($move == 'up') { $rep_order = $cur_order - 1; } elseif ($move == 'down') { $rep_order = $cur_order + 1; } else { $rep_order = $cur_order; } if ($rep_order < 0 || $rep_order >= $c) { $rep_order = $cur_order; } $temp = intval($images[$cur_order]['order']); $images[$cur_order]['order'] = intval($images[$rep_order]['order']); $images[$rep_order]['order'] = intval($temp); for ($i = 0; $i < $c; $i++) { $order = $images[$i]['order']; $id = $images[$i]['id']; System::database()->Update('gallery', "`order`='{$order}'", "`id`='{$id}'"); } Audit('Фотогалерея: Перемещение изображения "' . $img['title'] . '" (id: ' . $img['id'] . ')'); } System::cache()->Delete('tree', 'gallery'); $cat = isset($_GET['cat']) ? '&cat=' . SafeEnv($_GET['cat'], 11, int) : ''; $page = isset($_GET['page']) ? '&page=' . SafeEnv($_GET['cat'], 11, int) : ''; GO(ADMIN_FILE . '?exe=gallery' . $cat . $page); }
function AdminFdbAdminGenTableMenu($name) { global $action; // Добавляем в меню список таблиц и выбраннную таблицу System::admin()->BreadCrumbAdd('Список таблиц', 'exe=dbadmin&a=main'); $num_rows = 0; $tables = System::database()->GetTableInfo(); SortArray($tables, 'name'); $prefs = strpos($name, '_'); if ($prefs !== false) { $pref = substr($name, 0, $prefs); // Выводим сначала таблицы с префиксом foreach ($tables as $table) { $n = SafeDb($table['name'], 255, str); if (substr($n, 0, $prefs) == $pref) { System::admin()->BreadCrumbMenuItem($n, 'exe=dbadmin&a=structure&name=' . $n); } if ($n == $name) { $num_rows = SafeDB($table['num_rows'], 11, int); } } System::admin()->BreadCrumbMenuDelimiter(); foreach ($tables as $table) { $n = SafeDb($table['name'], 255, str); if (substr($n, 0, $prefs) != $pref) { System::admin()->BreadCrumbMenuItem($n, 'exe=dbadmin&a=structure&name=' . $n); } if ($n == $name) { $num_rows = SafeDB($table['num_rows'], 11, int); } } } else { foreach ($tables as $table) { $n = SafeDb($table['name'], 255, str); System::admin()->BreadCrumbMenuItem($n, 'exe=dbadmin&a=structure&name=' . $n); if ($n == $name) { $num_rows = SafeDB($table['num_rows'], 11, int); } } } System::admin()->BreadCrumbAdd($name, 'exe=dbadmin&a=main'); System::admin()->SideBarAddMenuItem('Структура таблицы', 'exe=dbadmin&a=structure&name=' . $name, 'structure'); System::admin()->SideBarAddMenuItem('Обзор записей (' . $num_rows . ')', 'exe=dbadmin&a=review&name=' . $name, 'review'); System::admin()->SideBarAddMenuItem('Добавить запись', 'exe=dbadmin&a=insert&name=' . $name, 'insert'); System::admin()->SideBarAddMenuItem('Редактировать структуру', 'exe=dbadmin&a=edittable&name=' . $name, 'edittable'); System::admin()->SideBarAddMenuItem('Очистить таблицу', 'exe=dbadmin&a=truncatetable&name=' . $name, 'truncatetable'); System::admin()->SideBarAddMenuItem('Удалить таблицу', 'exe=dbadmin&a=droptable&name=' . $name, 'droptable'); System::admin()->SideBarAddMenuBlock('Таблица "' . $_GET['name'] . '"', $action); }
/** * Возвращает ранги пользователей * @return array|null|string */ function &GetUserRanks() { global $system_userranks_cache; if ($system_userranks_cache == null) { if (System::cache()->HasCache(system_cache, 'userranks')) { $system_userranks_cache = System::cache()->Get(system_cache, 'userranks'); } else { $ranks = System::database()->Select('userranks', ''); SortArray($ranks, 'min'); foreach ($ranks as $rank) { $system_userranks_cache[$rank['id']] = $rank; } System::cache()->Write(system_cache, 'userranks', $system_userranks_cache); } } return $system_userranks_cache; }
function IndexArticlesShow($cat) { if ($cat != 0) { System::site()->SetTitle('Статьи в категории ' . SafeDB(IndexArticlesGetTree()->IdCats[$cat]['title'], 255, str)); } if (isset($_GET['page'])) { $page = SafeEnv($_GET['page'], 11, int); } else { $page = 1; } $arts = System::database()->Select('articles', GetWhereByAccess('view', ($cat != 0 ? "`cat_id`='{$cat}' and " : '') . "`active`='1'")); SortArray($arts, 'public', true); // Постраничная навигация $num = System::config('articles/articles_on_page'); $navigation = new Navigation($page); $nav_link = Ufu('index.php?name=articles' . ($cat != 0 ? '&cat=' . $cat : ''), 'articles/' . ($cat != 0 ? '{cat}/' : '') . 'page{page}/', true); $navigation->FrendlyUrl = System::config('general/ufu'); $navigation->GenNavigationMenu($arts, $num, $nav_link); if (System::database()->NumRows() > 0) { System::site()->AddTemplatedBox('', 'module/article.html'); System::site()->AddBlock('articles', true, true, 'art'); foreach ($arts as $art) { RenderArticle($art); } } elseif (!isset(IndexArticlesGetTree()->Cats[$cat]) && count(IndexArticlesGetTree()->Cats) > 0) { System::site()->AddTextBox('', '<p align="center">В этой категории статей пока нет.</p>'); } }
function AdminCommentsFind() { if (System::config('comments/disable_posts_engine')) { System::admin()->AddCenterBox('Ошибка'); System::admin()->HighlightError('Система комментариев отключена.'); return; } // Рекурсивная функция для поиска родителя комментария верхнего уровня function CommentsFindTopLevelPost(&$posts, $post_id, $post_parent_id) { if (isset($posts[$post_parent_id])) { if ($posts[$post_parent_id]['post_parent_id'] == 0) { return $posts[$post_parent_id]['id']; } return CommentsFindTopLevelPost($posts, $posts[$post_parent_id]['id'], $posts[$post_parent_id]['post_parent_id']); } else { return $post_id; } } // id таблицы комментариев в таблице comments и id комментария $table_id = SafeEnv($_GET['table'], 11, int); $post_id = SafeEnv($_GET['post_id'], 11, int); System::database()->Select('comments', "`id`='{$table_id}'"); if (!System::database()->NumRows()) { System::admin()->AddCenterBox('Ошибка'); System::admin()->HighlightError('Таблица комментариев не найдена.'); return; } $table = System::database()->FetchRow(); // Загружаем комментарий System::database()->Select($table['table'], "`id`='{$post_id}'"); if (!System::database()->NumRows()) { System::admin()->AddCenterBox('Ошибка'); System::admin()->HighlightError('Комментарий не найден.'); return; } $post = System::database()->FetchRow(); // Загружаем объект комментария $id_coll = SafeEnv($table['id_coll'], 255, str); $object_id = SafeEnv($post['object_id'], 11, int); System::database()->Select($table['objects_table'], "`{$id_coll}`='{$object_id}'"); if (!System::database()->NumRows()) { System::admin()->AddCenterBox('Ошибка'); System::admin()->HighlightError('Объект комментария не найден.'); return; } $object = System::database()->FetchRow(); $en_navigation = System::config('comments/ennav'); $navigation_page = 1; if ($en_navigation) { // Включена постраничная навигация в комментариях // Количество комментарий на страницу $comments_on_page = System::config('comments/onpage'); // Загружаем комментарии объекта $object_postsdb = System::database()->Select($table['table'], "`object_id`='{$object_id}'"); SortArray($object_postsdb, 'post_date', !System::config('comments/decreasesort')); if (count($object_postsdb) <= $comments_on_page) { // Навигация не требуется $en_navigation = false; } else { // Определяем страницу на котором отображается комментарий if ($post['post_parent_id'] == 0) { // Комментарий верхнего уровня $post_top_id = $post_id; } else { // Поиск родительского комментария верхнего уровня // Агрегируем комментарии объекта по id $object_posts = array(); foreach ($object_postsdb as $p) { $object_posts[$p['id']] = $p; } $post_top_id = CommentsFindTopLevelPost($object_posts, $post_id, $post['post_parent_id']); } // Берём только комментарии верхнего уровня $object_top_posts = array(); foreach ($object_postsdb as $p) { if ($p['post_parent_id'] == 0) { $object_top_posts[$p['id']] = true; } } // Узнаём порядковый номер post_top_id $index = array_search($post_top_id, array_keys($object_top_posts)); $navigation_page = ceil(($index + 1) / $comments_on_page); // Определили страницу if ($navigation_page > 1) { $en_navigation = true; } } } if (System::config('general/ufu')) { if ($en_navigation) { $url_template = $table['nav_ufu']; } else { $url_template = $table['ufu']; } } else { $url_template = $table['url']; if ($en_navigation) { $url_template .= '&' . urlencode($table['page_param']) . '=' . $navigation_page; } } // Парсим шаблон URL $keys = array(); foreach ($object as $key => &$val) { $val = urlencode($val); $keys['{' . $key . '}'] =& $val; } $keys['{' . $table['page_param'] . '}'] = $navigation_page; $url = str_replace(array_keys($keys), array_values($keys), $url_template); GO($url . '#post_' . $post_id); }
function AdminCodetesterSnippets($type) { System::admin()->AddSubTitle('Сниппеты'); UseScript('jquery_ui_table'); if (isset($_REQUEST['onpage'])) { $num = intval($_REQUEST['onpage']); } else { $num = 20; } if (isset($_REQUEST['page'])) { $page = intval($_REQUEST['page']); } else { $page = 1; } $snippets_db = System::database()->Select('snippets', "`type`='{$type}'"); $columns = array('title'); $sortby = ''; $sortbyid = -1; $desc = true; if (isset($_REQUEST['sortby'])) { $sortby = $columns[$_REQUEST['sortby']]; $sortbyid = intval($_REQUEST['sortby']); $desc = $_REQUEST['desc'] == '1'; } if ($sortby != '') { SortArray($snippets_db, $sortby, $desc); } $table = new jQueryUiTable(); $table->listing = ADMIN_FILE . '?exe=codetester&a=' . $type . 'snippets&ajax'; $table->del = ADMIN_FILE . '?exe=codetester&a=delete'; $table->total = count($snippets_db); $table->onpage = $num; $table->page = $page; $table->sortby = $sortbyid; $table->sortdesc = $desc; $table->AddColumn('Заголовок'); $table->AddColumn('Функции', 'center', false, true); $snippets_db = ArrayPage($snippets_db, $num, $page); // Берем только новости с текущей страницы foreach ($snippets_db as $snip) { $id = SafeDB($snip['id'], 11, int); $editlink = ADMIN_FILE . '?exe=codetester&id=' . $id . '&lang=' . $type; $func = ''; $func .= System::admin()->SpeedButton('Редактировать', $editlink, 'images/admin/edit.png'); $func .= System::admin()->SpeedConfirmJs('Удалить', '$(\'#jqueryuitable\').table(\'deleteRow\', ' . $id . ');', 'images/admin/delete.png', 'Уверены, что хотите удалить этот сниппет?'); $table->AddRow($id, '<b>' . System::admin()->Link(SafeDB($snip['title'], 255, str), $editlink) . '</b>', $func); } if (isset($_GET['ajax'])) { echo $table->GetOptions(); exit; } else { $table->AddTable('Сниппеты'); } }
function AdminExtensions() { UseScript('jquery_ui'); $mod_dir = System::config('mod_dir'); $blocks_dir = System::config('blocks_dir'); $plug_dir = System::config('plug_dir'); $tpl_dir = System::config('tpl_dir'); // Стили $style = '<style> .ex-mod{ border-bottom: 1px #ccf solid; background-color: #DDEAF7; cursor: pointer; } .ex-mod:hover{ background-color: #F5F5FF; } .ex-mod-info { padding-top: 4px; } .ex-mod-info-description { padding-top: 0; margin-bottom: 5px; } .mod_info { margin-bottom: 5px; } </style>'; // JS System::site()->AddJS(' window.last_mod_id = ""; ShowModInfo = function(id){ $(".mod_info").slideUp().parents(".ex-mod").css("background-color", "#DDEAF7"); if(last_mod_id != id){ $("#mod_info_"+id).slideDown().parents(".ex-mod").css("background-color", "#FFF"); last_mod_id = id; }else{ last_mod_id = ""; } }; window.last_block_id = ""; ShowBlockInfo = function(id){ $(".mod_info").slideUp().parents(".ex-mod").css("background-color", "#DDEAF7"); if(last_block_id != id){ $("#mod_info_"+id).slideDown().parents(".ex-mod").css("background-color", "#FFF"); last_block_id = id; }else{ last_block_id = ""; } }; '); // Модули $modules_html = '<div style="border-top: 1px #ccf solid; ">'; $mods = System::database()->Select('modules', "`system`='0'"); SortArray($mods, 'name'); foreach ($mods as $mod) { $info = ExtLoadInfo($mod_dir . $mod['folder']); if ($info === false) { continue; } $mid = SafeEnv($mod['id'], 11, int); $func = ''; $func .= System::admin()->SpeedStatus('Отключить', 'Подключить', ADMIN_FILE . '?exe=extensions&a=changestatus&type=' . EXT_MODULE . '&id=' . $mid, $mod['enabled'] == '1', 'images/bullet_green.png', 'images/bullet_red.png'); $func .= System::admin()->SpeedButton('Настройки', ADMIN_FILE . '?exe=extensions&a=mod_config&name=' . SafeDB($mod['folder'], 255, str), 'images/admin/config.png'); // Показываем кнопку удаления, только тогда, когда существует программа удаления if (is_file($mod_dir . $mod['folder'] . '/uninstall.php')) { $func .= System::admin()->SpeedConfirm('Удалить', ADMIN_FILE . '?exe=extensions&a=uninstall&type=' . EXT_MODULE . '&name=' . SafeDB($mod['folder'], 255, str), 'images/admin/delete.png', 'Полностью удалить модуль ' . $mod['name'] . '?'); } if (is_file($mod_dir . $mod['folder'] . '/icon.png')) { $icon = $mod_dir . $mod['folder'] . '/icon.png'; } else { $icon = 'images/application.png'; } if (isset($info['version'])) { $version = SafeDB($info['version'], 255, str); } else { $version = CMS_VERSION; } if (isset($info['author'])) { $author = SafeDB($info['author'], 255, str); } else { $author = ''; } if (isset($info['site'])) { $site = SafeDB($info['site'], 255, str); } else { $site = ''; } if (isset($info['description'])) { $description = SafeDB($info['description'], 0, str, false, false); } else { $description = 'Нет описания.'; } $modules_html .= '<table width="100%" class="ex-mod"> <tr onmousedown="ShowModInfo(\'mod' . $mid . '\');"> <td style="padding-left: 11px; vertical-align: top;"> <div style="float: left;"> <div style="float:left; padding-top: 6px;"><img src="' . $icon . '"></div> <div style="float:left; padding-top: 7px;"> ' . SafeDB($mod['name'], 255, str) . ' (v' . $version . ')</div> </div> </td> <td width="90" align="center" style="padding: 3px; padding-bottom: 2px;"> <div style="float: left">' . $func . '</div> </td> </tr> <tr> <td colspan="2"> <div class="mod_info" id="mod_info_mod' . $mid . '" style="display: none; padding: 4px; padding-left: 11px;"> <div class="ex-mod-info-description">' . $description . '</div> ' . ($author != '' ? '<div class="ex-mod-info">Автор: ' . $author . '</div>' : '') . ' ' . ($site != '' ? '<div class="ex-mod-info">Сайт: <a href="' . $site . '" target="_blank">' . $site . '</a></div>' : '') . ' </div> </td> </tr> </table>'; } $modules_html .= '</div>'; // Блоки $blocks_html = '<div style="border-top: 1px #ccf solid; ">'; $mods = System::database()->Select('block_types'); SortArray($mods, 'name'); foreach ($mods as $mod) { $info = ExtLoadInfo($blocks_dir . $mod['folder']); if ($info === false) { continue; } $mid = SafeEnv($mod['id'], 11, int); $func = ''; if (is_file($blocks_dir . $mod['folder'] . '/uninstall.php')) { // Показываем кнопку удаления, только тогда, когда существует программа удаления $func .= System::admin()->SpeedConfirm('Удалить', ADMIN_FILE . '?exe=extensions&a=uninstall&type=' . EXT_BLOCK . '&name=' . SafeDB($mod['folder'], 255, str), 'images/admin/delete.png', 'Полностью удалить модуль ' . $mod['name'] . '?'); } if (isset($info['icon']) && $info['icon'] != '') { $icon = SafeDB($info['icon'], 255, str); } else { $icon = 'images/application.png'; } if (isset($info['version'])) { $version = SafeDB($info['version'], 255, str); } else { $version = CMS_VERSION; } if (isset($info['author']) && $info['author'] != '') { $author = SafeDB($info['author'], 255, str); } else { $author = ''; } if (isset($info['site']) && $info['site'] != '') { $site = SafeDB($info['site'], 255, str); } else { $site = ''; } if (isset($info['description']) && $info['description'] != '' && $info['description'] != ' - ') { $description = SafeDB($info['description'], 0, str, false, false); } else { $description = 'Нет описания.'; } $blocks_html .= '<table width="100%" class="ex-mod"> <tr onmousedown="ShowBlockInfo(\'block' . $mid . '\');"> <td style="padding-left: 11px; vertical-align: top;"> <div style="float: left;"> <div style="float:left; padding-top: 6px;"><img src="' . $icon . '"></div> <div style="float:left; padding-top: 7px;"> ' . SafeDB($mod['name'], 255, str) . ' (v' . $version . ')</div> </div> </td> <td width="62" align="center" style="padding: 3px; padding-bottom: 2px;"> <div style="float: left">' . $func . '</div> </td> </tr> <tr> <td colspan="2"> <div class="mod_info" id="mod_info_block' . $mid . '" style="display: none; padding: 4px; padding-left: 11px;"> <div class="ex-mod-info-description">' . $description . '</div> ' . ($author != '' ? '<div class="ex-mod-info">Автор: ' . $author . '</div>' : '') . ' ' . ($site != '' ? '<div class="ex-mod-info">Сайт: <a href="' . $site . '" target="_blank">' . $site . '</a></div>' : '') . ' </div> </td> </tr> </table>'; } $blocks_html .= '</div>'; // Плагины $plugins_html = '<div style="border-top: 1px #ccf solid; ">'; $mods = System::database()->Select('plugins', "`hidden`='0'"); SortArray($mods, 'group'); $configs_groups = PluginsConfigsGroups(); foreach ($mods as $mod) { if ($mod['group'] != '') { $path = $plug_dir . $mod['group'] . '/' . $mod['name']; } else { $path = $plug_dir . $mod['name']; } $info = ExtLoadInfo($path); if ($info === false) { continue; } $mid = SafeEnv($mod['id'], 11, int); $func = ''; $group = SafeDB(($mod['group'] != '' ? $mod['group'] . '.' : '') . $mod['name'], 255, str); if (isset($configs_groups[$group])) { $func .= System::admin()->SpeedButton('Настройки', ADMIN_FILE . '?exe=extensions&a=plug_config&group=' . $group, 'images/admin/config.png'); } $func .= System::admin()->SpeedStatus('Отключить', 'Подключить', ADMIN_FILE . '?exe=extensions&a=changestatus&type=' . EXT_PLUGIN . '&id=' . $mid, $mod['enabled'] == '1', 'images/bullet_green.png', 'images/bullet_red.png'); // Показываем кнопку удаления, только тогда, когда существует программа удаления if (isset($info['1.3']) || is_file($path . '/uninstall.php')) { $func .= System::admin()->SpeedConfirm('Удалить', ADMIN_FILE . '?exe=extensions&a=uninstall&type=' . EXT_PLUGIN . '&name=' . SafeDB($mod['name'], 255, str) . ($mod['group'] != '' ? '&group=' . SafeDB($mod['group'], 255, str) : ''), 'images/admin/delete.png', 'Полностью удалить плагин ' . $mod['name'] . '?'); } $name = SafeDB($info['name'], 255, str); if (isset($info['icon']) && $info['icon'] != '') { $icon = SafeDB($info['icon'], 255, str); } else { $icon = 'images/application.png'; } if (isset($info['version'])) { $version = SafeDB($info['version'], 255, str); } else { $version = CMS_VERSION; } if (isset($info['author']) && $info['author'] != '') { $author = SafeDB($info['author'], 255, str); } else { $author = ''; } if (isset($info['site']) && $info['site'] != '') { $site = SafeDB($info['site'], 255, str); } else { $site = ''; } if (isset($info['description']) && $info['description'] != '' && $info['description'] != ' - ') { $description = SafeDB($info['description'], 0, str, false, false); } else { $description = 'Нет описания.'; } $plugins_html .= '<table width="100%" class="ex-mod"> <tr onmousedown="ShowBlockInfo(\'plug' . $mid . '\');"> <td style="padding-left: 11px; vertical-align: top;"> <div style="float: left;"> <div style="float:left; padding-top: 6px;"><img src="' . $icon . '"></div> <div style="float:left; padding-top: 7px;"> ' . $name . ' (v' . $version . ')</div> </div> </td> <td width="62" align="center" style="padding: 3px; padding-bottom: 2px;"> <div style="float: left">' . $func . '</div> </td> </tr> <tr> <td colspan="2"> <div class="mod_info" id="mod_info_plug' . $mid . '" style="display: none; padding: 4px; padding-left: 11px;"> <div class="ex-mod-info-description">' . $description . '</div> ' . ($author != '' ? '<div class="ex-mod-info">Автор: ' . $author . '</div>' : '') . ' ' . ($site != '' ? '<div class="ex-mod-info">Сайт: <a href="' . $site . '" target="_blank">' . $site . '</a></div>' : '') . ' <div class="ex-mod-info">Тип: ' . AdminExtensionsPluginType($mod['type']) . '</div> </div> </td> </tr> </table>'; } $plugins_html .= '</div>'; // Шаблоны $templates_html = '<div style="border-top: 1px #ccf solid; ">'; $mods = System::database()->Select('templates', "`default`='0'"); SortArray($mods, 'name'); foreach ($mods as $mod) { $info = ExtLoadInfo($tpl_dir . $mod['folder']); if ($info === false) { $info = array('name' => $mod['folder'], 'description' => '', 'author' => '', 'site' => '', 'version' => '1.0', 'admin' => false); } $mid = SafeEnv($mod['id'], 11, int); $name = SafeDB($info['name'], 255, str); $func = ''; $func .= System::admin()->SpeedConfirm('Удалить шаблон', ADMIN_FILE . '?exe=extensions&a=uninstall&type=' . EXT_TEMPLATE . '&name=' . SafeDB($mod['folder'], 255, str), 'images/admin/delete.png', 'Удалить шаблон ' . $name . '?'); if (isset($info['icon']) && $info['icon'] != '') { $icon = $info['icon']; } else { $icon = 'images/application.png'; } if (isset($info['version'])) { $version = SafeDB($info['version'], 255, str); } else { $version = ''; } if (isset($info['author']) && $info['author'] != '') { $author = SafeDB($info['author'], 255, str); } else { $author = ''; } if (isset($info['site']) && $info['site'] != '') { $site = SafeDB($info['site'], 255, str); } else { $site = ''; } if (isset($info['description']) && $info['description'] != '' && $info['description'] != ' - ') { $description = SafeDB($info['description'], 0, str, false, false); } else { $description = 'Нет описания.'; } $templates_html .= '<table width="100%" class="ex-mod"> <tr onmousedown="ShowBlockInfo(\'tpl' . $mid . '\');"> <td style="padding-left: 11px; vertical-align: top;"> <div style="float: left;"> <div style="float:left; padding-top: 6px;"><img src="' . $icon . '"></div> <div style="float:left; padding-top: 7px;"> ' . $name . ($version != '' ? ' (v' . $version . ')' : '') . ($mod['admin'] == '1' ? ' (Админ-панель)' : '') . '</div> </div> </td> <td width="62" align="center" style="padding: 3px; padding-bottom: 2px;"> <div style="float: left">' . $func . '</div> </td> </tr> <tr> <td colspan="2"> <div class="mod_info" id="mod_info_tpl' . $mid . '" style="display: none; padding: 4px; padding-left: 11px;"> <div class="ex-mod-info-description">' . $description . '</div> ' . ($author != '' ? '<div class="ex-mod-info">Автор: ' . $author . '</div>' : '') . ' ' . ($site != '' ? '<div class="ex-mod-info">Сайт: <a href="' . $site . '" target="_blank">' . $site . '</a></div>' : '') . ' </div> </td> </tr> </table>'; } $templates_html .= '</div>'; // Выводим расширения по вкладкам System::admin()->AddOnLoadJS(' $("#tabs").tabs({ event: "mousedown", beforeLoad: function( event, ui ){ return false; } }).css("width", "700px"); $(".ui-tabs .ui-tabs-panel") .css("padding", "0") .css("padding-top","3px") .css("height", "400px") .css("overflow-y", "auto"); '); $html = '<div id="tabs"> <ul> <li><a href="#tabs-1"><img src="' . MOD_ICON . '" style="vertical-align: bottom;"> Модули</a></li> <li><a href="#tabs-2"><img src="images/blocks.png" style="vertical-align: bottom;"> Блоки</a></li> <li><a href="#tabs-3"><img src="images/plugins.png" style="vertical-align: bottom;"> Плагины</a></li> <li><a href="#tabs-4"><img src="images/skins.png" style="vertical-align: bottom;"> Шаблоны</a></li> </ul> <div id="tabs-1">' . $modules_html . '</div> <div id="tabs-2">' . $blocks_html . '</div> <div id="tabs-3">' . $plugins_html . '</div> <div id="tabs-4">' . $templates_html . '</div> </div>'; System::admin()->AddTextBox('Расширения', $style . $html); }
function ForumAdminGetUsersTypesComboBox($group = '', $rank = 0) { global $db, $site, $forum_lang; $mdb = $db->Select('userranks'); SortArray($mdb, 'min', false); $types = array(array('id' => '0', 'title' => $forum_lang['all_rang'], 'select' => false)); foreach ($mdb as $type) { if ($type['id'] > 0) { $types[$type['id']] = array('id' => $type['id'], 'title' => $type['title'], 'select' => $rank == $type['id'] ? true : false); } } $usertypes = array(); foreach ($types as $type) { $site->DataAdd($usertypes, $type['id'], $type['title'], $type['select']); } return $site->Select($group, $usertypes); }