Browse Source

Fixes

pull/3/head
M@d D3n 7 years ago
parent
commit
7aa7bb0df2
  1. 5
      class/class.database.php
  2. 2
      class/class.debug.php
  3. 2
      class/class.rubs.php
  4. 72
      class/class.session.memcached.php
  5. 17
      class/class.sysblocks.php
  6. 8
      class/class.template.php
  7. 10
      functions/func.parserequest.php
  8. 4
      functions/func.sysblock.php
  9. 6
      inc/config.php
  10. 18
      inc/init.php
  11. 81
      inc/sitemap.php
  12. 3
      install/structure_base.sql
  13. 11
      lib/debug/debug.css

5
class/class.database.php

@ -850,6 +850,11 @@
return $cache_id = 'navigations/' . $cache_id[1];
}
if (substr_count($cache_id, '__') > 0)
{
return str_replace('__', '/', $cache_id);
}
return $cache_id;
}

2
class/class.debug.php

@ -653,6 +653,8 @@
$out = PHP_EOL;
$out .= '<link rel="stylesheet" href="/lib/debug/debug.css" />';
$out .= PHP_EOL;
$out .= '<script>window.jQuery || document.write(\'<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">\x3C/script>\')</script>';
$out .= PHP_EOL;
$out .= '<script src="/lib/debug/debug.js"></script>';
$out .= PHP_EOL;
$out .= '

2
class/class.rubs.php

@ -1410,7 +1410,7 @@
SET
rubric_changed = '" . time() . "'
WHERE
rubric_id = '" . $rubric_id . "'
Id = '" . $rubric_id . "'
");
$AVE_DB->clearCache('rub_' . $rubric_id);

72
class/class.session.memcached.php

@ -0,0 +1,72 @@
<?php
/**
* AVE.cms
*
* @package AVE.cms
* @version 3.x
* @filesource
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
*
* @license GPL v.2
*/
class AVE_Session_Memcached
{
private $memcached;
private $ttl;
private $prefix;
function __construct()
{
$this->memcached = new Memcached;
$this->memcached->addServer(MEMCACHED_SERVER, MEMCACHED_PORT);
$this->ttl = (defined('SESSION_LIFETIME') && is_numeric(SESSION_LIFETIME))
? SESSION_LIFETIME
: (get_cfg_var("session.gc_maxlifetime") < 1440 ? 1440 : get_cfg_var("session.gc_maxlifetime"));
$this->prefix = 'sess_';
}
/* Open session */
function _open($sess_save_path, $session_name)
{
return true;
}
/* Close session */
function _close()
{
return true;
}
/* Read session */
function _read($id)
{
return $this->memcached->get($this->prefix . $id) ? : '';
}
/* Write new data */
function _write ($id, $sess_data)
{
$this->memcached->set($this->prefix . $id, $sess_data, time() + $this->ttl);
return true;
}
/* Destroy session */
function _destroy ($id)
{
$this->memcached->delete($this->prefix . $id);
return true;
}
/* Garbage collection, deletes old sessions */
function _gc ($maxlifetime)
{
return true;
}
}
?>

17
class/class.sysblocks.php

@ -283,17 +283,14 @@
function clearCache ($id, $alias = null)
{
$cache_id = md5('sysblock' . $id);
$cache_alias = md5('sysblock' . $alias);
$from_id = BASE_DIR . '/tmp/cache/sql/sysblocks/' . $id;
rrmdir($from_id);
$cache_id_file = BASE_DIR . '/tmp/cache/sql/sysblock/' . $cache_id . '.cache';
$cache_alias_file = BASE_DIR . '/tmp/cache/sql/sysblock/' . $cache_alias . '.cache';
if (file_exists($cache_id_file))
unlink($cache_id_file);
if (file_exists($cache_alias_file))
unlink($cache_alias_file);
if ($alias)
{
$from_alias = BASE_DIR . '/tmp/cache/sql/sysblocks/' . $alias;
rrmdir($from_alias);
}
}
}
?>

8
class/class.template.php

@ -245,11 +245,11 @@
write_htaccess_deny($this->cache_dir . '/');
// Memcached
if ($_REQUEST['ajax'] && Memcached_Server && Memcached_Port)
if (MEMCACHED_SERVER && MEMCACHED_PORT)
{
$memcache = new Memcache;
$memcache->connect(Memcached_Server, Memcached_Port);
$memcache->flush();
$m = new Memcached();
$m->addServer(MEMCACHED_SERVER, MEMCACHED_PORT);
$m->flush();
}
// Очищаем кэш шаблона документов рубрики

10
functions/func.parserequest.php

