Browse Source

Fixes

pull/3/head
M@d D3n 6 years ago
parent
commit
09a63d195a
  1. 39
      class/class.debug.php
  2. 2
      fields/multi_checkbox/field.php
  3. 38
      install/data_base.sql
  4. 277
      install/index.php
  5. 42
      install/structure_base.sql

39
class/class.debug.php

@ -92,7 +92,7 @@
else else
$fn_name = 'EVAL'; $fn_name = 'EVAL';
if (! $bg) if (empty($bg))
$bg = '43648c'; $bg = '43648c';
$var_dump = ' $var_dump = '
@ -101,7 +101,7 @@
margin: 20px; margin: 20px;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
background-color: #f1efef; background-color: #f1efef;
border-radius: 5px; border-radius: 3px;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.1); box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
font-family: "Consolas", Verdana, Arial; font-family: "Consolas", Verdana, Arial;
font-size: 11px; font-size: 11px;
@ -114,7 +114,6 @@
padding-top: 10px; padding-top: 10px;
padding-bottom: 10px; padding-bottom: 10px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
background-color: #' . $bg . ';
background-repeat: repeat-x; background-repeat: repeat-x;
border-bottom: 1px solid #ffffff; border-bottom: 1px solid #ffffff;
} }
@ -126,7 +125,7 @@
} }
</style> </style>
<div class="debug_bg"> <div class="debug_bg">
<div class="debug_top"> <div class="debug_top" style="background-color: #' . $bg . ';">
var_dump(<strong>' . trim($fn_name) . '</strong>) var_dump(<strong>' . trim($fn_name) . '</strong>)
</div> </div>
'.self::_trace().' '.self::_trace().'
@ -212,8 +211,8 @@
margin: 20px; margin: 20px;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
background-color: #f1efef; background-color: #f1efef;
border-radius: 5px; border-radius: 3px;
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1); box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
font-family: Consolas, Verdana, Arial; font-family: Consolas, Verdana, Arial;
font-size: 11px; font-size: 11px;
} }
@ -225,7 +224,6 @@
padding-top: 10px; padding-top: 10px;
padding-bottom: 10px; padding-bottom: 10px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
background-color: #'.$bg.';
background-repeat: repeat-x; background-repeat: repeat-x;
border-bottom: 1px solid #ffffff; border-bottom: 1px solid #ffffff;
} }
@ -237,7 +235,7 @@
} }
</style> </style>
<div class="debug_bg"> <div class="debug_bg">
<div class="debug_top"> <div class="debug_top" style="background-color: #' . $bg . ';">
print_r(<strong>' . trim($fn_name) . '</strong>) print_r(<strong>' . trim($fn_name) . '</strong>)
</div> </div>
'.self::_trace().' '.self::_trace().'
@ -323,8 +321,8 @@
margin: 20px; margin: 20px;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
background-color: #f1efef; background-color: #f1efef;
border-radius: 5px; border-radius: 3px;
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1); box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
font-family: Consolas, Verdana, Arial; font-family: Consolas, Verdana, Arial;
font-size: 11px; font-size: 11px;
} }
@ -336,7 +334,6 @@
padding-top: 10px; padding-top: 10px;
padding-bottom: 10px; padding-bottom: 10px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
background-color: #'.$bg.';
background-repeat: repeat-x; background-repeat: repeat-x;
border-bottom: 1px solid #ffffff; border-bottom: 1px solid #ffffff;
} }
@ -348,7 +345,7 @@
} }
</style> </style>
<div class="debug_bg"> <div class="debug_bg">
<div class="debug_top"> <div class="debug_top" style="background-color: #' . $bg . ';">
var_export(<strong>' . trim($fn_name) . '</strong>) var_export(<strong>' . trim($fn_name) . '</strong>)
</div> </div>
'.self::_trace().' '.self::_trace().'
@ -432,10 +429,9 @@
margin: 20px; margin: 20px;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
background-color: #f1efef; background-color: #f1efef;
border-radius: 5px; border-radius: 3px;
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1); box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
font-family: Consolas, Verdana, Arial; font-family: Consolas, Verdana, Arial;
border-radius: 3px;
font-size: 11px; font-size: 11px;
} }
.debug_top { .debug_top {
@ -446,7 +442,6 @@
padding-top: 10px; padding-top: 10px;
padding-bottom: 10px; padding-bottom: 10px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
background-color: #'.$bg.';
background-repeat: repeat-x; background-repeat: repeat-x;
border-bottom: 1px solid #ffffff; border-bottom: 1px solid #ffffff;
} }
@ -458,7 +453,7 @@
} }
</style> </style>
<div class="debug_bg"> <div class="debug_bg">
<div class="debug_top"> <div class="debug_top" style="background-color: #' . $bg . ';">
var_export(<strong>' . trim($fn_name) . '</strong>) var_export(<strong>' . trim($fn_name) . '</strong>)
</div> </div>
'.self::_trace().' '.self::_trace().'
@ -538,14 +533,7 @@
$fn_name = 'EVAL'; $fn_name = 'EVAL';
if (! $bg) if (! $bg)
{
$br = '2a5885';
$bg = '43648c'; $bg = '43648c';
}
else
{
$br = $bg;
}
$var_dump = ' $var_dump = '
<style> <style>
@ -553,7 +541,7 @@
margin: 20px; margin: 20px;
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
background-color: #f1efef; background-color: #f1efef;
border-radius: 5px; border-radius: 3px;
box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1); box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
font-family: Consolas, Verdana, Arial; font-family: Consolas, Verdana, Arial;
font-size: 11px; font-size: 11px;
@ -566,7 +554,6 @@
padding-top: 10px; padding-top: 10px;
padding-bottom: 10px; padding-bottom: 10px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75); text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
background-color: #'.$bg.';
background-repeat: repeat-x; background-repeat: repeat-x;
border-bottom: 1px solid #ffffff; border-bottom: 1px solid #ffffff;
} }
@ -578,7 +565,7 @@
} }
</style> </style>
<div class="debug_bg"> <div class="debug_bg">
<div class="debug_top"> <div class="debug_top" style="background-color: #' . $bg . ';">
var_dump(<strong>' . trim($fn_name) . '</strong>) var_dump(<strong>' . trim($fn_name) . '</strong>)
</div> </div>
'.self::_trace().' '.self::_trace().'

