From a8d05b234cba640e01c8e6930b85d6e8f0bba05c Mon Sep 17 00:00:00 2001 From: Pavel Mikulik Date: Sun, 17 Oct 2010 20:36:18 +0000 Subject: [PATCH] hits and referers moved to plugins (not tested yet) --- datas/config-sample.php | 2 - index.php | 2 - lang/en/admin.en.lang.php | 28 ---- lang/en/main.en.lang.php | 4 +- lang/ru/admin.ru.lang.php | 29 ---- lang/ru/main.ru.lang.php | 2 - modules/forums/inc/forums.editpost.php | 2 - modules/forums/inc/forums.newtopic.php | 2 - modules/forums/inc/forums.posts.php | 1 - modules/forums/inc/forums.sections.php | 2 - modules/forums/inc/forums.topics.php | 1 - modules/index/index.php | 2 - modules/page/inc/page.add.php | 1 - modules/page/inc/page.edit.php | 1 - modules/page/inc/page.list.php | 1 - modules/page/inc/page.main.php | 1 - modules/pm/inc/pm.list.php | 1 - modules/pm/inc/pm.message.php | 2 - modules/pm/inc/pm.send.php | 2 - modules/polls/polls.php | 2 - modules/view/view.php | 2 - plugins/hits/hits.admin.home.php | 149 ++++++++++++++++++ .../hits/hits.admin.php | 51 +++--- plugins/hits/hits.global.php | 37 +++++ plugins/hits/hits.header.php | 41 +++++ plugins/hits/hits.setup.php | 29 ++++ plugins/hits/inc/hits.functions.php | 72 +++++++++ plugins/hits/lang/hits.en.lang.php | 34 ++++ plugins/hits/lang/hits.ru.lang.php | 33 ++++ plugins/hits/setup/hits.install.sql | 15 ++ plugins/hits/setup/hits.uninstall.sql | 1 + plugins/hits/tpl/hits.admin.home.tpl | 50 ++++++ .../hits/tpl/hits.admin.tpl | 0 plugins/referers/lang/referers.en.lang.php | 23 +++ plugins/referers/lang/referers.ru.lang.php | 23 +++ .../referers/referers.admin.php | 46 +++--- plugins/referers/referers.global.php | 40 +++++ plugins/referers/referers.setup.php | 23 +++ plugins/referers/setup/referers.install.sql | 6 + plugins/referers/setup/referers.uninstall.sql | 1 + .../referers/tpl/referers.admin.tpl | 0 plugins/trashcan/lang/trashcan.en.lang.php | 4 +- plugins/trashcan/lang/trashcan.ru.lang.php | 4 +- plugins/trashcan/trashcan.admin.php | 2 +- setup/install.sql | 26 --- system/admin/admin.home.php | 132 +--------------- system/admin/admin.main.php | 4 +- system/admin/admin.other.php | 2 - system/admin/tpl/admin.home.tpl | 50 +----- system/admin/tpl/admin.other.tpl | 12 -- system/common.php | 37 ----- system/functions.php | 80 +--------- system/header.php | 2 + 53 files changed, 642 insertions(+), 477 deletions(-) create mode 100644 plugins/hits/hits.admin.home.php rename system/admin/admin.hits.php => plugins/hits/hits.admin.php (82%) create mode 100644 plugins/hits/hits.global.php create mode 100644 plugins/hits/hits.header.php create mode 100644 plugins/hits/hits.setup.php create mode 100644 plugins/hits/inc/hits.functions.php create mode 100644 plugins/hits/lang/hits.en.lang.php create mode 100644 plugins/hits/lang/hits.ru.lang.php create mode 100644 plugins/hits/setup/hits.install.sql create mode 100644 plugins/hits/setup/hits.uninstall.sql create mode 100644 plugins/hits/tpl/hits.admin.home.tpl rename system/admin/tpl/admin.hits.tpl => plugins/hits/tpl/hits.admin.tpl (100%) create mode 100644 plugins/referers/lang/referers.en.lang.php create mode 100644 plugins/referers/lang/referers.ru.lang.php rename system/admin/admin.referers.php => plugins/referers/referers.admin.php (73%) create mode 100644 plugins/referers/referers.global.php create mode 100644 plugins/referers/referers.setup.php create mode 100644 plugins/referers/setup/referers.install.sql create mode 100644 plugins/referers/setup/referers.uninstall.sql rename system/admin/tpl/admin.referers.tpl => plugins/referers/tpl/referers.admin.tpl (100%) diff --git a/datas/config-sample.php b/datas/config-sample.php index 02a2c358e..259d60cb0 100644 --- a/datas/config-sample.php +++ b/datas/config-sample.php @@ -161,8 +161,6 @@ $db_plugins = $db_x.'plugins'; $db_rated = $db_x.'rated'; $db_ratings = $db_x.'ratings'; -$db_referers = $db_x.'referers'; -$db_stats = $db_x.'stats'; $db_structure = $db_x.'structure'; $db_updates = $db_x.'updates'; $db_users = $db_x.'users'; diff --git a/index.php b/index.php index d967f180a..34d230e03 100644 --- a/index.php +++ b/index.php @@ -147,8 +147,6 @@ $out['subtitle'] = empty($out['subtitle']) ? $L['plu_title'] : $out['subtitle']; $sys['sublocation'] = $out['subtitle']; - cot_online_update(); - if ($ext_display_header) { require_once $cfg['system_dir'] . '/header.php'; diff --git a/lang/en/admin.en.lang.php b/lang/en/admin.en.lang.php index defea1cfc..dda25c6b5 100644 --- a/lang/en/admin.en.lang.php +++ b/lang/en/admin.en.lang.php @@ -23,9 +23,6 @@ * Home Section */ -$L['home_hitsmonth'] = 'Hits for the past 15 days'; -$L['home_pastdays'] = 'Activity for the past 7 days'; - $L['home_newusers'] = 'New members'; $L['home_newpages'] = 'New pages'; $L['home_newtopics'] = 'New topics'; @@ -161,11 +158,7 @@ $L['cfg_cache_forums'] = array('Page cache in forums', 'Caches entire pages output for guests'); // New in 0.7.0 $L['cfg_cache_index'] = array('Page cache on index', 'Index will be static for all guests'); // New in 0.7.0 $L['cfg_cache_page'] = array('Page cache in page and list', 'Caches entire pages for guests'); // New in 0.7.0 -$L['cfg_disablehitstats'] = array('Disable hit statistics', 'Referers and hits per day'); -$L['cfg_disableactivitystats'] = array('Do not display statistics of activity', 'Activity for the last 7 days
Displayed on the home page administration panel'); -$L['cfg_disabledbstats'] = array('Do not display database statistics', 'Displayed on the home page administration panel'); $L['cfg_gzip'] = array('Gzip', 'Gzip compression of the HTML output'); -$L['cfg_hit_percision'] = array('Optimized hit counter precision', ''); // New in 0.7.0 $L['cfg_shared_drv'] = array('Shared memory cache driver', '(go to Other - Cache)'); // New in 0.7.0 /** @@ -465,26 +458,6 @@ $L['alreadyupdatednewentry'] = 'Entry updated'; //N-0.0.2 $L['alreadydeletednewentry'] = 'Entry deleted'; //N-0.0.2 -/** - * Other Section - * Hits Subsection - */ - -$L['adm_byyear'] = 'By year'; -$L['adm_bymonth'] = 'By month'; -$L['adm_byweek'] = 'By week'; - -$L['adm_ref_lowhits'] = 'Purge entries where hits are lower than 5'; -$L['adm_maxhits'] = 'Maximum hitcount was reached %1$s, %2$s pages displayed this day.'; - -/** - * Other Section - * Referers Subsection - */ - -$L['adm_ref_prune'] = 'Cleaned'; -$L['adm_ref_prunelowhits'] = 'Referers with the number of visitors is less 5 successfully removed'; - /** * Other Section * Log Subsection @@ -499,7 +472,6 @@ $L['adm_checkthemes'] = 'Check if all files are present in themes'; $L['adm_checktheme'] = 'Check TPL files for the theme'; $L['adm_checkingtheme'] = 'Checking the theme...'; -$L['adm_hits'] = 'Hits'; $L['adm_check_ok'] = 'Ok'; $L['adm_check_missing'] = 'Missing'; diff --git a/lang/en/main.en.lang.php b/lang/en/main.en.lang.php index 36d59ee4c..055c89d00 100644 --- a/lang/en/main.en.lang.php +++ b/lang/en/main.en.lang.php @@ -121,7 +121,7 @@ $L['Hi'] = 'Hi'; $L['Hidden'] = 'Hidden'; $L['Hide'] = 'Hide'; -$L['Hits'] = 'Hits'; +$L['refes'] = 'Hits'; $L['Home'] = 'Home'; $L['Hook'] = 'Hook'; $L['Hooks'] = 'Hooks'; @@ -245,8 +245,6 @@ $L['Reason'] = 'Reason'; $L['Recipient'] = 'Recipient'; // New in 0.1.0 $L['Recipients'] = 'Recipients'; // New in 0.1.0 -$L['Referer'] = 'Referer'; -$L['Referers'] = 'Referers'; $L['Refresh'] = 'Refresh'; $L['Register'] = 'Register'; $L['Registered'] = 'Registered'; diff --git a/lang/ru/admin.ru.lang.php b/lang/ru/admin.ru.lang.php index 9249da6ed..2bb4cdbd5 100644 --- a/lang/ru/admin.ru.lang.php +++ b/lang/ru/admin.ru.lang.php @@ -23,9 +23,6 @@ * Home Section */ -$L['home_hitsmonth'] = 'Хиты за последние 15 дней'; -$L['home_pastdays'] = 'Активность за последние 7 дней'; - $L['home_newusers'] = 'Новые пользователи'; $L['home_newpages'] = 'Новые страницы'; $L['home_newtopics'] = 'Новые темы'; @@ -161,11 +158,7 @@ $L['cfg_cache_forums'] = array('Страничный кеш в форумах', 'Кеширует страницы целиком для гостей'); // New in 0.7.0 $L['cfg_cache_index'] = array('Страничный кеш на главной', 'Главная страница будет статичной для всех гостей'); // New in 0.7.0 $L['cfg_cache_page'] = array('Страничный кеш в page и list', 'Кеширует страницы целиком для гостей'); // New in 0.7.0 -$L['cfg_disablehitstats'] = array('Отключить статистику', 'Рефереры и хиты за день'); -$L['cfg_disableactivitystats'] = array('Не отображать статистику активности', 'Активность за последние 7 дней
Отображается на главной странице управления сайтом'); -$L['cfg_disabledbstats'] = array('Не отображать статистику базы данных', 'Отображается на главной странице управления сайтом'); $L['cfg_gzip'] = array('Gzip', 'Gzip-сжатие для исходящего HTML-кода'); -$L['cfg_hit_percision'] = array('Точность оптимизированного счётчика просмотров', ''); // New in 0.7.0 $L['cfg_shared_drv'] = array('Драйвер кеша в ОЗУ', '(См. Модули - Внутренний кеш)'); // New in 0.7.0 /** @@ -464,27 +457,6 @@ $L['alreadyaddnewentry'] = 'Новая запись добавлена'; // New in 0.0.2 $L['alreadyupdatednewentry'] = 'Запись обновлена'; // New in 0.0.2 $L['alreadydeletednewentry'] = 'Запись удалена'; // New in 0.0.2 - -/** - * Other Section - * Hits Subsection - */ - -$L['adm_byyear'] = 'По годам'; -$L['adm_bymonth'] = 'По месяцам'; -$L['adm_byweek'] = 'По неделям'; - -$L['adm_ref_lowhits'] = 'Удалить записи с количеством хитов менее 5'; -$L['adm_maxhits'] = 'Максимальное количество хитов (%2$s) зафиксировано %1$s'; - -/** - * Other Section - * Referers Subsection - */ - -$L['adm_ref_prune'] = 'Очищено'; -$L['adm_ref_prunelowhits'] = 'Рефералы с количеством посетителей менее 5 удалены'; - /** * Other Section * Log Subsection @@ -499,7 +471,6 @@ $L['adm_checkthemes'] = 'Проверить наличие всех файлов в скине'; $L['adm_checkskin'] = 'Проверить TPL-файлы скина'; $L['adm_checkingskin'] = 'Проверяю скин...'; -$L['adm_hits'] = 'Хиты'; $L['adm_check_ok'] = 'Ok'; $L['adm_check_missing'] = 'Отсутствует'; diff --git a/lang/ru/main.ru.lang.php b/lang/ru/main.ru.lang.php index 71dc65e5a..348f06c72 100644 --- a/lang/ru/main.ru.lang.php +++ b/lang/ru/main.ru.lang.php @@ -245,8 +245,6 @@ $L['Reason'] = 'Причина'; $L['Recipient'] = 'Получатель'; // New in N-0.1.0 $L['Recipients'] = 'Получатели'; // New in N-0.1.0 -$L['Referer'] = 'Реферал'; -$L['Referers'] = 'Рефералы'; $L['Refresh'] = 'Обновить'; $L['Register'] = 'Зарегистрироваться'; $L['Registered'] = 'Дата регистрации'; diff --git a/modules/forums/inc/forums.editpost.php b/modules/forums/inc/forums.editpost.php index 2619d11a4..7b37c6665 100644 --- a/modules/forums/inc/forums.editpost.php +++ b/modules/forums/inc/forums.editpost.php @@ -196,8 +196,6 @@ $out['subtitle'] = cot_title('title_forum_editpost', $title_params); $out['head'] .= $R['code_noindex']; -cot_online_update(); - /* === Hook === */ foreach (cot_getextplugins('forums.editpost.main') as $pl) { diff --git a/modules/forums/inc/forums.newtopic.php b/modules/forums/inc/forums.newtopic.php index 83b905f4f..90eb428dd 100644 --- a/modules/forums/inc/forums.newtopic.php +++ b/modules/forums/inc/forums.newtopic.php @@ -203,8 +203,6 @@ $out['subtitle'] = cot_title('title_forum_newtopic', $title_params); $out['head'] .= $R['code_noindex']; -cot_online_update(); - /* === Hook === */ foreach (cot_getextplugins('forums.newtopic.main') as $pl) { diff --git a/modules/forums/inc/forums.posts.php b/modules/forums/inc/forums.posts.php index 9fe209f4d..606ae6998 100644 --- a/modules/forums/inc/forums.posts.php +++ b/modules/forums/inc/forums.posts.php @@ -140,7 +140,6 @@ } $sys['sublocation'] = $fs_title; -cot_online_update(); $cat = $cot_forums_str[$s]; diff --git a/modules/forums/inc/forums.sections.php b/modules/forums/inc/forums.sections.php index eb8519a7a..bce771a27 100644 --- a/modules/forums/inc/forums.sections.php +++ b/modules/forums/inc/forums.sections.php @@ -29,8 +29,6 @@ $ce = explode('_', $s); $sys['sublocation'] = $L['Home']; -cot_online_update(); - /* === Hook === */ foreach (cot_getextplugins('forums.sections.first') as $pl) { diff --git a/modules/forums/inc/forums.topics.php b/modules/forums/inc/forums.topics.php index 573f49409..d91bfec4d 100644 --- a/modules/forums/inc/forums.topics.php +++ b/modules/forums/inc/forums.topics.php @@ -118,7 +118,6 @@ function cursort($trigger, $way) /* ===== */ $sys['sublocation'] = $fs_title; -cot_online_update(); $cat = $cot_forums_str[$fs_id]; diff --git a/modules/index/index.php b/modules/index/index.php index dde81ee17..a1b826aed 100644 --- a/modules/index/index.php +++ b/modules/index/index.php @@ -28,8 +28,6 @@ } /* ===== */ -cot_online_update(); - list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('index', 'a'); /* === Hook === */ diff --git a/modules/page/inc/page.add.php b/modules/page/inc/page.add.php index 7a3f0ec64..c292d8c9e 100644 --- a/modules/page/inc/page.add.php +++ b/modules/page/inc/page.add.php @@ -152,7 +152,6 @@ $out['subtitle'] = cot_title('title_page', $title_params); $out['head'] .= $R['code_noindex']; $sys['sublocation'] = $cot_cat[$c]['title']; -cot_online_update(); /* === Hook === */ foreach (cot_getextplugins('page.add.main') as $pl) diff --git a/modules/page/inc/page.edit.php b/modules/page/inc/page.edit.php index d943d021f..cf50cc938 100644 --- a/modules/page/inc/page.edit.php +++ b/modules/page/inc/page.edit.php @@ -208,7 +208,6 @@ $out['subtitle'] = cot_title('title_page', $title_params); $out['head'] .= $R['code_noindex']; $sys['sublocation'] = $cot_cat[$c]['title']; -cot_online_update(); /* === Hook === */ foreach (cot_getextplugins('page.edit.main') as $pl) diff --git a/modules/page/inc/page.list.php b/modules/page/inc/page.list.php index 15e46aa7b..4c2b36a14 100644 --- a/modules/page/inc/page.list.php +++ b/modules/page/inc/page.list.php @@ -63,7 +63,6 @@ $dc = empty($dc) ? 0 : (int) $dc; $sys['sublocation'] = $cat['title']; -cot_online_update(); $cfg['maxrowsperpage'] = ($c == 'all' || $c == 'system') ? $cfg['maxrowsperpage'] * 2 : $cfg['maxrowsperpage']; diff --git a/modules/page/inc/page.main.php b/modules/page/inc/page.main.php index bfa9aa8a4..d89a91d5c 100644 --- a/modules/page/inc/page.main.php +++ b/modules/page/inc/page.main.php @@ -46,7 +46,6 @@ $cat = $cot_cat[$pag['page_cat']]; $sys['sublocation'] = $pag['page_title']; -cot_online_update(); $pag['page_begin_noformat'] = $pag['page_date']; $pag['page_tab'] = (empty($pg)) ? 0 : $pg; diff --git a/modules/pm/inc/pm.list.php b/modules/pm/inc/pm.list.php index 218ea663c..030b1a8da 100644 --- a/modules/pm/inc/pm.list.php +++ b/modules/pm/inc/pm.list.php @@ -112,7 +112,6 @@ $out['subtitle'] = cot_title('title_pm_main', $title_params); $out['head'] .= $R['code_noindex']; -cot_online_update(); /* === Title === */ $sql = $db->query("SELECT COUNT(*) FROM $db_pm WHERE $sqlfilter"); diff --git a/modules/pm/inc/pm.message.php b/modules/pm/inc/pm.message.php index 53a0fabd4..242f0ecd3 100644 --- a/modules/pm/inc/pm.message.php +++ b/modules/pm/inc/pm.message.php @@ -87,8 +87,6 @@ $out['subtitle'] = cot_title('title_pm_main', $title_params); $out['head'] .= $R['code_noindex']; -cot_online_update(); - /* === Hook === */ foreach (cot_getextplugins('pm.main') as $pl) { diff --git a/modules/pm/inc/pm.send.php b/modules/pm/inc/pm.send.php index f5a1039cc..015f97d3b 100644 --- a/modules/pm/inc/pm.send.php +++ b/modules/pm/inc/pm.send.php @@ -243,8 +243,6 @@ $out['subtitle'] = cot_title('title_pm_send', $title_params); $out['head'] .= $R['code_noindex']; -cot_online_update(); - /* === Hook === */ foreach (cot_getextplugins('pm.send.main') as $pl) { diff --git a/modules/polls/polls.php b/modules/polls/polls.php index 8492cd78d..024d23003 100644 --- a/modules/polls/polls.php +++ b/modules/polls/polls.php @@ -68,8 +68,6 @@ $out['subtitle'] = $L['Polls']; -cot_online_update(); - /* === Hook === */ foreach (cot_getextplugins('polls.main') as $pl) { diff --git a/modules/view/view.php b/modules/view/view.php index 297fb9606..9b9e45913 100644 --- a/modules/view/view.php +++ b/modules/view/view.php @@ -97,8 +97,6 @@ } } -cot_online_update(); - require_once $cfg['system_dir'].'/header.php'; $t = new XTemplate(cot_skinfile('plugin')); diff --git a/plugins/hits/hits.admin.home.php b/plugins/hits/hits.admin.home.php new file mode 100644 index 000000000..54da4dac0 --- /dev/null +++ b/plugins/hits/hits.admin.home.php @@ -0,0 +1,149 @@ +query("SELECT * FROM $db_stats WHERE stat_name LIKE '20%' ORDER BY stat_name DESC LIMIT ".$timeback_stats); + while ($row = $sql->fetch()) + { + $year = mb_substr($row['stat_name'], 0, 4); + $mons = mb_substr($row['stat_name'], 5, 2); + $day = mb_substr($row['stat_name'], 8, 2); + $dat = @date('d D', mktime(0, 0, 0, $mons, $day, $year)); + $hits_d[$dat] = $row['stat_value']; + } + + if (is_array($hits_d)) + { + $hits_d_max = max($hits_d); + + foreach ($hits_d as $day => $hits) + { + $percentbar = floor(($hits / $hits_d_max) * 100); + $tt->assign(array( + 'ADMIN_HOME_DAY' => $day, + 'ADMIN_HOME_HITS' => $hits, + 'ADMIN_HOME_PERCENTBAR' => $percentbar + )); + $tt->parse('MAIN.STAT.ADMIN_HOME_ROW'); + } + } + $tt->assign('ADMIN_HOME_MORE_HITS_URL', cot_url('admin', 'm=hits')); + $tt->parse('MAIN.STAT'); +} + +//Show activity stats +if (!$cfg['plugin']['hits']['disableactivitystats']) +{ + $timeback = $sys['now_offset'] - (7 * 86400);// 7 days + + $sql = $db->query("SELECT COUNT(*) FROM $db_users WHERE user_regdate>'$timeback'"); + $newusers = $sql->fetchColumn(); + + $sql = $db->query("SELECT COUNT(*) FROM $db_pages WHERE page_date >'$timeback'"); + $newpages = $sql->fetchColumn(); + + cot_require('forums'); + + $sql = $db->query("SELECT COUNT(*) FROM $db_forum_topics WHERE ft_creationdate>'$timeback'"); + $newtopics = $sql->fetchColumn(); + + $sql = $db->query("SELECT COUNT(*) FROM $db_forum_posts WHERE fp_updated>'$timeback'"); + $newposts = $sql->fetchColumn(); + + if (function_exists('cot_get_newcomments')) + { + $newcomments = cot_get_newcomments($timeback); + } + + if ($cfg['module']['pm']) + { + cot_require('pm'); + $sql = $db->query("SELECT COUNT(*) FROM $db_pm WHERE pm_date>'$timeback'"); + $newpms = $sql->fetchColumn(); + } + + $tt->assign(array( + 'ADMIN_HOME_NEWUSERS_URL' => cot_url('users', 'f=all&s=regdate&w=desc'), + 'ADMIN_HOME_NEWUSERS' => $newusers, + 'ADMIN_HOME_NEWPAGES_URL' => cot_url('admin', 'm=page'), + 'ADMIN_HOME_NEWPAGES' => $newpages, + 'ADMIN_HOME_NEWTOPICS_URL' => cot_url('forums'), + 'ADMIN_HOME_NEWTOPICS' => $newtopics, + 'ADMIN_HOME_NEWPOSTS_URL' => cot_url('forums'), + 'ADMIN_HOME_NEWPOSTS' => $newposts, + 'ADMIN_HOME_NEWCOMMENTS_URL' => cot_url('admin', 'm=comments'), + 'ADMIN_HOME_NEWCOMMENTS' => $newcomments, + 'ADMIN_HOME_NEWPMS' => $newpms + )); + $tt->parse('MAIN.ACTIVITY'); +} + + +$tt->parse('MAIN'); + +//Show db stats +if (!$cfg['plugin']['hits']['disabledbstats']) +{ + $sql = $db->query("SHOW TABLES"); + + while ($row = $sql->fetch(PDO::FETCH_NUM)) + { + $table_name = $row[0]; + $status = $db->query("SHOW TABLE STATUS LIKE '$table_name'"); + $status1 = $status->fetch(); + $tables[] = $status1; + } + + while (list($i,$dat) = each($tables)) + { + $table_length = $dat['Index_length'] + $dat['Data_length']; + $total_length += $table_length; + $total_rows += $dat['Rows']; + $total_index_length += $dat['Index_length']; + $total_data_length += $dat['Data_length']; + } + + $sql = $db->query("SELECT DISTINCT(pl_code) FROM $db_plugins WHERE 1 GROUP BY pl_code"); + $totalplugins = $sql->rowCount(); + + $sql = $db->query("SELECT COUNT(*) FROM $db_plugins"); + $totalhooks = $sql->fetchColumn(); + + $t->assign(array( + 'ADMIN_HOME_DB_TOTAL_ROWS' => $total_rows, + 'ADMIN_HOME_DB_INDEXSIZE' => number_format(($total_index_length / 1024), 1, '.', ' '), + 'ADMIN_HOME_DB_DATASSIZE' => number_format(($total_data_length / 1024), 1, '.', ' '), + 'ADMIN_HOME_DB_TOTALSIZE' => number_format(($total_length / 1024), 1, '.', ' '), + 'ADMIN_HOME_TOTALPLUGINS' => $totalplugins, + 'ADMIN_HOME_TOTALHOOKS' => $totalhooks + )); +} + +$t->assign('ADMIN_HOME_HITS', $tt->text('MAIN')); + + +?> \ No newline at end of file diff --git a/system/admin/admin.hits.php b/plugins/hits/hits.admin.php similarity index 82% rename from system/admin/admin.hits.php rename to plugins/hits/hits.admin.php index 9b26f8625..5e4efae68 100644 --- a/system/admin/admin.hits.php +++ b/plugins/hits/hits.admin.php @@ -3,7 +3,7 @@ * Administration panel - Hits * * @package Cotonti - * @version 0.1.0 + * @version 0.9.0 * @author Neocrome, Cotonti Team * @copyright Copyright (c) Cotonti Team 2008-2009 * @license BSD @@ -11,20 +11,20 @@ (defined('COT_CODE') && defined('COT_ADMIN')) or die('Wrong URL.'); -list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('admin', 'a'); +list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('plug', 'hits'); cot_block($usr['auth_read']); -$t = new XTemplate(cot_skinfile('admin.hits')); +cot_require_lang('hits', 'plug'); +cot_require('hits', true); +$tt = new XTemplate(cot_skinfile('hits.admin', true)); -$adminpath[] = array(cot_url('admin', 'm=other'), $L['Other']); -$adminpath[] = array(cot_url('admin', 'm=hits'), $L['Hits']); $adminhelp = $L['adm_help_hits']; $f = cot_import('f', 'G', 'TXT'); $v = cot_import('v', 'G', 'TXT'); /* === Hook === */ -foreach (cot_getextplugins('admin.hits.first') as $pl) +foreach (cot_getextplugins('hits.admin.first') as $pl) { include $pl; } @@ -47,12 +47,12 @@ $hits_d_max = max($hits_d); $ii = 0; /* === Hook - Part1 : Set === */ - $extp = cot_getextplugins('admin.hits.loop'); + $extp = cot_getextplugins('hits.admin.loop'); /* ===== */ foreach($hits_d as $day => $hits) { $percentbar = floor(($hits / $hits_d_max) * 100); - $t->assign(array( + $tt->assign(array( 'ADMIN_HITS_ROW_DAY' => $day, 'ADMIN_HITS_ROW_HITS' => $hits, 'ADMIN_HITS_ROW_PERCENTBAR' => $percentbar, @@ -66,11 +66,11 @@ } /* ===== */ - $t->parse('MAIN.YEAR_OR_MONTH.ROW'); + $tt->parse('MAIN.YEAR_OR_MONTH.ROW'); $ii++; } - $t->parse('MAIN.YEAR_OR_MONTH'); + $tt->parse('MAIN.YEAR_OR_MONTH'); } else { @@ -101,13 +101,13 @@ $hits_m_max = max($hits_m); $hits_y_max = max($hits_y); /* === Hook - Part1 : Set === */ - $extp = cot_getextplugins('admin.hits.loop'); + $extp = cot_getextplugins('hits.admin.loop'); /* ===== */ $ii = 0; foreach ($hits_y as $year => $hits) { $percentbar = floor(($hits / $hits_y_max) * 100); - $t->assign(array( + $tt->assign(array( 'ADMIN_HITS_ROW_YEAR_URL' => cot_url('admin', 'm=hits&f=year&v=' . $year), 'ADMIN_HITS_ROW_YEAR' => $year, 'ADMIN_HITS_ROW_YEAR_HITS' => $hits, @@ -118,14 +118,14 @@ include $pl; } /* ===== */ - $t->parse('MAIN.DEFAULT.ROW_YEAR'); + $tt->parse('MAIN.DEFAULT.ROW_YEAR'); $ii++; } $ii = 0; foreach ($hits_m as $month => $hits) { $percentbar = floor(($hits / $hits_m_max) * 100); - $t->assign(array( + $tt->assign(array( 'ADMIN_HITS_ROW_MONTH_URL' => cot_url('admin', 'm=hits&f=month&v=' . $month), 'ADMIN_HITS_ROW_MONTH' => $month, 'ADMIN_HITS_ROW_MONTH_HITS' => $hits, @@ -136,7 +136,7 @@ include $pl; } /* ===== */ - $t->parse('MAIN.DEFAULT.ROW_MONTH'); + $tt->parse('MAIN.DEFAULT.ROW_MONTH'); $ii++; } $ii = 0; @@ -144,7 +144,7 @@ { $ex = explode('-W', $week); $percentbar = floor(($hits / $hits_w_max) * 100); - $t->assign(array( + $tt->assign(array( 'ADMIN_HITS_ROW_WEEK' => $week, 'ADMIN_HITS_ROW_WEEK_HITS' => $hits, 'ADMIN_HITS_ROW_WEEK_PERCENTBAR' => $percentbar @@ -154,32 +154,25 @@ include $pl; } /* ===== */ - $t->parse('MAIN.DEFAULT.ROW_WEEK'); + $tt->parse('MAIN.DEFAULT.ROW_WEEK'); $ii++; } - $t->assign(array( + $tt->assign(array( 'ADMIN_HITS_MAXHITS' => sprintf($L['adm_maxhits'], $max_date, $max_hits) )); } - $t->parse('MAIN.DEFAULT'); + $tt->parse('MAIN.DEFAULT'); } /* === Hook === */ -foreach (cot_getextplugins('admin.hits.tags') as $pl) +foreach (cot_getextplugins('hits.admin.tags') as $pl) { include $pl; } /* ===== */ -$t->parse('MAIN'); -if (COT_AJAX) -{ - $t->out('MAIN'); -} -else -{ - $adminmain = $t->text('MAIN'); -} +$tt->parse('MAIN'); +$plugin_body = $tt->text('MAIN'); ?> \ No newline at end of file diff --git a/plugins/hits/hits.global.php b/plugins/hits/hits.global.php new file mode 100644 index 000000000..ef0a162cb --- /dev/null +++ b/plugins/hits/hits.global.php @@ -0,0 +1,37 @@ +mem) +{ + $hits = $cache->mem->inc('hits', 'system'); + $cfg['hit_precision'] > 0 || $cfg['plugin']['hits']['hit_precision'] = 100; + if ($hits % $cfg['hit_precision'] == 0) + { + cot_stat_inc('totalpages', $cfg['plugin']['hits']['hit_precision']); + cot_stat_inc($sys['day'], $cfg['plugin']['hits']['hit_precision']); + } +} +else +{ + cot_stat_inc('totalpages'); + cot_stat_update($sys['day']); +} + +?> \ No newline at end of file diff --git a/plugins/hits/hits.header.php b/plugins/hits/hits.header.php new file mode 100644 index 000000000..7b66a437b --- /dev/null +++ b/plugins/hits/hits.header.php @@ -0,0 +1,41 @@ +mem && $cache->mem->exists('maxusers', 'system')) +{ + $maxusers = $cache->mem->get('maxusers', 'system'); +} +else +{ + $sql = $db->query("SELECT stat_value FROM $db_stats where stat_name='maxusers' LIMIT 1"); + $maxusers = (int) @$sql->fetchColumn(); + $cache && $cache->mem && $cache->mem->store('maxusers', $maxusers, 'system', 0); +} + +if ($maxusers < $sys['whosonline_all_count']) +{ + $sql = $db->query("UPDATE $db_stats SET stat_value='".$sys['whosonline_all_count']."' + WHERE stat_name='maxusers'"); +} + + + +?> \ No newline at end of file diff --git a/plugins/hits/hits.setup.php b/plugins/hits/hits.setup.php new file mode 100644 index 000000000..52c84c06e --- /dev/null +++ b/plugins/hits/hits.setup.php @@ -0,0 +1,29 @@ + diff --git a/plugins/hits/inc/hits.functions.php b/plugins/hits/inc/hits.functions.php new file mode 100644 index 000000000..74f50b35c --- /dev/null +++ b/plugins/hits/inc/hits.functions.php @@ -0,0 +1,72 @@ +query("INSERT INTO $db_stats (stat_name, stat_value) VALUES ('".$db->prep($name)."', 1)"); +} + +/** + * Returns statistics parameter + * + * @param string $name Parameter name + * @return int + */ +function cot_stat_get($name) +{ + global $db, $db_stats; + + $sql = $db->query("SELECT stat_value FROM $db_stats where stat_name='$name' LIMIT 1"); + return ($sql->rowCount() > 0) ? (int) $sql->fetchColumn() : FALSE; +} + +/** + * Increments stats + * + * @param string $name Parameter name + * @param int $value Increment step + */ +function cot_stat_inc($name, $value = 1) +{ + global $db, $db_stats; + $db->query("UPDATE $db_stats SET stat_value=stat_value+$value WHERE stat_name='$name'"); +} + +/** + * Inserts new stat or increments value if it already exists + * + * @param string $name Parameter name + * @param int $value Increment step + */ +function cot_stat_update($name, $value = 1) +{ + global $db, $db_stats; + $db->query("INSERT INTO $db_stats (stat_name, stat_value) + VALUES ('".$db->prep($name)."', 1) + ON DUPLICATE KEY UPDATE stat_value=stat_value+$value"); +} + +?> diff --git a/plugins/hits/lang/hits.en.lang.php b/plugins/hits/lang/hits.en.lang.php new file mode 100644 index 000000000..48af842d6 --- /dev/null +++ b/plugins/hits/lang/hits.en.lang.php @@ -0,0 +1,34 @@ +Displayed on the home page administration panel'); +$L['cfg_disabledbstats'] = array('Do not display database statistics', 'Displayed on the home page administration panel'); +$L['cfg_hit_precision'] = array('Optimized hit counter precision', ''); // New in 0.7.0 + +/** + * Other Section + * Hits Subsection + */ + +$L['adm_byyear'] = 'By year'; +$L['adm_bymonth'] = 'By month'; +$L['adm_byweek'] = 'By week'; + +$L['adm_ref_lowhits'] = 'Purge entries where hits are lower than 5'; +$L['adm_maxhits'] = 'Maximum hitcount was reached %1$s, %2$s pages displayed this day.'; + +$L['home_hitsmonth'] = 'Hits for the past 15 days'; +$L['home_pastdays'] = 'Activity for the past 7 days'; + +?> diff --git a/plugins/hits/lang/hits.ru.lang.php b/plugins/hits/lang/hits.ru.lang.php new file mode 100644 index 000000000..b2fc4792e --- /dev/null +++ b/plugins/hits/lang/hits.ru.lang.php @@ -0,0 +1,33 @@ +Отображается на главной странице управления сайтом'); +$L['cfg_disabledbstats'] = array('Не отображать статистику базы данных', 'Отображается на главной странице управления сайтом'); +$L['cfg_hit_precision'] = array('Точность оптимизированного счётчика просмотров', ''); // New in 0.7.0 + +/** + * Other Section + * Hits Subsection + */ + +$L['adm_byyear'] = 'По годам'; +$L['adm_bymonth'] = 'По месяцам'; +$L['adm_byweek'] = 'По неделям'; + +$L['adm_ref_lowhits'] = 'Удалить записи с количеством хитов менее 5'; +$L['adm_maxhits'] = 'Максимальное количество хитов (%2$s) зафиксировано %1$s'; + +$L['home_hitsmonth'] = 'Хиты за последние 15 дней'; +$L['home_pastdays'] = 'Активность за последние 7 дней'; +?> diff --git a/plugins/hits/setup/hits.install.sql b/plugins/hits/setup/hits.install.sql new file mode 100644 index 000000000..8893886d6 --- /dev/null +++ b/plugins/hits/setup/hits.install.sql @@ -0,0 +1,15 @@ + +CREATE TABLE `cot_stats` ( + `stat_name` varchar(32) collate utf8_unicode_ci NOT NULL default '', + `stat_value` int NOT NULL default '0', + PRIMARY KEY (`stat_name`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +INSERT INTO `cot_stats` (`stat_name`, `stat_value`) VALUES +('totalpages', 0), +('totalmailsent', 0), +('totalmailpmnot', 0), +('totalpms', 0), +('totalantihammer', 0), +('textboxerprev', 0), +('version', 999); \ No newline at end of file diff --git a/plugins/hits/setup/hits.uninstall.sql b/plugins/hits/setup/hits.uninstall.sql new file mode 100644 index 000000000..6d6829531 --- /dev/null +++ b/plugins/hits/setup/hits.uninstall.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS `cot_stats`; \ No newline at end of file diff --git a/plugins/hits/tpl/hits.admin.home.tpl b/plugins/hits/tpl/hits.admin.home.tpl new file mode 100644 index 000000000..f063e6640 --- /dev/null +++ b/plugins/hits/tpl/hits.admin.home.tpl @@ -0,0 +1,50 @@ + + +
+

