- getStepTitle(); ?> -
- - getErrors()) { ?> -- - -
diff --git a/.gitignore b/.gitignore
index 489d73a8..a6f5ec67 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ application/logs
uploads
application/tmp
application/plugins/admin
+application/install
diff --git a/Readme.EN.txt b/Readme.EN.txt
deleted file mode 100644
index 65e36753..00000000
--- a/Readme.EN.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-LiveStreet 2.0.0
-
-Free social engine.
-
-INSTALLATION
-1. Copy files to the engine to the desired directory site
-2. Go the address http://you_site/
-3. Follow the instructions of the installer.
\ No newline at end of file
diff --git a/Readme.RU.txt b/Readme.RU.txt
deleted file mode 100644
index 63f7ebed..00000000
--- a/Readme.RU.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-LiveStreet 2.0.0
-
-Бесплатный движок блого-социальной сети.
-
-
-УСТАНОВКА
-1. Скопировать файлы движка в нужный каталог сайта
-2. Зайти через браузер на ваш сайт ( http://ваш_сайт_на_ls/ ), автоматически запустится инсталлятор
-3. Следовать инструкциям установщика.
-
-
-ОБНОВЛЕНИЕ С ВЕРСИИ 1.0.3
-0. ОБЯЗАТЕЛЬНО СДЕЛАЙТЕ РЕЗЕРВНЫЕ КОПИИ ВАШЕГО САЙТА И БАЗЫ ДАННЫХ
-1. Обновить до версии 2.0.0 возможно только базу данных, поэтому копировать новую версию поверх старой НЕЛЬЗЯ, для установки используйте чистый каталог
-2. Скопировать файлы движка в новый нужный каталог сайта
-3. Скопировать в новый каталог (/application/config/) файл config.local.php от вашей старой версии 1.0 и скопировать каталог /uploads/ со всеми файлами. Обязательно дать права на запись в этот каталог и перезапись всех файлов.
-4. Зайти через браузер на ваш сайт ( http://ваш_сайт_на_ls/ ), автоматически запустится инсталлятор
-5. На первом шаге следует выбрать режим обновления сайта, далее следовать инструкциям установщика.
-
-
-КОНФИГУРАЦИЯ И НАСТРОЙКА ДВИЖКА
-Настройки находятся в файле /application/config/config.php. Для их изменения желательно переопределять эти настройки в файле config.local.php, это позволит избежать проблем при последующих обновлениях.
-Управление плагинами находится по адресу /admin/plugins/
-Для более удобного управления сайтом рекомендуем активировать плагин админ-панели (входит в комплект)
-
-
-По всем вопросам обращайтесь на сайт русского комьюнити http://livestreet.ru
-Официальный сайт проекта http://livestreetcms.com
-Каталог плагинов и шаблонов https://catalog.livestreetcms.com
\ No newline at end of file
diff --git a/application/install/backend/.htaccess b/application/install/backend/.htaccess
deleted file mode 100644
index 2859d7f4..00000000
--- a/application/install/backend/.htaccess
+++ /dev/null
@@ -1,2 +0,0 @@
-Order Deny,Allow
-Deny from all
\ No newline at end of file
diff --git a/application/install/backend/config.php b/application/install/backend/config.php
deleted file mode 100644
index 1c285388..00000000
--- a/application/install/backend/config.php
+++ /dev/null
@@ -1,113 +0,0 @@
- $mValue);
- }
-
- $sContent = file_get_contents(self::$sFileConfig);
- foreach ($aValues as $sName => $mValue) {
- $sContent = self::_writeValue($sName, $mValue, $sContent);
- }
- file_put_contents(self::$sFileConfig, $sContent);
- return true;
- }
-
- static public function get($sName, $mDefault = null)
- {
- if (!self::checkFile(false)) {
- return $mDefault;
- }
-
- $aConfig = include(self::$sFileConfig);
-
- if (strpos($sName, '.')) {
- $sVal = $aConfig;
- $aKeys = explode('.', $sName);
- foreach ($aKeys as $k) {
- if (isset($sVal[$k])) {
- $sVal = $sVal[$k];
- } else {
- return $mDefault;
- }
- }
- } else {
- if (isset($aConfig[$sName])) {
- $sVal = $aConfig[$sName];
- } else {
- return $mDefault;
- }
- }
- return $sVal;
-
- }
-
- static public function _writeValue($sName, $mValue, $sContent)
- {
- $sName = '$config[\'' . implode('\'][\'', explode('.', $sName)) . '\']';
- $mValue = self::_convertToConfigValue($mValue);
- /**
- * Если переменная уже определена в конфиге,
- * то меняем значение.
- */
- if (substr_count($sContent, $sName)) {
- $sContent = preg_replace("~" . preg_quote($sName) . ".+;~Ui", $sName . ' = ' . $mValue . ';', $sContent);
- } else {
- $sContent = str_replace('return $config;', $sName . ' = ' . $mValue . ';' . PHP_EOL . 'return $config;',
- $sContent);
- }
- return $sContent;
- }
-
- static public function _convertToConfigValue($mValue)
- {
- switch (true) {
- case is_string($mValue):
- return "'" . addslashes($mValue) . "'";
-
- case is_bool($mValue):
- return ($mValue) ? "true" : "false";
-
- case is_array($mValue):
- $sArrayString = "";
- foreach ($mValue as $sKey => $sValue) {
- $sArrayString .= "'{$sKey}'=>" . self::_convertToConfigValue($sValue) . ",";
- }
- return "array(" . $sArrayString . ")";
-
- case is_numeric($mValue):
- return $mValue;
-
- default:
- return "'" . (string)$mValue . "'";
- }
- }
-
- static public function checkFile($bCheckWritable = true)
- {
- if (is_null(self::$sFileConfig) or !file_exists(self::$sFileConfig)) {
- self::$sLastError = InstallCore::getLang('config.errors.file_not_found');
- return false;
- }
- if ($bCheckWritable) {
- if (!is_writable(self::$sFileConfig)) {
- self::$sLastError = InstallCore::getLang('config.errors.file_not_writable');
- return false;
- }
- }
- return true;
- }
-
-}
\ No newline at end of file
diff --git a/application/install/backend/core.php b/application/install/backend/core.php
deleted file mode 100644
index 2f11ef8d..00000000
--- a/application/install/backend/core.php
+++ /dev/null
@@ -1,420 +0,0 @@
-defineGroups($aGroups);
- $this->loadLang();
- $this->loadStoredData();
- self::$oLayout = new InstallTemplate('layout.tpl.php');
- }
-
- protected function defineGroups($aGroups)
- {
- $aGroupsResult = array();
- $aParamsResult = array();
- foreach ($aGroups as $sGroup => $aSteps) {
- foreach ($aSteps as $sStep => $aParams) {
- if (is_int($sStep)) {
- $sStep = $aParams;
- $aParams = array();
- }
- $aParamsResult[$sGroup][$sStep] = $aParams;
- $aGroupsResult[$sGroup][] = $sStep;
- }
- }
- self::$aGroups = $aGroupsResult;
- self::$aGroupsParams = $aParamsResult;
- }
-
- /**
- * Запускает процесс инсталляции
- */
- public function run()
- {
- if (self::getRequest('reset')) {
- self::$aStoredData = array();
- self::saveStoredData();
- }
- /**
- * Получаем текущую группу
- */
- $sGroup = self::getRequestStr('group');
- if ($sGroup) {
- return $this->runGroup($sGroup);
- }
- /**
- * Если группа не определена и она только одна - запускаем
- */
- if (!$sGroup and count(self::$aGroups) == 1) {
- $aGroupNames = array_keys(self::$aGroups);
- return $this->runGroup(array_shift($aGroupNames));
- }
- /**
- * Показываем страницу выбора группы
- */
- self::setPreviousStepHide();
- self::setNextStepHide();
- self::setInstallResetHide();
- self::render('index.tpl.php', array('groups' => array_keys(self::$aGroups)));
- }
-
- public function runGroup($sGroup)
- {
- if (!isset(self::$aGroups[$sGroup])) {
- return self::renderError('Not found group');
- }
- $aGroup = self::$aGroups[$sGroup];
- /**
- * Определяем текущий шаг
- * Смотрим его в куках, если там нет, то используем первый
- * Шаг сквозной для всех групп, поэтому при установке у одной группы - у других он сбрасывается на первый
- */
- $sCurrentStep = self::getStoredData('step');
- if (!$sCurrentStep or !in_array($sCurrentStep, $aGroup)) {
- if (!$sFirst = array_shift($aGroup)) {
- return self::renderError('Not found steps');
- }
- $sCurrentStep = $sFirst;
- }
-
- $sNextStep = self::getNextStep($sGroup, $sCurrentStep);
- $sPrevousStep = self::getPreviousStep($sGroup, $sCurrentStep);
- if (!$sPrevousStep) {
-
- }
- if (!$sNextStep) {
- self::setNextStepHide();
- }
- if (isset($_POST['action_previous'])) {
- if ($sPrevousStep) {
- InstallCore::setStoredData('step', $sPrevousStep);
- InstallCore::location($sGroup);
- } elseif (count(self::$aGroups) > 1) {
- /**
- * Перенаправлям на страницу выбора группы
- */
- self::location();
- }
- }
- return $this->runStep($sCurrentStep, $sGroup);
- }
-
- public function runStep($sStep, $sGroup)
- {
- $sClass = 'InstallStep' . ucfirst($sStep);
- if (!class_exists($sClass)) {
- return self::renderError('Not found step ' . $sStep);
- }
- $aParams = isset(self::$aGroupsParams[$sGroup][$sStep]) ? self::$aGroupsParams[$sGroup][$sStep] : array();
- $oStep = new $sClass($sGroup, $aParams);
- if (isset($_POST['action_next'])) {
- /**
- * Сначала обрабатываем шаг
- */
- $oStep->_process();
- }
- $oStep->_show();
- }
-
- protected function loadLang()
- {
- $sLang = 'ru';
- $sFilePath = INSTALL_DIR . DIRECTORY_SEPARATOR . 'frontend' . DIRECTORY_SEPARATOR . 'i18n' . DIRECTORY_SEPARATOR . $sLang . '.php';
- if (file_exists($sFilePath)) {
- self::$aLangMsg = require($sFilePath);
- }
- }
-
- protected function loadStoredData()
- {
- $aData = isset($_COOKIE[self::COOKIE_NAME]) ? $_COOKIE[self::COOKIE_NAME] : '';
- if (get_magic_quotes_gpc()) {
- $this->stripslashes($aData);
- }
- self::$aStoredData = $aData ? @unserialize($aData) : array();
- }
-
- static public function saveStoredData()
- {
- $sData = serialize(self::$aStoredData);
- setcookie(self::COOKIE_NAME, $sData, time() + 60 * 60 * 24);
- }
-
- static public function getStoredData($sName, $mDefault = null)
- {
- return isset(self::$aStoredData[$sName]) ? self::$aStoredData[$sName] : $mDefault;
- }
-
- static public function setStoredData($sName, $mValue)
- {
- self::$aStoredData[$sName] = $mValue;
- self::saveStoredData();
- }
-
- static public function getDataFilePath($sFile)
- {
- return dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . $sFile;
- }
-
- static public function renderError($sMsg, $sTitle = null)
- {
- self::render('error.tpl.php', array('msg' => $sMsg, 'title' => $sTitle));
- }
-
- static public function render($sTemplate, $aVars = array())
- {
-
- if (is_object($sTemplate)) {
- $oTemplate = $sTemplate;
- self::$oLayout->assign($aVars);
- } else {
- $oTemplate = new InstallTemplate($sTemplate, $aVars);
- }
-
- $oTemplate->setParent(self::$oLayout);
- $sContent = $oTemplate->render();
- self::$oLayout->assign('content', $sContent);
-
- echo(self::$oLayout->render());
- exit();
- }
-
- static public function assign($mName, $mValue = null)
- {
- self::$oLayout->assign($mName, $mValue);
- }
-
- static public function getRequest($sName, $mDefault = null)
- {
- $sName = str_replace('.', '_', $sName);
- return isset($_REQUEST[$sName]) ? $_REQUEST[$sName] : $mDefault;
- }
-
- static public function getRequestStr($sName, $mDefault = null)
- {
- $sVal = self::getRequest($sName, $mDefault);
- return is_scalar($sVal) ? (string)$sVal : '';
- }
-
- static public function getLang($sName)
- {
- if (strpos($sName, '.')) {
- $sLang = self::$aLangMsg;
- $aKeys = explode('.', $sName);
- foreach ($aKeys as $k) {
- if (isset($sLang[$k])) {
- $sLang = $sLang[$k];
- } else {
- return $sName;
- }
- }
- } else {
- if (isset(self::$aLangMsg[$sName])) {
- $sLang = self::$aLangMsg[$sName];
- } else {
- return $sName;
- }
- }
- return $sLang;
- }
-
- static public function getNextStep($sGroup, $sStep = null)
- {
- $aGroups = self::$aGroups;
- if (isset($aGroups[$sGroup])) {
- if (is_null($sStep)) {
- return array_shift($aGroups[$sGroup]);
- } else {
- if (false !== ($iPos = array_search($sStep, $aGroups[$sGroup]))) {
- $aNext = array_slice($aGroups[$sGroup], $iPos + 1, 1);
- $sNext = current($aNext);
- return $sNext !== false ? $sNext : null;
- }
- }
- } else {
- return null;
- }
- }
-
- static public function getPreviousStep($sGroup, $sStep = null)
- {
- $aGroups = self::$aGroups;
- if (isset($aGroups[$sGroup])) {
- if (is_null($sStep)) {
- return array_shift($aGroups[$sGroup]);
- } else {
- if ($iPos = array_search($sStep, $aGroups[$sGroup])) {
- $aPrev = array_slice($aGroups[$sGroup], $iPos - 1, 1);
- $sPrev = current($aPrev);
- return $sPrev !== false ? $sPrev : null;
- }
- }
- } else {
- return null;
- }
- }
-
- static public function location($sGroup = '')
- {
- header('Location: ./' . ($sGroup ? '?group=' . $sGroup : ''));
- exit;
- }
-
- static public function setInstallResetHide($bHide = true)
- {
- self::$oLayout->assign('install_reset_hide', $bHide);
- }
-
- static public function setNextStepHide($bHide = true)
- {
- self::$oLayout->assign('next_step_hide', $bHide);
- }
-
- static public function setNextStepDisable($bDisable = true)
- {
- self::$oLayout->assign('next_step_disable', $bDisable);
- }
-
- static public function setPreviousStepHide($bHide = true)
- {
- self::$oLayout->assign('previous_step_hide', $bHide);
- }
-
- static public function setPreviousStepDisable($bDisable = true)
- {
- self::$oLayout->assign('previous_step_disable', $bDisable);
- }
-
- protected function stripslashes(&$data)
- {
- if (is_array($data)) {
- foreach ($data as $sKey => $value) {
- if (is_array($value)) {
- $this->stripslashes($data[$sKey]);
- } else {
- $data[$sKey] = stripslashes($value);
- }
- }
- } else {
- $data = stripslashes($data);
- }
- }
-
- /**
- * Выполняет транслитерацию текста
- *
- * @param $sText
- * @param bool $bLower
- * @return mixed|string
- */
- static public function transliteration($sText, $bLower = true)
- {
- $aConverter = array(
- 'а' => 'a',
- 'б' => 'b',
- 'в' => 'v',
- 'г' => 'g',
- 'д' => 'd',
- 'е' => 'e',
- 'ё' => 'e',
- 'ж' => 'zh',
- 'з' => 'z',
- 'и' => 'i',
- 'й' => 'y',
- 'к' => 'k',
- 'л' => 'l',
- 'м' => 'm',
- 'н' => 'n',
- 'о' => 'o',
- 'п' => 'p',
- 'р' => 'r',
- 'с' => 's',
- 'т' => 't',
- 'у' => 'u',
- 'ф' => 'f',
- 'х' => 'h',
- 'ц' => 'c',
- 'ч' => 'ch',
- 'ш' => 'sh',
- 'щ' => 'sch',
- 'ь' => "'",
- 'ы' => 'y',
- 'ъ' => "'",
- 'э' => 'e',
- 'ю' => 'yu',
- 'я' => 'ya',
- 'А' => 'A',
- 'Б' => 'B',
- 'В' => 'V',
- 'Г' => 'G',
- 'Д' => 'D',
- 'Е' => 'E',
- 'Ё' => 'E',
- 'Ж' => 'Zh',
- 'З' => 'Z',
- 'И' => 'I',
- 'Й' => 'Y',
- 'К' => 'K',
- 'Л' => 'L',
- 'М' => 'M',
- 'Н' => 'N',
- 'О' => 'O',
- 'П' => 'P',
- 'Р' => 'R',
- 'С' => 'S',
- 'Т' => 'T',
- 'У' => 'U',
- 'Ф' => 'F',
- 'Х' => 'H',
- 'Ц' => 'C',
- 'Ч' => 'Ch',
- 'Ш' => 'Sh',
- 'Щ' => 'Sch',
- 'Ь' => "'",
- 'Ы' => 'Y',
- 'Ъ' => "'",
- 'Э' => 'E',
- 'Ю' => 'Yu',
- 'Я' => 'Ya',
- " " => "-",
- "." => "",
- "/" => "-",
- "_" => "-",
- 'і' => 'i',
- 'І' => 'I',
- 'ї' => 'i',
- 'Ї' => 'I',
- 'є' => 'e',
- 'Є' => 'E',
- 'ґ' => 'g',
- 'Ґ' => 'G',
- '«' => '',
- '»' => '',
- );
- $sRes = strtr($sText, $aConverter);
- if ($sResIconv = @iconv("UTF-8", "ISO-8859-1//IGNORE//TRANSLIT", $sRes)) {
- $sRes = $sResIconv;
- }
- $sRes = preg_replace('/[^A-Za-z0-9\-]/', '', $sRes);
- $sRes = preg_replace('/\-{2,}/', '-', $sRes);
- if ($bLower) {
- $sRes = strtolower($sRes);
- }
- return $sRes;
- }
-}
\ No newline at end of file
diff --git a/application/install/backend/step.php b/application/install/backend/step.php
deleted file mode 100644
index 64e8a927..00000000
--- a/application/install/backend/step.php
+++ /dev/null
@@ -1,357 +0,0 @@
-aParams = array_merge($this->aParams, $aParams);
- $this->oTemplate = new InstallTemplate($this->getTemplateName());
- $this->sGroup = $sGroup;
- $this->init();
- }
-
- public function init()
- {
-
- }
-
- public function getParam($sName, $mDefault = null)
- {
- return array_key_exists($sName, $this->aParams) ? $this->aParams[$sName] : $mDefault;
- }
-
- protected function getTemplateName()
- {
- return 'steps/' . $this->getName() . '.tpl.php';
- }
-
- public function getErrors()
- {
- return $this->aErrors;
- }
-
- protected function addError($sMsg)
- {
- $this->aErrors[] = $sMsg;
- return false;
- }
-
- public function getName()
- {
- $aPath = explode('_', install_func_underscore(get_class($this)));
- array_shift($aPath);
- array_shift($aPath);
- $sName = ucfirst(install_func_camelize(join('_', $aPath)));
- $sName{0} = strtolower($sName{0});
- return $sName;
- }
-
- public function getStepTitle()
- {
- return InstallCore::getLang('steps.' . $this->getName() . '.title');
- }
-
- public function getGroupTitle()
- {
- return InstallCore::getLang('groups.' . $this->sGroup . '.title');
- }
-
- /**
- * Выводит шаблон шага
- */
- protected function render()
- {
- InstallCore::assign('currentStep', $this);
- $this->oTemplate->assign('currentStep', $this);
- InstallCore::render($this->oTemplate);
- }
-
- protected function assign($mName, $mValue = null)
- {
- $this->oTemplate->assign($mName, $mValue);
- }
-
- /**
- * Запускает отображение шага
- */
- public function _show()
- {
- if ($this->beforeShow()) {
- $this->show();
- $this->afterShow();
- $this->render();
- } else {
- /**
- * todo: нужно изменить - показываем только страницу с ошибкой
- */
- return self::renderError('Вернитесь на прошлый шаг');
- }
- }
-
- /**
- * Запускает выполнение шага - когда пользователь жмет "Далее" на текущем шаге
- */
- public function _process()
- {
- if ($this->beforeProcess()) {
- if ($this->process()) {
- $this->afterProcess();
- /**
- * Устанавливаем следующий шаг
- */
- if ($sNextStep = InstallCore::getNextStep($this->sGroup, $this->getName())) {
- InstallCore::setStoredData('step', $sNextStep);
- }
- /**
- * Редиректим
- */
- InstallCore::location($this->sGroup);
- } else {
- /**
- * todo: здесь нужно показать сам текущий шаг с сообщением об ошибке
- */
- //return InstallCore::renderError('Ошибка при выполнении шага');
- }
- } else {
- /**
- * todo: нужно изменить - показываем сам шаг с сообщением об ошибке
- */
- //return InstallCore::renderError('Невозможно выполнить шаг');
- }
- }
-
- protected function getDBConnection($sHost, $iPort, $sUser, $sPasswd, $bGeneral = false)
- {
- $oDb = @mysqli_connect($sHost, $sUser, $sPasswd, '', $iPort);
- if ($oDb) {
- /**
- * Валидация версии MySQL сервера
- */
- if (!version_compare(mysqli_get_server_info($oDb), '5.0.0', '>')) {
- return $this->addError(InstallCore::getLang('db.errors.db_version'));
- }
- mysqli_query($oDb, 'set names utf8');
- if ($bGeneral) {
- $this->rDbLink = $oDb;
- }
- return $oDb;
- }
- return $this->addError(InstallCore::getLang('db.errors.db_connect'));
- }
-
- protected function setDbParams($aParams)
- {
- $this->aDbParams = $aParams;
- }
-
- protected function importDumpDB($oDb, $sFile, $aParams = null)
- {
- $sFileQuery = @file_get_contents($sFile);
-
- if (is_null($aParams)) {
- $aParams = $this->aDbParams;
- }
-
- if (isset($aParams['prefix'])) {
- $sFileQuery = str_replace('prefix_', $aParams['prefix'], $sFileQuery);
- }
- $aQuery = preg_split("#;(\n|\r)#", $sFileQuery, null, PREG_SPLIT_NO_EMPTY);
- /**
- * Массив для сбора ошибок
- */
- $aErrors = array();
-
- if (isset($aParams['check_table'])) {
- /**
- * Смотрим, какие таблицы существуют в базе данных
- */
- $aDbTables = array();
- $aResult = @mysqli_query($oDb, "SHOW TABLES");
- if (!$aResult) {
- return array(
- 'result' => false,
- 'errors' => array($this->addError(InstallCore::getLang('db.errors.db_query')))
- );
- }
- while ($aRow = mysqli_fetch_array($aResult, MYSQLI_NUM)) {
- $aDbTables[] = $aRow[0];
- }
- /**
- * Если среди таблиц БД уже есть нужная таблица, то выполнять SQL-дамп не нужно
- */
- if (in_array($aParams['prefix'] . $aParams['check_table'], $aDbTables)) {
- return array('result' => true, 'errors' => array());
- }
- }
- /**
- * Проверка на существование поля
- */
- if (isset($aParams['check_table_field'])) {
- list($sCheckTable, $sCheckField) = $aParams['check_table_field'];
- $sCheckTable = str_replace('prefix_', $aParams['prefix'], $sCheckTable);
- $aResult = @mysqli_query($oDb, "SHOW FIELDS FROM `{$sCheckTable}`");
- if (!$aResult) {
- return array(
- 'result' => false,
- 'errors' => array($this->addError(InstallCore::getLang('db.errors.db_query')))
- );
- }
- while ($aRow = mysqli_fetch_assoc($aResult)) {
- if ($aRow['Field'] == $sCheckField) {
- return array('result' => true, 'errors' => array());
- }
- }
- }
- /**
- * Выполняем запросы по очереди
- */
- foreach ($aQuery as $sQuery) {
- $sQuery = trim($sQuery);
- /**
- * Заменяем движек, если таковой указан в запросе
- */
- if (isset($aParams['engine'])) {
- $sQuery = str_ireplace('ENGINE=InnoDB', "ENGINE={$aParams['engine']}", $sQuery);
- }
-
- if ($sQuery != '') {
- $bResult = mysqli_query($oDb, $sQuery);
- if (!$bResult) {
- $sError = mysqli_error($oDb);
- if (isset($aParams['skip_fk_errors']) and $aParams['skip_fk_errors'] and
- (stripos($sError, 'errno: 152') !== false or stripos($sError, 'errno: 150') !== false or (stripos($sError, '_fk') !== false and stripos($sError, 'DROP') !== false))
- ) {
- // пропускаем ошибки связанные с внешними ключами
- } else {
- $aErrors[] = mysqli_error($oDb);
- }
- }
- }
- }
-
- return array('result' => count($aErrors) ? false : true, 'errors' => $aErrors);
- }
-
- protected function dbCheckTable($sTable)
- {
- /**
- * Смотрим, какие таблицы существуют в базе данных
- */
- $aDbTables = array();
- $aResult = @mysqli_query($this->rDbLink, "SHOW TABLES");
- if (!$aResult) {
- return false;
- }
- while ($aRow = mysqli_fetch_array($aResult, MYSQLI_NUM)) {
- $aDbTables[] = $aRow[0];
- }
- /**
- * Ищем необходимую таблицу
- */
- $aParams = $this->aDbParams;
- if (isset($aParams['prefix'])) {
- $sTable = str_replace('prefix_', $aParams['prefix'], $sTable);
- }
- if (in_array($sTable, $aDbTables)) {
- return true;
- }
- return false;
- }
-
- protected function dbQuery($sQuery)
- {
- $aParams = $this->aDbParams;
- if (isset($aParams['prefix'])) {
- $sQuery = str_replace('prefix_', $aParams['prefix'], $sQuery);
- }
- if (isset($aParams['engine'])) {
- $sQuery = str_ireplace('ENGINE=InnoDB', "ENGINE={$aParams['engine']}", $sQuery);
- }
-
- if ($rResult = mysqli_query($this->rDbLink, $sQuery)) {
- return $rResult;
- }
- $aErrors[] = mysqli_error($this->rDbLink);
- return false;
- }
-
- protected function dbSelect($sQuery)
- {
- $aResult = array();
- if ($rResult = $this->dbQuery($sQuery)) {
- while ($aRow = mysqli_fetch_assoc($rResult)) {
- $aResult[] = $aRow;
- }
- }
- return $aResult;
- }
-
- protected function dbSelectOne($sQuery)
- {
- $aResult = $this->dbSelect($sQuery);
- if ($aResult) {
- $aRow = reset($aResult);
- return $aRow;
- }
- return array();
- }
-
- protected function dbInsertQuery($sTable, $aFields, $bRun = true)
- {
- $aPath = array();
- foreach ($aFields as $sFields => $sValue) {
- if (is_int($sValue)) {
- $aPath[] = "`{$sFields}` = " . $sValue;
- } else {
- $aPath[] = "`{$sFields}` = '" . mysqli_escape_string($this->rDbLink, $sValue) . "'";
- }
- }
- $sQuery = "INSERT INTO {$sTable} SET " . join(', ', $aPath);
- if ($bRun) {
- if ($this->dbQuery($sQuery)) {
- return mysqli_insert_id($this->rDbLink);
- }
- return false;
- } else {
- return $sQuery;
- }
- }
-
- protected function beforeShow()
- {
- return true;
- }
-
- protected function afterShow()
- {
-
- }
-
- protected function beforeProcess()
- {
- return true;
- }
-
- protected function afterProcess()
- {
-
- }
-
- public function show()
- {
-
- }
-
- public function process()
- {
- return true;
- }
-}
\ No newline at end of file
diff --git a/application/install/backend/step/checkRequirements.php b/application/install/backend/step/checkRequirements.php
deleted file mode 100644
index d77ce095..00000000
--- a/application/install/backend/step/checkRequirements.php
+++ /dev/null
@@ -1,119 +0,0 @@
-=')) {
- $aRequirements[] = array(
- 'name' => 'php_version',
- 'current' => PHP_VERSION
- );
- }
- if (!in_array(strtolower(@ini_get('safe_mode')), array('0', 'off', ''))) {
- $aRequirements[] = array(
- 'name' => 'safe_mode',
- 'current' => InstallCore::getLang('yes')
- );
- }
- if (!@preg_match('//u', '')) {
- $aRequirements[] = array(
- 'name' => 'utf8',
- 'current' => InstallCore::getLang('no')
- );
- }
- if (!@extension_loaded('mbstring')) {
- $aRequirements[] = array(
- 'name' => 'mbstring',
- 'current' => InstallCore::getLang('no')
- );
- }
- if (!in_array(strtolower(@ini_get('mbstring.func_overload')), array('0', '4', 'no overload'))) {
- $aRequirements[] = array(
- 'name' => 'mbstring_func_overload',
- 'current' => InstallCore::getLang('yes')
- );
- }
- if (!@extension_loaded('SimpleXML')) {
- $aRequirements[] = array(
- 'name' => 'xml',
- 'current' => InstallCore::getLang('no')
- );
- }
- if (@extension_loaded('xdebug')) {
- $iLevel = (int)@ini_get('xdebug.max_nesting_level');
- if ($iLevel < 1000) {
- $aRequirements[] = array(
- 'name' => 'xdebug',
- 'current' => InstallCore::getLang('yes') . " ({$iLevel})"
- );
- }
- }
- /**
- * Права на запись файлов
- */
- $bWriteSolutions = false;
- $sAppDir = dirname(INSTALL_DIR);
- $sDir = dirname($sAppDir) . DIRECTORY_SEPARATOR . 'uploads';
- if (!is_dir($sDir) or !is_writable($sDir)) {
- $aRequirements[] = array(
- 'name' => 'dir_uploads',
- 'current' => InstallCore::getLang('is_not_writable')
- );
- $bWriteSolutions = true;
- }
- $sDir = $sAppDir . DIRECTORY_SEPARATOR . 'plugins';
- if (!is_dir($sDir) or !is_writable($sDir)) {
- $aRequirements[] = array(
- 'name' => 'dir_plugins',
- 'current' => InstallCore::getLang('is_not_writable')
- );
- $bWriteSolutions = true;
- }
- $sDir = $sAppDir . DIRECTORY_SEPARATOR . 'tmp';
- if (!is_dir($sDir) or !is_writable($sDir)) {
- $aRequirements[] = array(
- 'name' => 'dir_tmp',
- 'current' => InstallCore::getLang('is_not_writable')
- );
- $bWriteSolutions = true;
- }
- $sDir = $sAppDir . DIRECTORY_SEPARATOR . 'logs';
- if (!is_dir($sDir) or !is_writable($sDir)) {
- $aRequirements[] = array(
- 'name' => 'dir_logs',
- 'current' => InstallCore::getLang('is_not_writable')
- );
- $bWriteSolutions = true;
- }
- $sFile = $sAppDir . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.local.php';
- if (!is_file($sFile) or !is_writable($sFile)) {
- $aRequirements[] = array(
- 'name' => 'file_config_local',
- 'current' => InstallCore::getLang('is_not_writable')
- );
- $bWriteSolutions = true;
- }
-
- if (count($aRequirements)) {
- InstallCore::setNextStepDisable();
- }
-
- if ($bWriteSolutions) {
- $sBuildPath = $sAppDir . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'build.sh';
- $sAdditionalSolution .= '' . InstallCore::getLang('steps.checkRequirements.writable_solution') . '
';
- $sAdditionalSolution .= 'chmod 0755 ' . $sBuildPath . '
';
- $sAdditionalSolution .= '' . $sBuildPath . '
';
- }
-
- $this->assign('requirements', $aRequirements);
- $this->assign('additionalSolution', $sAdditionalSolution);
- }
-
-}
diff --git a/application/install/backend/step/installAdmin.php b/application/install/backend/step/installAdmin.php
deleted file mode 100644
index ddb4e19f..00000000
--- a/application/install/backend/step/installAdmin.php
+++ /dev/null
@@ -1,62 +0,0 @@
-addError(InstallCore::getLang('steps.installAdmin.errors.mail'));
- }
- /**
- * Проверяем корректность пароль
- */
- $sPasswd = InstallCore::getRequestStr('admin_passwd');
- if (mb_strlen($sPasswd, 'UTF-8') < 3) {
- return $this->addError(InstallCore::getLang('steps.installAdmin.errors.passwd'));
- }
- /**
- * Получаем данные коннекта к БД из конфига
- */
- InstallConfig::$sFileConfig = dirname(INSTALL_DIR) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.local.php';
- /**
- * Коннект к серверу БД
- */
- if (!$oDb = $this->getDBConnection(InstallConfig::get('db.params.host'), InstallConfig::get('db.params.port'),
- InstallConfig::get('db.params.user'), InstallConfig::get('db.params.pass'))
- ) {
- return false;
- }
- /**
- * Выбираем БД
- */
- if (!@mysqli_select_db($oDb, InstallConfig::get('db.params.dbname'))) {
- return $this->addError(InstallCore::getLang('db.errors.db_query'));
- }
- /**
- * Обновляем пользователя
- */
- $sPrefix = InstallConfig::get('db.table.prefix');
- $sQuery = "
- UPDATE `{$sPrefix}user`
- SET
- `user_mail` = '{$sMail}',
- `user_admin` = '1',
- `user_password` = '" . md5($sPasswd) . "'
- WHERE `user_id` = 1";
-
- if (!mysqli_query($oDb, $sQuery)) {
- return $this->addError(InstallCore::getLang('db.errors.db_query'));
- }
- return true;
- }
-}
\ No newline at end of file
diff --git a/application/install/backend/step/installComplete.php b/application/install/backend/step/installComplete.php
deleted file mode 100644
index 51b41f41..00000000
--- a/application/install/backend/step/installComplete.php
+++ /dev/null
@@ -1,23 +0,0 @@
- md5(time() . mt_rand()),
- 'module.talk.encrypt' => md5(time() . mt_rand()),
- 'module.security.hash' => md5(time() . mt_rand()),
- );
- InstallConfig::save($aSave);
- }
-}
\ No newline at end of file
diff --git a/application/install/backend/step/installDb.php b/application/install/backend/step/installDb.php
deleted file mode 100644
index b2186e5d..00000000
--- a/application/install/backend/step/installDb.php
+++ /dev/null
@@ -1,156 +0,0 @@
-sConfigPath = dirname(INSTALL_DIR) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.local.php';
- InstallConfig::$sFileConfig = $this->sConfigPath;
- }
-
- /**
- * Получаем данные для загрузки на форму
- * Возможные источники: реквест, конфиг, дефолтные значения
- *
- * @param $sName
- * @param null $mDefault
- * @param bool $bUseHtmlspecialchars
- *
- * @return mixed|null|string
- */
- public function getValue($sName, $mDefault = null, $bUseHtmlspecialchars = true)
- {
- $mResult = null;
- $sNameRequest = str_replace('.', '_', $sName);
- if (isset($_REQUEST[$sNameRequest])) {
- $mResult = $_REQUEST[$sNameRequest];
- } else {
- $mResult = InstallConfig::get($sName, $mDefault);
- }
- return $bUseHtmlspecialchars ? htmlspecialchars($mResult) : $mResult;
- }
-
- /**
- * Обработка отправки формы
- *
- * @return bool
- */
- public function process()
- {
- if (!$aRes = $this->processDbCheck()) {
- return $aRes;
- }
- list($oDb, $sEngineDB) = $aRes;
- /**
- * Запускаем импорт дампов, сначала GEO DB
- */
- list($bResult, $aErrors) = array_values($this->importDumpDB($oDb, InstallCore::getDataFilePath('sql/geo.sql'),
- array(
- 'engine' => $sEngineDB,
- 'prefix' => InstallCore::getRequestStr('db.table.prefix'),
- 'check_table' => 'geo_city'
- )));
- if ($bResult) {
- /**
- * Запускаем основной дамп
- */
- list($bResult, $aErrors) = array_values($this->importDumpDB($oDb,
- InstallCore::getDataFilePath('sql/dump.sql'), array(
- 'engine' => $sEngineDB,
- 'prefix' => InstallCore::getRequestStr('db.table.prefix'),
- 'check_table' => 'topic'
- )));
- if ($bResult) {
- return true;
- }
- }
- return $this->addError(join('
', $aErrors));
- }
-
- protected function processDbCheck()
- {
- /**
- * Коннект к серверу БД
- */
- if (!$oDb = $this->getDBConnection(InstallCore::getRequestStr('db.params.host'),
- InstallCore::getRequestStr('db.params.port'), InstallCore::getRequestStr('db.params.user'),
- InstallCore::getRequestStr('db.params.pass'))
- ) {
- return false;
- }
- /**
- * Выбор БД
- */
- $sNameDb = InstallCore::getRequestStr('db.params.dbname');
- if (!InstallCore::getRequest('db_create')) {
- if (!@mysqli_select_db($oDb, $sNameDb)) {
- return $this->addError(InstallCore::getLang('steps.installDb.errors.db_not_found'));
- }
- } else {
- /**
- * Пытаемся создать БД
- */
- @mysqli_query($oDb,
- "CREATE DATABASE IF NOT EXISTS `{$sNameDb}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
- if (!@mysqli_select_db($oDb, $sNameDb)) {
- return $this->addError(InstallCore::getLang('steps.installDb.errors.db_not_create'));
- }
- }
- /**
- * Проверяем корректность префикса таблиц
- */
- if (!preg_match('#^[a-z0-9\_]*$#i', InstallCore::getRequestStr('db.table.prefix'))) {
- return $this->addError(InstallCore::getLang('steps.installDb.errors.db_table_prefix'));
- }
- /**
- * Определяем поддержку InnoDB
- */
- $sEngineDB = 'MyISAM';
- if ($aRes = @mysqli_query($oDb, 'SHOW ENGINES')) {
- while ($aRow = mysqli_fetch_assoc($aRes)) {
- if (strtoupper($aRow['Engine']) == 'INNODB' and in_array(strtoupper($aRow['Support']),
- array('DEFAULT', 'YES'))
- ) {
- $sEngineDB = 'InnoDB';
- break;
- }
- }
- }
-
- $sPathRootWeb = $this->getPathRootWeb();
- $aDirs = array();
- $sDirs = trim(str_replace('http://' . $_SERVER['HTTP_HOST'], '', $sPathRootWeb), '/');
- if ($sDirs != '') {
- $aDirs = explode('/', $sDirs);
- }
-
- /**
- * Прописываем параметры в конфиг
- */
- $aSave = array(
- 'db.params.host' => InstallCore::getRequestStr('db.params.host'),
- 'db.params.port' => InstallCore::getRequestStr('db.params.port'),
- 'db.params.dbname' => InstallCore::getRequestStr('db.params.dbname'),
- 'db.params.user' => InstallCore::getRequestStr('db.params.user'),
- 'db.params.pass' => InstallCore::getRequestStr('db.params.pass'),
- 'db.table.prefix' => InstallCore::getRequestStr('db.table.prefix'),
- 'db.tables.engine' => $sEngineDB,
- 'path.root.web' => $sPathRootWeb,
- 'path.offset_request_url' => count($aDirs),
- );
- if (!InstallConfig::save($aSave)) {
- return $this->addError(InstallConfig::$sLastError);
- }
- return array($oDb, $sEngineDB);
- }
-
- protected function getPathRootWeb()
- {
- $sPath = rtrim('http://' . $_SERVER['HTTP_HOST'], '/') . str_replace('/install/index.php', '',
- $_SERVER['PHP_SELF']);
- return preg_replace('#\/application$#', '', $sPath);
- }
-}
\ No newline at end of file
diff --git a/application/install/backend/step/updateComplete.php b/application/install/backend/step/updateComplete.php
deleted file mode 100644
index 5920d97a..00000000
--- a/application/install/backend/step/updateComplete.php
+++ /dev/null
@@ -1,6 +0,0 @@
-processDbCheck()) {
- return $aRes;
- }
-
- return true;
- }
-}
\ No newline at end of file
diff --git a/application/install/backend/step/updateVersion.php b/application/install/backend/step/updateVersion.php
deleted file mode 100644
index 34b34188..00000000
--- a/application/install/backend/step/updateVersion.php
+++ /dev/null
@@ -1,893 +0,0 @@
-assign('from_version', InstallCore::getStoredData('update_from_version'));
- $this->assign('convert_versions', $this->aVersionConvert);
- }
-
- public function process()
- {
- set_time_limit(0);
- /**
- * Коннект к серверу БД
- */
- if (!$oDb = $this->getDBConnection(InstallConfig::get('db.params.host'), InstallConfig::get('db.params.port'),
- InstallConfig::get('db.params.user'), InstallConfig::get('db.params.pass'), true)
- ) {
- return false;
- }
- /**
- * Выбираем БД
- */
- if (!@mysqli_select_db($oDb, InstallConfig::get('db.params.dbname'))) {
- return $this->addError(InstallCore::getLang('db.errors.db_query'));
- }
-
- $this->setDbParams(array(
- 'prefix' => InstallConfig::get('db.table.prefix'),
- 'engine' => InstallConfig::get('db.tables.engine'),
- ));
- $sVersion = InstallCore::getRequestStr('from_version');
- /**
- * Проверяем наличие конвертора
- * Конвертор представляет собой отдельный метод вида converFrom_X1_Y1_Z1_to_X2_Y2_Z2
- */
- $sMethod = 'convertFrom_' . str_replace('.', '_', $sVersion) . '_to_' . str_replace('.', '_', VERSION);
- if (!method_exists($this, $sMethod)) {
- return $this->addError(InstallCore::getLang('steps.updateVersion.errors.not_found_convert'));
- }
- InstallCore::setStoredData('update_from_version', $sVersion);
- /**
- * Запускаем конвертор
- */
- return call_user_func_array(array($this, $sMethod), array($oDb));
- }
-
- /**
- * Конвертор версии 2.0.0 в 2.0.1
- *
- * @param $oDb
- *
- * @return bool
- */
- public function convertFrom_2_0_0_to_2_0_1($oDb)
- {
-
- /**
- * Запускаем SQL патч
- */
- $sFile = 'sql' . DIRECTORY_SEPARATOR . 'patch_2.0.0_to_2.0.1.sql';
- list($bResult, $aErrors) = array_values($this->importDumpDB($oDb, InstallCore::getDataFilePath($sFile), array(
- 'engine' => InstallConfig::get('db.tables.engine'),
- 'prefix' => InstallConfig::get('db.table.prefix'),
- 'skip_fk_errors' => true
- )));
- if ($bResult) {
- return true;
- }
- return $this->addError(join('
', $aErrors));
- }
-
- /**
- * Конвертор версии 1.0.3 в 2.0.0
- *
- * @param $oDb
- *
- * @return bool
- */
- public function convertFrom_1_0_3_to_2_0_0($oDb)
- {
- /**
- * Запускаем SQL патч
- */
- $sFile = 'sql' . DIRECTORY_SEPARATOR . 'patch_1.0.3_to_2.0.0.sql';
- list($bResult, $aErrors) = array_values($this->importDumpDB($oDb, InstallCore::getDataFilePath($sFile), array(
- 'engine' => InstallConfig::get('db.tables.engine'),
- 'prefix' => InstallConfig::get('db.table.prefix'),
- 'check_table' => 'cron_task',
- 'skip_fk_errors' => true
- )));
- if ($bResult) {
- /**
- * Проверяем необходимость конвертировать таблицу плагина Page
- */
- if ($this->dbCheckTable("prefix_page")) {
- $sFile = 'sql' . DIRECTORY_SEPARATOR . 'patch_page_1.3_to_2.0.sql';
- list($bResult, $aErrors) = array_values($this->importDumpDB($oDb, InstallCore::getDataFilePath($sFile),
- array(
- 'engine' => InstallConfig::get('db.tables.engine'),
- 'prefix' => InstallConfig::get('db.table.prefix'),
- 'check_table_field' => array('prefix_page', 'id'),
- 'skip_fk_errors' => true
- )));
- if (!$bResult) {
- return $this->addError(join('
', $aErrors));
- }
- }
- /**
- * Конвертируем опросы
- * Сначала проверяем необходимость конвертации опросов
- */
- if ($this->dbCheckTable("prefix_topic_question_vote")) {
- $iPage = 1;
- $iLimitCount = 50;
- $iLimitStart = 0;
- while ($aTopics = $this->dbSelect("SELECT t.*, c.topic_extra FROM prefix_topic as t, prefix_topic_content as c WHERE topic_type = 'question' and t.topic_id = c.topic_id LIMIT {$iLimitStart},{$iLimitCount}")) {
- $iPage++;
- $iLimitStart = ($iPage - 1) * $iLimitCount;
- /**
- * Топики
- */
- foreach ($aTopics as $aTopic) {
- $aPollData = @unserialize($aTopic['topic_extra']);
- if (!isset($aPollData['answers'])) {
- continue;
- }
- /**
- * Создаем опрос
- */
- $aFields = array(
- 'user_id' => $aTopic['user_id'],
- 'target_type' => 'topic',
- 'target_id' => $aTopic['topic_id'],
- 'title' => htmlspecialchars($aTopic['topic_title']),
- 'count_answer_max' => 1,
- 'count_vote' => isset($aPollData['count_vote']) ? $aPollData['count_vote'] : 0,
- 'count_abstain' => isset($aPollData['count_vote_abstain']) ? $aPollData['count_vote_abstain'] : 0,
- 'date_create' => $aTopic['topic_date_add'],
- );
- if ($iPollId = $this->dbInsertQuery('prefix_poll', $aFields)) {
- foreach ($aPollData['answers'] as $iAnswerIdOld => $aAnswer) {
- /**
- * Создаем вариант ответа
- */
- $aFields = array(
- 'poll_id' => $iPollId,
- 'title' => htmlspecialchars($aAnswer['text']),
- 'count_vote' => htmlspecialchars($aAnswer['count']),
- 'date_create' => $aTopic['topic_date_add'],
- );
- if ($iAnswerId = $this->dbInsertQuery('prefix_poll_answer', $aFields)) {
- /**
- * Получаем список кто голосовал за этот вариант
- */
- if ($aVotes = $this->dbSelect("SELECT * FROM prefix_topic_question_vote WHERE topic_id = '{$aTopic['topic_id']}' AND answer = '{$iAnswerIdOld}' ")) {
- foreach ($aVotes as $aVote) {
- /**
- * Добавляем новый факт голосования за вариант
- */
- $aFields = array(
- 'poll_id' => $iPollId,
- 'user_id' => $aVote['user_voter_id'],
- 'answers' => serialize(array($iAnswerId)),
- 'date_create' => $aTopic['topic_date_add'],
- );
- $this->dbInsertQuery('prefix_poll_vote', $aFields);
- }
- }
- }
- }
- /**
- * Добавляем факты голосования воздержавшихся
- */
- /**
- * Получаем список кто голосовал за этот вариант
- */
- if ($aVotes = $this->dbSelect("SELECT * FROM prefix_topic_question_vote WHERE topic_id = '{$aTopic['topic_id']}' AND answer = -1 ")) {
- foreach ($aVotes as $aVote) {
- /**
- * Добавляем новый факт воздержания
- */
- $aFields = array(
- 'poll_id' => $iPollId,
- 'user_id' => $aVote['user_voter_id'],
- 'answers' => serialize(array()),
- 'date_create' => $aTopic['topic_date_add'],
- );
- $this->dbInsertQuery('prefix_poll_vote', $aFields);
- }
- }
- }
- /**
- * Меняем тип топика
- */
- $this->dbQuery("UPDATE prefix_topic SET topic_type = 'topic' WHERE topic_id ='{$aTopic['topic_id']}'");
- /**
- * Убираем лишние данные из topic_extra
- */
- unset($aPollData['answers']);
- unset($aPollData['count_vote_abstain']);
- unset($aPollData['count_vote']);
- $sExtra = mysqli_escape_string($this->rDbLink, serialize($aPollData));
- $this->dbQuery("UPDATE prefix_topic_content SET topic_extra = '{$sExtra}' WHERE topic_id ='{$aTopic['topic_id']}'");
- }
- }
- /**
- * Удаляем старые таблицы
- */
- if (!$this->getErrors()) {
- $this->dbQuery('DROP TABLE prefix_topic_question_vote');
- }
- }
-
- /**
- * Конвертируем топик-ссылки
- */
- $iPage = 1;
- $iLimitCount = 50;
- $iLimitStart = 0;
- while ($aTopics = $this->dbSelect("SELECT t.*, c.topic_extra, c.topic_text, c.topic_text_short, c.topic_text_source FROM prefix_topic as t, prefix_topic_content as c WHERE topic_type = 'link' and t.topic_id = c.topic_id LIMIT {$iLimitStart},{$iLimitCount}")) {
- $iPage++;
- $iLimitStart = ($iPage - 1) * $iLimitCount;
- /**
- * Топики
- */
- foreach ($aTopics as $aTopic) {
- $aData = @unserialize($aTopic['topic_extra']);
- if (!isset($aData['url'])) {
- continue;
- }
- /**
- * Переносим ссылку в текст топика
- */
- $sUrl = $aData['url'];
- if (strpos($sUrl, '://') === false) {
- $sUrl = 'http://' . $sUrl;
- }
- $sUrl = htmlspecialchars($sUrl);
- $sTextAdd = "\n
{$sUrl}";
- $aTopic['topic_text'] .= $sTextAdd;
- $aTopic['topic_text_short'] .= $sTextAdd;
- $aTopic['topic_text_source'] .= $sTextAdd;
- unset($aData['url']);
- $sExtra = mysqli_escape_string($this->rDbLink, serialize($aData));
- $sText = mysqli_escape_string($this->rDbLink, $aTopic['topic_text']);
- $sTextShort = mysqli_escape_string($this->rDbLink, $aTopic['topic_text_short']);
- $sTextSource = mysqli_escape_string($this->rDbLink, $aTopic['topic_text_source']);
- $this->dbQuery("UPDATE prefix_topic_content SET topic_extra = '{$sExtra}', topic_text = '{$sText}', topic_text_short = '{$sTextShort}', topic_text_source = '{$sTextSource}' WHERE topic_id ='{$aTopic['topic_id']}'");
- /**
- * Меняем тип топика
- */
- $this->dbQuery("UPDATE prefix_topic SET topic_type = 'topic' WHERE topic_id ='{$aTopic['topic_id']}'");
- }
- }
-
- /**
- * Конвертируем топик-фотосеты
- */
- if ($this->dbCheckTable("prefix_topic_photo")) {
- $iPage = 1;
- $iLimitCount = 50;
- $iLimitStart = 0;
- while ($aTopics = $this->dbSelect("SELECT t.*, c.topic_extra, c.topic_text, c.topic_text_short, c.topic_text_source FROM prefix_topic as t, prefix_topic_content as c WHERE topic_type = 'photoset' and t.topic_id = c.topic_id LIMIT {$iLimitStart},{$iLimitCount}")) {
- $iPage++;
- $iLimitStart = ($iPage - 1) * $iLimitCount;
- /**
- * Топики
- */
- foreach ($aTopics as $aTopic) {
- $aData = @unserialize($aTopic['topic_extra']);
- if (!isset($aData['main_photo_id'])) {
- continue;
- }
- /**
- * Получаем фото
- */
- if ($aPhotos = $this->dbSelect("SELECT * FROM prefix_topic_photo WHERE topic_id = '{$aTopic['topic_id']}' ")) {
- $aMediaItems = array();
- foreach ($aPhotos as $aPhoto) {
- /**
- * Необходимо перенести изображение в media и присоеденить к топику
- */
- $sFileSource = $this->convertPathWebToServer($aPhoto['path']);
- /**
- * Формируем список старых изображений для удаления
- */
- $sMask = pathinfo($sFileSource,
- PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR . pathinfo($sFileSource,
- PATHINFO_FILENAME) . '_*';
- $aFilesForRemove = array();
- if ($aPaths = glob($sMask)) {
- foreach ($aPaths as $sPath) {
- $aFilesForRemove[$sPath] = $sPath;
- }
- }
-
- if ($oImage = $this->createImageObject($sFileSource)) {
- $iWidth = $oImage->getSize()->getWidth();
- $iHeight = $oImage->getSize()->getHeight();
- if ($this->resizeImage($oImage, 1000)) {
- if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_1000x')) {
- unset($aFilesForRemove[$sFileSave]);
- }
- }
-
- if ($oImage = $this->createImageObject($sFileSource)) {
- if ($this->resizeImage($oImage, 500)) {
- if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_500x')) {
- unset($aFilesForRemove[$sFileSave]);
- }
- }
- }
-
- if ($oImage = $this->createImageObject($sFileSource)) {
- if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 100)) {
- if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_100x100crop')) {
- unset($aFilesForRemove[$sFileSave]);
- }
- }
- }
-
- if ($oImage = $this->createImageObject($sFileSource)) {
- if ($this->cropImage($oImage, 1) and $this->resizeImage($oImage, 50)) {
- if ($sFileSave = $this->saveImage($oImage, $sFileSource, '_50x50crop')) {
- unset($aFilesForRemove[$sFileSave]);
- }
- }
- }
-
- /**
- * Добавляем запись в медиа
- */
- $aDataMedia = array(
- 'image_sizes' => array(
- array(
- 'w' => 1000,
- 'h' => null,
- 'crop' => false,
- ),
- array(
- 'w' => 500,
- 'h' => null,
- 'crop' => false,
- ),
- array(
- 'w' => 100,
- 'h' => 100,
- 'crop' => true,
- ),
- array(
- 'w' => 50,
- 'h' => 50,
- 'crop' => true,
- ),
- ),
- );
- if ($aPhoto['description']) {
- $aDataMedia['title'] = htmlspecialchars($aPhoto['description']);
- }
- $aFields = array(
- 'user_id' => $aTopic['user_id'],
- 'type' => 1,
- 'target_type' => 'topic',
- 'file_path' => '[relative]' . str_replace(dirname(dirname(INSTALL_DIR)), '',
- $sFileSource),
- 'file_name' => pathinfo($sFileSource, PATHINFO_FILENAME),
- 'file_size' => filesize($sFileSource),
- 'width' => $iWidth,
- 'height' => $iHeight,
- 'date_add' => $aTopic['topic_date_add'],
- 'data' => serialize($aDataMedia),
- );
-
- if ($iMediaId = $this->dbInsertQuery('prefix_media', $aFields)) {
- /**
- * Добавляем связь медиа с топиком
- */
- $aFields = array(
- 'media_id' => $iMediaId,
- 'target_id' => $aTopic['topic_id'],
- 'target_type' => 'topic',
- 'date_add' => $aTopic['topic_date_add'],
- 'data' => '',
- );
- if ($iMediaTargetId = $this->dbInsertQuery('prefix_media_target', $aFields)) {
- $sFileWeb = InstallConfig::get('path.root.web') . str_replace(dirname(dirname(INSTALL_DIR)),
- '',
- $sFileSource);
- $aMediaItems[$iMediaId] = $sFileWeb;
- }
- }
- /**
- * Удаляем старые
- */
- foreach ($aFilesForRemove as $sFileRemove) {
- @unlink($sFileRemove);
- }
- }
- }
-
- /**
- * Добавляем в начало текста топика вывод фотосета
- */
- $sCodeRender = '';
- $sCodeSource = '';
- if ($aMediaItems) {
- $sCodeSource = '
t |