2
fields/multi_checkbox/field.php

@ -1,4 +1,4 @@
<? <?php
/** /**
* AVE.cms * AVE.cms

38
install/data_base.sql

@ -244,8 +244,8 @@ INSERT INTO `%%PRFX%%_document_fields` VALUES
(4, 2, 2, 0, 'Извините, запрошенный Вами документ не найден.', '0');#inst# (4, 2, 2, 0, 'Извините, запрошенный Вами документ не найден.', '0');#inst#
INSERT INTO `%%PRFX%%_documents` VALUES INSERT INTO `%%PRFX%%_documents` VALUES
(1, 1, 0, 0, '/', '0', '', 'Главная', 'Главная страница', '0', '0', '0', '1', '0', '', '', 'index,follow', '3', '0.5', '1', '0', '0', '0', '0', '', '', 'ru', '1', ''), (1, 1, 0, 0, '/', '0', '', 'Главная', 'Главная страница', '0', '0', '0', '1', '0', '', '', 'index,follow', '3', '0.5', '1', '0', '0', '0', '0', '', '', 'ru', '1', '', '0'),
(2, 1, 0, 0, '404-dokument-ne-najden', '0', '', '404 - Документ не найден', 'Ошибка 404', '0', '0', '0', '1', '0', '', '', 'noindex,nofollow', '6', '0', '1', '0', '0', '0', '0', '', '', 'ru', '2', '');#inst# (2, 1, 0, 0, '404-dokument-ne-najden', '0', '', '404 - Документ не найден', 'Ошибка 404', '0', '0', '0', '1', '0', '', '', 'noindex,nofollow', '6', '0', '1', '0', '0', '0', '0', '', '', 'ru', '2', '', '0');#inst#
INSERT INTO `%%PRFX%%_navigation` VALUES INSERT INTO `%%PRFX%%_navigation` VALUES
(1,'main','Основное меню','<li class=\"nav-item\">\n <a class=\"nav-link\" href=\"[tag:link]\">[tag:linkname]</a>\n</li>','','','<li class=\"nav-item active\">\n <a class=\"nav-link\" href=\"[tag:link]\">[tag:linkname]</a>\n</li>','','','<ul class=\"navbar-nav mr-auto\">\n[tag:content]\n</ul>','','','','','','','','1,2,3,4,5','1');#inst# (1,'main','Основное меню','<li class=\"nav-item\">\n <a class=\"nav-link\" href=\"[tag:link]\">[tag:linkname]</a>\n</li>','','','<li class=\"nav-item active\">\n <a class=\"nav-link\" href=\"[tag:link]\">[tag:linkname]</a>\n</li>','','','<ul class=\"navbar-nav mr-auto\">\n[tag:content]\n</ul>','','','','','','','','1,2,3,4,5','1');#inst#
@ -335,8 +335,38 @@ INSERT INTO `%%PRFX%%_user_groups` VALUES
(3, 'Модераторы', '1', '0', '', ''), (3, 'Модераторы', '1', '0', '', ''),
(4, 'Зарегистрированные', '1', '0', '', '');#inst# (4, 'Зарегистрированные', '1', '0', '', '');#inst#
INSERT INTO `%%PRFX%%_users` VALUES INSERT INTO `%%PRFX%%_users`
(1, '%%PASS%%', '%%EMAIL%%', '', '', '', '', '', '', '', '', '', '%%USERNAME%%', 1, '', UNIX_TIMESTAMP(), '1', UNIX_TIMESTAMP(), 'RU', '', '0', '0', '0', '0', '', '', '', '%%SALT%%', '', 0);#inst# SET
`Id` = 1,
`password` = '%%PASS%%',
`email` = '%%EMAIL%%',
`street` = '',
`street_nr` = '',
`zipcode` = '',
`city` = '',
`phone` = '',
`telefax` = '',
`description` = '',
`firstname` = '',
`lastname` = '',
`user_name` = '%%USERNAME%%',
`user_group` = 1,
`user_group_extra` = '',
`reg_time` = UNIX_TIMESTAMP(),
`status` = 1,
`last_visit` = UNIX_TIMESTAMP(),
`country` = 'RU',
`birthday` = '',
`deleted` = '0',
`del_time` = 0,
`emc` = '0',
`reg_ip` = '0',
`new_pass` = '',
`company` = '',
`taxpay` = '0',
`salt` = '%%SALT%%',
`new_salt` = '',
`user_ip` = 0;#inst#
INSERT INTO `%%PRFX%%_paginations` (`id`, `pagination_name`, `pagination_box`, `pagination_start_label`, `pagination_end_label`, `pagination_separator_box`, `pagination_separator_label`, `pagination_next_label`, `pagination_prev_label`, `pagination_link_box`, `pagination_active_link_box`, `pagination_link_template`, `pagination_link_active_template`) INSERT INTO `%%PRFX%%_paginations` (`id`, `pagination_name`, `pagination_box`, `pagination_start_label`, `pagination_end_label`, `pagination_separator_box`, `pagination_separator_label`, `pagination_next_label`, `pagination_prev_label`, `pagination_link_box`, `pagination_active_link_box`, `pagination_link_template`, `pagination_link_active_template`)
VALUES VALUES

277
install/index.php

@ -11,52 +11,85 @@
* @license GPL v.2 * @license GPL v.2
*/ */
/** /**
* Функции * Проверка подключения к БД
*
* @param string $dbhost
* @param string $dbuser
* @param string $dbpass
*
* @return bool
*/ */
function check_mysql_connect ($dbhost = '', $dbuser = '', $dbpass = '')
function check_mysql_connect($dbhost = '', $dbuser = '', $dbpass = '')
{ {
if ($dbhost != '' && $dbuser != '') if ($dbhost != '' && $dbuser != '')
{ if (@mysqli_connect($dbhost, $dbuser, $dbpass))
if (@mysqli_connect($dbhost, $dbuser, $dbpass)) return true; return true;
}
return false; return false;
} }
function check_mysql_query($link = '', $sql = '')
/**
* Проверка запроса к БД
*
* @param object $mysql_connect
* @param string $sql
*
* @return bool
*/
function check_mysql_query ($mysql_connect, $sql = '')
{ {
if ($sql != '' && $link != '') if ($sql != '' && $link != '')
{ if (@mysqli_query($mysql_connect, $sql))
if (@mysqli_query($link, $sql)) return true; return true;
}
return false; return false;
} }
function check_db_connect($dbhost = '', $dbuser = '', $dbpass = '', $dbname = '')
/**
* @param string $dbhost
* @param string $dbuser
* @param string $dbpass
* @param string $dbname
*
* @return bool
*/
function check_db_connect ($dbhost = '', $dbuser = '', $dbpass = '', $dbname = '')
{ {
if ($dbhost != '' && $dbuser != '' && $dbname != '') if ($dbhost != '' && $dbuser != '' && $dbname != '')
{ if (@mysqli_select_db(@mysqli_connect($dbhost, $dbuser, $dbpass), $dbname))
if (@mysqli_select_db(@mysqli_connect($dbhost, $dbuser, $dbpass), $dbname)) return true; return true;
}
return false; return false;
} }
function check_installed($prefix)
/**
* @param $prefix
*
* @return bool
*/
function check_installed ($prefix)
{ {
global $config; global $config;
$mysql = @mysqli_connect($config['dbhost'], $config['dbuser'], $config['dbpass'], $config['dbname']); $mysql = @mysqli_connect($config['dbhost'], $config['dbuser'], $config['dbpass'], $config['dbname']);
$query = @mysqli_query($mysql, "SELECT 1 FROM " . $prefix . "_users LIMIT 1"); $query = @mysqli_query($mysql, "SELECT 1 FROM " . $prefix . "_users LIMIT 1");
if (@mysqli_num_rows($query)) return true; if (@mysqli_num_rows($query))
else return false; return true;
else
return false;
} }
function check_required()
/**
*
*/
function check_required ()
{ {
global $error_is_required, $lang_i; global $error_is_required, $lang_i;
@ -67,23 +100,25 @@
foreach ($required as $is_required) foreach ($required as $is_required)
{ {
if (@!is_file(BASE_DIR . $is_required)) if (@!is_file(BASE_DIR . $is_required))
{
array_push($error_is_required, $lang_i['error_is_required'] . $is_required . $lang_i['error_is_required_2'] ); array_push($error_is_required, $lang_i['error_is_required'] . $is_required . $lang_i['error_is_required_2'] );
} }
}
$myphp = @PHP_VERSION; $myphp = @PHP_VERSION;
if ($myphp) if ($myphp)
{ {
$myphp_v = str_replace('.', '', $myphp); $myphp_v = str_replace('.', '', $myphp);
if ($myphp_v < $required_php) if ($myphp_v < $required_php)
{
array_push($error_is_required, $lang_i['phpversion_toold'] . $required_php); array_push($error_is_required, $lang_i['phpversion_toold'] . $required_php);
} }
} }
}
function check_writable()
/**
*
*/
function check_writable ()
{ {
global $error_is_required, $lang_i; global $error_is_required, $lang_i;
@ -96,25 +131,27 @@
foreach ($writeable as $must_writeable) foreach ($writeable as $must_writeable)
{ {
if (! is_writable(BASE_DIR . $must_writeable)) if (! is_writable(BASE_DIR . $must_writeable))
{
array_push($error_is_required, $lang_i['error_is_writeable'] . $must_writeable . $lang_i['error_is_writeable_2'] ); array_push($error_is_required, $lang_i['error_is_writeable'] . $must_writeable . $lang_i['error_is_writeable_2'] );
} }
} }
}
function clean_db ($name="", $prefix="", $mysql_connect)
/**
* @param string $name
* @param string $prefix
* @param $mysql_connect
*/
function clean_db ($name, $prefix, $mysql_connect)
{ {
@mysqli_select_db($mysql_connect, $name); @mysqli_select_db($mysql_connect, $name);
$query = @mysqli_query($mysql_connect, "SHOW TABLES FROM " . $name); $query = @mysqli_query($mysql_connect, "SHOW TABLES FROM " . $name);
while ($row = @mysqli_fetch_array($query, MYSQL_NUM)) while ($row = @mysqli_fetch_array($query, MYSQLI_NUM))
{
if (preg_match("/^" . $prefix . "/", $row[0])) if (preg_match("/^" . $prefix . "/", $row[0]))
{
@mysqli_query($mysql_connect ,"DROP TABLE " . $row[0]); @mysqli_query($mysql_connect ,"DROP TABLE " . $row[0]);
} }
}
}
/** /**
* Convert size from 10M to bytes * Convert size from 10M to bytes
@ -148,6 +185,7 @@
return $size; return $size;
} }
/** /**
* Get GD version * Get GD version
* @return string * @return string
@ -163,6 +201,7 @@
return NULL; return NULL;
} }
/** /**
* Get PCRE version * Get PCRE version
* @return string * @return string
@ -176,6 +215,7 @@
return $version; return $version;
} }
/** /**
* Get MySQL version * Get MySQL version
* @return string * @return string
@ -186,6 +226,13 @@
return $version[0]; return $version[0];
} }
/**
* @param $level
* @param $text
*
* @return string
*/
function check_param($level, $text) function check_param($level, $text)
{ {
$level = intval($level); $level = intval($level);
@ -209,13 +256,14 @@
$img = 'ico_ok_noproblem'; $img = 'ico_ok_noproblem';
break; break;
} }
return $img; return $img;
} }
/** /* @subpackage install */
* @subpackage install
*/
error_reporting(E_ERROR); error_reporting(E_ERROR);
ini_set('display_errors', 7); ini_set('display_errors', 7);
@ -227,14 +275,19 @@
define('BASE_DIR', str_replace("\\", "/", dirname(dirname(__FILE__)))); define('BASE_DIR', str_replace("\\", "/", dirname(dirname(__FILE__))));
//-- Debug Class
require (BASE_DIR . '/class/class.debug.php');
$Debug = new Debug;
if (! is_writable(BASE_DIR . '/tmp/cache/smarty/')) if (! is_writable(BASE_DIR . '/tmp/cache/smarty/'))
die('Cache folder is not writeable!'); die('Cache folder is not writeable!');
include(BASE_DIR . '/config/db.config.php'); include (BASE_DIR . '/config/db.config.php');
include(BASE_DIR . '/inc/config.php'); include (BASE_DIR . '/inc/config.php');
include(BASE_DIR . '/functions/func.common.php'); include (BASE_DIR . '/functions/func.common.php');
include(BASE_DIR . '/functions/func.helpers.php'); include (BASE_DIR . '/functions/func.logs.php');
include(BASE_DIR . '/class/class.template.php'); include (BASE_DIR . '/functions/func.helpers.php');
include (BASE_DIR . '/class/class.template.php');
$AVE_Template = new AVE_Template(BASE_DIR . '/install/tpl/'); $AVE_Template = new AVE_Template(BASE_DIR . '/install/tpl/');
@ -371,27 +424,26 @@
} }
// Создать новую БД // Создать новую БД
if(isset($_REQUEST['dbcreat'])){ if (isset($_REQUEST['dbcreat']))
{
$link = check_mysql_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']); $link = check_mysql_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']);
if (false === $link) { if (false === $link)
$AVE_Template->assign('warning', 'Ошибка соединения: ' . mysqli_error()); $AVE_Template->assign('warning', 'Ошибка соединения: ' . mysqli_error());
} else { else
$mysqli_connect = @mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']); $mysqli_connect = @mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass']);
}
if(false === $db_connect) { if (false === $db_connect)
{
@mysqli_query($mysqli_connect, "SET collation_server = 'utf8_general_ci'"); @mysqli_query($mysqli_connect, "SET collation_server = 'utf8_general_ci'");
@mysqli_query($mysqli_connect, "SET character_set_server = 'utf8'"); @mysqli_query($mysqli_connect, "SET character_set_server = 'utf8'");
$sql = 'CREATE DATABASE ' . $_POST['dbname']; $sql = 'CREATE DATABASE ' . $_POST['dbname'];
if (false === check_mysql_query($mysqli_connect, $sql)) { if (false === check_mysql_query($mysqli_connect, $sql))
$AVE_Template->assign('warning', 'Ошибка при создании базы данных: ' . mysqli_error() . "\n"); $AVE_Template->assign('warning', 'Ошибка при создании базы данных: ' . mysqli_error() . "\n");
} }
} }
}
$check_installed = check_installed($_POST['dbprefix']); $check_installed = check_installed($_POST['dbprefix']);
@ -407,50 +459,88 @@
} }
$fp = @fopen(BASE_DIR . '/config/db.config.php', 'w+'); $fp = @fopen(BASE_DIR . '/config/db.config.php', 'w+');
// Записываем данные для подключения
@fwrite($fp, "<?php\n" @fwrite($fp, "<?php\n"
. "\$config = array();\n" . "\t\$config = [\n"
. "\$config['dbhost'] = \"" . stripslashes(trim($_POST['dbhost'])) . "\";\n" . "\t\t'dbhost' => \"" . stripslashes(trim($_POST['dbhost'])) . "\",\n"
. "\$config['dbuser'] = \"" . stripslashes(trim($_POST['dbuser'])) . "\";\n" . "\t\t'dbuser' => \"" . stripslashes(trim($_POST['dbuser'])) . "\",\n"
. "\$config['dbpass'] = \"" . stripslashes(trim($_POST['dbpass'])) . "\";\n" . "\t\t'dbpass' => \"" . stripslashes(trim($_POST['dbpass'])) . "\",\n"
. "\$config['dbname'] = \"" . stripslashes(trim($_POST['dbname'])) . "\";\n" . "\t\t'dbname' => \"" . stripslashes(trim($_POST['dbname'])) . "\",\n"
. "\$config['dbpref'] = \"" . stripslashes(trim($_POST['dbprefix'])) . "\";\n" . "\t\t'dbpref' => \"" . stripslashes(trim($_POST['dbprefix'])) . "\",\n"
. "\$config['dbport'] = null;\n" . "\t\t'dbport' => null,\n"
. "\$config['dbsock'] = null;\n" . "\t\t'dbsock' => null\n"
. "\t];\n"
. "?>" . "?>"
); );
@fclose($fp); @fclose($fp);
// Класс для работы с БД
require_once (BASE_DIR . '/class/class.database.php');
//-- Если не существует объекта по работе с БД
if (! isset($AVE_DB))
{
//-- Подключаем конфигурационный файл с параметрами подключения
require_once (BASE_DIR . '/config/db.config.php');
//-- Если параметры не указаны, прерываем работу
if (! isset($config))
exit;
//-- Если константа префикса таблиц не задана, принудительно определяем ее на основании параметров в файле db.config.php
if (! defined('PREFIX'))
define('PREFIX', $config['dbpref']);
//-- Создаем объект для работы с БД
try {
$AVE_DB = AVE_DB::getInstance($config)
//-- Назначаем кодировку
->setCharset('utf8')
//-- Назначаем БД
->setDatabaseName($config['dbname']);
}
catch (AVE_DB_Exception $e)
{
ob_start();
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 3600');
header('X-Powered-By:');
echo $e->getMessage();
die;
}
unset ($config);
}
// Открываем файл структуры БД
$filename = BASE_DIR . '/install/structure_base.sql'; $filename = BASE_DIR . '/install/structure_base.sql';
$handle = fopen($filename, 'r'); $handle = fopen($filename, 'r');
$db_structure = fread($handle, filesize($filename)); $db_structure = fread($handle, filesize($filename));
fclose($handle); fclose($handle);
// Подставляем префикс
$db_structure = str_replace('%%PRFX%%', $_POST['dbprefix'], $db_structure); $db_structure = str_replace('%%PRFX%%', $_POST['dbprefix'], $db_structure);
$mysql_connect = @mysqli_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], $_POST['dbname']); // Массив запросов
@mysqli_select_db($mysql_connect, $_POST['dbname']);
$ar = explode('#inst#', $db_structure); $ar = explode('#inst#', $db_structure);
foreach ($ar as $in) foreach ($ar as $sql)
{ if (! empty($sql))
@mysqli_query($mysql_connect, "$in"); $AVE_DB->Query($sql);
}
$AVE_Template->display('step5.tpl'); $AVE_Template->display('step5.tpl');
exit; exit;
} }
elseif (true === $connect && true === $check_installed) elseif (true === $connect && true === $check_installed)
{
$AVE_Template->assign('installed', $AVE_Template->get_config_vars('database_installed')); $AVE_Template->assign('installed', $AVE_Template->get_config_vars('database_installed'));
}
else else
{
$AVE_Template->assign('warning', $AVE_Template->get_config_vars('database_not_connect')); $AVE_Template->assign('warning', $AVE_Template->get_config_vars('database_not_connect'));
} }
}
else else
{ {
$dbpref = make_random_string(5, 'abcdefghijklmnopqrstuvwxyz0123456789'); $dbpref = make_random_string(5, 'abcdefghijklmnopqrstuvwxyz0123456789');
@ -468,6 +558,43 @@
$regex_password = '/[^\x20-\xFF]/'; $regex_password = '/[^\x20-\xFF]/';
$regex_email = '/^[\w.-]+@[a-z0-9.-]+\.(?:[a-z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$/i'; $regex_email = '/^[\w.-]+@[a-z0-9.-]+\.(?:[a-z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)$/i';
// Класс для работы с БД
require_once (BASE_DIR . '/class/class.database.php');
//-- Если не существует объекта по работе с БД
if (! isset($AVE_DB))
{
//-- Подключаем конфигурационный файл с параметрами подключения
require_once (BASE_DIR . '/config/db.config.php');
//-- Если параметры не указаны, прерываем работу
if (! isset($config))
exit;
//-- Если константа префикса таблиц не задана, принудительно определяем ее на основании параметров в файле db.config.php
if (! defined('PREFIX'))
define('PREFIX', $config['dbpref']);
//-- Создаем объект для работы с БД
try {
$AVE_DB = AVE_DB::getInstance($config)
//-- Назначаем кодировку
->setCharset('utf8')
//-- Назначаем БД
->setDatabaseName($config['dbname']);
}
catch (AVE_DB_Exception $e)
{
ob_start();
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Temporarily Unavailable');
header('Retry-After: 3600');
header('X-Powered-By:');
echo $e->getMessage();
die;
}
}
$errors = array(); $errors = array();
if ($_POST['email'] == '') array_push($errors, $AVE_Template->get_config_vars('noemail')); if ($_POST['email'] == '') array_push($errors, $AVE_Template->get_config_vars('noemail'));
if (! preg_match($regex_email, $_POST['email'])) array_push($errors, $AVE_Template->get_config_vars('email_no_specialchars')); if (! preg_match($regex_email, $_POST['email'])) array_push($errors, $AVE_Template->get_config_vars('email_no_specialchars'));
@ -480,16 +607,9 @@
if (true === $db_connect && ! sizeof($errors)) if (true === $db_connect && ! sizeof($errors))
{ {
if (isset($_POST['demo']) && 1 == $_POST['demo']) if (isset($_POST['demo']) && 1 == $_POST['demo'])
{
$filename = BASE_DIR . '/install/data_demo.sql'; $filename = BASE_DIR . '/install/data_demo.sql';
}
else else
{
$filename = BASE_DIR . '/install/data_base.sql'; $filename = BASE_DIR . '/install/data_base.sql';
}
$mysql_connect = @mysqli_connect($config['dbhost'], $config['dbuser'], $config['dbpass']);
@mysqli_select_db($mysql_connect, $config['dbname']);
$handle = fopen($filename, 'r'); $handle = fopen($filename, 'r');
$dbin = fread($handle, filesize($filename)); $dbin = fread($handle, filesize($filename));
@ -510,12 +630,9 @@
$ar = explode('#inst#', $dbin); $ar = explode('#inst#', $dbin);
foreach ($ar as $in) foreach ($ar as $sql)
{ if (! empty($sql))
@mysqli_query($mysql_connect, "SET NAMES 'utf8'"); $AVE_DB->Query($sql);
@mysqli_query($mysql_connect, "SET COLLATION_CONNECTION = 'utf8_general_ci'");
@mysqli_query($mysql_connect, $in);
}
$AVE_Template->display('step6.tpl'); $AVE_Template->display('step6.tpl');

42
install/structure_base.sql

@ -31,10 +31,10 @@ CREATE TABLE `%%PRFX%%_document_fields` (
`document_in_search` enum('1','0') NOT NULL DEFAULT '1', `document_in_search` enum('1','0') NOT NULL DEFAULT '1',
PRIMARY KEY (`Id`), PRIMARY KEY (`Id`),
KEY `document_id` (`document_id`), KEY `document_id` (`document_id`),
KEY `field_id` (`rubric_field_id`), KEY `field_value` (`field_value`(333)),
KEY `value` (`field_value`), KEY `field_number_value` (`field_number_value`),
KEY `number_value` (`field_number_value`), KEY `rubric_field_id` (`rubric_field_id`),
KEY `queries` (`document_id`, `rubric_field_id`) KEY `queries` (`document_id`,`rubric_field_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;#inst# ) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;#inst#
@ -90,18 +90,18 @@ CREATE TABLE `%%PRFX%%_documents` (
`rubric_id` mediumint(5) unsigned NOT NULL DEFAULT '0', `rubric_id` mediumint(5) unsigned NOT NULL DEFAULT '0',
`rubric_tmpl_id` mediumint(5) unsigned NOT NULL DEFAULT '0', `rubric_tmpl_id` mediumint(5) unsigned NOT NULL DEFAULT '0',
`document_parent` int(10) unsigned NOT NULL DEFAULT '0', `document_parent` int(10) unsigned NOT NULL DEFAULT '0',
`document_alias` varchar(255) NOT NULL DEFAULT '', `document_alias` varchar(255) NOT NULL,
`document_alias_history` enum('0','1','2') NOT NULL DEFAULT '0', `document_alias_history` enum('0','1','2') NOT NULL DEFAULT '0',
`document_short_alias` VARCHAR(10) NOT NULL DEFAULT '', # 3.24 `document_short_alias` varchar(10) NOT NULL DEFAULT '',
`document_title` varchar(255) NOT NULL DEFAULT '', `document_title` varchar(255) NOT NULL,
`document_breadcrum_title` varchar(255) NOT NULL DEFAULT '', `document_breadcrum_title` varchar(255) NOT NULL,
`document_published` int(10) unsigned NOT NULL DEFAULT '0', `document_published` int(10) unsigned NOT NULL DEFAULT '0',
`document_expire` int(10) unsigned NOT NULL DEFAULT '0', `document_expire` int(10) unsigned NOT NULL DEFAULT '0',
`document_changed` int(10) unsigned NOT NULL DEFAULT '0', `document_changed` int(10) unsigned NOT NULL DEFAULT '0',
`document_author_id` mediumint(5) unsigned NOT NULL DEFAULT '1', `document_author_id` mediumint(5) unsigned NOT NULL DEFAULT '1',
`document_in_search` enum('1','0') NOT NULL DEFAULT '1', `document_in_search` enum('1','0') NOT NULL DEFAULT '1',
`document_meta_keywords` text NOT NULL DEFAULT '', `document_meta_keywords` text NOT NULL,
`document_meta_description` text NOT NULL DEFAULT '', `document_meta_description` text NOT NULL,
`document_meta_robots` enum('index,follow','index,nofollow','noindex,nofollow') NOT NULL DEFAULT 'index,follow', `document_meta_robots` enum('index,follow','index,nofollow','noindex,nofollow') NOT NULL DEFAULT 'index,follow',
`document_sitemap_freq` tinyint(1) NOT NULL DEFAULT '3', `document_sitemap_freq` tinyint(1) NOT NULL DEFAULT '3',
`document_sitemap_pr` float NOT NULL DEFAULT '0.5', `document_sitemap_pr` float NOT NULL DEFAULT '0.5',
@ -110,20 +110,22 @@ CREATE TABLE `%%PRFX%%_documents` (
`document_count_print` int(10) unsigned NOT NULL DEFAULT '0', `document_count_print` int(10) unsigned NOT NULL DEFAULT '0',
`document_count_view` int(10) unsigned NOT NULL DEFAULT '0', `document_count_view` int(10) unsigned NOT NULL DEFAULT '0',
`document_linked_navi_id` mediumint(5) unsigned NOT NULL DEFAULT '0', `document_linked_navi_id` mediumint(5) unsigned NOT NULL DEFAULT '0',
`document_teaser` text NOT NULL DEFAULT '', `document_teaser` text NOT NULL,
`document_tags` text NOT NULL DEFAULT '', `document_tags` text NOT NULL,
`document_lang` varchar(5) NOT NULL DEFAULT '', `document_lang` varchar(5) NOT NULL,
`document_lang_group` int(10) NOT NULL DEFAULT '0', `document_lang_group` int(10) NOT NULL DEFAULT '0',
`document_property` text, `document_property` text,
`document_rating` int(3) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`Id`), PRIMARY KEY (`Id`),
UNIQUE KEY `alias` (`document_alias`), UNIQUE KEY `document_alias` (`document_alias`),
KEY `rubric_id` (`rubric_id`), KEY `rubric_id` (`rubric_id`),
KEY `parent` (`document_parent`), KEY `document_parent` (`document_parent`),
KEY `published` (`document_published`), KEY `document_published` (`document_published`),
KEY `expire` (`document_expire`), KEY `document_expire` (`document_expire`),
KEY `status` (`document_status`), KEY `document_status` (`document_status`),
KEY `deleted` (`document_deleted`), KEY `document_deleted` (`document_deleted`),
KEY `count_view` (`document_count_view`) KEY `document_count_view` (`document_count_view`),
KEY `document_rating` (`document_rating`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;#inst# ) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;#inst#

Loading…
Cancel
Save