function AdminExtensionsInstall()
{
    global $db, $config, $site;
    // Для обратной совместимости
    $count = SafeEnv($_POST['count'], 11, int);
    $new_installed = array();
    for ($i = 0; $i < $count; $i++) {
        if (isset($_POST['install_' . $i])) {
            $type = $_POST['type_' . $i];
            $folder = RealPath2($_POST['folder_' . $i], 255, str);
            switch ($type) {
                case EXT_PLUGIN:
                    $group = '';
                    $group_info = null;
                    if (isset($_POST['group_' . $i])) {
                        $group = $_POST['group_' . $i];
                        $group_info = ExtLoadInfo(System::config('plug_dir') . $group);
                    }
                    $path = RealPath2(System::config('plug_dir') . $group . '/' . $folder);
                    $info = ExtLoadInfo($path, $group_info);
                    if ($info === false) {
                        continue;
                    }
                    if (isset($info['1.3'])) {
                        // Установка старой версии плагина
                        $function = '';
                        if (isset($info['function'])) {
                            $function = $info['function'];
                        }
                        $type = '';
                        if (isset($info['function'])) {
                            $type = $info['function'];
                        }
                        ExtAddPlugin($group, $folder, $info['function'], $info['type']);
                        if (is_file($path . '/install.php')) {
                            require $path . '/install.php';
                        }
                        $new_installed[] = $info;
                    } else {
                        if (is_file($path . '/install.php')) {
                            // Наличие install.php обязательно
                            require $path . '/install.php';
                            $new_installed[] = $info;
                        }
                    }
                    Audit('Расширения: Установка плагина: ' . $group . '/' . $folder);
                    break;
                case EXT_BLOCK:
                    $path = RealPath2(System::config('blocks_dir') . $folder);
                    $info = ExtLoadInfo($path);
                    if ($info === false) {
                        continue;
                    }
                    require $path . '/install.php';
                    $new_installed[] = $info;
                    Audit('Расширения: Установка блока: ' . $folder);
                    break;
                case EXT_MODULE:
                    $path = RealPath2(System::config('mod_dir') . $folder);
                    $info = ExtLoadInfo($path);
                    if ($info === false) {
                        continue;
                    }
                    require $path . '/install.php';
                    if (isset($info['1.3'])) {
                        // Добавляем пункт меню
                        $folder = SafeEnv($folder, 255, str);
                        $mod_name = SafeEnv($info['name'], 255, str);
                        AdminMenuAddModule($mod_name, $folder);
                    }
                    $new_installed[] = $info;
                    Audit('Расширения: Установка модуля: ' . $folder);
                    break;
                case EXT_TEMPLATE:
                    // Установка тем оформления происходит автоматически
                    $path = RealPath2(System::config('tpl_dir') . $folder);
                    $info = ExtLoadInfo($path);
                    if ($info === false) {
                        $info = array('name' => $folder, 'description' => '', 'author' => '', 'site' => '', 'version' => '1.0', 'admin' => false);
                    }
                    $admin = isset($info['admin']) && $info['admin'] ? '1' : '0';
                    ExtAddTemplate($info['name'], $folder, $admin);
                    $new_installed[] = $info;
                    Audit('Расширения: Установка шаблона: ' . $folder);
                    break;
            }
        }
    }
    $html = '';
    $html .= '<div style="border: 1px #cfcfcf solid; width: 50%; background-color: #fff; margin-bottom: 5px;">';
    if (count($new_installed) > 0) {
        foreach ($new_installed as $info) {
            $html .= Indent('
				<table style="width: 100%;">
					<tr>
						<td style="padding: 5px;">' . SafeDB($info['name'], 255, str) . '</td>
						<td style="width: 120px; padding: 5px;"><img src="images/admin/accept.png" style="vertical-align: middle;" /> Установлено</td>
					</tr>
				</table>
			');
        }
        $html .= '</div>' . System::admin()->Button('Назад', 'onclick="history.go(-1);"') . System::admin()->Button('Далее', "onclick=\"Admin.LoadPage('" . ADMIN_FILE . "?exe=extensions');\"");
        System::cache()->Clear('config');
    } else {
        $html .= '<div style="padding:  5px;">Вы не выбрали расширения для установки. Нажмите "назад" и отметьте галочками расширения которые нужно установить.</div>';
        $html .= '</div>' . System::admin()->Button('Назад', 'onclick="history.go(-1);"');
    }
    System::admin()->AddTextBox('Установка расширений', $html);
}
$table_forum_subscription = 'a:6:{s:4:"name";s:18:"forum_subscription";s:4:"size";i:530;s:4:"type";s:6:"MyISAM";s:4:"cols";a:3:{i:0;a:6:{s:4:"name";s:2:"id";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;s:14:"auto_increment";b:1;s:7:"primary";b:1;}i:1;a:5:{s:4:"name";s:5:"topic";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;s:5:"index";b:1;}i:2;a:5:{s:4:"name";s:4:"user";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;s:5:"index";b:1;}}s:8:"num_rows";i:0;s:7:"counter";i:0;}';
$table_forum_topics_read = 'a:6:{s:7:"counter";i:0;s:8:"num_rows";i:0;s:4:"name";s:17:"forum_topics_read";s:4:"size";s:3:"626";s:4:"type";s:6:"MyISAM";s:4:"cols";a:3:{i:0;a:4:{s:4:"name";s:3:"mid";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:1;a:4:{s:4:"name";s:3:"tid";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:2;a:4:{s:4:"name";s:4:"date";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}}}';
$table_forum_topics = 'a:6:{s:7:"counter";i:0;s:8:"num_rows";i:0;s:4:"name";s:12:"forum_topics";s:4:"size";i:2013;s:4:"type";s:6:"MyISAM";s:4:"cols";a:16:{i:0;a:6:{s:4:"name";s:2:"id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:14:"auto_increment";s:1:"1";s:7:"primary";s:1:"1";}i:1;a:5:{s:4:"name";s:8:"forum_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:2;a:5:{s:4:"name";s:5:"title";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:3;a:4:{s:4:"name";s:5:"state";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"notnull";s:1:"1";}i:4;a:4:{s:4:"name";s:5:"posts";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:5;a:4:{s:4:"name";s:4:"hits";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:6;a:4:{s:4:"name";s:10:"start_date";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:7;a:5:{s:4:"name";s:10:"starter_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:8;a:5:{s:4:"name";s:12:"starter_name";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:9;a:4:{s:4:"name";s:9:"last_post";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:10;a:4:{s:4:"name";s:14:"last_poster_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:11;a:5:{s:4:"name";s:16:"last_poster_name";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:12;a:5:{s:4:"name";s:9:"uniq_code";s:4:"type";s:4:"char";s:6:"length";s:2:"12";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:13;a:5:{s:4:"name";s:12:"close_topics";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:14;a:5:{s:4:"name";s:5:"stick";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:15;a:5:{s:4:"name";s:6:"delete";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}}}';
$table_forums = 'a:6:{s:7:"counter";i:5;s:8:"num_rows";i:3;s:4:"name";s:6:"forums";s:4:"size";i:3159;s:4:"cols";a:21:{i:0;a:6:{s:4:"name";s:2:"id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:14:"auto_increment";s:1:"1";s:7:"primary";s:1:"1";}i:1;a:5:{s:4:"name";s:9:"parent_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:2;a:5:{s:4:"name";s:5:"title";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:3;a:3:{s:4:"name";s:11:"description";s:4:"type";s:4:"text";s:7:"notnull";s:1:"1";}i:4;a:4:{s:4:"name";s:6:"topics";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:5;a:4:{s:4:"name";s:5:"posts";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:6;a:4:{s:4:"name";s:9:"last_post";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:7;a:4:{s:4:"name";s:14:"last_poster_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:8;a:5:{s:4:"name";s:16:"last_poster_name";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:9;a:5:{s:4:"name";s:10:"last_title";s:4:"type";s:7:"varchar";s:6:"length";s:3:"255";s:7:"default";s:0:"";s:7:"notnull";s:1:"1";}i:10;a:4:{s:4:"name";s:7:"last_id";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";}i:11;a:5:{s:4:"name";s:5:"order";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:12;a:5:{s:4:"name";s:6:"status";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"notnull";s:1:"1";s:5:"index";s:1:"1";}i:13;a:4:{s:4:"name";s:4:"view";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"notnull";s:1:"1";}i:14;a:5:{s:4:"name";s:15:"admin_theme_add";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:15;a:5:{s:4:"name";s:13:"no_link_guest";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:16;a:5:{s:4:"name";s:17:"new_message_email";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:17;a:5:{s:4:"name";s:11:"rang_access";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:18;a:5:{s:4:"name";s:12:"rang_message";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:19;a:5:{s:4:"name";s:14:"rang_add_theme";s:4:"type";s:3:"int";s:6:"length";s:2:"11";s:7:"default";s:1:"0";s:7:"notnull";b:1;}i:20;a:5:{s:4:"name";s:11:"close_topic";s:4:"type";s:3:"int";s:6:"length";s:1:"1";s:7:"default";s:1:"0";s:7:"notnull";b:1;}}s:4:"type";s:6:"MyISAM";}';
$table_forum_online = 'a:7:{s:7:"counter";i:1338127624;s:8:"num_rows";i:1;s:4:"cols";a:7:{i:0;a:6:{s:4:"name";s:4:"time";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;s:14:"auto_increment";b:1;s:7:"primary";b:1;}i:1;a:4:{s:4:"name";s:7:"user_id";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;}i:2;a:5:{s:4:"name";s:9:"user_name";s:4:"type";s:7:"varchar";s:6:"length";i:255;s:7:"default";s:0:"";s:7:"notnull";b:1;}i:3;a:4:{s:4:"name";s:10:"user_level";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;}i:4;a:4:{s:4:"name";s:7:"user_ip";s:4:"type";s:7:"varchar";s:6:"length";i:255;s:7:"notnull";b:1;}i:5;a:3:{s:4:"name";s:9:"forum_cat";s:4:"type";s:4:"text";s:7:"notnull";b:1;}i:6;a:4:{s:4:"name";s:11:"forum_topic";s:4:"type";s:3:"int";s:6:"length";i:11;s:7:"notnull";b:1;}}s:7:"comment";s:0:"";s:4:"type";s:6:"MYISAM";s:4:"size";i:1001;s:4:"name";s:12:"forum_online";}';
$db = System::database();
$db->CreateTable('forum_basket_post', unserialize($table_forum_basket_post));
$db->CreateTable('forum_basket_topics', unserialize($table_forum_basket_topics));
$db->CreateTable('forum_posts', unserialize($table_forum_posts));
$db->CreateTable('forum_subscription', unserialize($table_forum_subscription));
$db->CreateTable('forum_topics_read', unserialize($table_forum_topics_read));
$db->CreateTable('forum_topics', unserialize($table_forum_topics));
$db->CreateTable('forums', unserialize($table_forums));
$db->CreateTable('forum_online', unserialize($table_forum_online));
// Конфигурация
$group = AddConfigGroup('forum', 'Форум');
AddConfig($group, 'topics_on_page', 'Количество тем на страницу', '10', '', true, 'edit:w60px', '3,int,false');
AddConfig($group, 'posts_on_page', 'Количество сообщений на страницу', '10', '', true, 'edit:w60px', '3,int,false');
AddConfig($group, 'basket', 'Использовать удаление через "корзину"', '1', 'Если Да - то удаляемые темы и сообщения будут перемещаться в "корзину" и только после указанного в настройках кол-ва дней будут удаляться без возможности восстановления.', true, 'combo', '1,bool,false', '1:Да,0:Нет');
AddConfig($group, 'clear_basket_day', 'Автоочистка корзины', '7', 'Через сколько дней удалять без возможности восстановления темы и сообщения из "корзины".', true, 'edit:w60px', '11,int,false');
AddConfig($group, 'max_word_length', 'Максимальная длина слова', '80', 'При превышении - слово будет разделено тегом BR. 0 - длина слова не ограничена.', true, 'edit:w60px', '11,int,false');
AddConfig($group, 'del_auto_time', 'Последний запуск чистки корзины форума', '0');
// Пункты за сообщения на форуме
AddPointsConfig('forum_post', 'Сообщение на форуме', '', '5');
// Доступ
AddAccessRestriction('forum', 'forum', 'Форум');
// Модуль
ExtAddModule('Форум', 'forum');
// Добавляем пункт меню
AdminMenuAddModule('Форум', 'forum');