Browse Source

v 3.25

pull/3/head
M@d D3n 7 years ago
parent
commit
d88076284b
  1. 4
      README.md
  2. 92
      admin/functions/func.admin.common.php
  3. 5
      admin/settings.php
  4. 1
      admin/start.php
  5. 40
      admin/templates/js/main.js
  6. 2
      admin/templates/rubs/list.tpl
  7. 6
      admin/templates/rubs/tmpls.tpl
  8. 6
      admin/templates/start.tpl
  9. 23
      class/class.database.php
  10. 10
      class/class.rubs.php
  11. 2
      inc/config.php
  12. 18
      inc/sitemap.php
  13. 25
      inc/thumb.php

4
README.md

@ -1,4 +1,4 @@
# AVE.cms v3.24
# AVE.cms v3.25
###### Многофункциональная, система управления сайтом.
## Оглавление
@ -73,4 +73,4 @@ Google+: [Google+](https://plus.google.com/106406255345948508717)
---
Copyright © 2007-2018 [Ave-Cms.Ru](https://ave-cms.ru) | [AVE.cms 3.24](https://ave-cms.ru)
Copyright © 2007-2018 [Ave-Cms.Ru](https://ave-cms.ru) | [AVE.cms 3.25](https://ave-cms.ru)

92
admin/functions/func.admin.common.php

@ -8,6 +8,7 @@
* @filesource
*/
/**
* Если был referer, то перенапрявляем на него
*
@ -75,27 +76,34 @@
$AVE_Template->assign('logs', $logs);
}
/**
* Список пользователей за последние $onlinetime секунд
*
* @param int $onlinetime количество секунд
* @return Array массив из пользователей отсортированный по последней активности
*/
function get_online_users($onlinetime=USERS_TIME_SHOW)
function get_online_users($onlinetime = USERS_TIME_SHOW)
{
global $AVE_DB, $AVE_Template;
$time=(time()-intval($onlinetime));
$sql=@$AVE_DB->Query("SELECT * FROM ".PREFIX."_users WHERE last_visit>".$time." ORDER BY last_visit DESC");
$online_users=Array();
while ($row = $sql->FetchRow())
{
$row->user_name = get_username_by_id($row->Id);
$row->user_group_name = get_usergroup_by_id($row->user_group);
array_push($online_users,$row);
}
$AVE_Template->assign('online_users', $online_users);
}
/**
* Форматированный вывод размера
*
@ -105,21 +113,13 @@
function format_size($file_size)
{
if ($file_size >= 1073741824)
{
$file_size = round($file_size / 1073741824 * 100) / 100 . ' Gb';
}
elseif ($file_size >= 1048576)
{
$file_size = round($file_size / 1048576 * 100) / 100 . ' Mb';
}
elseif ($file_size >= 1024)
{
$file_size = round($file_size / 1024 * 100) / 100 . ' Kb';
}
else
{
$file_size = $file_size . ' b';
}
return $file_size;
}
@ -135,37 +135,50 @@
$cnts = array();
$cnts['templates'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_templates")->GetCell();
$cnts['documents'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_documents")->GetCell();
$cnts['request'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_request") ->GetCell();
$cnts['rubrics'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_rubrics") ->GetCell();
$cnts['request'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_request")->GetCell();
$cnts['rubrics'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_rubrics")->GetCell();
$sql = $AVE_DB->Query("
SELECT
`ModuleStatus`,
COUNT(`ModuleStatus`) AS cntStatus
FROM " . PREFIX . "_module
FROM
" . PREFIX . "_module
GROUP BY `ModuleStatus`
");
while ($row = $sql->FetchRow())
{
$cnts['modules_' . $row->ModuleStatus] = $row->cntStatus;
}
$sql = $AVE_DB->Query("
SELECT
status,
COUNT(status) AS cntStatus
FROM " . PREFIX . "_users
FROM
" . PREFIX . "_users
GROUP BY status
");
while ($row = $sql->FetchRow())
{
$cnts['users_' . $row->status] = $row->cntStatus;
}
$AVE_Template->assign('cnts', $cnts);
}
function countDocuments($rubric_id = null)
{
global $AVE_DB;
if (is_numeric($rubric_id) && $rubric_id > 0)
$count = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_documents WHERE rubric_id = '".$rubric_id."'")->GetCell();
else
$count = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_documents")->GetCell();
echo $count;
}
/**
* Размер дириктории
*
@ -175,12 +188,16 @@
function get_dir_size($directory)
{
if (!is_dir($directory)) return -1;
$size = 0;
if ($DIR = opendir($directory))
{
while (($dirfile = readdir($DIR)) !== false)
{
if (@is_link($directory . '/' . $dirfile) || $dirfile == '.' || $dirfile == '..') continue;
if (@is_link($directory . '/' . $dirfile) || $dirfile == '.' || $dirfile == '..')
continue;
if (@is_file($directory . '/' . $dirfile))
{
$size += filesize($directory . '/' . $dirfile);
@ -188,22 +205,21 @@
elseif (@is_dir($directory . '/' . $dirfile))
{
$dirSize = get_dir_size($directory . '/' . $dirfile);
if ($dirSize >= 0)
{
$size += $dirSize;
}
else
{
return -1;
}
}
}
closedir($DIR);
}
return $size;
}
/**
* Размер базы данных
*
@ -214,11 +230,11 @@
global $AVE_DB;
$mysql_size = 0;
$sql = $AVE_DB->Query("SHOW TABLE STATUS LIKE '" . PREFIX . "_%'");
while ($row = $sql->FetchAssocArray())
{
$mysql_size += $row['Data_length'] + $row['Index_length'];
}
return format_size($mysql_size);
}
@ -392,14 +408,19 @@
$handle = fopen($filename, 'rb');
if ($handle === false) return false;
if ($handle === false)
return false;
while (!feof($handle))
{
$buffer = fread($handle, $chunksize);
echo $buffer;
flush();
if ($retbytes) $cnt += strlen($buffer);
if ($retbytes)
$cnt += strlen($buffer);
}
$status = fclose($handle);
@ -504,7 +525,9 @@
$row->canDelete = 0;
$row->canEndDel = 0;
$row->canOpenClose = 0;
$row->rubric_admin_teaser_template=@eval2var(' ?>'.($row->rubric_admin_teaser_template>'' ? @showrequestelement($row,$row->rubric_admin_teaser_template) : '').'<?php ');
$row->rubric_admin_teaser_template = @eval2var(' ?>'.($row->rubric_admin_teaser_template > ''
? @showrequestelement($row, $row->rubric_admin_teaser_template)
: '').'<?php ');
// разрешаем редактирование и удаление
// если автор имеет право изменять свои документы в рубрике
@ -549,7 +572,7 @@
function showrubricName($id)
{
global $AVE_DB, $AVE_Template;
global $AVE_DB;
$sql = $AVE_DB->Query("SELECT rubric_title FROM " . PREFIX . "_rubrics WHERE Id='$id'");
$row = $sql->fetchrow();
@ -558,7 +581,7 @@
function showuserName($id)
{
global $AVE_DB, $AVE_Template;
global $AVE_DB;
$sql = $AVE_DB->Query("SELECT user_name FROM " . PREFIX . "_users WHERE Id='$id'");
$row = $sql->fetchrow();
@ -569,13 +592,16 @@
{
global $AVE_Template;
$showCache = format_size(get_dir_size($AVE_Template->compile_dir)+get_dir_size($AVE_Template->cache_dir_root));
$showCache = format_size(get_dir_size($AVE_Template->cache_dir_root));
echo json_encode(array($showCache, 'accept'));
}
function templateName($id)
{
global $AVE_DB, $AVE_Template;
global $AVE_DB;
$sql = $AVE_DB->Query("
SELECT * FROM " . PREFIX . "_templates
@ -588,7 +614,7 @@
function groupName($id)
{
global $AVE_DB, $AVE_Template;
global $AVE_DB;
$sql = $AVE_DB->Query("
SELECT * FROM " . PREFIX . "_user_groups

5
admin/settings.php

@ -148,6 +148,11 @@
case 'showcache':
cacheShow();
exit;
case 'showcountdocs':
$rubric_id = isset($_REQUEST['rubric_id']) ? $_REQUEST['rubric_id'] : null;
countDocuments($rubric_id);
exit;
}
break;

1
admin/start.php

@ -23,7 +23,6 @@
get_online_users();
getLogRecords();
//$AVE_Template->config_load(BASE_DIR . '/admin/lang/' . $_SESSION['admin_language'] . '/main.txt', 'index');
$AVE_Template->assign('php_version', (@PHP_VERSION != '') ? @PHP_VERSION : 'unknow');
$AVE_Template->assign('domain', $_SERVER["HTTP_HOST"]);
$AVE_Template->assign('mysql_version', $GLOBALS['AVE_DB']->mysql_version());

40
admin/templates/js/main.js

@ -366,6 +366,7 @@ var AveAdmin = {
this.clear_revisions();
this.clear_counter();
this.cache_show();
this.docs_show();
this.main_form();
this.select_form();
this.sticky_panel();
@ -675,6 +676,45 @@ var AveAdmin = {
},
//Показать размер кэша
docs_show: function() {
$('.showDocs').click(function(event, x) {
event.preventDefault();
var title = cacheShowTitle;
var confirm = cacheShowConfirm;
var rubric_id = $(this).attr('data-rubric-id');
var block = $(this);
jConfirm(
confirm,
title,
function(b) {
if (b) {
$.alerts._overlay('hide');
$.alerts._overlay('show');
$.ajax({
url: ave_path + 'admin/index.php?do=settings&sub=showcountdocs',
type: 'POST',
data: ({
rubric_id: rubric_id
}),
success: function(data) {
$.alerts._overlay('hide');
block.before(data).remove();
}
});
}
}
);
});
},
//Окно удаления едемента
confirm_delete: function() {

2
admin/templates/rubs/list.tpl

@ -179,7 +179,7 @@ $(function() {ldelim}
</select>
{/if}
</td>
<td align="center"><strong class="code">{$rubric->doc_count}</strong></td>
<td align="center"><strong class="code"><a href="javascript:void(0);" class="link showDocs" data-rubric-id="{$rubric->Id}">{#MAIN_STAT_CACHE_SHOW#}</a></strong></td>
<td align="center">
{if check_permission('rubric_edit')}
<input type="checkbox" name="rubric_docs_active[{$rubric->Id}]" value="1" {if $rubric->rubric_docs_active == 1}checked="checked"{/if}>

6
admin/templates/rubs/tmpls.tpl

@ -104,7 +104,6 @@ $(document).ready(function(){ldelim}
<col width="20">
<col width="20">
<col width="20">
<col width="20">
{if $templates}
<thead>
@ -113,7 +112,6 @@ $(document).ready(function(){ldelim}
<td>{#RUBRIC_TMPLS_NAME#}</td>
<td>{#RUBRIC_TMPLS_AUTHOR#}</td>
<td>{#RUBRIC_TMPLS_DATE#}</td>
<td align="center"><a href="javascript:void(0);" class="topDir icon_sprite ico_list float" style="cursor: help; display: inline-block" title="{#RUBRIC_TMPLS_COUNT_DOCS#}"></a></td>
{if check_permission('rubric_edit')}<td colspan="3">{#RUBRIC_TMPLS_ACTIONS#}</td>{/if}
</tr>
</thead>
@ -139,10 +137,6 @@ $(document).ready(function(){ldelim}
<span class="date_text dgrey">{$template->created|date_format:$TIME_FORMAT|pretty_date}</span>
</td>
<td>
<strong class="code">{$template->doc_count}</strong>
</td>
{if check_permission('rubric_edit')}
<td nowrap="nowrap" width="1%" align="center">
<a class="topleftDir CopyTmpl icon_sprite ico_copy" title="{#RUBRIC_TMPLS_COPY#}" href="index.php?do=rubs&action=tmpls_copy&tmpls_id={$template->id}&rubric_id={$smarty.request.Id|escape}&cp={$sess}"></a>

6
admin/templates/start.tpl

@ -22,14 +22,14 @@
{rdelim}
{rdelim});
{rdelim});
</script>
</script>
</li>
</ul>
{/if}
{if $login_menu && $online_users > "1"}
<ul class="messages first">
<li class="highlight grey">{#MAIN_USERS_LAST_TIME#}
<li class="highlight grey">{#MAIN_USERS_LAST_TIME#}
{foreach from=$online_users item=item name=online_users}
<a href="index.php?do=user&action=edit&Id={$item->Id}" class="topDir link" title="{$item->user_group_name}">{if $item->user_group == "1"}<strong>{$item->user_name}</strong>{else}{$item->user_name}{/if}</a>{if !$smarty.foreach.online_users.last}, {/if}
{/foreach}
@ -164,7 +164,7 @@
<tbody>
<tr class="noborder">
<td>{#MAIN_STAT_DOCUMENTS#}</td>
<td align="right"><span class="cmsStats">{$cnts.documents}</span></td>
<td align="right"><span class="cmsStats"><a href="javascript:void(0);" class="link showDocs">{#MAIN_STAT_CACHE_SHOW#}</a></span></td>
</tr>
<tr>
<td>{#MAIN_STAT_RUBRICS#}</td>

23
class/class.database.php

@ -1414,6 +1414,29 @@
}
/**
* Метод, предназначенный для очищения кеша документов
*
* @param $cache_id
* @return bool
*/
public function clearCurrentCache($cache_id, $sql = '', $ext = '')
{
$cache_id = $this->cacheId($cache_id);
$cache_file = md5($sql) . $ext;
$cache_dir = BASE_DIR . '/tmp/cache/sql/' . (trim($cache_id) > ''
? trim($cache_id) . '/'
: substr($cache_file, 0, 2) . '/' . substr($cache_file, 2, 2) . '/' . substr($cache_file, 4, 2) . '/');
if (file_exists($cache_dir . $cache_file))
unlink($cache_dir . $cache_file);
return true;
}
/**
* Метод, предназначенный для очищения кеша документов
*

10
class/class.rubs.php

@ -75,14 +75,11 @@
$sql = $AVE_DB->Query("
SELECT
rub.*,
COUNT(doc.Id) AS doc_count,
(SELECT 1 FROM " . PREFIX . "_documents WHERE rubric_id = rub.Id LIMIT 1) AS doc_count,
(SELECT count(*) FROM " . PREFIX . "_rubric_fields AS fld WHERE fld.rubric_id = rub.Id) AS fld_count,
(SELECT count(*) FROM " . PREFIX . "_rubric_templates AS tmpls WHERE tmpls.rubric_id = rub.Id) AS tmpls_count
FROM
" . PREFIX . "_rubrics AS rub
LEFT JOIN
" . PREFIX . "_documents AS doc
ON rubric_id = rub.Id
GROUP BY rub.Id
ORDER BY rub.rubric_position
LIMIT " . $set_start . "," . $page_limit
@ -1972,15 +1969,12 @@
SELECT
rub.*,
rubrics.rubric_title,
COUNT(doc.Id) AS doc_count
(SELECT 1 FROM " . PREFIX . "_documents WHERE rubric_id = rub.rubric_id AND rubric_tmpl_id = rub.id LIMIT 1) AS doc_count
FROM
" . PREFIX . "_rubric_templates AS rub
LEFT JOIN
" . PREFIX . "_rubrics AS rubrics
ON rubrics.Id = rub.rubric_id
LEFT JOIN
" . PREFIX . "_documents AS doc
ON (doc.rubric_id = rub.rubric_id AND doc.rubric_tmpl_id = rub.id)
WHERE
rub.rubric_id = '" . (int)$_REQUEST['Id'] . "'
GROUP

2
inc/config.php

@ -12,7 +12,7 @@
*/
@define('APP_NAME', 'AVE.cms');
@define('APP_VERSION', '3.24');
@define('APP_VERSION', '3.25');
@define('APP_INFO', '<a target="_blank" href="https://www.ave-cms.ru/">Ave-Cms.Ru</a> '.'&copy; 2007-' . date('Y'));
$GLOBALS['CMS_CONFIG']['USER_IP'] = array('DESCR' =>'Использовать IP для автологина на сайте','default'=>false,'TYPE'=>'bool','VARIANT'=>'');

18
inc/sitemap.php

@ -11,7 +11,6 @@
* @license GPL v.2
*/
header ('Content-type: text/xml');
define ('START_MICROTIME', microtime());
@ -53,6 +52,8 @@
'6' => 'never'
);
if (! isset($_REQUEST['id'])):
// Вытаскиваем кол-во документов
$sql = "
SELECT STRAIGHT_JOIN
@ -91,7 +92,8 @@
if ($num > $_end)
$parts = ceil($num/$_end);
if (! isset($_REQUEST['id'])):
header ('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
echo '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;
@ -149,7 +151,17 @@
LIMIT ".$_start.",".$_end.";
";
$res = $AVE_DB->Query($sql, SITEMAP_CACHE_LIFETIME, 'sitemap');
$res = $AVE_DB->Query($sql, SITEMAP_CACHE_LIFETIME, 'sitemap', true, '.limit');
if (! $res->NumRows())
{
report404();
$AVE_DB->clearCurrentCache('sitemap', $sql, '.limit');
header ($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true);
exit;
}
header ('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;

25
inc/thumb.php

@ -69,7 +69,10 @@
}
//-- Подгружаем настройки системы
require(dirname(__FILE__) . '/config.php');
require (dirname(__FILE__) . '/config.php');
//-- Подгружаем функции логирования
require_once BASE_DIR . '/functions/func.logs.php';
//-- Разрешенные расширения файлов
$allowedExt = array('jpg', 'jpeg', 'png', 'gif', 'JPG', 'JPEG', 'PNG', 'GIF');
@ -130,13 +133,23 @@
exit;
}
else
{
report404();
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
exit(0);
}
list(, $thumbPath) = explode('/' . UPLOAD_DIR . '/', dirname($imagefile), 2);
$lenThumbDir = strlen(THUMBNAIL_DIR);
// --
if ($lenThumbDir && substr($thumbPath, -$lenThumbDir) != THUMBNAIL_DIR)
{
exit(0);
}
$thumbPath = $baseDir . '/' . UPLOAD_DIR . '/' . $thumbPath;
$imagePath = $lenThumbDir ? dirname($thumbPath) : $thumbPath;
@ -145,7 +158,7 @@
$nameParts = explode('.', $thumbName);
$countParts = count($nameParts);
if ($countParts < 2 || !in_array(strtolower(end($nameParts)), $allowedExt))
if ($countParts < 2 || ! in_array(strtolower(end($nameParts)), $allowedExt))
exit(0);
$matches = array();
@ -156,6 +169,8 @@
//-- Если нет параметров, отдаем 404
if (! isset($matches[0]))
{
report404();
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
exit(0);
}
@ -167,6 +182,8 @@
{
if (! in_array($check, $allowedAdmin))
{
report404();
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
exit(0);
}
@ -224,6 +241,8 @@
{
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
report404();
$imageName = 'noimage.png';
if (! file_exists("$imagePath/$imageName"))
@ -281,7 +300,7 @@
//-- Если можно сохранять миниатюру
if ($save)
{
if (! file_exists($thumbPath) && ! mkdir($thumbPath, 0777))
if (! file_exists($thumbPath) && ! mkdir($thumbPath, 0777, true))
exit(0);
if ($thumb->save("$thumbPath/$thumbName"))

Loading…
Cancel
Save