{PHP.L.home_hitsmonth}

+ + + + + + + + + +
{ADMIN_HOME_DAY} +
+
+
+
{PHP.L.Hits}: {ADMIN_HOME_HITS}{ADMIN_HOME_PERCENTBAR}%
+

{PHP.L.More}...

+
+ + + +
+

{PHP.L.home_pastdays}

+ + + + + + + + + + + + + + + + + + + + + +
{PHP.L.home_newusers}{ADMIN_HOME_NEWUSERS}
{PHP.L.home_newpages}{ADMIN_HOME_NEWPAGES}
{PHP.L.home_newtopics}{ADMIN_HOME_NEWTOPICS}
{PHP.L.home_newposts}{ADMIN_HOME_NEWPOSTS}
{PHP.L.home_newpms}{ADMIN_HOME_NEWPMS}
+
+ + \ No newline at end of file diff --git a/system/admin/tpl/admin.hits.tpl b/plugins/hits/tpl/hits.admin.tpl similarity index 100% rename from system/admin/tpl/admin.hits.tpl rename to plugins/hits/tpl/hits.admin.tpl diff --git a/plugins/referers/lang/referers.en.lang.php b/plugins/referers/lang/referers.en.lang.php new file mode 100644 index 000000000..2b26a8509 --- /dev/null +++ b/plugins/referers/lang/referers.en.lang.php @@ -0,0 +1,23 @@ + diff --git a/plugins/referers/lang/referers.ru.lang.php b/plugins/referers/lang/referers.ru.lang.php new file mode 100644 index 000000000..e75676ed7 --- /dev/null +++ b/plugins/referers/lang/referers.ru.lang.php @@ -0,0 +1,23 @@ + diff --git a/system/admin/admin.referers.php b/plugins/referers/referers.admin.php similarity index 73% rename from system/admin/admin.referers.php rename to plugins/referers/referers.admin.php index 495ad174c..f35f8384c 100644 --- a/system/admin/admin.referers.php +++ b/plugins/referers/referers.admin.php @@ -1,9 +1,14 @@ $url) { - $t->assign('ADMIN_REFERERS_REFERER', htmlspecialchars($referer)); + $tt->assign('ADMIN_REFERERS_REFERER', htmlspecialchars($referer)); foreach($url as $uri => $count) { - $t->assign(array( + $tt->assign(array( 'ADMIN_REFERERS_URI' => htmlspecialchars(cot_cutstring($uri, 128)), 'ADMIN_REFERERS_COUNT' => $count, 'ADMIN_REFERERS_ODDEVEN' => cot_build_oddeven($ii) @@ -75,9 +80,9 @@ include $pl; } /* ===== */ - $t->parse('MAIN.REFERERS_ROW.REFERERS_URI'); + $tt->parse('MAIN.REFERERS_ROW.REFERERS_URI'); } - $t->parse("MAIN.REFERERS_ROW"); + $tt->parse("MAIN.REFERERS_ROW"); $ii++; } $is_ref_empty = true; @@ -87,7 +92,7 @@ $is_ref_empty = false; } -$t->assign(array( +$tt->assign(array( 'ADMIN_REFERERS_URL_PRUNE' => cot_url('admin', 'm=referers&a=prune&'.cot_xg()), 'ADMIN_REFERERS_URL_PRUNELOWHITS' => cot_url('admin', 'm=referers&a=prunelowhits&'.cot_xg()), 'ADMIN_REFERERS_PAGINATION_PREV' => $pagenav['prev'], @@ -97,23 +102,16 @@ 'ADMIN_REFERERS_ON_PAGE' => $ii )); -cot_display_messages($t); +cot_display_messages($tt); /* === Hook === */ -foreach (cot_getextplugins('admin.referers.tags') as $pl) +foreach (cot_getextplugins('referers.admin.tags') as $pl) { include $pl; } /* ===== */ -$t->parse('MAIN'); -if (COT_AJAX) -{ - $t->out('MAIN'); -} -else -{ - $adminmain = $t->text('MAIN'); -} +$tt->parse('MAIN'); +$plugin_body = $tt->text('MAIN'); ?> \ No newline at end of file diff --git a/plugins/referers/referers.global.php b/plugins/referers/referers.global.php new file mode 100644 index 000000000..3a4f76657 --- /dev/null +++ b/plugins/referers/referers.global.php @@ -0,0 +1,40 @@ +query("INSERT INTO $db_referers + (ref_url, ref_count, ref_date) + VALUES + ('".$db->prep($sys['referer'])."', 1, {$sys['now_offset']}) + ON DUPLICATE KEY UPDATE + ref_count=ref_count+1, ref_date={$sys['now_offset']}"); +} + + + +?> \ No newline at end of file diff --git a/plugins/referers/referers.setup.php b/plugins/referers/referers.setup.php new file mode 100644 index 000000000..03049e530 --- /dev/null +++ b/plugins/referers/referers.setup.php @@ -0,0 +1,23 @@ + diff --git a/plugins/referers/setup/referers.install.sql b/plugins/referers/setup/referers.install.sql new file mode 100644 index 000000000..ef70612b6 --- /dev/null +++ b/plugins/referers/setup/referers.install.sql @@ -0,0 +1,6 @@ +CREATE TABLE `cot_referers` ( + `ref_url` varchar(255) collate utf8_unicode_ci NOT NULL default '', + `ref_date` int unsigned NOT NULL default '0', + `ref_count` int NOT NULL default '0', + PRIMARY KEY (`ref_url`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; \ No newline at end of file diff --git a/plugins/referers/setup/referers.uninstall.sql b/plugins/referers/setup/referers.uninstall.sql new file mode 100644 index 000000000..9c2860f37 --- /dev/null +++ b/plugins/referers/setup/referers.uninstall.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS `cot_referers`; \ No newline at end of file diff --git a/system/admin/tpl/admin.referers.tpl b/plugins/referers/tpl/referers.admin.tpl similarity index 100% rename from system/admin/tpl/admin.referers.tpl rename to plugins/referers/tpl/referers.admin.tpl diff --git a/plugins/trashcan/lang/trashcan.en.lang.php b/plugins/trashcan/lang/trashcan.en.lang.php index 025fa33af..3563ad4b5 100644 --- a/plugins/trashcan/lang/trashcan.en.lang.php +++ b/plugins/trashcan/lang/trashcan.en.lang.php @@ -1,8 +1,8 @@ query("SELECT * FROM $db_stats WHERE stat_name LIKE '20%' ORDER BY stat_name DESC LIMIT ".$timeback_stats); - while ($row = $sql->fetch()) - { - $year = mb_substr($row['stat_name'], 0, 4); - $mons = mb_substr($row['stat_name'], 5, 2); - $day = mb_substr($row['stat_name'], 8, 2); - $dat = @date('d D', mktime(0, 0, 0, $mons, $day, $year)); - $hits_d[$dat] = $row['stat_value']; - } - - if (is_array($hits_d)) - { - $hits_d_max = max($hits_d); - - foreach ($hits_d as $day => $hits) - { - $percentbar = floor(($hits / $hits_d_max) * 100); - $t->assign(array( - 'ADMIN_HOME_DAY' => $day, - 'ADMIN_HOME_HITS' => $hits, - 'ADMIN_HOME_PERCENTBAR' => $percentbar - )); - $t->parse('MAIN.ADMIN_HOME_ROW'); - } - } - $t->assign('ADMIN_HOME_MORE_HITS_URL', cot_url('admin', 'm=hits')); -} - -//Show activity stats -if (!$cfg['disableactivitystats']) -{ - $timeback = $sys['now_offset'] - (7 * 86400);// 7 days - - $sql = $db->query("SELECT COUNT(*) FROM $db_users WHERE user_regdate>'$timeback'"); - $newusers = $sql->fetchColumn(); - - $sql = $db->query("SELECT COUNT(*) FROM $db_pages WHERE page_date >'$timeback'"); - $newpages = $sql->fetchColumn(); - - cot_require('forums'); - - $sql = $db->query("SELECT COUNT(*) FROM $db_forum_topics WHERE ft_creationdate>'$timeback'"); - $newtopics = $sql->fetchColumn(); - - $sql = $db->query("SELECT COUNT(*) FROM $db_forum_posts WHERE fp_updated>'$timeback'"); - $newposts = $sql->fetchColumn(); - - if (function_exists('cot_get_newcomments')) - { - $newcomments = cot_get_newcomments($timeback); - } - - if ($cfg['module']['pm']) - { - cot_require('pm'); - $sql = $db->query("SELECT COUNT(*) FROM $db_pm WHERE pm_date>'$timeback'"); - $newpms = $sql->fetchColumn(); - } - - $t->assign(array( - 'ADMIN_HOME_NEWUSERS_URL' => cot_url('users', 'f=all&s=regdate&w=desc'), - 'ADMIN_HOME_NEWUSERS' => $newusers, - 'ADMIN_HOME_NEWPAGES_URL' => cot_url('admin', 'm=page'), - 'ADMIN_HOME_NEWPAGES' => $newpages, - 'ADMIN_HOME_NEWTOPICS_URL' => cot_url('forums'), - 'ADMIN_HOME_NEWTOPICS' => $newtopics, - 'ADMIN_HOME_NEWPOSTS_URL' => cot_url('forums'), - 'ADMIN_HOME_NEWPOSTS' => $newposts, - 'ADMIN_HOME_NEWCOMMENTS_URL' => cot_url('admin', 'm=comments'), - 'ADMIN_HOME_NEWCOMMENTS' => $newcomments, - 'ADMIN_HOME_NEWPMS' => $newpms - )); -} - -//Show db stats -if (!$cfg['disabledbstats']) -{ - $sql = $db->query("SHOW TABLES"); - - while ($row = $sql->fetch(PDO::FETCH_NUM)) - { - $table_name = $row[0]; - $status = $db->query("SHOW TABLE STATUS LIKE '$table_name'"); - $status1 = $status->fetch(); - $tables[] = $status1; - } - - while (list($i,$dat) = each($tables)) - { - $table_length = $dat['Index_length'] + $dat['Data_length']; - $total_length += $table_length; - $total_rows += $dat['Rows']; - $total_index_length += $dat['Index_length']; - $total_data_length += $dat['Data_length']; - } - - $sql = $db->query("SELECT DISTINCT(pl_code) FROM $db_plugins WHERE 1 GROUP BY pl_code"); - $totalplugins = $sql->rowCount(); - - $sql = $db->query("SELECT COUNT(*) FROM $db_plugins"); - $totalhooks = $sql->fetchColumn(); - - $t->assign(array( - 'ADMIN_HOME_DB_TOTAL_ROWS' => $total_rows, - 'ADMIN_HOME_DB_INDEXSIZE' => number_format(($total_index_length / 1024), 1, '.', ' '), - 'ADMIN_HOME_DB_DATASSIZE' => number_format(($total_data_length / 1024), 1, '.', ' '), - 'ADMIN_HOME_DB_TOTALSIZE' => number_format(($total_length / 1024), 1, '.', ' '), - 'ADMIN_HOME_TOTALPLUGINS' => $totalplugins, - 'ADMIN_HOME_TOTALHOOKS' => $totalhooks - )); -} - $t->assign(array( 'ADMIN_HOME_URL' => cot_url('admin', 'm=page'), 'ADMIN_HOME_PAGESQUEUED' => $pagesqueued, @@ -198,6 +81,14 @@ 'ADMIN_HOME_REVISION' => $L['home_rev'].$cfg['revision'], 'ADMIN_HOME_DB_VERSION' => $cfg['dbversion'] )); + +/* === Hook === */ +foreach (cot_getextplugins('admin.home', 'R') as $pl) +{ + include $pl; +} +/* ===== */ + $t->parse('MAIN'); if (COT_AJAX) { @@ -208,11 +99,4 @@ $adminmain = $t->text('MAIN'); } -/* === Hook === */ -foreach (cot_getextplugins('admin.home', 'R') as $pl) -{ - include $pl; -} -/* ===== */ - ?> \ No newline at end of file diff --git a/system/admin/admin.main.php b/system/admin/admin.main.php index 5ad811943..cee3f1de5 100644 --- a/system/admin/admin.main.php +++ b/system/admin/admin.main.php @@ -34,8 +34,8 @@ } /* ===== */ -$standard_admin = array('banlist', 'cache.disk', 'cache', 'config', 'extrafields', 'hits', 'home', 'infos', - 'log', 'other', 'extensions', 'ratings', 'referers', 'rights', 'rightsbyitem', 'structure', 'urls', 'users'); +$standard_admin = array('banlist', 'cache.disk', 'cache', 'config', 'extrafields', 'home', 'infos', + 'log', 'other', 'extensions', 'ratings', 'rights', 'rightsbyitem', 'structure', 'urls', 'users'); $inc_file = (empty($m)) ? 'home' : $m; $inc_file = (empty($s)) ? $inc_file : $inc_file.'.'.$s; diff --git a/system/admin/admin.other.php b/system/admin/admin.other.php index 0ee86b172..f23f37aec 100644 --- a/system/admin/admin.other.php +++ b/system/admin/admin.other.php @@ -142,8 +142,6 @@ function cot_admin_other_cmp($pl_a, $pl_b) 'ADMIN_OTHER_URL_BBCODE' => cot_url('admin', 'm=bbcode'), 'ADMIN_OTHER_URL_URLS' => cot_url('admin', 'm=urls'), 'ADMIN_OTHER_URL_BANLIST' => cot_url('admin', 'm=banlist'), - 'ADMIN_OTHER_URL_HITS' => cot_url('admin', 'm=hits'), - 'ADMIN_OTHER_URL_REFERS' => cot_url('admin', 'm=referers'), 'ADMIN_OTHER_URL_LOG' => cot_url('admin', 'm=log'), 'ADMIN_OTHER_URL_INFOS' => cot_url('admin', 'm=infos'), 'ADMIN_OTHER_URL_RATINGS' => cot_url('admin', 'm=ratings') diff --git a/system/admin/tpl/admin.home.tpl b/system/admin/tpl/admin.home.tpl index 64987a01b..7b959fe77 100644 --- a/system/admin/tpl/admin.home.tpl +++ b/system/admin/tpl/admin.home.tpl @@ -8,53 +8,7 @@

{ADMIN_HOME_UPDATE_REVISION} {ADMIN_HOME_UPDATE_MESSAGE}

- -
-

{PHP.L.home_hitsmonth}

- - - - - - - - - - - -
{ADMIN_HOME_DAY} -
-
-
-
{PHP.L.Hits}: {ADMIN_HOME_HITS}{ADMIN_HOME_PERCENTBAR}%
-

{PHP.L.More}...

-
-
-

{PHP.L.home_pastdays}

- - - - - - - - - - - - - - - - - - - - - -
{PHP.L.home_newusers}{ADMIN_HOME_NEWUSERS}
{PHP.L.home_newpages}{ADMIN_HOME_NEWPAGES}
{PHP.L.home_newtopics}{ADMIN_HOME_NEWTOPICS}
{PHP.L.home_newposts}{ADMIN_HOME_NEWPOSTS}
{PHP.L.home_newpms}{ADMIN_HOME_NEWPMS}
-
- + {ADMIN_HOME_HITS}

Cotonti:

@@ -66,7 +20,7 @@ - + diff --git a/system/admin/tpl/admin.other.tpl b/system/admin/tpl/admin.other.tpl index fd6f85143..614cca1d0 100644 --- a/system/admin/tpl/admin.other.tpl +++ b/system/admin/tpl/admin.other.tpl @@ -29,18 +29,6 @@ {PHP.L.Banlist} - - - - - - - -
{PHP.L.Database} {ADMIN_HOME_DB_VERSION}
{PHP.L.home_db_rows} {ADMIN_HOME_DB_TOTAL_ROWS}
{PHP.R.icon_stats} - {PHP.L.Hits} -
{PHP.R.icon_stats} - {PHP.L.Referers} -
{PHP.R.icon_page} diff --git a/system/common.php b/system/common.php index 90c1af0bf..9ce72689a 100644 --- a/system/common.php +++ b/system/common.php @@ -519,43 +519,6 @@ function cot_disable_mqgpc(&$value, $key) $out['copyright'] = "".$L['foo_poweredby']." Cotonti"; -/* ======== Basic statistics ======== */ - -if (!$cfg['disablehitstats']) -{ - if ($cache && $cache->mem) - { - $hits = $cache->mem->inc('hits', 'system'); - $cfg['hit_precision'] > 0 || $cfg['hit_precision'] = 100; - if ($hits % $cfg['hit_precision'] == 0) - { - cot_stat_inc('totalpages', $cfg['hit_precision']); - cot_stat_inc($sys['day'], $cfg['hit_precision']); - } - } - else - { - cot_stat_inc('totalpages'); - cot_stat_update($sys['day']); - } - - $sys['referer'] = substr($_SERVER['HTTP_REFERER'], 0, 255); - - if (!empty($sys['referer']) - && mb_stripos($sys['referer'], $cfg['mainurl']) === false - && mb_stripos($sys['referer'], $cfg['hostip']) === false - && mb_stripos($sys['referer'], str_ireplace('//www.', '//', $cfg['mainurl'])) === false - && mb_stripos(str_ireplace('//www.', '//', $sys['referer']), $cfg['mainurl']) === false) - { - $db->query("INSERT INTO $db_referers - (ref_url, ref_count, ref_date) - VALUES - ('".$db->prep($sys['referer'])."', 1, {$sys['now_offset']}) - ON DUPLICATE KEY UPDATE - ref_count=ref_count+1, ref_date={$sys['now_offset']}"); - } -} - /* ======== Categories ======== */ if (!$cot_cat) diff --git a/system/functions.php b/system/functions.php index 87dfcd8d3..3fd34b40c 100644 --- a/system/functions.php +++ b/system/functions.php @@ -573,7 +573,7 @@ function cot_mail($fmail, $subject, $body, $headers='', $additional_parameters = */ function cot_online_update() { - global $db, $cfg, $sys, $usr, $out, $db_online, $db_stats, $cache, $cot_usersonline, $env, $Ls; + global $db, $cfg, $sys, $usr, $out, $db_online, $cache, $cot_usersonline, $env, $Ls; if (!$cfg['disablewhosonline']) { if ($env['location'] != $sys['online_location'] @@ -641,27 +641,6 @@ function cot_online_update() } $sys['whosonline_all_count'] = $sys['whosonline_reg_count'] + $sys['whosonline_vis_count']; $out['whosonline'] = ($cfg['disablewhosonline']) ? '' : cot_declension($sys['whosonline_reg_count'], $Ls['Members']).', '.cot_declension($sys['whosonline_vis_count'], $Ls['Guests']); - - /* ======== Max users ======== */ - if (!$cfg['disablehitstats']) - { - if ($cache && $cache->mem && $cache->mem->exists('maxusers', 'system')) - { - $maxusers = $cache->mem->get('maxusers', 'system'); - } - else - { - $sql = $db->query("SELECT stat_value FROM $db_stats where stat_name='maxusers' LIMIT 1"); - $maxusers = (int) @$sql->fetchColumn(); - $cache && $cache->mem && $cache->mem->store('maxusers', $maxusers, 'system', 0); - } - - if ($maxusers < $sys['whosonline_all_count']) - { - $sql = $db->query("UPDATE $db_stats SET stat_value='".$sys['whosonline_all_count']."' - WHERE stat_name='maxusers'"); - } - } } } @@ -3371,63 +3350,6 @@ function cot_xp() return '
'; } - -/* - * =============================== Statistics API ============================= -*/ - -/** - * Creates new stats parameter - * - * @param string $name Parameter name - */ -function cot_stat_create($name) -{ - global $db, $db_stats; - - $db->query("INSERT INTO $db_stats (stat_name, stat_value) VALUES ('".$db->prep($name)."', 1)"); -} - -/** - * Returns statistics parameter - * - * @param string $name Parameter name - * @return int - */ -function cot_stat_get($name) -{ - global $db, $db_stats; - - $sql = $db->query("SELECT stat_value FROM $db_stats where stat_name='$name' LIMIT 1"); - return ($sql->rowCount() > 0) ? (int) $sql->fetchColumn() : FALSE; -} - -/** - * Increments stats - * - * @param string $name Parameter name - * @param int $value Increment step - */ -function cot_stat_inc($name, $value = 1) -{ - global $db, $db_stats; - $db->query("UPDATE $db_stats SET stat_value=stat_value+$value WHERE stat_name='$name'"); -} - -/** - * Inserts new stat or increments value if it already exists - * - * @param string $name Parameter name - * @param int $value Increment step - */ -function cot_stat_update($name, $value = 1) -{ - global $db, $db_stats; - $db->query("INSERT INTO $db_stats (stat_name, stat_value) - VALUES ('".$db->prep($name)."', 1) - ON DUPLICATE KEY UPDATE stat_value=stat_value+$value"); -} - /* * ============================ URL and URI =================================== */ diff --git a/system/header.php b/system/header.php index f2f50ae09..66f1ddf96 100644 --- a/system/header.php +++ b/system/header.php @@ -20,6 +20,8 @@ } /* ===== */ +cot_online_update(); + $out['logstatus'] = ($usr['id'] > 0) ? $L['hea_youareloggedas'].' '.$usr['name'] : $L['hea_youarenotlogged']; $out['userlist'] = (cot_auth('users', 'a', 'R')) ? cot_rc_link(cot_url('users'), $L['Users']) : '';