<?php

error_reporting(E_ALL ^ E_NOTICE);
@ini_set('display_errors', true);
@ini_set('html_errors', false);
@ini_set('error_reporting', E_ALL ^ E_NOTICE);

define('DATALIFEENGINE', true);
define('ROOT_DIR', dirname ( __FILE__ ));
define('ENGINE_DIR', ROOT_DIR.'/engine');

$db_charset = "cp1251";
$db_collate = "cp1251_general_ci";

require_once ENGINE_DIR.'/data/config.php';

if ($config['version_id'] >= 8)
	require_once ENGINE_DIR.'/inc/include/functions.inc.php';
elseif ($config['version_id'] < 8 AND $config['version_id'] >= 7)
	require_once ENGINE_DIR.'/inc/functions.inc.php';

if ($config['version_id'] < "6.3")
	require_once ENGINE_DIR.'/inc/mysql.php';
else 
	require_once ENGINE_DIR.'/classes/mysql.php';

require_once ENGINE_DIR.'/data/dbconfig.php';

if ($config['version_id'] >= 8.2)
{
    $check = $db->super_query("SELECT id FROM `" . PREFIX . "_admin_sections` WHERE name = 'admin_logicboard_dle'");
    if (!$check['id'])
        $db->query("INSERT INTO `" . PREFIX . "_admin_sections` (`name`, `title`, `descr`, `icon`, `allow_groups`) VALUES ('admin_logicboard_dle', 'LogicBoard (DLE Edition)', 'Настройки LogicBoard (DLE Edition).', 'logicboard_img.png', '1')");
}

$forum = $db->super_query("SELECT conf_value FROM " . LB_DB_PREFIX . "_configuration WHERE conf_key = 'general_site'");

if (!$forum['conf_value']) exit ("Настройка general_site не найдена!");

$config = <<<HTML
<?PHP
\$logicboard_conf['url'] = "{$forum['conf_value']}";
\$logicboard_conf['last_topic'] = "1";
\$logicboard_conf['last_topic_num'] = "5";
\$logicboard_conf['show_last_forum'] = "0";
\$logicboard_conf['online_status'] = "1";
?>
HTML;

$con_file = fopen("engine/data/logicboard_conf.php", "w+") or die("Извините, но невозможно создать файл <b>.engine/data/logicboard_conf.php</b>.<br />Проверьте правильность проставленного CHMOD!");
fwrite($con_file, $config);
fclose($con_file);
@chmod("engine/data/logicboard_conf.php", 0666);

echo "<b>Установка завершена! Удалите данный файл с фтп.</b>";

?>