@ -869,6 +869,11 @@
$sql_request = str_replace($search, '', $sql_request);
}
}
}
else
{
$sql_request = $params['SQL_QUERY'];
}
// Если просили просто показать сформированный запрос
if ((isset($params['DEBUG']) && $params['DEBUG'] == 1) || $request->request_show_sql == 1)
@ -877,11 +882,6 @@
return $return;
}
}
else
{
$sql_request = $params['SQL_QUERY'];
}
// Выполняем запрос к бд
$sql = $AVE_DB->Query($sql_request, (int)$request->request_cache_lifetime, 'rqs_' . $id, true, '.request');

4
functions/func.sysblock.php

@ -33,13 +33,13 @@
$cache = md5('sysblock' . $id);
$cache_file = BASE_DIR . '/tmp/cache/sql/sysblock/' . $cache . '.cache';
$cache_file = BASE_DIR . '/tmp/cache/sql/sysblocks/' . $id . '/' . $cache . '.code';
// Если включен DEV MODE, то отключаем кеширование запросов
if (defined('DEV_MODE') AND DEV_MODE)
$cache_file = null;
if (! file_exists(dirname($cache_file)))
if (! is_dir(dirname($cache_file)))
mkdir(dirname($cache_file), 0766, true);
if (file_exists($cache_file))

6
inc/config.php

