diff --git a/README.md b/README.md index 1304dd9..630a35c 100644 --- a/README.md +++ b/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) \ No newline at end of file +Copyright © 2007-2018 [Ave-Cms.Ru](https://ave-cms.ru) | [AVE.cms 3.25](https://ave-cms.ru) \ No newline at end of file diff --git a/admin/functions/func.admin.common.php b/admin/functions/func.admin.common.php index 00b87ad..3c2812d 100644 --- a/admin/functions/func.admin.common.php +++ b/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) : '').'rubric_admin_teaser_template = @eval2var(' ?>'.($row->rubric_admin_teaser_template > '' + ? @showrequestelement($row, $row->rubric_admin_teaser_template) + : '').'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 diff --git a/admin/settings.php b/admin/settings.php index bea299e..7d5cf35 100644 --- a/admin/settings.php +++ b/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; diff --git a/admin/start.php b/admin/start.php index f380260..e74459b 100644 --- a/admin/start.php +++ b/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()); diff --git a/admin/templates/js/main.js b/admin/templates/js/main.js index 7917cda..b41c9f4 100644 --- a/admin/templates/js/main.js +++ b/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() { diff --git a/admin/templates/rubs/list.tpl b/admin/templates/rubs/list.tpl index f0ac9fe..a49cd46 100755 --- a/admin/templates/rubs/list.tpl +++ b/admin/templates/rubs/list.tpl @@ -179,7 +179,7 @@ $(function() {ldelim} {/if} - {$rubric->doc_count} + {#MAIN_STAT_CACHE_SHOW#} {if check_permission('rubric_edit')} rubric_docs_active == 1}checked="checked"{/if}> diff --git a/admin/templates/rubs/tmpls.tpl b/admin/templates/rubs/tmpls.tpl index fc08788..b421610 100644 --- a/admin/templates/rubs/tmpls.tpl +++ b/admin/templates/rubs/tmpls.tpl @@ -104,7 +104,6 @@ $(document).ready(function(){ldelim} - {if $templates} @@ -113,7 +112,6 @@ $(document).ready(function(){ldelim} {#RUBRIC_TMPLS_NAME#} {#RUBRIC_TMPLS_AUTHOR#} {#RUBRIC_TMPLS_DATE#} - {if check_permission('rubric_edit')}{#RUBRIC_TMPLS_ACTIONS#}{/if} @@ -139,10 +137,6 @@ $(document).ready(function(){ldelim} {$template->created|date_format:$TIME_FORMAT|pretty_date} - - {$template->doc_count} - - {if check_permission('rubric_edit')} diff --git a/admin/templates/start.tpl b/admin/templates/start.tpl index 45e871e..c1bb3b8 100644 --- a/admin/templates/start.tpl +++ b/admin/templates/start.tpl @@ -22,14 +22,14 @@ {rdelim} {rdelim}); {rdelim}); - + {/if} {if $login_menu && $online_users > "1"}