diff --git a/class/class.database.php b/class/class.database.php
index 079ed5a..aea6c89 100755
--- a/class/class.database.php
+++ b/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;
}
diff --git a/class/class.debug.php b/class/class.debug.php
index 8ad56e7..7b138e1 100644
--- a/class/class.debug.php
+++ b/class/class.debug.php
@@ -653,6 +653,8 @@
$out = PHP_EOL;
$out .= '';
$out .= PHP_EOL;
+ $out .= '';
+ $out .= PHP_EOL;
$out .= '';
$out .= PHP_EOL;
$out .= '
diff --git a/class/class.rubs.php b/class/class.rubs.php
index 04c7cf3..25b19ee 100755
--- a/class/class.rubs.php
+++ b/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);
diff --git a/class/class.session.memcached.php b/class/class.session.memcached.php
new file mode 100644
index 0000000..806812b
--- /dev/null
+++ b/class/class.session.memcached.php
@@ -0,0 +1,72 @@
+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;
+ }
+ }
+?>
\ No newline at end of file
diff --git a/class/class.sysblocks.php b/class/class.sysblocks.php
index fabdfbe..6a84bf5 100644
--- a/class/class.sysblocks.php
+++ b/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);
+ }
}
}
?>
\ No newline at end of file
diff --git a/class/class.template.php b/class/class.template.php
index 74fdf71..89f36fd 100644
--- a/class/class.template.php
+++ b/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();
}
// Очищаем кэш шаблона документов рубрики
diff --git a/functions/func.parserequest.php b/functions/func.parserequest.php
index 13a782e..17db59d 100755
--- a/functions/func.parserequest.php
+++ b/functions/func.parserequest.php
@@ -869,20 +869,20 @@
$sql_request = str_replace($search, '', $sql_request);
}
}
-
- // Если просили просто показать сформированный запрос
- if ((isset($params['DEBUG']) && $params['DEBUG'] == 1) || $request->request_show_sql == 1)
- {
- $return = Debug::_print($sql_request);
-
- return $return;
- }
}
else
{
$sql_request = $params['SQL_QUERY'];
}
+ // Если просили просто показать сформированный запрос
+ if ((isset($params['DEBUG']) && $params['DEBUG'] == 1) || $request->request_show_sql == 1)
+ {
+ $return = Debug::_print($sql_request);
+
+ return $return;
+ }
+
// Выполняем запрос к бд
$sql = $AVE_DB->Query($sql_request, (int)$request->request_cache_lifetime, 'rqs_' . $id, true, '.request');
diff --git a/functions/func.sysblock.php b/functions/func.sysblock.php
index 759c307..a40e8ed 100644
--- a/functions/func.sysblock.php
+++ b/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))
diff --git a/inc/config.php b/inc/config.php
index 0018560..843b423 100755
--- a/inc/config.php
+++ b/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'=>'');
diff --git a/inc/init.php b/inc/init.php
index 0010906..a7e7e2e 100644
--- a/inc/init.php
+++ b/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,7 +321,8 @@
);
//-- Страт сессии
- session_start();
+ if (session_status() !== PHP_SESSION_ACTIVE)
+ session_start();
if (isset($HTTP_SESSION_VARS))
$_SESSION = $HTTP_SESSION_VARS;
diff --git a/inc/sitemap.php b/inc/sitemap.php
index 3723d7f..2eca4bd 100644
--- a/inc/sitemap.php
+++ b/inc/sitemap.php
@@ -15,7 +15,7 @@
define ('START_MICROTIME', microtime());
- define ('BASE_DIR', str_replace("\\", "/", rtrim($_SERVER['DOCUMENT_ROOT'],'/')));
+ define ('BASE_DIR', str_replace("\\", "/", rtrim($_SERVER['DOCUMENT_ROOT'], '/')));
if (! @filesize(BASE_DIR . '/config/db.config.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++):
?>
- = HOST . '/sitemap-' . $i . '.xml'; ?>
- = date("c"); ?>
+
+
- endfor;
+';
else:
?>
-
+ 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):
?>
- echo HOST . '/'; ?>
- echo date("c", time()); ?>
+
+
weekly
0.8
- endif; ?>
-
+
+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");
?>
- echo $document_alias; ?>
- echo $date; ?>
- echo $changefreq[$row['document_sitemap_freq']]; ?>
- echo $row['document_sitemap_pr']; ?>
+
+
+
+
- endwhile; ?>
+
- endif; ?>
\ No newline at end of file
+
\ No newline at end of file
diff --git a/install/structure_base.sql b/install/structure_base.sql
index 93d4f62..71d1d3b 100755
--- a/install/structure_base.sql
+++ b/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#
diff --git a/lib/debug/debug.css b/lib/debug/debug.css
index 5e86d1e..874272a 100644
--- a/lib/debug/debug.css
+++ b/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;