@ -104,7 +104,7 @@
$GLOBALS['CMS_CONFIG']['WATERMARKS_DIR'] = array('DESCR' => 'Директория для хранения оригиналов изображений (watermark)','default'=>'watermarks','TYPE'=>'string','VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['WATERMARKS_FILE'] = array('DESCR' => 'Файл watermark','default'=>'uploads/watermark.png','TYPE'=>'string','VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['SESSION_SAVE_HANDLER'] = array('DESCR' => 'Хранить сессии в БД','default'=>true,'TYPE'=>'bool','VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['SESSION_SAVE_HANDLER'] = array('DESCR' => 'Хранение сессий', 'default'=>'mysql', 'TYPE'=>'dropdown', 'VARIANT' => array('mysql', 'files', 'memcached'));
$GLOBALS['CMS_CONFIG']['SESSION_LIFETIME'] = array('DESCR' => 'Время жизни сессии (Значение по умолчанию 24 часа)','default'=>60*60*24,'TYPE'=>'integer','VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['COOKIE_LIFETIME'] = array('DESCR' => 'Время жизни cookie автологина (60*60*24*14 - 2 недели)','default'=>60*60*24*14,'TYPE'=>'integer','VARIANT'=>'');
@ -130,8 +130,8 @@
$GLOBALS['CMS_CONFIG']['YANDEX_MAP_API_KEY'] = array('DESCR' => 'Yandex MAP API REY','default'=>'','TYPE'=>'string','VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['GOOGLE_MAP_API_KEY'] = array('DESCR' => 'Google MAP API REY','default'=>'','TYPE'=>'string','VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['Memcached_Server'] = array('DESCR' => 'Адрес Memcached сервера','default'=>'','TYPE'=>'string','VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['Memcached_Port'] = array('DESCR' => 'Порт Memcached сервера','default'=>'','TYPE'=>'string','VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['MEMCACHED_SERVER'] = array('DESCR' => 'Адрес Memcached сервера','default'=>'','TYPE'=>'string','VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['MEMCACHED_PORT'] = array('DESCR' => 'Порт Memcached сервера','default'=>'','TYPE'=>'string','VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['DB_EXPORT_GZ'] = array('DESCR' => 'Создание резервной копии базы данных со сжатием','default'=>false,'TYPE'=>'bool','VARIANT'=>'');
$GLOBALS['CMS_CONFIG']['DB_EXPORT_TPL'] = array('DESCR' => 'Шаблон имени файла экспорта бд (%SERVER%,%DATE%,%TIME%)','default'=>'%SERVER%_DB_BackUP_%DATE%_%TIME%','TYPE'=>'string','VARIANT'=>'');

18
inc/init.php

@ -160,6 +160,12 @@
ini_set ('session.use_trans_sid', 0);
ini_set ('url_rewriter.tags', '');
if (SESSION_SAVE_HANDLER == 'memcached')
{
ini_set ('session.lazy_write', 0);
ini_set ('session.save_handler', 'memcached');
ini_set ('session.save_path', MEMCACHED_SERVER.':'.MEMCACHED_PORT . '?persistent=1&weight=1&timeout=1&retry_interval=15');
}
//-- Переключение для нормальной работы с русскими буквами в некоторых функциях
mb_internal_encoding("UTF-8");
@ -212,7 +218,7 @@
foreach (array(ATTACH_DIR, 'cache', 'backup', 'logs', 'session', 'update') as $dir)
write_htaccess_deny(BASE_DIR . '/tmp/' . $dir);
foreach (array('check', 'combine', 'module', 'redactor', 'smarty', 'sql', 'tpl') as $dir)
foreach (array('combine', 'module', 'redactor', 'smarty', 'sql', 'tpl') as $dir)
write_htaccess_deny(BASE_DIR . '/tmp/cache/' . $dir);
//-- Шаблоны
@ -284,12 +290,19 @@
set_cookie_domain();
//-- Работа с сессиями
if (! SESSION_SAVE_HANDLER)
if (! SESSION_SAVE_HANDLER || SESSION_SAVE_HANDLER == 'files')
{
//-- Класс для работы с сессиями
require (BASE_DIR . '/class/class.session.files.php');
$ses_class = new AVE_Session();
}
//-- Работа с сессиями
else if (SESSION_SAVE_HANDLER == 'memcached')
{
//-- Класс для работы с сессиями
require (BASE_DIR . '/class/class.session.memcached.php');
$ses_class = new AVE_Session_Memcached();
}
else
{
//-- Класс для работы с сессиями
@ -308,6 +321,7 @@
);
//-- Страт сессии
if (session_status() !== PHP_SESSION_ACTIVE)
session_start();
if (isset($HTTP_SESSION_VARS))

81
inc/sitemap.php

@ -24,9 +24,7 @@
}
if (substr($_SERVER['REQUEST_URI'], 0, strlen('/index.php?')) != '/index.php?')
{
$_SERVER['REQUEST_URI'] = str_ireplace('_','-',$_SERVER['REQUEST_URI']);
}
require_once (BASE_DIR . '/inc/init.php');
@ -57,23 +55,34 @@
// Вытаскиваем кол-во документов
$sql = "
SELECT STRAIGHT_JOIN SQL_CALC_FOUND_ROWS
SELECT STRAIGHT_JOIN
COUNT(doc.Id) AS count
FROM
" . PREFIX . "_documents doc
" . PREFIX . "_documents AS doc
LEFT JOIN
" . PREFIX . "_rubrics rub
" . PREFIX . "_rubrics AS rub
ON rub.Id = doc.rubric_id
LEFT JOIN
" . PREFIX . "_rubric_permissions rubperm
ON rubperm.rubric_id = doc.rubric_id
" . PREFIX . "_rubric_templates AS tmpl
ON tmpl.rubric_id = rub.Id
LEFT JOIN
" . PREFIX . "_rubric_permissions AS rubperm
ON rubperm.rubric_id = rub.Id
WHERE
rub.rubric_template NOT LIKE ''
# Не пустой шаблон
(rub.rubric_template NOT LIKE '' OR tmpl.template NOT LIKE '')
# Статус документа = 1
AND doc.document_status = 1
# Документ не удален
AND doc.document_deleted = 1
$publish
# Документ не равен 1
AND doc.Id != 1
# Документ не равен 404 ошибке
AND doc.Id != " . PAGE_NOT_FOUND_ID . "
# Документы разрешены для индексации
AND (document_meta_robots NOT LIKE '%noindex%' or document_meta_robots NOT LIKE '%nofollow%')
# Разрешены для просмотра гостям
AND (rubperm.user_group_id = 2 AND rubperm.rubric_permission LIKE '%docread%')
";
@ -89,41 +98,55 @@
for ($i = 1; $i <= $parts; $i++):
?>
<sitemap>
<loc><?= HOST . '/sitemap-' . $i . '.xml'; ?></loc>
<lastmod><?= date("c"); ?></lastmod>
<loc><?php echo HOST . '/sitemap-' . $i . '.xml'; ?></loc>
<lastmod><?php echo date("c"); ?></lastmod>
</sitemap>
<? endfor;
<?php endfor;
echo '</sitemapindex>';
else:
?>
<?
<?php
if ((int)$_REQUEST['id'] > 1)
$_start = ((int)$_REQUEST['id']-1) * $_end;
$sql = "
SELECT STRAIGHT_JOIN SQL_CALC_FOUND_ROWS
SELECT STRAIGHT_JOIN
doc.Id,
doc.document_alias,
doc.document_published,
doc.document_changed,
doc.document_sitemap_freq,
doc.document_sitemap_pr
FROM " . PREFIX . "_documents doc
LEFT JOIN " . PREFIX . "_rubrics rub
FROM
" . PREFIX . "_documents AS doc
LEFT JOIN
" . PREFIX . "_rubrics AS rub
ON rub.Id = doc.rubric_id
LEFT JOIN " . PREFIX . "_rubric_permissions rubperm
ON rubperm.rubric_id = doc.rubric_id
LEFT JOIN
" . PREFIX . "_rubric_templates AS tmpl
ON tmpl.rubric_id = rub.Id
LEFT JOIN
" . PREFIX . "_rubric_permissions AS rubperm
ON rubperm.rubric_id = rub.Id
WHERE
rub.rubric_template NOT LIKE ''
# Не пустой шаблон
(rub.rubric_template NOT LIKE '' OR tmpl.template NOT LIKE '')
# Статус документа = 1
AND doc.document_status = 1
# Документ не удален
AND doc.document_deleted = 1
$publish
# Документ не равен 1
AND doc.Id != 1
# Документ не равен 404 ошибке
AND doc.Id != " . PAGE_NOT_FOUND_ID . "
# Документы разрешены для индексации
AND (document_meta_robots NOT LIKE '%noindex%' or document_meta_robots NOT LIKE '%nofollow%')
# Разрешены для просмотра гостям
AND (rubperm.user_group_id = 2 AND rubperm.rubric_permission LIKE '%docread%')
GROUP BY doc.Id
ORDER BY doc.document_published ASC
LIMIT ".$_start.",".$_end."
LIMIT ".$_start.",".$_end.";
";
$res = $AVE_DB->Query($sql, SITEMAP_CACHE_LIFETIME, 'sitemap');
@ -133,24 +156,24 @@
if ((int)$_REQUEST['id'] == 1):
?>
<url>
<loc><? echo HOST . '/'; ?></loc>
<lastmod><? echo date("c", time()); ?></lastmod>
<loc><?php echo HOST . '/'; ?></loc>
<lastmod><?php echo date("c", time()); ?></lastmod>
<changefreq>weekly</changefreq>
<priority>0.8</priority>
</url>
<? endif; ?>
<?
<?php endif; ?>
<?php
while($row = $res->FetchAssocArray()):
$document_alias = $abs_path . $row['document_alias'] . URL_SUFF;
$document_alias = HOST . str_ireplace($abs_path . '/' . URL_SUFF, '/', $document_alias);
$date = $row["document_published"] ? date("c", $row["document_published"]) : date("c");
?>
<url>
<loc><? echo $document_alias; ?></loc>
<lastmod><? echo $date; ?></lastmod>
<changefreq><? echo $changefreq[$row['document_sitemap_freq']]; ?></changefreq>
<priority><? echo $row['document_sitemap_pr']; ?></priority>
<loc><?php echo $document_alias; ?></loc>
<lastmod><?php echo $date; ?></lastmod>
<changefreq><?php echo $changefreq[$row['document_sitemap_freq']]; ?></changefreq>
<priority><?php echo $row['document_sitemap_pr']; ?></priority>
</url>
<? endwhile; ?>
<?php endwhile; ?>
</urlset>
<? endif; ?>
<?php endif; ?>

3
install/structure_base.sql

@ -120,7 +120,8 @@ CREATE TABLE `%%PRFX%%_documents` (
KEY `document_parent` (`document_parent`),
KEY `document_status` (`document_status`),
KEY `document_published` (`document_published`),
KEY `document_expire` (`document_expire`)
KEY `document_expire` (`document_expire`),
KEY `document_count_view` (`document_count_view`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;#inst#

11
lib/debug/debug.css

@ -1,12 +1,13 @@
/* == Debug Panel == */
#debug-panel {
font-size: 12px;
font-size: 12px !important;
opacity: 0.9;
position: fixed;
bottom: 0;
left: 0;
z-index: 2000;
width: 100%;
font-family: Consolas, Monaco, Menlo, "Courier New", monospace !important;
}
#debug-panel .debug-wrapper {
padding: 0px .875em;
@ -19,9 +20,9 @@
padding: 10px;
height: 350px;
padding-top: 1em;
font-size: 12px;
font-size: 12px !important;
color: #888;
font-family: Monaco, Menlo, Consolas, "Courier New", monospace
font-family: Consolas, Monaco, Menlo, "Courier New", monospace !important;
}
#debug-panel .debug-wrapper .legend {
background-color: #f9f9f9;
@ -32,7 +33,7 @@
}
#debug-panel .debug-wrapper .legend span {
color: #999;
font-weight: 300
font-weight: 300 !important
}
#debug-panel a {
text-decoration: none;
@ -42,6 +43,8 @@
}
#debug-panel pre {
border: 0px;
font-family: Consolas, Monaco, Menlo, "Courier New", monospace !important;
font-size: 12px !important;
}
#debugArrowMinimize {
float: right;

Loading…
Cancel
Save