Файл: install/step/2.php
Строк: 41
<?php
if (filter_has_var(INPUT_POST, 'submit'))
{
try
{
$db = new PDO ('mysql:host=' . $_POST['dbhost'] .';dbname=' . $_POST['dbname'], $_POST['dbuser'], $_POST['dbpass'], [
PDO::ATTR_PERSISTENT => true
]);
$_SESSION['step'] = 3;
foreach (glob(INSTALL . 'table/*.sql') AS $file)
{
$filename = str_replace('.sql', null, str_replace(INSTALL . 'table/', null, $file));
$sql = SQLParser::getQueriesFromFile($file);
for ($i = 0; $i < count($sql); $i++)
{
$db->query($sql[$i]);
}
}
$dataDb = [
'dbhost' => $_POST['dbhost'],
'dbname' => $_POST['dbname'],
'dbuser' => $_POST['dbuser'],
'dbpass' => $_POST['dbpass']
];
$dataApi = [
'id_client' => $catalog['id_client'],
'secret_key' => $catalog['secret_key'],
];
Core::config($dataDb, 'db', 'Данные БД');
Core::config($dataApi, 'api', 'Api NetsCMS');
Core::go('?');
}
catch (PDOException $e)
{
$error = 'Не удалось подключиться к базе данных';
}
}
Core::show('error');
$listing[] = [
'title' => 'Подключение к БД',
'div' => 'razdel',
];
$elements[] = [
'type' => 'input',
'title' => 'Хост',
'br' => 1,
'info' => [
'name' => 'dbhost',
'value' => 'localhost',
]
];
$elements[] = [
'type' => 'input',
'title' => 'Пользователь',
'br' => 1,
'info' => [
'name' => 'dbuser',
]
];
$elements[] = [
'type' => 'input',
'title' => 'База данных',
'br' => 1,
'info' => [
'name' => 'dbname',
]
];
$elements[] = [
'type' => 'password',
'title' => 'Пароль',
'br' => 1,
'info' => [
'name' => 'dbpass',
]
];
$elements[] = [
'type' => 'submit',
'info' => [
'name' => 'submit',
'value' => 'Подключиться'
]
];
$smarty->assign([
'method' => 'POST',
'action' => '?',
'el' => $elements,
'listing' => $listing
]);
$smarty->display('listing.tpl');
$smarty->display('form.tpl');