1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-28 20:45:00 +03:00

Доработка инсталлятора

This commit is contained in:
Mzhelskiy Maxim 2015-03-21 21:50:48 +07:00
parent a4e1c21f82
commit 178670f6f4
6 changed files with 166 additions and 10 deletions

View file

@ -314,4 +314,107 @@ class InstallCore
$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;
}
}

View file

@ -45,6 +45,15 @@ class InstallStepCheckRequirements extends InstallStep
'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})"
);
}
}
/**
* Права на запись файлов
*/

View file

@ -428,6 +428,31 @@ class InstallStepUpdateVersion extends InstallStep
}
}
/**
* Конвертируем урлы топиков к ЧПУ формату
*/
$iPage = 1;
$iLimitCount = 50;
$iLimitStart = 0;
while ($aTopics = $this->dbSelect("SELECT * FROM prefix_topic WHERE topic_slug = '' LIMIT {$iLimitStart},{$iLimitCount}")) {
$iPage++;
$iLimitStart = ($iPage - 1) * $iLimitCount;
/**
* Топики
*/
foreach ($aTopics as $aTopic) {
$sSlug = InstallCore::transliteration($aTopic['topic_title']);
$sSlug = $this->GetUniqueTopicSlug($sSlug, $aTopic['topic_id']);
$sSlug = mysqli_escape_string($this->rDbLink, $sSlug);
/**
* Меняем тип топика
*/
$this->dbQuery("UPDATE prefix_topic SET topic_slug = '{$sSlug}' WHERE topic_id ='{$aTopic['topic_id']}'");
}
}
/**
* Конвертируем аватарки блогов
*/
@ -818,4 +843,21 @@ class InstallStepUpdateVersion extends InstallStep
return false;
}
}
protected function GetUniqueTopicSlug($sSlug, $iSkipTopicId = null)
{
$iPostfix = 0;
do {
$sUrl = $sSlug . ($iPostfix ? '-' . $iPostfix : '');
$iPostfix++;
} while (($aTopic = $this->getTopicBySlug($sUrl)) and (is_null($iSkipTopicId) or $iSkipTopicId != $aTopic['topic_id']));
return $sUrl;
}
protected function getTopicBySlug($sUrl)
{
$sUrl = mysqli_escape_string($this->rDbLink, $sUrl);
return $this->dbSelectOne("SELECT * FROM prefix_topic WHERE topic_slug = '{$sUrl}' ");
}
}

View file

@ -39,6 +39,10 @@ return array(
'title' => 'Поддержка XML (SimpleXML)',
'solution' => 'Для корректной работы необходимо расширение SimpleXML. Обратитесь к хостингу.',
),
'xdebug' => array(
'title' => 'Использование Xdebug',
'solution' => 'Для корректной работы необходимо отключить Xdebug или повысить значение <b>xdebug.max_nesting_level</b> до 1000. Обратитесь к хостингу.',
),
'dir_uploads' => array(
'title' => 'Каталог /uploads',
'solution' => 'Необходимо дать каталогу права на запись.',

View file

@ -1,7 +1,5 @@
<div class="complete">
<p>Приятного использования LiveStreet!<p>
<div class="alert alert--info">
Обязательно удалите каталог /application/install/
</div>
<p>
Теперь обязательно удалите каталог <b>/application/install/</b> и можете <a href="<?php echo InstallConfig::get('path.root.web'); ?>">перейти на сайт</a>.
</p>
</div>

View file

@ -1,7 +1,7 @@
<div class="complete">
<p>Приятного использования новой версией LiveStreet!</p>
<div class="alert alert--info">
Обязательно удалите каталог /application/install/
</div>
<p>
Теперь обязательно удалите каталог <b>/application/install/</b> и можете <a href="<?php echo InstallConfig::get('path.root.web'); ?>">перейти на сайт</a>.
<br/>
Приятного использования новой версией LiveStreet!
</p>
</div>