Skip to content

Commit

Permalink
6.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pafnuty committed Feb 22, 2020
1 parent 92eaaad commit 9df8d37
Show file tree
Hide file tree
Showing 14 changed files with 1,373 additions and 1,415 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 6.0.1
- Полностью прекращена поддержка DLE старше 13 версии.
- Теперь можно вносить изменения в файлы модуля (не классы) через систему плагинов.

# 6.0.0
- Теперь модуль не гарантирует совместимость с версиями DLE ниже, чем 13.x и скоро будет убрана их поддержка полностью.
- Установка в виде плагина.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DLE-BlockPro — тот самый модуль для вывода новостей!
![version](https://img.shields.io/badge/version-6.0.0-red.svg?style=flat-square "Version")
![version](https://img.shields.io/badge/version-6.0.1-red.svg?style=flat-square "Version")
![DLE](https://img.shields.io/badge/DLE-13.x-green.svg?style=flat-square "DLE Version")
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/dle-modules/DLE-BlockPro/blob/master/LICENSE)

Expand Down
171 changes: 82 additions & 89 deletions blockpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,20 @@

define('DATALIFEENGINE', true);
define('ROOT_DIR', dirname(__FILE__));
define('ENGINE_DIR', ROOT_DIR . '/engine');

include_once ENGINE_DIR . '/plugins/loader/loader.php';
include(DLEPlugins::Check(ENGINE_DIR . '/data/config.php'));
define('ENGINE_DIR', ROOT_DIR.'/engine');
include_once ENGINE_DIR.'/classes/plugins.class.php';

/** @var array $config */
if ($config['version_id'] > 10.2) {
date_default_timezone_set($config['date_adjust']);
$_TIME = time();
} else {
$_TIME = time() + ($config['date_adjust'] * 60);
}
date_default_timezone_set($config['date_adjust']);


if ($config['http_home_url'] == '') {
$config['http_home_url'] = explode('blockpro.php', $_SERVER['PHP_SELF']);
$config['http_home_url'] = reset($config['http_home_url']);
$config['http_home_url'] = 'http://' . $_SERVER['HTTP_HOST'] . $config['http_home_url'];
$config['http_home_url'] = explode('blockpro.php', $_SERVER['PHP_SELF']);
$config['http_home_url'] = reset($config['http_home_url']);
$config['http_home_url'] = 'http://'.$_SERVER['HTTP_HOST'].$config['http_home_url'];
}

require_once(DLEPlugins::Check(ENGINE_DIR . '/classes/mysql.php'));
require_once(DLEPlugins::Check(ENGINE_DIR . '/data/dbconfig.php'));
require_once(DLEPlugins::Check(ENGINE_DIR . '/modules/functions.php'));
require_once(DLEPlugins::Check(ENGINE_DIR.'/modules/functions.php'));

check_xss();

Expand All @@ -51,122 +43,123 @@
$member_id = [];

if ($config['allow_registration']) {
require_once ENGINE_DIR . '/modules/sitelogin.php';
require_once(DLEPlugins::Check(ENGINE_DIR.'/modules/sitelogin.php'));
}
if (!$is_logged) {
$member_id['user_group'] = 5;
$member_id['user_group'] = 5;
}
if (!$cat_info) {
$user_group = get_vars('usergroup');
$user_group = get_vars('usergroup');
}
if (!$cat_info) {
$cat_info = get_vars("category");
$cat_info = get_vars("category");
}

$blockId = $isJs = $isRSS = $isIframe = false;
if (isset($_REQUEST['block'])) {
$blockId = $_REQUEST['block'];
$isJs = true;
$blockId = $_REQUEST['block'];
$isJs = true;
}
if (isset($_REQUEST['channel'])) {
$blockId = $_REQUEST['channel'];
$isRSS = true;
$blockId = $_REQUEST['channel'];
$isRSS = true;
}
if (isset($_REQUEST['frame'])) {
$blockId = $_REQUEST['frame'];
$isIframe = true;
$blockId = $_REQUEST['frame'];
$isIframe = true;
}
$blockId = $db->safesql($blockId);

$_cr = false;
if ($blockId) {
$arCr = $db->super_query("SELECT params FROM " . PREFIX . "_blockpro_blocks WHERE block_id='{$blockId}'");
$_cr = $arCr['params'];
$arCr = $db->super_query("SELECT params FROM ".PREFIX."_blockpro_blocks WHERE block_id='{$blockId}'");
$_cr = $arCr['params'];
}
$externalOutput = '';

if ($_cr) {
// Если запись существует — работаем.
$isAjaxConfig = true;
$ajaxConfigArr = unserialize($_cr);
// Если запись существует — работаем.
$isAjaxConfig = true;
$ajaxConfigArr = unserialize($_cr);

if ($ajaxConfigArr['cacheLive']) {
// Меняем префикс кеша для того, чтобы он не чистился автоматически, если указано время жизни кеша.
$ajaxConfigArr['cachePrefix'] = 'base';
}
if ($ajaxConfigArr['cacheLive']) {
// Меняем префикс кеша для того, чтобы он не чистился автоматически, если указано время жизни кеша.
$ajaxConfigArr['cachePrefix'] = 'base';
}

// Формируем имя кеша
$cacheName = implode('_', $ajaxConfigArr) . $config['skin'];
// Формируем имя кеша
$cacheName = implode('_', $ajaxConfigArr).$config['skin'];

// Определяем необходимость создания кеша для разных групп
$cacheSuffix = ($ajaxConfigArr['cacheSuffixOff']) ? false : true;
// Определяем необходимость создания кеша для разных групп
$cacheSuffix = ($ajaxConfigArr['cacheSuffixOff']) ? false : true;

// Если установлено время жизни кеша
if ($ajaxConfigArr['cacheLive']) {
// Формируем имя кеш-файла в соответствии с правилами формирования тагового стандартными средствами DLE, для последующей проверки на существование этого файла.
$_end_file = (!$ajaxConfigArr['cacheSuffixOff']) ? ($is_logged) ? '_' . $member_id['user_group'] : '_0' : false;
$filedate = ENGINE_DIR . '/cache/' . $ajaxConfigArr['cachePrefix'] . '_' . md5($cacheName) . $_end_file . '.tmp';
// Если установлено время жизни кеша
if ($ajaxConfigArr['cacheLive']) {
// Формируем имя кеш-файла в соответствии с правилами формирования тагового стандартными средствами DLE, для последующей проверки на существование этого файла.
$_end_file = (!$ajaxConfigArr['cacheSuffixOff']) ? ($is_logged) ? '_'.$member_id['user_group'] : '_0' : false;
$filedate = ENGINE_DIR.'/cache/'.$ajaxConfigArr['cachePrefix'].'_'.md5($cacheName).$_end_file.'.tmp';

if (@file_exists($filedate)) {
$cache_time = time() - @filemtime($filedate);
} else {
$cache_time = $ajaxConfigArr['cacheLive'] * 60;
}
if ($cache_time >= $ajaxConfigArr['cacheLive'] * 60) {
$clear_time_cache = true;
}
}
if (@file_exists($filedate)) {
$cache_time = time() - @filemtime($filedate);
} else {
$cache_time = $ajaxConfigArr['cacheLive'] * 60;
}
if ($cache_time >= $ajaxConfigArr['cacheLive'] * 60) {
$clear_time_cache = true;
}
}

// Говорим модулю, что он — внешний блок
$external = true;
include ENGINE_DIR . '/modules/base/blockpro.php';
// Говорим модулю, что он — внешний блок
$external = true;
include(DLEPlugins::Check(ENGINE_DIR.'/modules/base/blockpro.php'));

if ($isJs) {
header("Content-type: text/javascript; charset=" . $config['charset']);
// Подготавливаем контент к выводу
/** @var string $output */
$result = prepareBlock($output);
$externalOutput = '\'' . $result . '\'';
if ($isJs) {
header("Content-type: text/javascript; charset=".$config['charset']);
// Подготавливаем контент к выводу
/** @var string $output */
$result = prepareBlock($output);
$externalOutput = '\''.$result.'\'';

// Подсчитаем время выполнения скрипта и добавим данные об этом в вывод.
$timeStop = round(microtime(true) - $timeStart, 5);
// Подсчитаем время выполнения скрипта и добавим данные об этом в вывод.
$timeStop = round(microtime(true) - $timeStart, 5);

$jsBlockId = str_replace('-', '', $blockId);
$jsBlockId = str_replace('-', '', $blockId);

$consoleLog = 'console.log(\'[blockpro]: id: ' . $blockId . ', time: ' . $timeStop . ' s.\');';
$consoleLog = 'console.log(\'[blockpro]: id: '.$blockId.', time: '.$timeStop.' s.\');';

$printOutput = 'var j' . $jsBlockId . ' = document.getElementById(\'' . $blockId . '\');if(j' . $jsBlockId . '){j' . $jsBlockId . '.innerHTML = ' . $externalOutput . '};' . $consoleLog;
}
if ($isRSS) {
header("Content-type: application/xml; charset=" . $config['charset']);
$printOutput = 'var j'.$jsBlockId.' = document.getElementById(\''.$blockId.'\');if(j'.$jsBlockId.'){j'
.$jsBlockId.'.innerHTML = '.$externalOutput.'};'.$consoleLog;
}
if ($isRSS) {
header("Content-type: application/xml; charset=".$config['charset']);

$printOutput = $output;
}
$printOutput = $output;
}

if ($isIframe) {
header("Content-type: text/html; charset=" . $config['charset']);
if ($isIframe) {
header("Content-type: text/html; charset=".$config['charset']);

$printOutput = $output;
}
$printOutput = $output;
}


// Выводим результаты работы модуля в виде js-строки
/** @var string $printOutput */
echo $printOutput;
// Выводим результаты работы модуля в виде js-строки
/** @var string $printOutput */
echo $printOutput;

} else {
if ($isJs) {
$noData = 'console.warn(\'[blockpro]: no content to show\');';
} else {
$noData = 'no content to show';
}
echo $noData;
if ($isJs) {
$noData = 'console.warn(\'[blockpro]: no content to show\');';
} else {
$noData = 'no content to show';
}
echo $noData;
}

function prepareBlock($text) {
$search = ["\n", "\t"];
$text = str_replace($search, '', $text);
$text = addslashes($text);
$search = ["\n", "\t"];
$text = str_replace($search, '', $text);
$text = addslashes($text);

return $text;
return $text;
}
2 changes: 1 addition & 1 deletion blockpro.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<name>BlockPro</name>
<description>Модуль предназначен для удобного вывода новостей на сайте</description>
<icon>engine/skins/images/blockpro.png</icon>
<version>6.0.0</version>
<version>6.0.1</version>
<dleversion>13</dleversion>
<versioncompare>greater</versioncompare>
<upgradeurl>https://updates.pafnuty.name/check-bp.php</upgradeurl>
Expand Down
6 changes: 2 additions & 4 deletions engine/ajax/base/save_block_pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@
define('ROOT_DIR', substr(dirname(__FILE__), 0, -17));

define('ENGINE_DIR', ROOT_DIR . '/engine');
include_once ENGINE_DIR . '/plugins/loader/loader.php';
include_once ENGINE_DIR.'/classes/plugins.class.php';

include (DLEPlugins::Check(ENGINE_DIR . '/data/config.php'));
/** @var array $config */
if ($config['http_home_url'] == "") {
$config['http_home_url'] = explode("engine/ajax/base/save_block_pro.php", $_SERVER['PHP_SELF']);
$config['http_home_url'] = reset($config['http_home_url']);
$config['http_home_url'] = "http://" . $_SERVER['HTTP_HOST'] . $config['http_home_url'];
}
require_once (DLEPlugins::Check(ENGINE_DIR . '/classes/mysql.php'));
require_once (DLEPlugins::Check(ENGINE_DIR . '/data/dbconfig.php'));

require_once (DLEPlugins::Check(ENGINE_DIR . '/modules/functions.php'));
if ($config['version_id'] > 9.6) {
dle_session();
Expand Down
Loading

0 comments on commit 9df8d37

Please sign in to comment.