/** * @desc Load Application Classes * @param $checks */ private function load_apps($checks = CHECK_ALL_UPDATES) { if (ServerConfiguration::get_phpversion() > self::PHP_MIN_VERSION_UPDATES) { $user_locale = AppContext::get_current_user()->get_locale(); if ($checks & CHECK_KERNEL) { // Add the kernel to the check list $this->apps[] = new Application('kernel', $user_locale, Application::KERNEL_TYPE, Environment::get_phpboost_version(), Updates::PHPBOOST_OFFICIAL_REPOSITORY); } if ($checks & CHECK_MODULES) { $activated_modules = ModulesManager::get_activated_modules_map_sorted_by_localized_name(); foreach ($activated_modules as $module) { $this->apps[] = new Application($module->get_id(), $user_locale, Application::MODULE_TYPE, $module->get_configuration()->get_version(), $module->get_configuration()->get_repository()); } } if ($checks & CHECK_THEMES) { // Add Themes $activated_themes = ThemesManager::get_activated_themes_map(); foreach ($activated_themes as $id => $value) { $repository = $value->get_configuration()->get_repository(); if (!empty($repository)) { $this->apps[] = new Application($id, $user_locale, Application::TEMPLATE_TYPE, $value->get_configuration()->get_version(), $repository); } } } } }
private function generate_options() { $options = array(); foreach (ThemesManager::get_activated_themes_map() as $theme) { if ($this->check_authorizations) { if ($theme->check_auth()) { $options[] = new FormFieldSelectChoiceOption($theme->get_configuration()->get_name(), $theme->get_id()); } } else { $options[] = new FormFieldSelectChoiceOption($theme->get_configuration()->get_name(), $theme->get_id()); } } return $options; }
if ($erase) { $file = new File('../stats/cache/robots.txt'); try { $file->delete(); } catch (IOException $exception) { echo $exception->getMessage(); } } $tpl->put_all(array('L_SITE' => $LANG['site'], 'L_STATS' => $LANG['stats'], 'L_USERS' => $LANG['member_s'], 'L_VISITS' => $LANG['guest_s'], 'L_PAGES' => $LANG['page_s'], 'L_BROWSERS' => $LANG['browser_s'], 'L_OS' => $LANG['os'], 'L_LANG' => $LANG['stat_lang'], 'L_KEYWORD' => $LANG['keyword_s'], 'L_REFERER' => $LANG['referer_s'], 'L_ROBOTS' => $LANG['robots'], 'L_UPDATE' => $LANG['update'], 'L_RESET' => $LANG['reset'], 'L_AUTHORIZATIONS' => $LANG['admin.authorizations'], 'L_READ_AUTHORIZATION' => $LANG['admin.authorizations.read'], 'READ_AUTHORIZATION' => Authorizations::generate_select(StatsAuthorizationsService::READ_AUTHORIZATIONS, StatsConfig::load()->get_authorizations()))); $date_lang = LangLoader::get('date-common'); if (!empty($members)) { $stats_cache = StatsCache::load(); $last_user_group_color = User::get_group_color($stats_cache->get_stats_properties('last_member_groups'), $stats_cache->get_stats_properties('last_member_level')); $tpl->put_all(array('C_STATS_USERS' => true, 'C_LAST_USER_GROUP_COLOR' => !empty($last_user_group_color), 'LAST_USER' => $stats_cache->get_stats_properties('last_member_login'), 'LAST_USER_LEVEL_CLASS' => UserService::get_level_class($stats_cache->get_stats_properties('last_member_level')), 'LAST_USER_GROUP_COLOR' => $last_user_group_color, 'U_LAST_USER_PROFILE' => UserUrlBuilder::profile($stats_cache->get_stats_properties('last_member_id'))->rel(), 'USERS' => $stats_cache->get_stats_properties('nbr_members'), 'GRAPH_RESULT_THEME' => !file_exists('../cache/theme.png') ? '<img src="display_stats.php?theme=1" alt="' . $LANG['theme_s'] . '" />' : '<img src="../cache/theme.png" alt="' . $LANG['theme_s'] . '" />', 'GRAPH_RESULT_SEX' => !file_exists('../cache/sex.png') ? '<img src="display_stats.php?sex=1" alt="' . $LANG['sex'] . '" />' : '<img src="../cache/sex.png" alt="' . $LANG['sex'] . '" />', 'L_LAST_USER' => $LANG['last_member'], 'L_TEMPLATES' => $LANG['theme_s'], 'L_PSEUDO' => LangLoader::get_message('display_name', 'user-common'), 'L_MSG' => $LANG['message_s'], 'L_TOP_TEN_POSTERS' => $LANG['top_10_posters'], 'L_COLORS' => $LANG['colors'], 'L_USERS' => $LANG['member_s'], 'L_SEX' => $LANG['sex'])); $stats_array = array(); foreach (ThemesManager::get_activated_themes_map() as $theme) { $stats_array[$theme->get_id()] = $db_querier->count(DB_TABLE_MEMBER, "WHERE theme = '" . $theme->get_id() . "'"); } $Stats = new ImagesStats(); $Stats->load_data($stats_array, 'ellipse'); foreach ($Stats->data_stats as $name => $angle_value) { $array_color = $Stats->array_allocated_color[$Stats->image_color_allocate_dark(false, NO_ALLOCATE_COLOR)]; $tpl->assign_block_vars('templates', array('NBR_THEME' => NumberHelper::round($angle_value * $Stats->nbr_entry / 360, 0), 'COLOR' => 'RGB(' . $array_color[0] . ', ' . $array_color[1] . ', ' . $array_color[2] . ')', 'THEME' => $name == 'Other' ? $LANG['other'] : $name, 'PERCENT' => NumberHelper::round($angle_value / 3.6, 1))); } $stats_array = array(); $result = $db_querier->select("SELECT member.user_id, count(ext_field.user_sex) as compt, ext_field.user_sex\n\t\tFROM " . PREFIX . "member member\n\t\tLEFT JOIN " . DB_TABLE_MEMBER_EXTENDED_FIELDS . " ext_field ON ext_field.user_id = member.user_id\n\t\tGROUP BY ext_field.user_sex\n\t\tORDER BY compt"); while ($row = $result->fetch()) { switch ($row['user_sex']) { case 0: $name = $LANG['unknown']; break;
private function list_themes() { $choices_list = array(); $choices_list[] = new FormFieldSelectChoiceOption('--', ''); foreach (ThemesManager::get_activated_themes_map() as $id => $value) { $choices_list[] = new FormFieldSelectChoiceOption($value->get_configuration()->get_name(), $id); } return $choices_list; }
private function build_javascript_picture_themes() { $text = 'var theme = new Array;' . "\n"; foreach (ThemesManager::get_activated_themes_map() as $theme) { $text .= 'theme["' . $theme->get_id() . '"] = "' . Url::to_rel($this->get_picture_theme($theme->get_id())) . '";' . "\n"; } $text .= 'var theme_id = HTMLForms.getField("theme").getValue(); document.images[\'img_theme\'].src = theme[theme_id];'; return $text; }
$menu_template->put_all(array('L_ENABLED' => LangLoader::get_message('enabled', 'common'), 'L_DISABLED' => LangLoader::get_message('disabled', 'common'), 'I_HEADER' => Menu::BLOCK_POSITION__HEADER, 'I_SUBHEADER' => Menu::BLOCK_POSITION__SUB_HEADER, 'I_TOPCENTRAL' => Menu::BLOCK_POSITION__TOP_CENTRAL, 'I_BOTTOMCENTRAL' => Menu::BLOCK_POSITION__BOTTOM_CENTRAL, 'I_TOPFOOTER' => Menu::BLOCK_POSITION__TOP_FOOTER, 'I_FOOTER' => Menu::BLOCK_POSITION__FOOTER, 'I_LEFT' => Menu::BLOCK_POSITION__LEFT, 'I_RIGHT' => Menu::BLOCK_POSITION__RIGHT, 'U_TOKEN' => AppContext::get_session()->get_token())); foreach ($menus_blocks as $block_id => $menus) { // For each block $i = 0; $max = count($menus); foreach ($menus as $menu) { // For each Menu in this block $menu_tpl = clone $menu_template; $id = $menu->get_id(); $enabled = $menu->is_enabled(); if (!$enabled) { $block_id = Menu::BLOCK_POSITION__NOT_ENABLED; } $edit_link = menu_admin_link($menu, 'edit'); $del_link = menu_admin_link($menu, 'delete'); $mini = in_array($block_id, array(Menu::BLOCK_POSITION__LEFT, Menu::BLOCK_POSITION__NOT_ENABLED, Menu::BLOCK_POSITION__RIGHT)); $vertical_position = in_array($block_id, array(Menu::BLOCK_POSITION__LEFT, Menu::BLOCK_POSITION__RIGHT)); $menu_tpl->put_all(array('NAME' => $menu->get_formated_title(), 'IDMENU' => $id, 'CONTENTS' => $menu->admin_display(), 'ACTIV' => $enabled ? 'disable' : 'enable', 'UNACTIV' => $enabled ? 'enable' : 'disable', 'C_MENU_ACTIVATED' => $enabled, 'C_EDIT' => !empty($edit_link), 'C_DEL' => !empty($del_link), 'C_UP' => $block_id != Menu::BLOCK_POSITION__NOT_ENABLED && $i > 0, 'C_DOWN' => $block_id != Menu::BLOCK_POSITION__NOT_ENABLED && $i < $max - 1, 'C_VERTICAL' => $vertical_position, 'C_HORIZONTAL' => !$vertical_position, 'L_DEL' => LangLoader::get_message('delete', 'common'), 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_ACTIVATE' => LangLoader::get_message('enable', 'common'), 'L_UNACTIVATE' => LangLoader::get_message('disable', 'common'), 'L_MOVE_UP' => $LANG['move_up'], 'L_MOVE_DOWN' => $LANG['move_down'], 'U_EDIT' => menu_admin_link($menu, 'edit'), 'U_DELETE' => menu_admin_link($menu, 'delete'), 'U_UP' => menu_admin_link($menu, 'up'), 'U_DOWN' => menu_admin_link($menu, 'down'), 'U_MOVE' => menu_admin_link($menu, 'move'))); $tpl->assign_block_vars(get_block($block_id), array('MENU' => $menu_tpl->render())); $i++; } } foreach (ThemesManager::get_activated_themes_map() as $theme => $properties) { $configuration = $properties->get_configuration(); $selected = empty($name_theme) ? AppContext::get_current_user()->get_theme() == $theme : $name_theme == $theme ? ' selected="selected"' : ''; $tpl->assign_block_vars('themes', array('NAME' => $configuration->get_name(), 'IDNAME' => $theme, 'SELECTED' => $selected)); } $columns_disable = ThemesManager::get_theme($name_theme)->get_columns_disabled(); $tpl->put_all(array('NAME_THEME' => $name_theme, 'CHECKED_RIGHT_COLUMN' => !$columns_disable->right_columns_is_disabled() ? 'checked="checked"' : '', 'CHECKED_LEFT_COLUMN' => !$columns_disable->left_columns_is_disabled() ? 'checked="checked"' : '', 'CHECKED_FOOTER_COLUMN' => !$columns_disable->footer_is_disabled() ? 'checked="checked"' : '', 'CHECKED_TOP_FOOTER_COLUMN' => !$columns_disable->top_footer_is_disabled() ? 'checked="checked"' : '', 'CHECKED_BOTTOM_CENTRAL_COLUMN' => !$columns_disable->bottom_central_is_disabled() ? 'checked="checked"' : '', 'CHECKED_TOP_CENTRAL_COLUMN' => !$columns_disable->top_central_is_disabled() ? 'checked="checked"' : '', 'CHECKED_SUB_HEADER_COLUMN' => !$columns_disable->sub_header_is_disabled() ? 'checked="checked"' : '', 'CHECKED_HEADER_COLUMN' => !$columns_disable->header_is_disabled() ? 'checked="checked"' : '', 'C_RIGHT_COLUMN' => $columns_disable->right_columns_is_disabled(), 'C_LEFT_COLUMN' => $columns_disable->left_columns_is_disabled(), 'C_FOOTER_COLUMN' => $columns_disable->footer_is_disabled(), 'C_TOP_FOOTER_COLUMN' => $columns_disable->top_footer_is_disabled(), 'C_BOTTOM_CENTRAL_COLUMN' => $columns_disable->bottom_central_is_disabled(), 'C_TOP_CENTRAL_COLUMN' => $columns_disable->top_central_is_disabled(), 'C_SUB_HEADER_COLUMN' => $columns_disable->sub_header_is_disabled(), 'C_HEADER_COLUMN' => $columns_disable->header_is_disabled(), 'L_MENUS_MANAGEMENT' => $LANG['menus_management'], 'START_PAGE' => Environment::get_home_page(), 'L_INDEX' => $LANG['home'], 'L_CONFIRM_DEL_MENU' => LangLoader::get_message('confirm.delete', 'status-messages-common'), 'L_MOVETO' => $LANG['moveto'], 'L_GUEST' => $LANG['guest'], 'L_USER' => $LANG['member'], 'L_MODO' => $LANG['modo'], 'L_ADMIN' => $LANG['admin'], 'L_HEADER' => $LANG['menu_header'], 'L_SUB_HEADER' => $LANG['menu_subheader'], 'L_LEFT_MENU' => $LANG['menu_left'], 'L_RIGHT_MENU' => $LANG['menu_right'], 'L_TOP_CENTRAL_MENU' => $LANG['menu_top_central'], 'L_BOTTOM_CENTRAL_MENU' => $LANG['menu_bottom_central'], 'L_TOP_FOOTER' => $LANG['menu_top_footer'], 'L_FOOTER' => $LANG['menu_footer'], 'L_ADD_MENU' => $LANG['menus_add'], 'L_ADD_CONTENT_MENUS' => $LANG['menus_content_add'], 'L_ADD_LINKS_MENUS' => $LANG['menus_links_add'], 'L_ADD_FEED_MENUS' => $LANG['menus_feed_add'], 'L_VALID_POSTIONS' => $LANG['valid_position_menus'], 'L_THEME_MANAGEMENT' => $LANG['theme_management'], 'I_HEADER' => Menu::BLOCK_POSITION__HEADER, 'I_SUBHEADER' => Menu::BLOCK_POSITION__SUB_HEADER, 'I_TOPCENTRAL' => Menu::BLOCK_POSITION__TOP_CENTRAL, 'I_BOTTOMCENTRAL' => Menu::BLOCK_POSITION__BOTTOM_CENTRAL, 'I_TOPFOOTER' => Menu::BLOCK_POSITION__TOP_FOOTER, 'I_FOOTER' => Menu::BLOCK_POSITION__FOOTER, 'I_LEFT' => Menu::BLOCK_POSITION__LEFT, 'I_RIGHT' => Menu::BLOCK_POSITION__RIGHT, 'L_MENUS_AVAILABLE' => count($menus_blocks[Menu::BLOCK_POSITION__NOT_ENABLED]) ? $LANG['available_menus'] : $LANG['no_available_menus'], 'L_SUBMIT' => $LANG['submit'], 'L_RESET' => $LANG['reset'], 'U_TOKEN' => AppContext::get_session()->get_token())); $tpl->display(); require_once PATH_TO_ROOT . '/admin/admin_footer.php';
private function get_view() { $this->check_authorizations(); global $LANG, $auth_write, $Bread_crumb, $members, $pages, $pages_year, $referer, $keyword, $visit, $visit_year, $os, $browser, $user_lang, $stats_array_browsers, $stats_array_os, $stats_array_lang; require_once PATH_TO_ROOT . '/stats/stats_begin.php'; $tpl = new FileTemplate('stats/stats.tpl'); $date_lang = LangLoader::get('date-common'); $_NBR_ELEMENTS_PER_PAGE = 15; $tpl->put_all(array('U_STATS_SITE' => url('.php?site=1', '-site.php'), 'U_STATS_USERS' => url('.php?members=1', '-members.php'), 'U_STATS_VISIT' => url('.php?visit=1', '-visit.php'), 'U_STATS_PAGES' => url('.php?pages=1', '-pages.php'), 'U_STATS_REFERER' => url('.php?referer=1', '-referer.php'), 'U_STATS_KEYWORD' => url('.php?keyword=1', '-keyword.php'), 'U_STATS_BROWSER' => url('.php?browser=1', '-browser.php'), 'U_STATS_OS' => url('.php?os=1', '-os.php'), 'U_STATS_LANG' => url('.php?lang=1', '-lang.php'), 'L_SITE' => $LANG['site'], 'L_STATS' => $LANG['stats'], 'L_USERS' => $LANG['member_s'], 'L_VISITS' => $LANG['guest_s'], 'L_PAGES' => $LANG['page_s'], 'L_REFERER' => $LANG['referer_s'], 'L_KEYWORD' => $LANG['keyword_s'], 'L_BROWSERS' => $LANG['browser_s'], 'L_OS' => $LANG['os'], 'L_LANG' => $LANG['stat_lang'])); if ($members) { $stats_cache = StatsCache::load(); $last_user_group_color = User::get_group_color($stats_cache->get_stats_properties('last_member_groups'), $stats_cache->get_stats_properties('last_member_level')); $tpl->put_all(array('C_STATS_USERS' => true, 'C_LAST_USER_GROUP_COLOR' => !empty($last_user_group_color), 'LAST_USER' => $stats_cache->get_stats_properties('last_member_login'), 'LAST_USER_LEVEL_CLASS' => UserService::get_level_class($stats_cache->get_stats_properties('last_member_level')), 'LAST_USER_GROUP_COLOR' => $last_user_group_color, 'U_LAST_USER_PROFILE' => UserUrlBuilder::profile($stats_cache->get_stats_properties('last_member_id'))->rel(), 'USERS' => $stats_cache->get_stats_properties('nbr_members'), 'GRAPH_RESULT_THEME' => !file_exists('../cache/theme.png') ? '<img src="display_stats.php?theme=1" alt="' . $LANG['theme_s'] . '" />' : '<img src="../cache/theme.png" alt="' . $LANG['theme_s'] . '" />', 'GRAPH_RESULT_SEX' => !file_exists('../cache/sex.png') ? '<img src="display_stats.php?sex=1" alt="' . $LANG['sex'] . '" />' : '<img src="../cache/sex.png" alt="' . $LANG['sex'] . '" />', 'L_LAST_USER' => $LANG['last_member'], 'L_TEMPLATES' => $LANG['theme_s'], 'L_PSEUDO' => LangLoader::get_message('display_name', 'user-common'), 'L_MSG' => $LANG['message_s'], 'L_TOP_TEN_POSTERS' => $LANG['top_10_posters'], 'L_COLORS' => $LANG['colors'], 'L_USERS' => $LANG['member_s'], 'L_SEX' => $LANG['sex'])); $stats_array = array(); foreach (ThemesManager::get_activated_themes_map() as $theme) { $stats_array[$theme->get_id()] = PersistenceContext::get_querier()->count(DB_TABLE_MEMBER, "WHERE theme = '" . $theme->get_id() . "'"); } $Stats = new ImagesStats(); $Stats->load_data($stats_array, 'ellipse'); foreach ($Stats->data_stats as $name => $angle_value) { $array_color = $Stats->array_allocated_color[$Stats->image_color_allocate_dark(false, NO_ALLOCATE_COLOR)]; $tpl->assign_block_vars('templates', array('NBR_THEME' => NumberHelper::round($angle_value * $Stats->nbr_entry / 360, 0), 'COLOR' => 'RGB(' . $array_color[0] . ', ' . $array_color[1] . ', ' . $array_color[2] . ')', 'THEME' => $name == 'Other' ? $LANG['other'] : $name, 'PERCENT' => NumberHelper::round($angle_value / 3.6, 1))); } $stats_array = array(); $result = $this->db_querier->select("SELECT count(ext_field.user_sex) as compt, ext_field.user_sex\r\n\t\t\tFROM " . PREFIX . "member member\r\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER_EXTENDED_FIELDS . " ext_field ON ext_field.user_id = member.user_id\r\n\t\t\tGROUP BY ext_field.user_sex\r\n\t\t\tORDER BY compt"); while ($row = $result->fetch()) { switch ($row['user_sex']) { case 0: $name = $LANG['unknown']; break; case 1: $name = $LANG['male']; break; case 2: $name = $LANG['female']; break; } $stats_array[$name] = $row['compt']; } $result->dispose(); $Stats->color_index = 0; $Stats->load_data($stats_array, 'ellipse'); foreach ($Stats->data_stats as $name => $angle_value) { $array_color = $Stats->array_allocated_color[$Stats->image_color_allocate_dark(false, NO_ALLOCATE_COLOR)]; $tpl->assign_block_vars('sex', array('NBR_MBR' => NumberHelper::round($angle_value * $Stats->nbr_entry / 360, 0), 'COLOR' => 'RGB(' . $array_color[0] . ', ' . $array_color[1] . ', ' . $array_color[2] . ')', 'SEX' => $name == 'Other' ? $LANG['other'] : $name, 'PERCENT' => NumberHelper::round($angle_value / 3.6, 1))); } $i = 1; $result = $this->db_querier->select("SELECT user_id, display_name, level, groups, posted_msg\r\n\t\t\tFROM " . DB_TABLE_MEMBER . "\r\n\t\t\tORDER BY posted_msg DESC\r\n\t\t\tLIMIT 10 OFFSET 0"); while ($row = $result->fetch()) { $user_group_color = User::get_group_color($row['groups'], $row['level']); $tpl->assign_block_vars('top_poster', array('C_USER_GROUP_COLOR' => !empty($user_group_color), 'ID' => $i, 'LOGIN' => $row['display_name'], 'USER_LEVEL_CLASS' => UserService::get_level_class($row['level']), 'USER_GROUP_COLOR' => $user_group_color, 'USER_POST' => $row['posted_msg'], 'U_USER_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel())); $i++; } $result->dispose(); } elseif ($visit || $visit_year) { //On affiche les visiteurs totaux et du jour $compteur = array('nbr_ip' => 0, 'total' => 0); try { $compteur = $this->db_querier->select_single_row(DB_TABLE_VISIT_COUNTER, array('ip AS nbr_ip', 'total'), 'WHERE id = :id', array('id' => 1)); } catch (RowNotFoundException $e) { } $compteur_total = !empty($compteur['nbr_ip']) ? $compteur['nbr_ip'] : '1'; $compteur_day = !empty($compteur['total']) ? $compteur['total'] : '1'; $tpl->put_all(array('L_TODAY' => $date_lang['today'], 'L_TOTAL' => $LANG['total'], 'L_AVERAGE' => $LANG['average'], 'L_VISITORS' => $LANG['guest_s'] . ':', 'L_VISITS_DAY' => $LANG['guest_s'], 'L_DAY' => $date_lang['date'], 'L_MONTH' => $date_lang['month'], 'L_SUBMIT' => $LANG['submit'])); $time = Date::to_format(Date::DATE_NOW, 'Ym'); $current_year = substr($time, 0, 4); $current_month = substr($time, 4, 2); $month = retrieve(GET, 'm', (int) $current_month); $year = retrieve(GET, 'y', (int) $current_year); if ($visit_year) { $year = $visit_year; } //Gestion des mois pour s'adapter au array défini dans lang/main.php $array_l_months = array($date_lang['january'], $date_lang['february'], $date_lang['march'], $date_lang['april'], $date_lang['may'], $date_lang['june'], $date_lang['july'], $date_lang['august'], $date_lang['september'], $date_lang['october'], $date_lang['november'], $date_lang['december']); if (!empty($visit_year)) { //Années précédente et suivante $next_year = $visit_year + 1; $previous_year = $visit_year - 1; //On va chercher le nombre de jours présents dans la table, ainsi que le record mensuel $info = array('max_month' => 0, 'sum_month' => 0, 'nbr_month' => 0); try { $info = $this->db_querier->select_single_row(StatsSetup::$stats_table, array('MAX(nbr) as max_month', 'SUM(nbr) as sum_month', 'COUNT(DISTINCT(stats_month)) as nbr_month'), 'WHERE stats_year=:year GROUP BY stats_year', array('year' => $visit_year)); } catch (RowNotFoundException $e) { } $tpl->put_all(array('C_STATS_VISIT' => true, 'TYPE' => 'visit', 'VISIT_TOTAL' => $compteur_total, 'VISIT_DAY' => $compteur_day, 'YEAR' => $visit_year, 'COLSPAN' => 14, 'SUM_NBR' => $info['sum_month'], 'MAX_NBR' => $info['max_month'], 'MOY_NBR' => !empty($info['nbr_month']) ? NumberHelper::round($info['sum_month'] / $info['nbr_month'], 1) : 1, 'U_NEXT_LINK' => url('.php?year=' . $next_year), 'U_PREVIOUS_LINK' => url('.php?year=' . $previous_year))); //Année maximale $info_year = array('max_year' => 0, 'min_year' => 0); try { $info_year = $this->db_querier->select_single_row(StatsSetup::$stats_table, array('MAX(stats_year) as max_year', 'MIN(stats_year) as min_year'), ''); } catch (RowNotFoundException $e) { } $years = ''; for ($i = $info_year['min_year']; $i <= $info_year['max_year']; $i++) { $selected = $i == $year ? ' selected="selected"' : ''; $years .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; } $tpl->put_all(array('C_STATS_YEAR' => true, 'STATS_YEAR' => $years)); if (@extension_loaded('gd')) { $tpl->put_all(array('GRAPH_RESULT' => '<img src="display_stats.php?visit_year=1&year=' . $visit_year . '" alt="' . $LANG['total_visit'] . '" />')); //On fait la liste des visites journalières $result = $this->db_querier->select("SELECT stats_month, SUM(nbr) AS total\r\n\t\t\t\t\t\tFROM " . StatsSetup::$stats_table . "\r\n\t\t\t\t\t\tWHERE stats_year = :stats_year\r\n\t\t\t\t\t\tGROUP BY stats_month", array('stats_year' => $visit_year)); while ($row = $result->fetch()) { //On affiche les stats numériquement dans un tableau en dessous $tpl->assign_block_vars('value', array('U_DETAILS' => '<a href="stats' . url('.php?m=' . $row['stats_month'] . '&y=' . $visit_year . '&visit=1') . '#stats">' . $array_l_months[$row['stats_month'] - 1] . '</a>', 'NBR' => $row['total'])); } $result->dispose(); } else { $max_month = 1; $result = $this->db_querier->select("SELECT SUM(nbr) AS total\r\n\t\t\t\t\t\tFROM " . StatsSetup::$stats_table . "\r\n\t\t\t\t\t\tWHERE stats_year = :stats_year\r\n\t\t\t\t\t\tGROUP BY stats_month", array('stats_year' => $visit_year)); while ($row = $result->fetch()) { $max_month = $row['total'] <= $max_month ? $max_month : $row['total']; } $result->dispose(); $tpl->put_all(array('C_STATS_NO_GD' => true)); $i = 1; $last_month = 1; $months_not_empty = array(); $result = $this->db_querier->select("SELECT stats_month, SUM(nbr) AS total\r\n\t\t\t\t\tFROM " . StatsSetup::$stats_table . "\r\n\t\t\t\t\t\tWHERE stats_year = :stats_year\r\n\t\t\t\t\t\tGROUP BY stats_month", array('stats_year' => $visit_year)); while ($row = $result->fetch()) { $diff = 0; if ($row['stats_month'] != $i) { $diff = $row['stats_month'] - $i; for ($j = 0; $j < $diff; $j++) { $tpl->assign_block_vars('values', array('HEIGHT' => 0)); } } $i += $diff; //On a des stats pour ce mois-ci, on l'enregistre array_push($months_not_empty, $row['stats_month']); //On calcule la proportion (le maximum du mois tiendra toute la hauteur) $height = $row['total'] / $max_month * 200; $tpl->assign_block_vars('values', array('HEIGHT' => ceil($height))); $tpl->assign_block_vars('values.head', array()); //On affiche les stats numériquement dans un tableau en dessous $tpl->assign_block_vars('value', array('U_DETAILS' => '<a href="stats' . url('.php?m=' . $row['stats_month'] . '&y=' . $visit_year . '&visit=1') . '#stats">' . $array_l_months[$row['stats_month'] - 1] . '</a>', 'NBR' => $row['total'])); $last_month = $row['stats_month']; $i++; } $result->dispose(); //Génération des td manquants. $date_day = isset($date_day) ? $date_day : 1; for ($i = $last_month; $i < 12; $i++) { $tpl->assign_block_vars('end_td', array('END_TD' => '<td style="width:13px;"> </td>')); } //On liste les jours en dessous du graphique $i = 1; foreach ($array_l_months as $value) { $tpl->assign_block_vars('legend', array('LEGEND' => in_array($i, $months_not_empty) ? '<a href="stats' . url('.php?m=' . $i . '&y=' . $visit_year . '&visit=1') . '#stats">' . substr($value, 0, 3) . '</a>' : substr($value, 0, 3))); $i++; } } } else { //Nombre de jours pour chaque mois (gestion des années bissextiles) $bissextile = date("L", mktime(0, 0, 0, 1, 1, $year)) == 1 ? 29 : 28; $array_month = array(31, $bissextile, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); //Mois précédent et suivant $next_month = $month < 12 ? $month + 1 : 1; $next_year = $month < 12 ? $year : $year + 1; $previous_month = $month > 1 ? $month - 1 : 12; $previous_year = $month > 1 ? $year : $year - 1; //On va chercher le nombre de jours présents dans la table, ainsi que le record mensuel $info = array('max_nbr' => 0, 'min_day' => 0, 'sum_nbr' => 0, 'avg_nbr' => 0); try { $info = $this->db_querier->select_single_row(StatsSetup::$stats_table, array('MAX(nbr) as max_nbr', 'MIN(stats_day) as min_day', 'SUM(nbr) as sum_nbr', 'AVG(nbr) as avg_nbr'), 'WHERE stats_year=:year AND stats_month=:month GROUP BY stats_month', array('year' => $year, 'month' => $month)); } catch (RowNotFoundException $e) { } $tpl->put_all(array('C_STATS_VISIT' => true, 'TYPE' => 'visit', 'VISIT_TOTAL' => $compteur_total, 'VISIT_DAY' => $compteur_day, 'COLSPAN' => $array_month[$month - 1] + 2, 'SUM_NBR' => !empty($info['sum_nbr']) ? $info['sum_nbr'] : 0, 'MONTH' => $array_l_months[$month - 1], 'MAX_NBR' => $info['max_nbr'], 'MOY_NBR' => NumberHelper::round($info['avg_nbr'], 1), 'U_NEXT_LINK' => url('.php?m=' . $next_month . '&y=' . $next_year . '&visit=1', '-visit.php?m=' . $next_month . '&y=' . $next_year), 'U_PREVIOUS_LINK' => url('.php?m=' . $previous_month . '&y=' . $previous_year . '&visit=1', '-visit.php?m=' . $previous_month . '&y=' . $previous_year), 'U_YEAR' => '<a href="stats' . url('.php?year=' . $year) . '#stats">' . $year . '</a>', 'U_VISITS_MORE' => '<a href="stats' . url('.php?year=' . $year) . '#stats">' . $LANG['visits_year'] . ' ' . $year . '</a>')); $months = ''; for ($i = 1; $i <= 12; $i++) { $selected = $i == $month ? ' selected="selected"' : ''; $months .= '<option value="' . $i . '"' . $selected . '>' . $array_l_months[$i - 1] . '</option>'; } //Année maximale $info_year = array('max_year' => 0, 'min_year' => 0); try { $info_year = $this->db_querier->select_single_row(StatsSetup::$stats_table, array('MAX(stats_year) as max_year', 'MIN(stats_year) as min_year'), ''); } catch (RowNotFoundException $e) { } $years = ''; for ($i = $info_year['min_year']; $i <= $info_year['max_year']; $i++) { $selected = $i == $year ? ' selected="selected"' : ''; $years .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; } $tpl->put_all(array('C_STATS_YEAR' => true, 'C_STATS_MONTH' => true, 'STATS_YEAR' => $years, 'STATS_MONTH' => $months)); if (@extension_loaded('gd')) { $tpl->put_all(array('GRAPH_RESULT' => '<img src="display_stats.php?visit_month=1&year=' . $year . '&month=' . $month . '" alt="' . $LANG['total_visit'] . '" />')); //On fait la liste des visites journalières $result = $this->db_querier->select("SELECT nbr, stats_day AS day\r\n\t\t\t\t\t\tFROM " . StatsSetup::$stats_table . "\r\n\t\t\t\t\t\tWHERE stats_year = :year AND stats_month = :month\r\n\t\t\t\t\t\tGROUP BY stats_day", array('year' => $year, 'month' => $month)); while ($row = $result->fetch()) { $date_day = $row['day'] < 10 ? 0 . $row['day'] : $row['day']; //On affiche les stats numériquement dans un tableau en dessous $tpl->assign_block_vars('value', array('U_DETAILS' => $date_day . '/' . sprintf('%02d', $month) . '/' . $year, 'NBR' => $row['nbr'])); } $result->dispose(); } else { //Mois selectionné. if (!empty($month) && !empty($year)) { $tpl->put_all(array('C_STATS_NO_GD' => true)); //On rajoute un 0 devant tous les mois plus petits que 10 $month = $month < 10 ? '0' . $month : $month; unset($i); //On fait la liste des visites journalières $j = 0; $result = $this->db_querier->select("SELECT nbr, stats_day AS day\r\n\t\t\t\t\t\t\tFROM " . StatsSetup::$stats_table . "\r\n\t\t\t\t\t\t\tWHERE stats_year = :year AND stats_month = :month\r\n\t\t\t\t\t\t\tORDER BY stats_day", array('year' => $year, 'month' => $month)); while ($row = $result->fetch()) { //Complétion des jours précédent le premier enregistrement du mois. if ($j == 0) { for ($z = 1; $z < $row['day']; $z++) { $tpl->assign_block_vars('values', array('HEIGHT' => 0)); } $j++; } //Remplissage des trous possibles entre les enregistrements. $i = !isset($i) ? $row['day'] : $i; $diff = 0; if ($row['day'] != $i) { $diff = $row['day'] - $i; for ($j = 0; $j < $diff; $j++) { $tpl->assign_block_vars('values', array('HEIGHT' => 0)); } } $i += $diff; //On calcule la proportion (le maximum du mois tiendra toute la hauteur) $height = $row['nbr'] / $info['max_nbr'] * 200; $tpl->assign_block_vars('values', array('HEIGHT' => ceil($height))); $tpl->assign_block_vars('values.head', array()); $date_day = $row['day'] < 10 ? 0 . $row['day'] : $row['day']; //On affiche les stats numériquement dans un tableau en dessous $tpl->assign_block_vars('value', array('U_DETAILS' => $date_day . '/' . sprintf('%02d', $month) . '/' . $year, 'NBR' => $row['nbr'])); $i++; } $result->dispose(); //Génération des td manquants. $date_day = isset($date_day) ? $date_day : 1; for ($i = $date_day; $i < $array_month[$month - 1] - 1; $i++) { $tpl->assign_block_vars('end_td', array('END_TD' => '<td style="width:13px;"> </td>')); } //On liste les jours en dessous du graphique for ($i = 1; $i <= $array_month[$month - 1]; $i++) { $tpl->assign_block_vars('legend', array('LEGEND' => $i)); } } } } } elseif ($pages || $pages_year) { $time = Date::to_format(Date::DATE_NOW, 'Ymj'); $current_year = substr($time, 0, 4); $current_month = substr($time, 4, 2); $current_day = substr($time, 6, 2); $day = retrieve(GET, 'd', (int) $current_day); $month = retrieve(GET, 'm', (int) $current_month); if ($pages_year) { $condition = 'WHERE stats_year=:year AND pages_detail <> \'\' GROUP BY stats_month'; $year = $pages_year; } elseif (retrieve(GET, 'd', false)) { $condition = 'WHERE stats_year=:year AND stats_month=:month AND stats_day=:day AND pages_detail <> \'\' GROUP BY stats_month'; $year = retrieve(GET, 'y', (int) $current_year); } else { $condition = 'WHERE stats_year=:year AND stats_month=:month AND pages_detail <> \'\' GROUP BY stats_month'; $year = retrieve(GET, 'y', (int) $current_year); } if (empty($pages_year)) { //On va chercher le nombre de jours présents dans la table, ainsi que le record mensuel $info = array('max_nbr' => 0, 'min_day' => 0, 'sum_nbr' => 0, 'avg_nbr' => 0); try { $info = $this->db_querier->select_single_row(StatsSetup::$stats_table, array('MAX(pages) as max_nbr', 'MIN(stats_day) as min_day', 'SUM(pages) as sum_nbr', 'AVG(pages) as avg_nbr', 'COUNT(DISTINCT(stats_month)) as nbr_month', 'pages'), $condition, array('year' => $year, 'month' => $month, 'day' => $day)); } catch (RowNotFoundException $e) { } } //On affiche les visiteurs totaux et du jour $compteur_total = $this->db_querier->get_column_value(StatsSetup::$stats_table, 'SUM(pages)', ''); $compteur_day = array_sum(StatsSaver::retrieve_stats('pages')) + 1; $compteur_total = $compteur_total + $compteur_day; $compteur_day = !empty($compteur_day) ? $compteur_day : '1'; $tpl->put_all(array('L_TODAY' => $date_lang['today'], 'L_TOTAL' => $LANG['total'], 'L_AVERAGE' => $LANG['average'], 'L_VISITORS' => $LANG['page_s'] . ':', 'L_VISITS_DAY' => $LANG['page_s'], 'L_DAY' => $date_lang['date'], 'L_MONTH' => $date_lang['month'], 'L_SUBMIT' => $LANG['submit'])); //Gestion des mois pour s'adapter au array défini dans lang/main.php $array_l_months = array($date_lang['january'], $date_lang['february'], $date_lang['march'], $date_lang['april'], $date_lang['may'], $date_lang['june'], $date_lang['july'], $date_lang['august'], $date_lang['september'], $date_lang['october'], $date_lang['november'], $date_lang['december']); if (!empty($pages_year)) { //Années précédente et suivante $next_year = $pages_year + 1; $previous_year = $pages_year - 1; //On va chercher le nombre de jours présents dans la table, ainsi que le record mensuel $info = array('max_nbr' => 0, 'sum_nbr' => 0, 'nbr_month' => 0); try { $info = $this->db_querier->select_single_row(StatsSetup::$stats_table, array('MAX(pages) as max_nbr', 'SUM(pages) as sum_nbr', 'COUNT(DISTINCT(stats_month)) as nbr_month'), 'WHERE stats_year = :year AND pages_detail <> \'\' GROUP BY stats_year', array('year' => $pages_year)); } catch (RowNotFoundException $e) { } $tpl->put_all(array('C_STATS_VISIT' => true, 'TYPE' => 'pages', 'VISIT_TOTAL' => $compteur_total, 'VISIT_DAY' => $compteur_day, 'YEAR' => $pages_year, 'COLSPAN' => 13, 'SUM_NBR' => $info['sum_nbr'], 'MAX_NBR' => $info['max_nbr'], 'MOY_NBR' => !empty($info['nbr_month']) ? NumberHelper::round($info['sum_nbr'] / $info['nbr_month'], 1) : 0, 'U_NEXT_LINK' => url('.php?pages_year=' . $next_year), 'U_PREVIOUS_LINK' => url('.php?pages_year=' . $previous_year))); //Année maximale $info_year = array('max_year' => 0, 'min_year' => 0); try { $info_year = $this->db_querier->select_single_row(StatsSetup::$stats_table, array('MAX(stats_year) as max_year', 'MIN(stats_year) as min_year'), ''); } catch (RowNotFoundException $e) { } $years = ''; for ($i = $info_year['min_year']; $i <= $info_year['max_year']; $i++) { $selected = $i == $year ? ' selected="selected"' : ''; $years .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; } $tpl->put_all(array('C_STATS_YEAR' => true, 'STATS_YEAR' => $years)); if (@extension_loaded('gd')) { $tpl->put_all(array('GRAPH_RESULT' => '<img src="display_stats.php?pages_year=1&year=' . $pages_year . '" alt="' . $LANG['total_visit'] . '" />')); //On fait la liste des visites journalières $result = $this->db_querier->select("SELECT stats_month, SUM(pages) AS total\r\n\t\t\t\t\t\tFROM " . StatsSetup::$stats_table . "\r\n\t\t\t\t\t\tWHERE stats_year = :stats_year\r\n\t\t\t\t\t\tGROUP BY stats_month", array('stats_year' => $pages_year)); while ($row = $result->fetch()) { //On affiche les stats numériquement dans un tableau en dessous $tpl->assign_block_vars('value', array('U_DETAILS' => '<a href="stats' . url('.php?m=' . $row['stats_month'] . '&y=' . $pages_year . '&pages=1') . '#stats">' . $array_l_months[$row['stats_month'] - 1] . '</a>', 'NBR' => $row['total'])); } $result->dispose(); } else { $result = $this->db_querier->select("SELECT SUM(nbr) AS total\r\n\t\t\t\t\t\tFROM " . StatsSetup::$stats_table . "\r\n\t\t\t\t\t\tWHERE stats_year = :stats_year\r\n\t\t\t\t\t\tGROUP BY stats_month", array('stats_year' => $visit_year)); $max_month = 1; while ($row = $result->fetch()) { $max_month = $row['total'] <= $max_month ? $max_month : $row['total']; } $tpl->put_all(array('C_STATS_NO_GD' => true)); $i = 1; $last_month = 1; $months_not_empty = array(); $result = $this->db_querier->select("SELECT stats_month, SUM(pages) AS total\r\n\t\t\t\t\t\tFROM " . StatsSetup::$stats_table . "\r\n\t\t\t\t\t\tWHERE stats_year = :stats_year\r\n\t\t\t\t\t\tGROUP BY stats_month", array('stats_year' => $visit_year)); while ($row = $result->fetch()) { $diff = 0; if ($row['stats_month'] != $i) { $diff = $row['stats_month'] - $i; for ($j = 0; $j < $diff; $j++) { $tpl->assign_block_vars('values', array('HEIGHT' => 0)); } } $i += $diff; //On a des stats pour ce mois-ci, on l'enregistre array_push($months_not_empty, $row['stats_month']); //On calcule la proportion (le maximum du mois tiendra toute la hauteur) $height = $row['total'] / $info['max_month'] * 200; $tpl->assign_block_vars('months', array('HEIGHT' => ceil($height))); $tpl->assign_block_vars('values.head', array()); //On affiche les stats numériquement dans un tableau en dessous $tpl->assign_block_vars('value', array('U_DETAILS' => '<a href="stats' . url('.php?m=' . $row['stats_month'] . '&y=' . $pages_year . '&pages=1') . '#stats">' . $array_l_months[$row['stats_month'] - 1] . '</a>', 'NBR' => $row['total'])); $last_month = $row['stats_month']; $i++; } $result->dispose(); //Génération des td manquants. $date_day = isset($date_day) ? $date_day : 1; for ($i = $last_month; $i < 12; $i++) { $tpl->assign_block_vars('end_td', array('END_TD' => '<td style="width:13px;"> </td>')); } //On liste les jours en dessous du graphique $i = 1; foreach ($array_l_months as $value) { $tpl->assign_block_vars('legend', array('LEGEND' => in_array($i, $months_not_empty) ? '<a href="stats' . url('.php?m=' . $i . '&y=' . $pages_year . '&pages=1') . '#stats">' . substr($value, 0, 3) . '</a>' : substr($value, 0, 3))); $i++; } } } elseif (retrieve(GET, 'd', false)) { //Nombre de jours pour chaque mois (gestion des années bissextiles) $bissextile = date("L", mktime(0, 0, 0, 1, 1, $year)) == 1 ? 29 : 28; $array_month = array(31, $bissextile, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); //Mois précédent et suivant $check_day = $day < $array_month[$month - 1]; $next_day = $check_day ? $day + 1 : 1; $next_month = !$check_day && $month < 12 ? $month + 1 : $month; $next_year = !$check_day && $month == 12 ? $year + 1 : $year; $previous_day = $day > 1 ? $day - 1 : $array_month[$month - 1]; $previous_month = $month > 1 ? $day == 1 ? $month - 1 : $month : 12; $previous_year = $month > 1 ? $year : $year - 1; $tpl->put_all(array('C_STATS_VISIT' => true, 'TYPE' => 'pages', 'VISIT_TOTAL' => $compteur_total, 'VISIT_DAY' => $compteur_day, 'SUM_NBR' => !empty($info['sum_nbr']) ? $info['sum_nbr'] : 0, 'MONTH' => $array_l_months[$month - 1], 'MAX_NBR' => $info['max_nbr'], 'MOY_NBR' => NumberHelper::round($info['avg_nbr'], 1), 'U_NEXT_LINK' => url('.php?d=' . $next_day . '&m=' . $next_month . '&y=' . $next_year . '&pages=1', '-pages.php?d=' . $next_day . '&m=' . $next_month . '&y=' . $next_year), 'U_PREVIOUS_LINK' => url('.php?d=' . $previous_day . '&m=' . $previous_month . '&y=' . $previous_year . '&pages=1', '-pages.php?d=' . $previous_day . '&m=' . $previous_month . '&y=' . $previous_year), 'U_YEAR' => '<a href="stats' . url('.php?pages_year=' . $year) . '#stats">' . $year . '</a>', 'U_VISITS_MORE' => '<a href="stats' . url('.php?pages_year=' . $year) . '#stats">' . $LANG['visits_year'] . ' ' . $year . '</a>')); $days = ''; for ($i = 1; $i <= $array_month[$month - 1]; $i++) { $selected = $i == $day ? ' selected="selected"' : ''; $days .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; } $months = ''; for ($i = 1; $i <= 12; $i++) { $selected = $i == $month ? ' selected="selected"' : ''; $months .= '<option value="' . $i . '"' . $selected . '>' . $array_l_months[$i - 1] . '</option>'; } //Année maximale $info_year = array('max_year' => 0, 'min_year' => 0); try { $info_year = $this->db_querier->select_single_row(StatsSetup::$stats_table, array('MAX(stats_year) as max_year', 'MIN(stats_year) as min_year'), ''); } catch (RowNotFoundException $e) { } $years = ''; for ($i = $info_year['min_year']; $i <= $info_year['max_year']; $i++) { $selected = $i == $year ? ' selected="selected"' : ''; $years .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; } $tpl->put_all(array('C_STATS_DAY' => true, 'C_STATS_MONTH' => true, 'C_STATS_YEAR' => true, 'STATS_DAY' => $days, 'STATS_MONTH' => $months, 'STATS_YEAR' => $years, 'GRAPH_RESULT' => '<img src="display_stats.php?pages_day=1&year=' . $year . '&month=' . $month . '&day=' . $day . '" alt="' . $LANG['total_visit'] . '" />')); //On fait la liste des visites journalières $result = $this->db_querier->select("SELECT pages, stats_day, stats_month, stats_year\r\n\t\t\t\t\tFROM " . StatsSetup::$stats_table . "\r\n\t\t\t\t\tWHERE stats_year = :stats_year AND stats_month = :stats_month\r\n\t\t\t\t\tGROUP BY stats_day", array('stats_year' => $year, 'stats_month' => $month)); while ($row = $result->fetch()) { $date_day = $row['stats_day'] < 10 ? 0 . $row['stats_day'] : $row['stats_day']; //On affiche les stats numériquement dans un tableau en dessous $tpl->assign_block_vars('value', array('U_DETAILS' => '<a href="stats' . url('.php?d=' . $row['stats_day'] . '&m=' . $row['stats_month'] . '&y=' . $row['stats_year'] . '&pages=1', '-pages.php?d=' . $row['stats_day'] . '&m=' . $row['stats_month'] . '&y=' . $row['stats_year']) . '#stats">' . $date_day . '/' . sprintf('%02d', $row['stats_month']) . '/' . $row['stats_year'] . '</a>', 'NBR' => $row['pages'])); } $result->dispose(); } else { //Nombre de jours pour chaque mois (gestion des années bissextiles) $bissextile = date("L", mktime(0, 0, 0, 1, 1, $year)) == 1 ? 29 : 28; $array_month = array(31, $bissextile, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); //Mois précédent et suivant $next_month = $month < 12 ? $month + 1 : 1; $next_year = $month < 12 ? $year : $year + 1; $previous_month = $month > 1 ? $month - 1 : 12; $previous_year = $month > 1 ? $year : $year - 1; $tpl->put_all(array('C_STATS_VISIT' => true, 'TYPE' => 'pages', 'VISIT_TOTAL' => $compteur_total, 'VISIT_DAY' => $compteur_day, 'COLSPAN' => $array_month[$month - 1] + 2, 'SUM_NBR' => !empty($info['sum_nbr']) ? $info['sum_nbr'] : 0, 'MONTH' => $array_l_months[$month - 1], 'MAX_NBR' => $info['max_nbr'], 'MOY_NBR' => NumberHelper::round($info['avg_nbr'], 1), 'U_NEXT_LINK' => url('.php?m=' . $next_month . '&y=' . $next_year . '&pages=1', '-pages.php?m=' . $next_month . '&y=' . $next_year), 'U_PREVIOUS_LINK' => url('.php?m=' . $previous_month . '&y=' . $previous_year . '&pages=1', '-pages.php?m=' . $previous_month . '&y=' . $previous_year), 'U_YEAR' => '<a href="stats' . url('.php?pages_year=' . $year) . '#stats">' . $year . '</a>', 'U_VISITS_MORE' => '<a href="stats' . url('.php?pages_year=' . $year) . '#stats">' . $LANG['visits_year'] . ' ' . $year . '</a>')); $months = ''; for ($i = 1; $i <= 12; $i++) { $selected = $i == $month ? ' selected="selected"' : ''; $months .= '<option value="' . $i . '"' . $selected . '>' . $array_l_months[$i - 1] . '</option>'; } //Année maximale $info_year = array('max_year' => 0, 'min_year' => 0); try { $info_year = $this->db_querier->select_single_row(StatsSetup::$stats_table, array('MAX(stats_year) as max_year', 'MIN(stats_year) as min_year'), ''); } catch (RowNotFoundException $e) { } $years = ''; for ($i = $info_year['min_year']; $i <= $info_year['max_year']; $i++) { $selected = $i == $year ? ' selected="selected"' : ''; $years .= '<option value="' . $i . '"' . $selected . '>' . $i . '</option>'; } $tpl->put_all(array('C_STATS_YEAR' => true, 'C_STATS_MONTH' => true, 'STATS_YEAR' => $years, 'STATS_MONTH' => $months)); if (@extension_loaded('gd')) { $tpl->put_all(array('GRAPH_RESULT' => '<img src="display_stats.php?pages_month=1&year=' . $year . '&month=' . $month . '" alt="' . $LANG['total_visit'] . '" />')); //On fait la liste des visites journalières $result = $this->db_querier->select("SELECT pages, stats_day, stats_month, stats_year\r\n\t\t\t\t\t\tFROM " . StatsSetup::$stats_table . "\r\n\t\t\t\t\t\tWHERE stats_year = :stats_year AND stats_month = :stats_month\r\n\t\t\t\t\t\tGROUP BY stats_day", array('stats_year' => $year, 'stats_month' => $month)); while ($row = $result->fetch()) { $date_day = $row['stats_day'] < 10 ? 0 . $row['stats_day'] : $row['stats_day']; //On affiche les stats numériquement dans un tableau en dessous $tpl->assign_block_vars('value', array('U_DETAILS' => '<a href="stats' . url('.php?d=' . $row['stats_day'] . '&m=' . $row['stats_month'] . '&y=' . $row['stats_year'] . '&pages=1', '-pages.php?d=' . $row['stats_day'] . '&m=' . $row['stats_month'] . '&y=' . $row['stats_year']) . '#stats">' . $date_day . '/' . sprintf('%02d', $row['stats_month']) . '/' . $row['stats_year'] . '</a>', 'NBR' => $row['pages'])); } $result->dispose(); } else { //Mois selectionné. if (!empty($month) && !empty($year)) { $tpl->put_all(array('C_STATS_NO_GD' => true)); //On rajoute un 0 devant tous les mois plus petits que 10 $month = $month < 10 ? '0' . $month : $month; unset($i); //On fait la liste des visites journalières $j = 0; $result = $this->db_querier->select("SELECT pages, stats_day AS day, stats_month, stats_year\r\n\t\t\t\t\t\t\tFROM " . StatsSetup::$stats_table . "\r\n\t\t\t\t\t\t\tWHERE stats_year = :stats_year AND stats_month = :stats_month\r\n\t\t\t\t\t\t\tGROUP BY stats_day", array('stats_year' => $year, 'stats_month' => $month)); while ($row = $result->fetch()) { //Complétion des jours précédent le premier enregistrement du mois. if ($j == 0) { for ($z = 1; $z < $row['day']; $z++) { $tpl->assign_block_vars('days', array('HEIGHT' => 0)); } $j++; } //Remplissage des trous possibles entre les enregistrements. $i = !isset($i) ? $row['day'] : $i; $diff = 0; if ($row['day'] != $i) { $diff = $row['day'] - $i; for ($j = 0; $j < $diff; $j++) { $tpl->assign_block_vars('days', array('HEIGHT' => 0)); } } $i += $diff; //On calcule la proportion (le maximum du mois tiendra toute la hauteur) $height = $row['pages'] / $info['max_nbr'] * 200; $tpl->assign_block_vars('values', array('HEIGHT' => ceil($height))); $tpl->assign_block_vars('values.head', array()); $date_day = $row['day'] < 10 ? 0 . $row['day'] : $row['day']; //On affiche les stats numériquement dans un tableau en dessous $tpl->assign_block_vars('value', array('U_DETAILS' => $date_day . '/' . sprintf('%02d', $row['stats_month']) . '/' . $row['stats_year'], 'NBR' => $row['pages'])); $i++; } $result->dispose(); //Génération des td manquants. $date_day = isset($date_day) ? $date_day : 1; for ($i = $date_day; $i < $array_month[$month - 1] - 1; $i++) { $tpl->assign_block_vars('end_td', array('END_TD' => '<td style="width:13px;"> </td>')); } //On liste les jours en dessous du graphique for ($i = 1; $i <= $array_month[$month - 1]; $i++) { $tpl->assign_block_vars('legend', array('LEGEND' => $i)); } } } } } elseif ($referer) { include_once PATH_TO_ROOT . '/stats/stats_functions.php'; $nbr_referer = $this->db_querier->count(StatsSetup::$stats_referer_table, 'WHERE type = :type', array('type' => 0), 'DISTINCT(url)'); $page = AppContext::get_request()->get_getint('p', 1); $pagination = new ModulePagination($page, $nbr_referer, $_NBR_ELEMENTS_PER_PAGE); $pagination->set_url(new Url('/stats/admin_stats.php?referer=1&p=%d')); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $result = $this->db_querier->select("SELECT id, COUNT(*) as count, url, relative_url, SUM(total_visit) as total_visit, SUM(today_visit) as today_visit, SUM(yesterday_visit) as yesterday_visit, nbr_day, MAX(last_update) as last_update\r\n\t\t\t\tFROM " . PREFIX . "stats_referer\r\n\t\t\t\tWHERE type = 0\r\n\t\t\t\tGROUP BY url\r\n\t\t\t\tORDER BY total_visit DESC\r\n\t\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); while ($row = $result->fetch()) { $trend_parameters = get_trend_parameters($row['total_visit'], $row['nbr_day'], $row['yesterday_visit'], $row['today_visit']); $tpl->assign_block_vars('referer_list', array('ID' => $row['id'], 'URL' => $row['url'], 'IMG_MORE' => '<a class="fa fa-plus-square-o" style="cursor:pointer;" onclick="XMLHttpRequest_referer(' . $row['id'] . ')" id="img_url' . $row['id'] . '"></a>', 'NBR_LINKS' => $row['count'], 'TOTAL_VISIT' => $row['total_visit'], 'AVERAGE_VISIT' => $trend_parameters['average'], 'LAST_UPDATE' => Date::to_format($row['last_update'], Date::FORMAT_DAY_MONTH_YEAR), 'TREND' => ($trend_parameters['picture'] ? '<i class="fa fa-trend-' . $trend_parameters['picture'] . '"></i> ' : '') . '(' . $trend_parameters['sign'] . $trend_parameters['trend'] . '%)')); } $result->dispose(); $tpl->put_all(array('C_STATS_REFERER' => true, 'C_REFERERS' => $nbr_referer, 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_URL' => $LANG['url'], 'L_TOTAL_VISIT' => $LANG['total_visit'], 'L_AVERAGE_VISIT' => $LANG['average_visit'], 'L_TREND' => $LANG['trend'], 'L_LAST_UPDATE' => $LANG['last_update'], 'L_NO_REFERER' => $LANG['no_referer'])); } elseif ($keyword) { include_once PATH_TO_ROOT . '/stats/stats_functions.php'; $nbr_keyword = $this->db_querier->count(StatsSetup::$stats_referer_table, 'WHERE type = :type', array('type' => 1), 'DISTINCT(relative_url)'); $page = AppContext::get_request()->get_getint('p', 1); $pagination = new ModulePagination($page, $nbr_keyword, $_NBR_ELEMENTS_PER_PAGE); $pagination->set_url(new Url('/stats/admin_stats.php?keyword=1&p=%d')); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $result = $this->db_querier->select("SELECT id, count(*) as count, relative_url, SUM(total_visit) as total_visit, SUM(today_visit) as today_visit, SUM(yesterday_visit) as yesterday_visit, nbr_day, MAX(last_update) as last_update\r\n\t\t\t\tFROM " . PREFIX . "stats_referer\r\n\t\t\t\tWHERE type = 1\r\n\t\t\t\tGROUP BY relative_url\r\n\t\t\t\tORDER BY total_visit DESC\r\n\t\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); while ($row = $result->fetch()) { $trend_parameters = get_trend_parameters($row['total_visit'], $row['nbr_day'], $row['yesterday_visit'], $row['today_visit']); $tpl->assign_block_vars('keyword_list', array('ID' => $row['id'], 'KEYWORD' => $row['relative_url'], 'IMG_MORE' => '<a class="fa fa-plus-square-o" style="cursor:pointer;" onclick="XMLHttpRequest_referer(' . $row['id'] . ')" id="img_url' . $row['id'] . '"></a>', 'NBR_LINKS' => $row['count'], 'TOTAL_VISIT' => $row['total_visit'], 'AVERAGE_VISIT' => $trend_parameters['average'], 'LAST_UPDATE' => Date::to_format($row['last_update'], Date::FORMAT_DAY_MONTH_YEAR), 'TREND' => ($trend_parameters['picture'] ? '<i class="fa fa-trend-' . $trend_parameters['picture'] . '"></i> ' : '') . '(' . $trend_parameters['sign'] . $trend_parameters['trend'] . '%)')); } $result->dispose(); $tpl->put_all(array('C_STATS_KEYWORD' => true, 'C_KEYWORDS' => $nbr_keyword, 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_SEARCH_ENGINE' => $LANG['keyword_s'], 'L_TOTAL_VISIT' => $LANG['total_visit'], 'L_AVERAGE_VISIT' => $LANG['average_visit'], 'L_TREND' => $LANG['trend'], 'L_LAST_UPDATE' => $LANG['last_update'], 'L_NO_KEYWORD' => $LANG['no_keyword'])); } elseif ($browser || $os || $user_lang) { $path = '../images/stats/'; if (!empty($browser)) { $tpl->put_all(array('C_STATS_BROWSERS' => true, 'GRAPH_RESULT' => !file_exists('../cache/browsers.png') ? '<img src="display_stats.php?browsers=1" alt="' . $LANG['browser_s'] . '" />' : '<img src="../cache/browsers.png" alt="' . $LANG['browser_s'] . '" />', 'L_BROWSERS' => $LANG['browser_s'], 'L_COLORS' => $LANG['colors'], 'L_PERCENTAGE' => $LANG['percentage'])); $stats_menu = 'browsers'; $array_stats_info = $stats_array_browsers; $path = '../images/stats/browsers/'; } elseif (!empty($os)) { $tpl->put_all(array('C_STATS_OS' => true, 'GRAPH_RESULT' => !file_exists('../cache/os.png') ? '<img src="display_stats.php?os=1" alt="' . $LANG['os'] . '" />' : '<img src="../cache/os.png" alt="' . $LANG['os'] . '" />', 'L_OS' => $LANG['os'], 'L_COLORS' => $LANG['colors'], 'L_PERCENTAGE' => $LANG['percentage'])); $stats_menu = 'os'; $array_stats_info = $stats_array_os; $path = '../images/stats/os/'; } elseif (!empty($user_lang)) { $tpl->put_all(array('C_STATS_LANG' => true, 'GRAPH_RESULT' => !file_exists('../cache/lang.png') ? '<img src="display_stats.php?lang=1" alt="' . $LANG['stat_lang'] . '" />' : '<img src="../cache/lang.png" alt="' . $LANG['stat_lang'] . '" />', 'L_LANG' => $LANG['stat_lang'], 'L_COLORS' => $LANG['colors'], 'L_PERCENTAGE' => $LANG['percentage'])); $stats_menu = 'lang'; $array_stats_info = $stats_array_lang; $path = '../images/stats/countries/'; } $Stats = new ImagesStats(); $Stats->load_data(StatsSaver::retrieve_stats($stats_menu), 'ellipse', 5); //Tri décroissant. arsort($Stats->data_stats); //Traitement des données. $array_stats_tmp = array(); $array_order = array(); $percent_other = 0; foreach ($Stats->data_stats as $value_name => $angle_value) { if (!isset($array_stats_info[$value_name]) || $value_name == 'other') { $value_name = 'other'; $angle_value += $percent_other; $percent_other += $angle_value; $stats_img = !empty($array_stats_info['other'][1]) ? '<img src="' . $path . $array_stats_info['other'][1] . '" alt="' . $LANG['other'] . '" />' : '<img src="' . TPL_PATH_TO_ROOT . '/images/stats/other.png" alt="' . $LANG['other'] . '" />'; $name_stats = $LANG['other']; } else { $stats_img = !empty($array_stats_info[$value_name][1]) ? '<img src="' . $path . $array_stats_info[$value_name][1] . '" alt="' . $array_stats_info[$value_name][0] . '" />' : '-'; $name_stats = $array_stats_info[$value_name][0]; } if (!isset($array_order[$value_name])) { $array_color = $Stats->array_allocated_color[$Stats->image_color_allocate_dark(false, NO_ALLOCATE_COLOR)]; $array_stats_tmp[$value_name] = array($name_stats, $array_color, $stats_img); $array_order[$value_name] = $angle_value; } } //Affichage. foreach ($array_order as $value_name => $angle_value) { $tpl->assign_block_vars('list', array('COLOR' => 'RGB(' . trim(implode(', ', $array_stats_tmp[$value_name][1]), ', ') . ')', 'IMG' => $array_stats_tmp[$value_name][2], 'L_NAME' => $array_stats_tmp[$value_name][0], 'PERCENT' => NumberHelper::round($angle_value / 3.6, 1))); } } else { $tpl->put_all(array('C_STATS_SITE' => true, 'START' => GeneralConfig::load()->get_site_install_date()->format(Date::FORMAT_DAY_MONTH_YEAR), 'VERSION' => GeneralConfig::load()->get_phpboost_major_version(), 'L_START' => $LANG['start'], 'L_VERSION' => $LANG['version'])); } return $tpl; }
private function construct_javascript_picture_theme() { $text = 'var theme = new Array;' . "\n"; $activated_themes = ThemesManager::get_activated_themes_map(); foreach ($activated_themes as $theme) { $text .= 'theme["' . $theme->get_id() . '"] = "' . $this->get_picture_theme($theme->get_id()) . '";' . "\n"; } return $text; }
private function build_javascript_picture_themes() { $text = 'var theme = new Array;' . "\n"; foreach (ThemesManager::get_activated_themes_map() as $theme) { $picture = $theme->get_configuration()->get_first_picture(); $text .= 'theme["' . $theme->get_id() . '"] = "' . TPL_PATH_TO_ROOT . '/templates/' . $theme->get_id() . '/' . $picture . '";' . "\n"; } $text .= 'var theme_id = HTMLForms.getField("theme").getValue(); document.images[\'img_theme\'].src = theme[theme_id];'; return $text; }
private function list_themes() { $choices_list = array(); $choices_list[] = new FormFieldSelectChoiceOption($this->lang['customization.interface.all-themes'], 'all'); foreach (ThemesManager::get_activated_themes_map() as $id => $value) { $choices_list[] = new FormFieldSelectChoiceOption($value->get_configuration()->get_name(), $id); } return $choices_list; }