Skip to content

Commit

Permalink
setcookie PHP 8.1 fix, php5.6 minimum, мелкие фиксы по поиску, учитыв…
Browse files Browse the repository at this point in the history
…ая ft_min_word_len
  • Loading branch information
fuzegit committed Dec 13, 2021
1 parent aadfa40 commit 2401122
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.RU.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Попробуйте сами в нашем [онлайн демо](https://demo.instantcms.ru/)

## Cистемные требования ##
* Интерпретатор PHP версии 5.5 или выше;
* Интерпретатор PHP версии 5.6 или выше;
* Модули для PHP: GD, iconv, mbstring, simplexml, json, filter;
* СУБД MySQL версии 5 или выше, MariaDB;
* Веб-сервер Apache с установленным модулем mod_rewrite.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Try it out for yourself in our [online demo](https://demo.instantcms.ru/)

## Requirements ##
* PHP 5.5+ (PHP 7, PHP 8 supported too)
* PHP 5.6+ (PHP 7, PHP 8 supported too)
* GD, iconv, mbstring, simplexml, json and filter PHP extension
* Mysql 5.0 or above, MariaDB and its support in PHP
* Apache + mod_rewrite or Nginx + converted .htaccess rules
Expand Down
49 changes: 26 additions & 23 deletions install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
session_start();

define('DS', DIRECTORY_SEPARATOR);
define('PATH', dirname(__FILE__).DS);
define('PATH', dirname(__FILE__) . DS);
define('DOC_ROOT', str_replace(DS, '/', realpath($_SERVER['DOCUMENT_ROOT'])));

header("Content-type:text/html; charset=utf-8");
Expand All @@ -15,55 +15,58 @@
$all_langs = get_langs();
$default_lang = 'en';

if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$user_lang = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
if(in_array($user_lang, $all_langs)){
if (in_array($user_lang, $all_langs)) {
$default_lang = $user_lang;
}
}

if (isset($_REQUEST['lang'])){
if(in_array($_REQUEST['lang'], $all_langs)){
if (isset($_REQUEST['lang'])) {
if (in_array($_REQUEST['lang'], $all_langs)) {
$_SESSION['install']['lang'] = $_REQUEST['lang'];
header('Location: ' . $_SERVER['SCRIPT_NAME']);die;
header('Location: ' . $_SERVER['SCRIPT_NAME']);
die;
}
}

$is_lang_selected = isset($_SESSION['install']['lang']);

$lang = $is_lang_selected ? $_SESSION['install']['lang'] : $default_lang;

define('LANG', $lang);

include PATH . DS . 'languages' . DS . LANG . DS . "language.php";

$steps = array(
array('id' => 'start', 'title' => LANG_STEP_START),
array('id' => 'license', 'title' => LANG_STEP_LICENSE),
array('id' => 'php', 'title' => LANG_STEP_PHP_CHECK),
array('id' => 'paths', 'title' => LANG_STEP_PATHS),
array('id' => 'site', 'title' => LANG_STEP_SITE),
array('id' => 'database', 'title' => LANG_STEP_DATABASE),
array('id' => 'admin', 'title' => LANG_STEP_ADMIN),
array('id' => 'config', 'title' => LANG_STEP_CONFIG),
array('id' => 'cron', 'title' => LANG_STEP_CRON),
array('id' => 'finish', 'title' => LANG_STEP_FINISH),
);
$steps = [
['id' => 'start', 'title' => LANG_STEP_START],
['id' => 'license', 'title' => LANG_STEP_LICENSE],
['id' => 'php', 'title' => LANG_STEP_PHP_CHECK],
['id' => 'paths', 'title' => LANG_STEP_PATHS],
['id' => 'site', 'title' => LANG_STEP_SITE],
['id' => 'database', 'title' => LANG_STEP_DATABASE],
['id' => 'admin', 'title' => LANG_STEP_ADMIN],
['id' => 'config', 'title' => LANG_STEP_CONFIG],
['id' => 'cron', 'title' => LANG_STEP_CRON],
['id' => 'finish', 'title' => LANG_STEP_FINISH]
];

$current_step = 0;

if (is_ajax_request()){
$step = $steps[(int)(isset($_POST['step']) ? $_POST['step'] : 0)];
if (is_ajax_request()) {
$step = $steps[(int) (isset($_POST['step']) ? $_POST['step'] : 0)];
$is_submit = isset($_POST['submit']);
echo json_encode( run_step($step, $is_submit) );
echo json_encode(run_step($step, $is_submit));
exit();
}

$step_result = run_step($steps[$current_step], false);

echo render('main', array(
echo render('main', [
'steps' => $steps,
'is_lang_selected' => $is_lang_selected,
'lang' => LANG,
'current_step' => $current_step,
'step_html' => $step_result['html'],
'langs' => get_langs()
));
]);
2 changes: 1 addition & 1 deletion install/languages/en/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
define('LANG_LICENSE_TRANSLATION', 'Russian');

define('LANG_PHP_VERSION', 'PHP version');
define('LANG_PHP_VERSION_REQ', 'PHP 5.5 or higher is required');
define('LANG_PHP_VERSION_REQ', 'PHP 5.6 or higher is required');
define('LANG_PHP_VERSION_DESC', 'Installed version');
define('LANG_PHP_VARIABLES', 'PHP configuration');
define('LANG_PHP_VARIABLES_HINT', 'Required conditions are marked gray');
Expand Down
2 changes: 1 addition & 1 deletion install/languages/ru/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
define('LANG_LICENSE_TRANSLATION', 'Перевод');

define('LANG_PHP_VERSION', 'Версия интерпретатора');
define('LANG_PHP_VERSION_REQ', 'Требуется PHP 5.5 или выше');
define('LANG_PHP_VERSION_REQ', 'Требуется PHP 5.6 или выше');
define('LANG_PHP_VERSION_DESC', 'Установленная версия');
define('LANG_PHP_VARIABLES', 'Опции настройки PHP');
define('LANG_PHP_VARIABLES_HINT', 'Серым цветом указано требуемое значение');
Expand Down
2 changes: 1 addition & 1 deletion install/steps/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ function create_admin($nickname, $email, $pass_hash){

$mysqli->query($sql);

setcookie('icms[auth]', $auth_data['auth_token'], time()+300, '/', null, false, true);
setcookie('icms[auth]', $auth_data['auth_token'], time()+300, '/', '', false, true);

}
2 changes: 1 addition & 1 deletion install/steps/php.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function step($is_submit) {

function check_requirements() {

$min_php_version = '5.5.0';
$min_php_version = '5.6.0';
$extensions = ['date', 'gd', 'json', 'mbstring', 'mysqli', 'session', 'filter', 'fileinfo'];
$extensions_extra = ['ftp', 'memcache', 'memcached', 'zip', 'curl'];

Expand Down
4 changes: 2 additions & 2 deletions system/config/version.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[version]
major = 2
minor = 14
build = 4
minor = 15
build = 0
date = 20220101
4 changes: 4 additions & 0 deletions system/controllers/search/actions/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ public function run($target = false) {
$this->model->setHighlightFields($search_controller['highlight_fields'][$sources_name]);
}

// Если по трём символам, то сортировка принудительно по дате
if($this->model->isThreeSymbolSearch()){
$order_by = 'date_pub';
}
// Сортировка
$this->model->orderByRaw(($order_by === 'date_pub' ? 'i.' : '').$order_by.' desc');

Expand Down
19 changes: 17 additions & 2 deletions system/controllers/search/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ public function setHighlightFields($highlight_fields) {
return $this;
}

/**
* Истина, если поиск по трём символам
*
* @return boolean
*/
public function isThreeSymbolSearch() {
return $this->three_symbol_search;
}

/**
* Подготавливается поисковый запрос
*
Expand All @@ -114,7 +123,13 @@ public function setQuery($query) {

if (!$stopwords || ($stopwords && !in_array($query, $stopwords, true))) {

$this->three_symbol_search = true;
// Узнаём минимальное кол-во символов для поиска
// ft_min_word_len для MyISAM, если у вас таблицы InnoDB, то замените на innodb_ft_min_token_size
$var_value = $this->db->getSqlVariableValue('ft_min_word_len');

if($var_value < 3){
$this->three_symbol_search = true;
}

$this->query[] = $query;

Expand Down Expand Up @@ -223,7 +238,7 @@ public function filterQuery() {
$query .= '%';
}

return $this->filter("CONCAT({$this->match_fields_str}) LIKE '{$query}");
return $this->filter("CONCAT({$this->match_fields_str}) LIKE '{$query}'");
}

$query = '\"' . $this->db->escape($this->original_query) . '\"';
Expand Down
12 changes: 12 additions & 0 deletions system/core/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,18 @@ public function getTableFieldsTypes($table) {
return $fields;
}

public function getSqlVariableValue($value) {

$value = $this->escape($value);

$result = $this->query("show variables like '{$value}'");

$data = $this->fetchAssoc($result);
$this->freeResult($result);

return isset($data['Value']) ? $data['Value'] : null;
}

//============================================================================//
//============================================================================//

Expand Down
4 changes: 2 additions & 2 deletions system/core/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,9 @@ public static function sessionClear() {
* @param int $time Время жизни, в секундах
* @param string $path Путь на сервере
* @param bool $http_only Куки недоступны для скриптов
* @param string $domain Домен действия. null - только текущий
* @param string $domain Домен действия. пусто - только текущий
* */
public static function setCookie($key, $value, $time = 3600, $path = '/', $http_only = true, $domain = null) {
public static function setCookie($key, $value, $time = 3600, $path = '/', $http_only = true, $domain = '') {

$cookie_domain = cmsConfig::get('cookie_domain');

Expand Down
2 changes: 1 addition & 1 deletion update/current/install.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* 2.14.3 => 2.14.4
* 2.14.3 => 2.15.0
*/
function install_package(){

Expand Down
6 changes: 3 additions & 3 deletions update/current/manifest.en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ type = "system"

[version]
major = "2"
minor = "14"
build = "4"
minor = "15"
build = "0"
date = "20220101"

[depends]
Expand All @@ -20,4 +20,4 @@ url = "https://instantcms.ru"

[description]
text[] = "Release details:"
text[] = "https://instantcms.ru/novosti/release2144.html"
text[] = "https://instantcms.ru/novosti/release2150.html"
6 changes: 3 additions & 3 deletions update/current/manifest.ru.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ type = "system"

[version]
major = "2"
minor = "14"
build = "4"
minor = "15"
build = "0"
date = "20220101"

[depends]
Expand All @@ -20,4 +20,4 @@ url = "https://instantcms.ru"

[description]
text[] = "Описание обновления:"
text[] = "https://instantcms.ru/novosti/release2144.html"
text[] = "https://instantcms.ru/novosti/release2150.html"

0 comments on commit 2401122

Please sign in to comment.