private function build_form($user_id) { $form = new HTMLForm('member-view-profile', '', false); $fieldset = new FormFieldsetHTML('profile', $this->lang['profile']); $form->add_fieldset($fieldset); if (AppContext::get_current_user()->check_level(User::ADMIN_LEVEL)) { $link_edit = '<a href="' . UserUrlBuilder::edit_profile($user_id)->rel() . '" title="' . $this->lang['profile.edit'] . '" class="fa fa-edit"></a>'; $fieldset->add_field(new FormFieldFree('profile_edit', $this->lang['profile.edit'], $link_edit)); } $fieldset->add_field(new FormFieldFree('display_name', $this->lang['display_name'], $this->user_infos['display_name'])); $fieldset->add_field(new FormFieldFree('level', $this->lang['level'], '<a class="' . UserService::get_level_class($this->user_infos['level']) . '">' . $this->get_level_lang() . '</a>')); $fieldset->add_field(new FormFieldFree('groups', $this->lang['groups'], $this->build_groups($this->user_infos['groups']))); $registration_date = new Date($this->user_infos['registration_date']); $fieldset->add_field(new FormFieldFree('registered_on', $this->lang['registration_date'], $registration_date ? $registration_date->format(Date::FORMAT_DAY_MONTH_YEAR) : '')); $fieldset->add_field(new FormFieldFree('nbr_msg', $this->lang['number-messages'], $this->user_infos['posted_msg'] . '<br>' . '<a href="' . UserUrlBuilder::messages($user_id)->rel() . '">' . $this->lang['messages'] . '</a>')); $last_connection_date = !empty($this->user_infos['last_connection_date']) ? Date::to_format($this->user_infos['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main'); $fieldset->add_field(new FormFieldFree('last_connect', $this->lang['last_connection'], $last_connection_date)); if (AppContext::get_current_user()->check_auth(UserAccountsConfig::load()->get_auth_read_members(), UserAccountsConfig::AUTH_READ_MEMBERS_BIT) && $this->user_infos['show_email']) { $link_email = '<a href="mailto:' . $this->user_infos['email'] . '" class="basic-button smaller">Mail</a>'; $fieldset->add_field(new FormFieldFree('email', $this->lang['email'], $link_email)); } if (!$this->same_user_view_profile($user_id) && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) { $link_mp = '<a href="' . UserUrlBuilder::personnal_message($user_id)->rel() . '" class="basic-button smaller">MP</a>'; $fieldset->add_field(new FormFieldFree('private_message', $this->lang['private_message'], $link_mp)); } MemberExtendedFieldsService::display_profile_fields($form, $user_id); $this->form = $form; }
private function build_table() { $table = new SQLHTMLTableModel(DB_TABLE_MEMBER, __CLASS__, array(new HTMLTableColumn('pseudo', 'display_name'), new HTMLTableColumn('email'), new HTMLTableColumn('inscrit le', 'registration_date'), new HTMLTableColumn('messages'), new HTMLTableColumn('derniere connexion'), new HTMLTableColumn('messagerie')), new HTMLTableSortingRule('user_id', HTMLTableSortingRule::ASC)); $table->set_caption('Liste des membres'); $options = array('horn' => 'Horn', 'coucou' => 'Coucou', 'teston' => 'teston'); $table->add_filter(new HTMLTableEqualsFromListSQLFilter('display_name', 'filter1', 'login Equals', $options)); $table->add_filter(new HTMLTableBeginsWithTextSQLFilter('display_name', 'filter2', 'login Begins with (regex)', '`^(?!%).+$`')); $table->add_filter(new HTMLTableBeginsWithTextSQLFilter('display_name', 'filter3', 'login Begins with (no regex)')); $table->add_filter(new HTMLTableEndsWithTextSQLFilter('display_name', 'filter4', 'login Ends with (regex)', '`^(?!%).+$`')); $table->add_filter(new HTMLTableEndsWithTextSQLFilter('display_name', 'filter5', 'login Ends with (no regex)')); $table->add_filter(new HTMLTableLikeTextSQLFilter('display_name', 'filter6', 'login Like (regex)', '`^toto`')); $table->add_filter(new HTMLTableLikeTextSQLFilter('display_name', 'filter7', 'login Like (no regex)')); $table->add_filter(new HTMLTableGreaterThanSQLFilter('user_id', 'filter8', 'id >')); $table->add_filter(new HTMLTableGreaterThanSQLFilter('user_id', 'filter9', 'id > (lower=3)', 3)); $table->add_filter(new HTMLTableGreaterThanSQLFilter('user_id', 'filter10', 'id > (upper=3)', HTMLTableNumberComparatorSQLFilter::NOT_BOUNDED, 3)); $table->add_filter(new HTMLTableGreaterThanSQLFilter('user_id', 'filter11', 'id > (lower=1, upper=3)', 1, 3)); $table->add_filter(new HTMLTableLessThanSQLFilter('user_id', 'filter12', 'id <')); $table->add_filter(new HTMLTableGreaterThanOrEqualsToSQLFilter('user_id', 'filter13', 'id >=')); $table->add_filter(new HTMLTableLessThanOrEqualsToSQLFilter('user_id', 'filter14', 'id <=')); $table->add_filter(new HTMLTableEqualsToSQLFilter('user_id', 'filter15', 'id =')); $html_table = new HTMLTable($table); $results = array(); $result = $table->get_sql_results(); foreach ($result as $row) { $results[] = new HTMLTableRow(array(new HTMLTableRowCell($row['display_name']), new HTMLTableRowCell($row['show_email'] == 1 ? '<a href="mailto:' . $row['email'] . '" class="basic-button smaller">Mail</a>' : ' '), new HTMLTableRowCell(Date::to_format($row['registration_date'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), new HTMLTableRowCell(!empty($row['posted_msg']) ? $row['posted_msg'] : '0'), new HTMLTableRowCell(!empty($row['last_connection_date']) ? Date::to_format($row['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main')), new HTMLTableRowCell('<a href="' . Url::to_rel('/user/pm.php?pm=' . $row['user_id']) . '" class="basic-button smaller">MP</a>'))); } $html_table->set_rows($table->get_number_of_matching_rows(), $results); return $html_table; }
private function build_table() { $table_model = new SQLHTMLTableModel(DB_TABLE_MEMBER, 'table', array(new HTMLTableColumn($this->lang['display_name'], 'display_name'), new HTMLTableColumn($this->lang['email']), new HTMLTableColumn($this->lang['registration_date'], 'registration_date'), new HTMLTableColumn($this->lang['messages'], 'posted_msg'), new HTMLTableColumn($this->lang['last_connection'], 'last_connection_date'), new HTMLTableColumn($this->lang['private_message'])), new HTMLTableSortingRule('display_name', HTMLTableSortingRule::ASC)); $table = new HTMLTable($table_model); $results = array(); $result = $table_model->get_sql_results('m LEFT JOIN ' . DB_TABLE_INTERNAL_AUTHENTICATION . ' ia ON ia.user_id = m.user_id'); foreach ($result as $row) { $posted_msg = !empty($row['posted_msg']) ? $row['posted_msg'] : '0'; $group_color = User::get_group_color($row['groups'], $row['level']); $author = new LinkHTMLElement(UserUrlBuilder::profile($row['user_id']), $row['display_name'], !empty($group_color) ? array('style' => 'color: ' . $group_color) : array(), UserService::get_level_class($row['level'])); $results[] = new HTMLTableRow(array(new HTMLTableRowCell($author), new HTMLTableRowCell($row['show_email'] == 1 ? new LinkHTMLElement('mailto:' . $row['email'], $this->lang['email'], array(), 'basic-button smaller') : ''), new HTMLTableRowCell(Date::to_format($row['registration_date'], Date::FORMAT_DAY_MONTH_YEAR)), new HTMLTableRowCell($posted_msg), new HTMLTableRowCell(!empty($row['last_connection_date']) ? Date::to_format($row['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main')), new HTMLTableRowCell(new LinkHTMLElement(UserUrlBuilder::personnal_message($row['user_id']), 'PM', array(), 'basic-button smaller')))); } $table->set_rows($table_model->get_number_of_matching_rows(), $results); $this->view->put('table', $table->display()); }
private function build_form($request) { $field = $request->get_value('field', NewsletterUrlBuilder::DEFAULT_SORT_FIELD); $sort = $request->get_value('sort', NewsletterUrlBuilder::DEFAULT_SORT_MODE); $current_page = $request->get_int('page', 1); $mode = $sort == 'top' ? 'ASC' : 'DESC'; if (!NewsletterAuthorizationsService::id_stream($this->stream->get_id())->read_archives()) { NewsletterAuthorizationsService::get_errors()->read_archives(); } if (!NewsletterStreamsCache::load()->stream_exists($this->stream->get_id())) { $controller = new UserErrorController(LangLoader::get_message('error', 'status-messages-common'), LangLoader::get_message('admin.stream-not-existed', 'common', 'newsletter')); DispatchManager::redirect($controller); } switch ($field) { case 'stream': $field_bdd = 'stream_id'; break; case 'subject': $field_bdd = 'subject'; break; case 'date': $field_bdd = 'timestamp'; break; case 'subscribers': $field_bdd = 'nbr_subscribers'; break; default: $field_bdd = 'timestamp'; } $stream_id = $this->stream->get_id(); $stream_condition = $stream_id ? "WHERE stream_id = '" . $stream_id . "'" : ""; $nbr_archives = PersistenceContext::get_querier()->count(NewsletterSetup::$newsletter_table_archives, $stream_condition); $pagination = $this->get_pagination($current_page, $nbr_archives, $field, $sort); $moderation_auth = NewsletterAuthorizationsService::id_stream($this->stream->get_id())->moderation_archives(); $this->view->put_all(array('C_MODERATE' => $moderation_auth, 'C_ARCHIVES' => (double) $nbr_archives, 'C_SPECIFIC_STREAM' => $stream_id, 'C_PAGINATION' => $pagination->has_several_pages(), 'NUMBER_COLUMN' => 3 + (int) (empty($stream_id) && !empty($nbr_archives)) + $moderation_auth, 'SORT_STREAM_TOP' => NewsletterUrlBuilder::archives($this->stream->get_id(), $this->stream->get_rewrited_name(), 'stream', 'top', $current_page)->rel(), 'SORT_STREAM_BOTTOM' => NewsletterUrlBuilder::archives($this->stream->get_id(), $this->stream->get_rewrited_name(), 'stream', 'bottom', $current_page)->rel(), 'SORT_SUBJECT_TOP' => NewsletterUrlBuilder::archives($this->stream->get_id(), $this->stream->get_rewrited_name(), 'subject', 'top', $current_page)->rel(), 'SORT_SUBJECT_BOTTOM' => NewsletterUrlBuilder::archives($this->stream->get_id(), $this->stream->get_rewrited_name(), 'subject', 'bottom', $current_page)->rel(), 'SORT_DATE_TOP' => NewsletterUrlBuilder::archives($this->stream->get_id(), $this->stream->get_rewrited_name(), 'date', 'top', $current_page)->rel(), 'SORT_DATE_BOTTOM' => NewsletterUrlBuilder::archives($this->stream->get_id(), $this->stream->get_rewrited_name(), 'date', 'bottom', $current_page)->rel(), 'SORT_SUBSCRIBERS_TOP' => NewsletterUrlBuilder::archives($this->stream->get_id(), $this->stream->get_rewrited_name(), 'subscribers', 'top', $current_page)->rel(), 'SORT_SUBSCRIBERS_BOTTOM' => NewsletterUrlBuilder::archives($this->stream->get_id(), $this->stream->get_rewrited_name(), 'subscribers', 'bottom', $current_page)->rel(), 'PAGINATION' => $pagination->display())); $result = PersistenceContext::get_querier()->select("SELECT *\n\t\tFROM " . NewsletterSetup::$newsletter_table_archives . "\n\t\t" . $stream_condition . "\n\t\tORDER BY " . $field_bdd . " " . $mode . "\n\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()) { $stream = NewsletterStreamsCache::load()->get_stream($row['stream_id']); $this->view->assign_block_vars('archives_list', array('STREAM_NAME' => $stream->get_name(), 'SUBJECT' => $row['subject'], 'DATE' => Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'NBR_SUBSCRIBERS' => $row['nbr_subscribers'], 'U_VIEW_STREAM' => NewsletterUrlBuilder::archives($stream->get_id(), $this->stream->get_rewrited_name())->rel(), 'U_VIEW_ARCHIVE' => NewsletterUrlBuilder::archive($row['id'])->rel(), 'U_DELETE_ARCHIVE' => NewsletterUrlBuilder::delete_archive($row['id'], $stream->get_id())->rel())); } $result->dispose(); }
private function build_table() { $number_admins = UserService::count_admin_members(); $table_model = new SQLHTMLTableModel(DB_TABLE_MEMBER, 'table', array(new HTMLTableColumn($this->lang['display_name'], 'display_name'), new HTMLTableColumn($this->lang['level'], 'level'), new HTMLTableColumn($this->lang['email']), new HTMLTableColumn($this->lang['registration_date'], 'registration_date'), new HTMLTableColumn($this->lang['last_connection'], 'last_connection_date'), new HTMLTableColumn($this->lang['approbation'], 'approved'), new HTMLTableColumn('')), new HTMLTableSortingRule('display_name', HTMLTableSortingRule::ASC)); $table = new HTMLTable($table_model); $table_model->set_caption(LangLoader::get_message('members.members-management', 'admin-user-common')); $results = array(); $result = $table_model->get_sql_results('m LEFT JOIN ' . DB_TABLE_INTERNAL_AUTHENTICATION . ' ia ON ia.user_id = m.user_id'); foreach ($result as $row) { $user = new User(); $user->set_properties($row); $edit_link = new LinkHTMLElement(UserUrlBuilder::edit_profile($user->get_id()), '', array('title' => LangLoader::get_message('edit', 'common')), 'fa fa-edit'); if ($user->get_level() != User::ADMIN_LEVEL || $user->get_level() == User::ADMIN_LEVEL && $number_admins > 1) { $delete_link = new LinkHTMLElement(AdminMembersUrlBuilder::delete($user->get_id()), '', array('title' => LangLoader::get_message('delete', 'common'), 'data-confirmation' => 'delete-element'), 'fa fa-delete'); } else { $delete_link = new LinkHTMLElement('', '', array('title' => LangLoader::get_message('delete', 'common'), 'onclick' => 'return false;'), 'fa fa-delete icon-disabled'); } $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true); $results[] = new HTMLTableRow(array(new HTMLTableRowCell(new LinkHTMLElement(UserUrlBuilder::profile($user->get_id()), $user->get_display_name(), !empty($user_group_color) ? array('style' => 'color: ' . $user_group_color) : array(), UserService::get_level_class($user->get_level()))), new HTMLTableRowCell(UserService::get_level_lang($user->get_level())), new HTMLTableRowCell(new LinkHTMLElement('mailto:' . $user->get_email(), $this->lang['email'], array(), 'basic-button smaller')), new HTMLTableRowCell(Date::to_format($row['registration_date'], Date::FORMAT_DAY_MONTH_YEAR)), new HTMLTableRowCell(!empty($row['last_connection_date']) ? Date::to_format($row['last_connection_date'], Date::FORMAT_DAY_MONTH_YEAR) : LangLoader::get_message('never', 'main')), new HTMLTableRowCell($row['approved'] ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common')), new HTMLTableRowCell($edit_link->display() . $delete_link->display()))); } $table->set_rows($table_model->get_number_of_matching_rows(), $results); $this->view->put_all(array('FORM' => $this->build_form()->display(), 'table' => $table->display())); }
* * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ require_once '../kernel/begin.php'; require_once '../forum/forum_begin.php'; require_once '../forum/forum_tools.php'; $Bread_crumb->add($config->get_forum_name(), 'index.php'); $Bread_crumb->add($LANG['stats'], ''); define('TITLE', $LANG['stats']); require_once '../kernel/header.php'; $tpl = new FileTemplate('forum/forum_stats.tpl'); $total_day = NumberHelper::round((time() - GeneralConfig::load()->get_site_install_date()->get_timestamp()) / (3600 * 24), 0); $timestamp_today = @mktime(0, 0, 1, Date::to_format(Date::DATE_NOW, 'm'), Date::to_format(Date::DATE_NOW, 'd'), Date::to_format(Date::DATE_NOW, 'y')); $total_topics = PersistenceContext::get_querier()->count(ForumSetup::$forum_topics_table); $total_messages = PersistenceContext::get_querier()->count(ForumSetup::$forum_message_table); $total_day = max(1, $total_day); $nbr_topics_day = NumberHelper::round($total_topics / $total_day, 1); $nbr_msg_day = NumberHelper::round($total_messages / $total_day, 1); $row = PersistenceContext::get_querier()->select_single_row_query("SELECT COUNT(*) as nbr_topics_today\nFROM " . ForumSetup::$forum_topics_table . " t\nJOIN " . ForumSetup::$forum_message_table . " m ON m.id = t.first_msg_id\nWHERE m.timestamp > :timestamp", array('timestamp' => $timestamp_today)); $nbr_topics_today = $row['nbr_topics_today']; $nbr_msg_today = PersistenceContext::get_querier()->count(ForumSetup::$forum_message_table, 'WHERE timestamp > :timestamp', array('timestamp' => $timestamp_today)); $vars_tpl = array('FORUM_NAME' => $config->get_forum_name(), 'NBR_TOPICS' => $total_topics, 'NBR_MSG' => $total_messages, 'NBR_TOPICS_DAY' => $nbr_topics_day, 'NBR_MSG_DAY' => $nbr_msg_day, 'NBR_TOPICS_TODAY' => $nbr_topics_today, 'NBR_MSG_TODAY' => $nbr_msg_today, 'L_FORUM_INDEX' => $LANG['forum_index'], 'L_FORUM' => $LANG['forum'], 'L_STATS' => $LANG['stats'], 'L_NBR_TOPICS' => $total_topics > 1 ? $LANG['topic_s'] : $LANG['topic'], 'L_NBR_MSG' => $total_messages > 1 ? $LANG['message_s'] : $LANG['message'], 'L_NBR_TOPICS_DAY' => $LANG['nbr_topics_day'], 'L_NBR_MSG_DAY' => $LANG['nbr_msg_day'], 'L_NBR_TOPICS_TODAY' => $LANG['nbr_topics_today'], 'L_NBR_MSG_TODAY' => $LANG['nbr_msg_today'], 'L_LAST_MSG' => $LANG['forum_last_msg'], 'L_POPULAR' => $LANG['forum_popular'], 'L_ANSWERS' => $LANG['forum_nbr_answers']); //Vérification des autorisations. $authorized_categories = ForumService::get_authorized_categories(Category::ROOT_CATEGORY); //Dernières réponses $result = PersistenceContext::get_querier()->select("SELECT t.id, t.title, c.id as cid, c.auth\nFROM " . PREFIX . "forum_topics t\nLEFT JOIN " . PREFIX . "forum_cats c ON c.id = t.idcat\nWHERE c.id_parent != 0 AND c.id IN :authorized_categories\nORDER BY t.last_timestamp DESC\nLIMIT 10", array('authorized_categories' => $authorized_categories)); while ($row = $result->fetch()) { $tpl->assign_block_vars('last_msg', array('U_TOPIC_ID' => url('.php?id=' . $row['id'], '-' . $row['id'] . '.php'), 'TITLE' => stripslashes($row['title'])));
$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 (!empty($keyword)) { include_once PATH_TO_ROOT . '/stats/stats_functions.php'; $nbr_keyword = $db_querier->count(StatsSetup::$stats_referer_table, 'WHERE type = 1', array(), '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 = $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\n\t\tFROM " . PREFIX . "stats_referer\n\t\tWHERE type = 1\n\t\tGROUP BY relative_url\n\t\tORDER BY total_visit DESC\n\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 (!empty($browser) || !empty($os) || !empty($user_lang)) { if (!empty($browser)) { $tpl->put_all(array('C_STATS_BROWSERS' => true, 'GRAPH_RESULT' => '<img src="display_stats.php?browsers=1" 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' => '<img src="display_stats.php?os=1" 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)) {
//Si le dernier message lu est présent on redirige vers lui, sinon on redirige vers le dernier posté. if (!empty($row['last_view_id'])) { $last_msg_id = $row['last_view_id']; $last_page = 'idm=' . $row['last_view_id'] . '&'; $last_page_rewrite = '-0-' . $row['last_view_id']; } else { $last_msg_id = $row['last_msg_id']; $last_page = ceil($row['nbr_msg'] / $config->get_number_messages_per_page()); $last_page_rewrite = $last_page > 1 ? '-' . $last_page : ''; $last_page = $last_page > 1 ? 'pt=' . $last_page . '&' : ''; } //On encode l'url pour un éventuel rewriting, c'est une opération assez gourmande $rewrited_title = ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? '+' . Url::encode_rewrite($row['title']) : ''; //Affichage du dernier message posté. $last_group_color = User::get_group_color($row['last_user_groups'], $row['last_user_level']); $last_msg = '<a href="topic' . url('.php?' . $last_page . 'id=' . $row['id'], '-' . $row['id'] . $last_page_rewrite . $rewrited_title . '.php') . '#m' . $last_msg_id . '" title=""><i class="fa fa-hand-o-right"></i></a>' . ' ' . $LANG['on'] . ' ' . Date::to_format($row['last_timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '<br /> ' . $LANG['by'] . ' ' . (!empty($row['last_login']) ? '<a class="small ' . UserService::get_level_class($row['last_user_level']) . '"' . (!empty($last_group_color) ? ' style="color:' . $last_group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($row['last_user_id'])->rel() . '">' . TextHelper::wordwrap_html($row['last_login'], 13) . '</a>' : '<em>' . $LANG['guest'] . '</em>'); //Ancre ajoutée aux messages non lus. $new_ancre = '<a href="topic' . url('.php?' . $last_page . 'id=' . $row['id'], '-' . $row['id'] . $last_page_rewrite . $rewrited_title . '.php') . '#m' . $last_msg_id . '" title=""><i class="fa fa-hand-o-right"></i></a>'; //On crée une pagination (si activé) si le nombre de topics est trop important. $page = AppContext::get_request()->get_getint('pt', 1); $topic_pagination = new ModulePagination($page, $row['nbr_msg'], $config->get_number_messages_per_page(), Pagination::LIGHT_PAGINATION); $topic_pagination->set_url(new Url('/forum/topic.php?id=' . $row['id'] . '&pt=%d')); $group_color = User::get_group_color($row['groups'], $row['user_level']); $tpl->assign_block_vars('topics', array('C_PAGINATION' => $topic_pagination->has_several_pages(), 'C_IMG_POLL' => !empty($row['question']), 'C_IMG_TRACK' => !empty($row['idtrack']), 'C_DISPLAY_MSG' => $config->is_message_before_topic_title_displayed() && $config->is_message_before_topic_title_icon_displayed() && $row['display_msg'], 'C_HOT_TOPIC' => $row['type'] == '0' && $row['status'] != '0' && $row['nbr_msg'] > $config->get_number_messages_per_page(), 'C_BLINK' => $blink, 'IMG_ANNOUNCE' => $img_announce, 'ANCRE' => $new_ancre, 'TYPE' => $type[$row['type']], 'TITLE' => stripslashes($row['title']), 'AUTHOR' => !empty($row['login']) ? '<a href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '" class="small ' . UserService::get_level_class($row['user_level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['login'] . '</a>' : '<em>' . $LANG['guest'] . '</em>', 'DESC' => $row['subtitle'], 'PAGINATION' => $topic_pagination->display(), 'MSG' => $row['nbr_msg'] - 1, 'VUS' => $row['nbr_views'], 'U_TOPIC_VARS' => url('.php?id=' . $row['id'], '-' . $row['id'] . $rewrited_title . '.php'), 'U_LAST_MSG' => $last_msg, 'L_DISPLAY_MSG' => $config->is_message_before_topic_title_displayed() && $row['display_msg'] ? $config->get_message_before_topic_title() : '')); } $result->dispose(); //Le membre a déjà lu tous les messages. if ($nbr_topics == 0) { $tpl->put_all(array('C_NO_TOPICS' => true, 'L_NO_TOPICS' => '0 ' . $LANG['no_last_read'])); } //Listes les utilisateurs en lignes.
} elseif (!empty($row['login'])) { $author = '<a href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '" class="small ' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['login'] . '</a>'; } else { $author = '<strike>' . $LANG['guest'] . '</strike>'; } $participants = $row['login_dest'] != $current_user->get_display_name() ? $row['login_dest'] : $author; $user_id_dest = $row['user_id_dest'] != $current_user->get_id() ? $row['user_id_dest'] : $row['user_id']; $participants_group_color = $participants != $LANG['admin'] && $participants != '<strike>' . $LANG['guest'] . '</strike>' ? User::get_group_color($row['dest_groups'], $row['dest_level']) : ''; switch ($author) { case $LANG['admin']: $participants_level_class = UserService::get_level_class(User::ADMIN_LEVEL); break; case '<strike>' . $LANG['guest'] . '</strike>': $participants_level_class = ''; break; default: $participants_level_class = UserService::get_level_class($row['dest_level']); break; } $participants = !empty($participants) ? '<a href="' . UserUrlBuilder::profile($user_id_dest)->rel() . '" class="' . $participants_level_class . '"' . (!empty($participants_group_color) ? ' style="color:' . $participants_group_color . '"' : '') . '>' . $participants . '</a>' : '<strike>' . $LANG['admin'] . '</strike>'; //Affichage du dernier message posté. $last_group_color = User::get_group_color($row['last_groups'], $row['last_level']); $last_msg = '<a href="pm' . url('.php?' . $last_page . 'id=' . $row['id'], '-0-' . $row['id'] . $last_page_rewrite . '.php') . '#m' . $row['last_msg_id'] . '" title="" class="fa fa-hand-o-right"></a>' . ' ' . $LANG['on'] . ' ' . Date::to_format($row['last_timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '<br />'; $last_msg .= $row['user_id'] == -1 ? $LANG['by'] . ' ' . $LANG['admin'] : $LANG['by'] . ' <a href="' . UserUrlBuilder::profile($row['last_user_id'])->rel() . '" class="small ' . UserService::get_level_class($row['last_level']) . '"' . (!empty($last_group_color) ? ' style="color:' . $last_group_color . '"' : '') . '>' . $row['last_login'] . '</a>'; $tpl->assign_block_vars('convers.list', array('INCR' => $i, 'ID' => $row['id'], 'ANNOUNCE' => $announce, 'TITLE' => $row['title'], 'MSG' => $row['nbr_msg'] - 1, 'U_PARTICIPANTS' => $row['user_convers_status'] != 0 ? '<strike>' . $participants . '</strike>' : $participants, 'U_CONVERS' => url('.php?id=' . $row['id'], '-0-' . $row['id'] . '.php'), 'U_AUTHOR' => $LANG['by'] . ' ' . $author, 'U_LAST_MSG' => $last_msg)); $i++; } $result->dispose(); $tpl->display(); } include '../kernel/footer.php';
$tpl->put_all(array('L_INFO' => $LANG['db_empty_dir'])); } else { $tpl->put_all(array('C_FILES' => true, 'L_INFO' => $LANG['db_restore_file'])); foreach ($filelist as $file) { $tpl->assign_block_vars('file', array('FILE_NAME' => $file['file_name'], 'WEIGHT' => $file['weight'], 'FILE_DATE' => $file['file_date'])); } } } else { //Sauvegarde if ($action == 'backup') { $backup_type = $request->has_postparameter('backup_type') && $request->get_postvalue('backup_type') != 'all' ? $request->get_postvalue('backup_type') == 'data' ? DBMSUtils::DUMP_DATA : DBMSUtils::DUMP_STRUCTURE : DBMSUtils::DUMP_STRUCTURE_AND_DATA; $selected_tables = $request->get_postarray('table_list'); if (empty($selected_tables)) { AppContext::get_response()->redirect(HOST . DIR . url('/database/admin_database.php?error=empty_list')); } $file_name = 'backup_' . PersistenceContext::get_dbms_utils()->get_database_name() . '_' . str_replace('/', '-', Date::to_format(Date::DATE_NOW, 'y-m-d-H-i-s')) . '.sql'; $file_path = PATH_TO_ROOT . '/cache/backup/' . $file_name; Environment::try_to_increase_max_execution_time(); PersistenceContext::get_dbms_utils()->dump_tables(new BufferedFileWriter(new File($file_path)), $selected_tables, $backup_type); AppContext::get_response()->redirect(HOST . DIR . url('/database/admin_database.php?error=backup_success&file=' . $file_name)); } if ($tables_backup) { $tables = PersistenceContext::get_dbms_utils()->list_tables(true); $tpl->put_all(array('C_DATABASE_BACKUP' => true, 'NBR_TABLES' => count($tables), 'TARGET' => url('admin_database.php?token=' . AppContext::get_session()->get_token()), 'SELECT_ALL' => $LANG['select_all'], 'SELECT_NONE' => $LANG['select_none'], 'L_BACKUP_DATABASE' => $LANG['db_backup_database'], 'L_EXPLAIN_BACKUP' => $LANG['db_backup_explain'], 'L_SELECTION' => $LANG['db_selected_tables'], 'L_BACKUP_ALL' => $LANG['db_backup_all'], 'L_BACKUP_STRUCT' => $LANG['db_backup_struct'], 'L_BACKUP_DATA' => $LANG['db_backup_data'], 'L_BACKUP' => $LANG['db_backup'])); $selected_tables = array(); $i = 0; foreach ($tables as $table) { if ($table == $get_table || $request->has_postparameter('table_' . $table) && $request->get_postvalue('table_' . $table) == 'on') { $selected_tables[] = $table; } $tpl->assign_block_vars('table_list', array('NAME' => $table, 'SELECTED' => in_array($table, $selected_tables) ? 'selected="selected"' : '', 'I' => $i));
$pagination = new ModulePagination($page, $nbrarchives, $_NBR_ELEMENTS_PER_PAGE); $pagination->set_url(new Url('/poll/poll.php?p=%d')); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $tpl->put_all(array('C_POLL_ARCHIVES' => true, 'C_IS_ADMIN' => AppContext::get_current_user()->check_level(User::ADMIN_LEVEL), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_ARCHIVE' => $LANG['archives'], 'L_BACK_POLL' => $LANG['poll_back'], 'L_ON' => $LANG['on'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_DELETE' => LangLoader::get_message('delete', 'common'))); //On recupère les sondages archivés. $result = PersistenceContext::get_querier()->select("SELECT id, question, votes, answers, type, timestamp\n\tFROM " . PREFIX . "poll\n\tWHERE archive = 1 AND visible = 1\n\tORDER BY timestamp DESC\n\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()) { $array_answer = explode('|', $row['answers']); $array_vote = explode('|', $row['votes']); $sum_vote = array_sum($array_vote); $sum_vote = $sum_vote == 0 ? 1 : $sum_vote; //Empêche la division par 0. $tpl->assign_block_vars('list', array('ID' => $row['id'], 'QUESTION' => stripslashes($row['question']), 'EDIT' => '<a href="' . PATH_TO_ROOT . '/poll/admin_poll' . url('.php?id=' . $row['id']) . '" title="' . LangLoader::get_message('edit', 'common') . '" class="fa fa-edit"></a>', 'DEL' => ' <a href="' . PATH_TO_ROOT . '/poll/admin_poll' . url('.php?delete=1&id=' . $row['id']) . '" title="' . LangLoader::get_message('delete', 'common') . '" class="fa fa-delete" data-confirmation="delete-element"></a>', 'VOTE' => $sum_vote, 'DATE' => Date::to_format(Date::DATE_NOW, Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'L_VOTE' => $sum_vote > 1 ? $LANG['poll_vote_s'] : $LANG['poll_vote'])); $array_poll = array_combine($array_answer, $array_vote); foreach ($array_poll as $answer => $nbrvote) { $tpl->assign_block_vars('list.result', array('ANSWERS' => $answer, 'NBRVOTE' => $nbrvote, 'WIDTH' => NumberHelper::round($nbrvote * 100 / $sum_vote, 1) * 4, 'PERCENT' => NumberHelper::round($nbrvote * 100 / $sum_vote, 1), 'L_VOTE' => $nbrvote > 1 ? $LANG['poll_vote_s'] : $LANG['poll_vote'])); } } $result->dispose(); $tpl->display(); } else { $modulesLoader = AppContext::get_extension_provider_service(); $module = $modulesLoader->get_provider('poll'); if ($module->has_extension_point(HomePageExtensionPoint::EXTENSION_POINT)) { echo $module->get_extension_point(HomePageExtensionPoint::EXTENSION_POINT)->get_home_page()->get_view()->display(); } } require_once '../kernel/footer.php';
$tpl->assign_block_vars('list', array('TITLE' => $LANG['wiki_consult_article'], 'AUTHOR' => !empty($row['login']) ? '<a href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '" class="' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['login'] . '</a>' : $row['user_ip'], 'DATE' => Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'U_ARTICLE' => $row['activ'] == 1 ? url('wiki.php?title=' . $row['encoded_title'], $row['encoded_title']) : url('wiki.php?id_contents=' . $row['id_contents']), 'CURRENT_RELEASE' => $row['activ'] == 1 ? '(' . $LANG['wiki_current_version'] . ')' : '', 'ACTIONS' => !empty($actions) ? $actions : $LANG['wiki_no_possible_action'])); } $result->dispose(); $tpl->put_all(array('L_VERSIONS' => $LANG['wiki_version_list'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_AUTHOR' => $LANG['wiki_author'], 'L_ACTIONS' => $LANG['wiki_possible_actions'])); $tpl->display(); } else { $_WIKI_NBR_ARTICLES_A_PAGE_IN_HISTORY = 25; //Champs sur lesquels on ordonne $field = $field == 'title' ? 'title' : 'timestamp'; $order = $order == 'asc' ? 'asc' : 'desc'; //On compte le nombre d'articles $nbr_articles = PersistenceContext::get_querier()->count(PREFIX . "wiki_articles", 'WHERE redirect = 0'); //On instancie la classe de pagination $page = AppContext::get_request()->get_getint('p', 1); $pagination = new ModulePagination($page, $nbr_articles, $_WIKI_NBR_ARTICLES_A_PAGE_IN_HISTORY); $pagination->set_url(new Url('/wiki/history.php?field=' . $field . '&order=' . $order . '&p=%d')); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $tpl = new FileTemplate('wiki/history.tpl'); $tpl->put_all(array('C_PAGINATION' => $pagination->has_several_pages(), 'L_HISTORY' => $LANG['wiki_history'], 'L_TITLE' => $LANG['wiki_article_title'], 'L_AUTHOR' => $LANG['wiki_author'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'TOP_TITLE' => $field == 'title' && $order == 'asc' ? '' : url('history.php?p=' . $page . '&field=title&order=asc'), 'BOTTOM_TITLE' => $field == 'title' && $order == 'desc' ? '' : url('history.php?p=' . $page . '&field=title&order=desc'), 'TOP_DATE' => $field == 'timestamp' && $order == 'asc' ? '' : url('history.php?p=' . $page . '&field=timestamp&order=asc'), 'BOTTOM_DATE' => $field == 'timestamp' && $order == 'desc' ? '' : url('history.php?p=' . $page . '&field=timestamp&order=desc'), 'PAGINATION' => $pagination->display())); $result = PersistenceContext::get_querier()->select("SELECT a.title, a.encoded_title, c.timestamp, c.id_contents AS id, c.user_id, c.user_ip, m.display_name, m.groups, m.level, c.id_article, c.activ, a.id_contents\n\t\tFROM " . PREFIX . "wiki_articles a\n\t\tLEFT JOIN " . PREFIX . "wiki_contents c ON c.id_contents = a.id_contents\n\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = c.user_id\n\t\tWHERE a.redirect = 0\n\t\tORDER BY " . ($field == 'title' ? 'a' : 'c') . "." . $field . " " . $order . "\n\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()) { $group_color = User::get_group_color($row['groups'], $row['level']); $tpl->assign_block_vars('list', array('TITLE' => stripslashes($row['title']), 'AUTHOR' => !empty($row['login']) ? '<a href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '" class="' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['login'] . '</a>' : $row['user_ip'], 'DATE' => Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'U_ARTICLE' => url('wiki.php?title=' . $row['encoded_title'], $row['encoded_title']))); } $result->dispose(); $tpl->display(); } require_once '../kernel/footer.php';
} foreach ($table_structure['fields'] as $fields_info) { $primary_key = false; foreach ($table_structure['index'] as $index_info) { if ($index_info['type'] == 'PRIMARY KEY' && in_array($fields_info['name'], explode(',', $index_info['fields']))) { $primary_key = true; break; } } //Champs. $tpl->assign_block_vars('field', array('FIELD_NAME' => $primary_key ? '<span style="text-decoration:underline">' . $fields_info['name'] . '<span>' : $fields_info['name'], 'FIELD_TYPE' => $fields_info['type'], 'FIELD_ATTRIBUTE' => $fields_info['attribute'], 'FIELD_NULL' => $fields_info['null'] ? '<strong>' . LangLoader::get_message('yes', 'common') . '</strong>' : LangLoader::get_message('no', 'common'), 'FIELD_DEFAULT' => $fields_info['default'], 'FIELD_EXTRA' => $fields_info['extra'])); } //index foreach ($table_structure['index'] as $index_info) { $tpl->assign_block_vars('index', array('INDEX_NAME' => $index_info['name'], 'INDEX_TYPE' => $index_info['type'], 'INDEX_FIELDS' => str_replace(',', '<br />', $index_info['fields']))); } //Infos sur la table. $free = NumberHelper::round($backup->tables[$table]['data_free'] / 1024, 1); $data = NumberHelper::round($backup->tables[$table]['data_length'] / 1024, 1); $index = NumberHelper::round($backup->tables[$table]['index_length'] / 1024, 1); $total = $index + $data; $l_total = $total > 1024 ? NumberHelper::round($total / 1024, 1) . ' MB' : $total . ' kB'; $free = $free > 1024 ? NumberHelper::round($free / 1024, 1) . ' MB' : $free . ' kB'; $data = $data > 1024 ? NumberHelper::round($data / 1024, 1) . ' MB' : $data . ' kB'; $index = $index > 1024 ? NumberHelper::round($index / 1024, 1) . ' MB' : $index . ' kB'; $tpl->put_all(array('C_DATABASE_TABLE_STRUCTURE' => true, 'C_DATABASE_TABLE_DATA' => false, 'C_AUTOINDEX' => !empty($backup->tables[$table]['auto_increment']) ? true : false, 'TABLE_ENGINE' => $backup->tables[$table]['engine'], 'TABLE_ROW_FORMAT' => $backup->tables[$table]['row_format'], 'TABLE_ROWS' => $backup->tables[$table]['rows'], 'TABLE_DATA' => $data != 0 ? $data : '-', 'TABLE_INDEX' => $index != 0 ? $index : '-', 'TABLE_TOTAL_SIZE' => $total != 0 ? $l_total : '-', 'TABLE_FREE' => $free != 0 ? '<span style="color:red">' . $free . '</span>' : '-', 'TABLE_COLLATION' => $backup->tables[$table]['collation'], 'TABLE_AUTOINCREMENT' => $backup->tables[$table]['auto_increment'], 'TABLE_CREATION_DATE' => Date::to_format(strtotime($backup->tables[$table]['create_time'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), 'TABLE_LAST_UPDATE' => Date::to_format(strtotime($backup->tables[$table]['update_time'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE)), 'L_TABLE_FIELD' => $LANG['db_table_field'], 'L_TABLE_TYPE' => $LANG['type'], 'L_TABLE_ATTRIBUTE' => $LANG['db_table_attribute'], 'L_TABLE_NULL' => $LANG['db_table_null'], 'L_TABLE_DEFAULT' => $LANG['default'], 'L_TABLE_EXTRA' => $LANG['db_table_extra'], 'L_TABLE_NAME' => $LANG['db_table_name'], 'L_TABLE_ROWS' => $LANG['db_table_rows'], 'L_TABLE_ROWS_FORMAT' => $LANG['db_table_rows_format'], 'L_TABLE_ENGINE' => $LANG['db_table_engine'], 'L_TABLE_COLLATION' => $LANG['db_table_collation'], 'L_TABLE_DATA' => $LANG['db_table_data'], 'L_TABLE_TOTAL' => $LANG['total'], 'L_INDEX_NAME' => $LANG['name'], 'L_TABLE_INDEX' => $LANG['db_table_index'], 'L_TABLE_FREE' => $LANG['db_table_free'], 'L_STATISTICS' => $LANG['stats'], 'L_OPTIMIZE' => $LANG['db_optimize'], 'L_AUTOINCREMENT' => $LANG['db_autoincrement'], 'L_LAST_UPDATE' => $LANG['last_update'], 'L_CREATION_DATE' => $LANG['creation_date'], 'L_OPTIMIZE' => $LANG['db_optimize'], 'L_SIZE' => $LANG['size'])); } else { AppContext::get_response()->redirect('/database/admin_database.php'); } $tpl->display(); require_once '../admin/admin_footer.php';
/** * @desc Return the string to print the result * @param &string[] $result_data the result's data * @return string[] The string to print the result of a search element */ public function parse_search_result($result_data) { global $LANG; load_module_lang('forum'); //Chargement de la langue du module. $tpl = new FileTemplate('forum/forum_generic_results.tpl'); $tpl->put_all(array('L_ON' => $LANG['on'], 'L_TOPIC' => $LANG['topic'])); $rewrited_title = ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? '+' . Url::encode_rewrite($result_data['title']) : ''; $tpl->put_all(array('USER_ONLINE' => '<i class="fa ' . (!empty($result_data['connect']) && $result_data['user_id'] !== -1 ? 'fa-online' : 'fa-offline') . '"></i>', 'U_USER_PROFILE' => !empty($result_data['user_id']) ? UserUrlBuilder::profile($result_data['user_id'])->rel() : '', 'USER_PSEUDO' => !empty($result_data['display_name']) ? TextHelper::wordwrap_html($result_data['display_name'], 13) : $LANG['guest'], 'U_TOPIC' => PATH_TO_ROOT . '/forum/topic' . url('.php?id=' . $result_data['topic_id'], '-' . $result_data['topic_id'] . $rewrited_title . '.php') . '#m' . $result_data['msg_id'], 'TITLE' => stripslashes($result_data['title']), 'DATE' => Date::to_format($result_data['date'], 'd/m/y'), 'CONTENTS' => FormatingHelper::second_parse(stripslashes($result_data['contents'])), 'USER_AVATAR' => '<img src="' . (UserAccountsConfig::load()->is_default_avatar_enabled() && !empty($result_data['avatar']) ? $result_data['avatar'] : PATH_TO_ROOT . '/templates/' . AppContext::get_current_user()->get_theme() . '/images/' . UserAccountsConfig::load()->get_default_avatar_name()) . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" class="message-avatar"/>')); return $tpl->render(); }
private static function compute_error_log_string($error_msg, $error_stacktrace, $errno = 0) { return Date::to_format(time(), 'Y-m-d H:i:s', Timezone::SERVER_TIMEZONE) . "\n" . $errno . "\n" . self::clean_error_string($error_msg) . "\n" . self::clean_error_string($error_stacktrace) . "\n"; }
if (!empty($row['last_view_id'])) { $last_msg_id = $row['last_view_id']; $last_page = 'idm=' . $row['last_view_id'] . '&'; $last_page_rewrite = '-0-' . $row['last_view_id']; } else { $last_msg_id = $row['last_msg_id']; $last_page = ceil($row['t_nbr_msg'] / $config->get_number_messages_per_page()); $last_page_rewrite = $last_page > 1 ? '-' . $last_page : ''; $last_page = $last_page > 1 ? 'pt=' . $last_page . '&' : ''; } $last_topic_title = ($config->is_message_before_topic_title_displayed() && $row['display_msg'] ? $config->get_message_before_topic_title() : '') . ' ' . $row['title']; $last_topic_title = strlen(TextHelper::html_entity_decode($last_topic_title)) > 25 ? TextHelper::substr_html($last_topic_title, 0, 25) . '...' : $last_topic_title; $last_topic_title = addslashes($last_topic_title); $row['login'] = !empty($row['login']) ? $row['login'] : $LANG['guest']; $group_color = User::get_group_color($row['groups'], $row['user_level']); $contents .= '<tr><td class="forum-notread" style="width:100%"><a href="topic' . url('.php?' . $last_page . 'id=' . $row['tid'], '-' . $row['tid'] . $last_page_rewrite . '+' . addslashes(Url::encode_rewrite($row['title'])) . '.php') . '#m' . $last_msg_id . '"><i class="fa fa-hand-o-right"></i></a> <a href="topic' . url('.php?id=' . $row['tid'], '-' . $row['tid'] . '+' . addslashes(Url::encode_rewrite($row['title'])) . '.php') . '" class="small">' . $last_topic_title . '</a></td><td class="forum-notread" style="white-space:nowrap">' . ($row['last_user_id'] != '-1' ? '<a href="' . UserUrlBuilder::profile($row['last_user_id'])->rel() . '" class="small ' . UserService::get_level_class($row['user_level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . addslashes($row['login']) . '</a>' : '<em>' . addslashes($LANG['guest']) . '</em>') . '</td><td class="forum-notread" style="white-space:nowrap">' . Date::to_format($row['last_timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '</td></tr>'; $nbr_msg_not_read++; } $result->dispose(); $max_visible_topics = 10; $height_visible_topics = $nbr_msg_not_read < $max_visible_topics ? 23 * $nbr_msg_not_read : 23 * $max_visible_topics; echo "array_unread_topics[0] = '" . $nbr_msg_not_read . "';\n"; echo "array_unread_topics[1] = '" . '<a class="small" href="' . PATH_TO_ROOT . '/forum/unread.php" title="' . addslashes($LANG['show_not_reads']) . '">' . addslashes($LANG['show_not_reads']) . (AppContext::get_current_user()->get_id() !== -1 ? ' (' . $nbr_msg_not_read . ')' : '') . '</a>' . "';\n"; echo "array_unread_topics[2] = '" . '<div style="width:438px;height:' . max($height_visible_topics, 65) . 'px;overflow:auto;padding:0px;" onmouseover="forum_hide_block(\\\'forum_unread\\\', 1);" onmouseout="forum_hide_block(\\\'forum_unread\\\', 0);"><table class="module-table" style="margin:2px;width:99%">' . $contents . "</table></div>';"; } else { echo ''; } } elseif (retrieve(GET, 'del', false)) { AppContext::get_session()->csrf_get_protect(); //Protection csrf //Instanciation de la class du forum.
DispatchManager::redirect($error_controller); } $tpl->put_all(array('C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_POLL_MANAGEMENT' => $LANG['poll_management'], 'L_POLL_ADD' => $LANG['poll_add'], 'L_POLL_CONFIG' => $LANG['poll_config'], 'L_REQUIRE' => LangLoader::get_message('form.explain_required_fields', 'status-messages-common'), 'L_QUESTION' => $LANG['question'], 'L_POLLS' => $LANG['polls'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_PSEUDO' => LangLoader::get_message('author', 'common'), 'L_APROB' => $LANG['aprob'], 'L_UPDATE' => $LANG['update'])); $result = PersistenceContext::get_querier()->select("SELECT p.id, p.question, p.archive, p.timestamp, p.visible, p.start, p.end, p.user_id, m.display_name, m.groups, m.level\n\tFROM " . PREFIX . "poll p\n\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON p.user_id = m.user_id\n\tORDER BY p.timestamp DESC \n\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()) { if ($row['visible'] == 2) { $aprob = $LANG['waiting']; } elseif ($row['visible'] == 1) { $aprob = LangLoader::get_message('yes', 'common'); } else { $aprob = LangLoader::get_message('no', 'common'); } $archive = $row['archive'] == 1 ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common'); //On reccourci le lien si il est trop long pour éviter de déformer l'administration. $question = stripslashes(strlen($row['question']) > 45 ? substr($row['question'], 0, 45) . '...' : $row['question']); $visible = ''; if ($row['start'] > 0) { $visible .= Date::to_format($row['start'], Date::FORMAT_DAY_MONTH_YEAR); } if ($row['end'] > 0 && $row['start'] > 0) { $visible .= ' ' . strtolower($LANG['until']) . ' ' . Date::to_format($row['end'], Date::FORMAT_DAY_MONTH_YEAR); } elseif ($row['end'] > 0) { $visible .= $LANG['until'] . ' ' . Date::to_format($row['end'], Date::FORMAT_DAY_MONTH_YEAR); } $group_color = User::get_group_color($row['groups'], $row['level']); $tpl->assign_block_vars('questions', array('C_USER_GROUP_COLOR' => !empty($group_color), 'QUESTIONS' => $question, 'IDPOLL' => $row['id'], 'PSEUDO' => $row['display_name'], 'USER_GROUP_COLOR' => $group_color, 'USER_LEVEL_CLASS' => UserService::get_level_class($row['level']), 'DATE' => Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'ARCHIVES' => $archive, 'APROBATION' => $aprob, 'VISIBLE' => !empty($visible) ? '(' . $visible . ')' : '', 'U_AUTHOR_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel())); } $result->dispose(); $tpl->display(); } require_once '../admin/admin_footer.php';
bread_crumb($media['idcat']); $Bread_crumb->add($media['name'], url('media.php?id=' . $id_media, 'media-' . $id_media . '-' . $media['idcat'] . '+' . Url::encode_rewrite($media['name']) . '.php')); define('TITLE', $media['name']); require_once '../kernel/header.php'; //MAJ du compteur. PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "media SET counter = counter + 1 WHERE id = :id", array('id' => $id_media)); $notation = new Notation(); $notation->set_module_name('media'); $notation->set_notation_scale($config->get_notation_scale()); $notation->set_id_in_module($id_media); $notation->set_number_notes($media['number_notes']); $notation->set_average_notes($media['average_notes']); $notation->set_user_already_noted(!empty($media['note'])); $nbr_notes = $media['number_notes']; $group_color = User::get_group_color($media['groups'], $media['level']); $tpl->put_all(array('ID' => $id_media, 'C_DISPLAY_MEDIA' => true, 'C_ROOT_CATEGORY' => $media['idcat'] == Category::ROOT_CATEGORY, 'C_MODO' => MediaAuthorizationsService::check_authorizations($media['idcat'])->moderation(), 'C_DISPLAY_NOTATION' => $config->is_notation_enabled(), 'C_DISPLAY_COMMENTS' => $config->are_comments_enabled(), 'ID_MEDIA' => $id_media, 'NAME' => $media['name'], 'CONTENTS' => stripslashes(FormatingHelper::second_parse($media['contents'])), 'COUNT' => $media['counter'], 'KERNEL_NOTATION' => NotationService::display_active_image($notation), 'HITS' => (int) $media['counter'] + 1 > 1 ? sprintf($MEDIA_LANG['n_times'], (int) $media['counter'] + 1) : sprintf($MEDIA_LANG['n_time'], (int) $media['counter'] + 1), 'U_COM' => PATH_TO_ROOT . '/media/media' . url('.php?id=' . $id_media . '&com=0', '-' . $id_media . '-' . $media['idcat'] . '+' . Url::encode_rewrite($media['name']) . '.php?com=0') . '#comments-list', 'L_COM' => CommentsService::get_number_and_lang_comments('media', $id_media), 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_SIZE' => $LANG['size'], 'L_MEDIA_INFOS' => $MEDIA_LANG['media_infos'], 'DATE' => Date::to_format($media['timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'L_MODO_PANEL' => $LANG['modo_panel'], 'L_UNAPROBED' => $MEDIA_LANG['unaprobed_media_short'], 'HEIGHT_P' => $media['height'] + 50, 'L_VIEWED' => $LANG['view'], 'L_BY' => $LANG['by'], 'BY' => !empty($media['display_name']) ? '<a href="' . UserUrlBuilder::profile($media['iduser'])->rel() . '" class="' . UserService::get_level_class($media['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $media['display_name'] . '</a>' : $LANG['guest'], 'U_UNVISIBLE_MEDIA' => url('media_action.php?unvisible=' . $id_media . '&token=' . AppContext::get_session()->get_token()), 'U_EDIT_MEDIA' => url('media_action.php?edit=' . $id_media), 'U_DELETE_MEDIA' => url('media_action.php?del=' . $id_media . '&token=' . AppContext::get_session()->get_token()), 'U_POPUP_MEDIA' => url('media_popup.php?id=' . $id_media), 'CATEGORY_NAME' => $media['idcat'] == Category::ROOT_CATEGORY ? LangLoader::get_message('module_title', 'common', 'media') : MediaService::get_categories_manager()->get_categories_cache()->get_category($media['idcat'])->get_name(), 'U_EDIT_CATEGORY' => $media['idcat'] == Category::ROOT_CATEGORY ? MediaUrlBuilder::configuration()->rel() : MediaUrlBuilder::edit_category($media['idcat'])->rel())); if (empty($mime_type_tpl[$media['mime_type']])) { $media_tpl = new FileTemplate('media/format/media_other.tpl'); } else { $media_tpl = new FileTemplate('media/' . $mime_type_tpl[$media['mime_type']]); } $media_tpl->put_all(array('URL' => $media['url'], 'MIME' => $media['mime_type'], 'WIDTH' => $media['width'], 'HEIGHT' => $media['height'])); $tpl->put('media_format', $media_tpl); //Affichage commentaires. if (AppContext::get_request()->get_getint('com', 0) == 0) { $comments_topic = new MediaCommentsTopic(); $comments_topic->set_id_in_module($id_media); $comments_topic->set_url(new Url('/media/media.php?id=' . $id_media . '&com=0')); $tpl->put_all(array('COMMENTS' => CommentsService::display($comments_topic)->render())); } $tpl->display();
if (empty($id_get)) { if ($search_member) { $login = retrieve(POST, 'login_mbr', ''); $user_id = PersistenceContext::get_querier()->get_column_value(DB_TABLE_MEMBER, 'user_id', 'WHERE display_name LIKE :name', array('name' => '%' . $login . '%')); if (!empty($user_id) && !empty($login)) { AppContext::get_response()->redirect(UserUrlBuilder::moderation_panel('ban', $user_id)); } else { AppContext::get_response()->redirect(UserUrlBuilder::moderation_panel('ban')); } } $moderation_panel_template->put_all(array('C_MODO_PANEL_USER_LIST' => true, 'L_PM' => $LANG['user_contact_pm'], 'L_INFO' => $LANG['user_ban_until'], 'L_ACTION_USER' => $LANG['ban_management'], 'L_PROFILE' => LangLoader::get_message('profile', 'user-common'), 'L_SEARCH_USER' => $LANG['search_member'], 'L_SEARCH' => $LANG['search'], 'L_REQUIRE_LOGIN' => $LANG['require_pseudo'])); $i = 0; $result = PersistenceContext::get_querier()->select("SELECT user_id, display_name, level, groups, delay_banned, warning_percentage\n\t\tFROM " . PREFIX . "member\n\t\tWHERE delay_banned > :now OR warning_percentage = 100\n\t\tORDER BY delay_banned", array('now' => time())); while ($row = $result->fetch()) { $group_color = User::get_group_color($row['groups'], $row['level']); $moderation_panel_template->assign_block_vars('member_list', array('C_USER_GROUP_COLOR' => !empty($group_color), 'LOGIN' => $row['display_name'], 'USER_LEVEL_CLASS' => UserService::get_level_class($row['level']), 'USER_GROUP_COLOR' => $group_color, 'INFO' => $row['warning_percentage'] != 100 ? Date::to_format($row['delay_banned'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) : $LANG['illimited'], 'U_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel(), 'U_ACTION_USER' => '<a href="' . UserUrlBuilder::moderation_panel('ban', $row['user_id'])->rel() . '" class="fa fa-forbidden"></a>', 'U_PM' => UserUrlBuilder::personnal_message($row['user_id'])->rel())); $i++; } $result->dispose(); if ($i === 0) { $moderation_panel_template->put_all(array('C_EMPTY_LIST' => true, 'L_NO_USER' => $LANG['no_ban'])); } } else { try { $member = PersistenceContext::get_querier()->select_single_row(DB_TABLE_MEMBER, array('display_name', 'level', 'groups', 'delay_banned', 'warning_percentage'), 'WHERE user_id=:id', array('id' => $id_get)); } catch (RowNotFoundException $e) { $error_controller = PHPBoostErrors::unexisting_element(); DispatchManager::redirect($error_controller); } $group_color = User::get_group_color($member['groups'], $member['level']); $moderation_panel_template->put_all(array('C_MODO_PANEL_USER_BAN' => true, 'C_USER_GROUP_COLOR' => !empty($group_color), 'LOGIN' => $member['display_name'], 'USER_LEVEL_CLASS' => UserService::get_level_class($member['level']), 'USER_GROUP_COLOR' => $group_color, 'KERNEL_EDITOR' => $editor->display(), 'U_PM' => UserUrlBuilder::personnal_message($id_get)->rel(), 'U_ACTION_INFO' => UserUrlBuilder::moderation_panel('ban', $id_get)->rel() . '&token=' . AppContext::get_session()->get_token(), 'U_PROFILE' => UserUrlBuilder::profile($id_get)->rel(), 'L_PM' => $LANG['user_contact_pm'], 'L_LOGIN' => LangLoader::get_message('display_name', 'user-common'), 'L_BAN' => $LANG['ban_user'], 'L_DELAY_BAN' => $LANG['user_ban_delay']));
$theme = ThemesManager::get_theme(AppContext::get_current_user()->get_theme()); $customize_interface = $theme->get_customize_interface(); $header_logo_path = $customize_interface->get_header_logo_path(); $tpl->put_all(array('L_QUICK_ACCESS' => $LANG['quick_access'], 'L_ADD_CONTENT' => $LANG['add_content'], 'L_MODULES_MANAGEMENT' => $LANG['modules_management'], 'L_ADD_ARTICLES' => $LANG['add_articles'], 'L_ADD_NEWS' => $LANG['add_news'], 'L_CUSTOMIZE_SITE' => $LANG['customize_site'], 'L_ADD_TEMPLATE' => $LANG['add_template'], 'L_MENUS_MANAGEMENT' => $LANG['menus_management'], 'L_CUSTOMIZE_TEMPLATE' => $LANG['customize_template'], 'L_SITE_MANAGEMENT' => $LANG['site_management'], 'L_GENERAL_CONFIG' => $LANG['general_config'], 'L_EMPTY_CACHE' => $LANG['empty_cache'], 'L_SAVE_DATABASE' => $LANG['save_database'], 'L_WELCOME_TITLE' => $LANG['welcome_title'], 'L_WELCOME_DESC' => $LANG['welcome_desc'], 'WRITING_PAD_CONTENT' => WritingPadConfig::load()->get_content(), 'C_HEADER_LOGO' => !empty($header_logo_path), 'HEADER_LOGO' => Url::to_rel($header_logo_path), 'C_NO_COM' => $i == 0, 'C_UNREAD_ALERTS' => (bool) AdministratorAlertService::get_number_unread_alerts(), 'L_INDEX_ADMIN' => $LANG['administration'], 'L_ADMIN_ALERTS' => $LANG['administrator_alerts'], 'L_NO_UNREAD_ALERT' => $LANG['no_unread_alert'], 'L_UNREAD_ALERT' => $LANG['unread_alerts'], 'L_DISPLAY_ALL_ALERTS' => $LANG['display_all_alerts'], 'L_ADMINISTRATOR_ALERTS' => $LANG['administrator_alerts'], 'L_QUICK_LINKS' => $LANG['quick_links'], 'L_ACTION_USERS_MANAGEMENT' => $LANG['action.members_management'], 'L_ACTION_MENUS_MANAGEMENT' => $LANG['action.menus_management'], 'L_ACTION_MODULES_MANAGEMENT' => $LANG['action.modules_management'], 'L_ACTION_THEMES_MANAGEMENT' => $LANG['action.themes_management'], 'L_ACTION_LANGS_MANAGEMENT' => $LANG['action.langs_management'], 'L_NO_COMMENT' => LangLoader::get_message('no_item_now', 'common'), 'L_LAST_COMMENTS' => $LANG['last_comments'], 'L_VIEW_ALL_COMMENTS' => $LANG['view_all_comments'], 'L_WRITING_PAD' => $LANG['writing_pad'], 'L_STATS' => $LANG['stats'], 'L_USER_ONLINE' => $LANG['user_online'], 'L_USER_IP' => $LANG['user_ip'], 'L_LOCALISATION' => $LANG['localisation'], 'L_LAST_UPDATE' => $LANG['last_update'], 'L_WEBSITE_UPDATES' => $LANG['website_updates'], 'L_BY' => $LANG['by'], 'L_UPDATE' => $LANG['update'], 'L_RESET' => $LANG['reset'], 'ADVISES' => $advises_form->display())); //Liste des personnes en lignes. $result = PersistenceContext::get_querier()->select("SELECT s.user_id, s.ip, s.timestamp, s.location_script, s.location_title, m.display_name, m.groups, m.level\nFROM " . DB_TABLE_SESSIONS . " s\nLEFT JOIN " . DB_TABLE_MEMBER . " m ON s.user_id = m.user_id\nWHERE s.timestamp > :timestamp\nORDER BY s.timestamp DESC", array('timestamp' => time() - SessionsConfig::load()->get_active_session_duration())); while ($row = $result->fetch()) { //On vérifie que la session ne correspond pas à un robot. $robot = Robots::get_robot_by_ip($row['ip']); switch ($row['level']) { case User::MEMBER_LEVEL: $class = 'member'; break; case User::MODERATOR_LEVEL: $class = 'modo'; break; case User::ADMIN_LEVEL: $class = 'admin'; break; } if (!empty($robot)) { $login = '******' . ($robot == 'unknow_bot' ? $LANG['unknow_bot'] : $robot) . '</span>'; } else { $group_color = User::get_group_color($row['groups'], $row['level']); $login = !empty($row['display_name']) ? '<a class="' . $class . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '">' . $row['display_name'] . '</a>' : $LANG['guest']; } $tpl->assign_block_vars('user', array('USER' => !empty($login) ? $login : $LANG['guest'], 'USER_IP' => $row['ip'], 'WHERE' => '<a href="' . $row['location_script'] . '">' . (!empty($row['location_title']) ? stripslashes($row['location_title']) : $LANG['unknown']) . '</a>', 'TIME' => Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE))); } $result->dispose(); $tpl->display(); require_once '../admin/admin_footer.php';
/** * @desc This function is called by the kernel on each displayed page to count the number of pages seen at each hour. */ public static function update_pages_displayed() { self::write_stats('pages', Date::to_format(Date::DATE_NOW, 'G')); }
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; }
} $user_accounts_config = UserAccountsConfig::load(); //Avatar if (empty($row['user_avatar'])) { $user_avatar = $user_accounts_config->is_default_avatar_enabled() == '1' ? '<img src="../templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name() . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" />' : ''; } else { $user_avatar = '<img src="' . Url::to_rel($row['user_avatar']) . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" />'; } //Affichage du nombre de message. if ($row['posted_msg'] >= 1) { $posted_msg = '<a href="' . UserUrlBuilder::messages($row['user_id'])->rel() . '" class="small">' . $LANG['message_s'] . '</a>: ' . $row['posted_msg']; } else { $posted_msg = !$is_guest ? '<a href="' . PATH_TO_ROOT . '/forum/membermsg' . url('.php?id=' . $row['user_id'], '') . '" class="small">' . $LANG['message'] . '</a>: 0' : $LANG['message'] . ': 0'; } $user_sign_field = $extended_fields_cache->get_extended_field_by_field_name('user_sign'); $tpl->assign_block_vars('list', array('C_GROUP_COLOR' => !empty($group_color), 'C_GUEST' => empty($row['display_name']), 'CONTENTS' => FormatingHelper::second_parse($row['contents']), 'DATE' => $LANG['on'] . ' ' . Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'ID' => $row['id'], 'USER_RANK' => $row['warning_percentage'] < '100' || time() - $row['delay_banned'] < 0 ? $user_rank : LangLoader::get_message('banned', 'user-common'), 'USER_IMG_ASSOC' => $user_assoc_img, 'USER_AVATAR' => $user_avatar, 'USER_GROUP' => $user_groups, 'USER_DATE' => !$is_guest ? $LANG['registered_on'] . ': ' . Date::to_format($row['registered'], Date::FORMAT_DAY_MONTH_YEAR) : '', 'USER_MSG' => !$is_guest ? $posted_msg : '', 'USER_MAIL' => !empty($row['email']) && $row['show_email'] == '1' ? '<a href="mailto:' . $row['email'] . '" class="basic-button smaller">Mail</a>' : '', 'USER_SIGN' => !empty($row['user_sign']) && !empty($user_sign_field) && $user_sign_field['display'] ? '____________________<br />' . FormatingHelper::second_parse($row['user_sign']) : '', 'USER_WARNING' => $row['warning_percentage'], 'USER_PM' => !$is_guest && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL) ? '<a href="' . UserUrlBuilder::personnal_message($row['user_id'])->rel() . '" class="basic-button smaller">MP</a>' : '', 'USER_ONLINE' => '<i class="fa ' . (!empty($row['connect']) ? 'fa-online' : 'fa-offline') . '"></i>', 'USER_PSEUDO' => !empty($row['display_name']) ? wordwrap(TextHelper::html_entity_decode($row['display_name']), 13, '<br />', 1) : $LANG['guest'], 'LEVEL_CLASS' => UserService::get_level_class($row['level']), 'GROUP_COLOR' => $group_color, 'U_USER_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel(), 'U_VARS_ANCRE' => url('.php?id=' . $row['idtopic'], '-' . $row['idtopic'] . $rewrited_title . '.php'), 'U_FORUM_CAT' => '<a class="forum-mbrmsg-links" href="' . PATH_TO_ROOT . '/forum/forum' . url('.php?id=' . $row['idcat'], '-' . $row['idcat'] . $rewrited_cat_title . '.php') . '">' . $row['name'] . '</a>', 'U_TITLE_T' => '<a class="forum-mbrmsg-links" href="' . PATH_TO_ROOT . '/forum/topic' . url('.php?id=' . $row['idtopic'], '-' . $row['idtopic'] . $rewrited_title . '.php') . '">' . stripslashes($row['title']) . '</a>')); foreach ($displayed_extended_fields as $field_type) { $field = $extended_fields_cache->get_extended_field_by_field_name($field_type); if (!empty($row[$field_type]) && !empty($field) && $field['display']) { $button = ''; if ($field['regex'] == 4) { foreach (MemberShortTextExtendedField::$brands_pictures_list as $id => $parameters) { if (strstr($row[$field_type], $id)) { $button = '<a href="mailto:' . $row[$field_type] . '" class="basic-button smaller"><i class="fa ' . $parameters['picture'] . '"></i> ' . $parameters['title'] . '</a>'; } } } else { if ($field['regex'] == 5) { $button = '<a href="' . $row[$field_type] . '" class="basic-button smaller">' . LangLoader::get_message('regex.website', 'admin-user-common') . '</a>'; foreach (MemberShortTextExtendedField::$brands_pictures_list as $id => $parameters) { if (strstr($row[$field_type], $id)) {
$tpl->put_all(array('ARRAY_JS' => $array_js, 'NBR_PICS' => $i - 1, 'MAX_START' => $i - 1 - $nbr_column_pics, 'START_THUMB' => $pos_pics - $start_thumbnails > 0 ? $pos_pics - $start_thumbnails : 0, 'END_THUMB' => $pos_pics + $end_thumbnails, 'L_INFORMATIONS' => $LANG['informations'], 'L_NAME' => $LANG['name'], 'L_POSTOR' => $LANG['postor'], 'L_VIEWS' => $LANG['views'], 'L_ADD_ON' => $LANG['add_on'], 'L_DIMENSION' => $LANG['dimension'], 'L_SIZE' => $LANG['size'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_APROB' => $LANG['aprob'], 'L_UNAPROB' => $LANG['unaprob'], 'L_THUMBNAILS' => $LANG['thumbnails'])); //Liste des catégories. $search_category_children_options = new SearchCategoryChildrensOptions(); $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS); $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS); $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($info_pics['id'] . 'cat', '', $info_pics['idcat'], $search_category_children_options); $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options'); $method->setAccessible(true); $categories_tree_options = $method->invoke($categories_tree); $cat_list = ''; foreach ($categories_tree_options as $option) { $cat_list .= $option->display()->render(); } $group_color = User::get_group_color($info_pics['groups'], $info_pics['level']); //Affichage de l'image et de ses informations. $tpl->assign_block_vars('pics.pics_max', array('C_APPROVED' => $info_pics['aprob'], 'C_PREVIOUS' => $pos_pics > 0, 'C_NEXT' => $pos_pics < $i - 1, 'C_LEFT_THUMBNAILS' => $pos_pics - $start_thumbnails, 'C_RIGHT_THUMBNAILS' => $pos_pics - $start_thumbnails <= $i - 1 - $nbr_column_pics, 'ID' => $info_pics['id'], 'IMG' => '<img src="show_pics.php?id=' . $idpics . '&cat=' . $id_category . '" alt="' . $info_pics['name'] . '" />', 'PICTURE_NAME' => stripslashes($info_pics['name']), 'NAME' => '<span id="fi_' . $info_pics['id'] . '">' . stripslashes($info_pics['name']) . '</span> <span id="fi' . $info_pics['id'] . '"></span>', 'POSTOR' => '<a class="' . UserService::get_level_class($info_pics['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($info_pics['user_id'])->rel() . '">' . $info_pics['display_name'] . '</a>', 'DATE' => Date::to_format($info_pics['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'VIEWS' => $info_pics['views'] + 1, 'DIMENSION' => $info_pics['width'] . ' x ' . $info_pics['height'], 'SIZE' => NumberHelper::round($info_pics['weight'] / 1024, 1), 'COLSPAN' => $config->get_columns_number() + 2, 'COLSPAN_PICTURE' => (int) ($pos_pics > 0) + (int) ($pos_pics < $i - 1), 'CAT' => $cat_list, 'RENAME' => addslashes($info_pics['name']), 'RENAME_CUT' => addslashes($info_pics['name']), 'U_DEL' => 'php?del=' . $info_pics['id'] . '&cat=' . $id_category . '&token=' . AppContext::get_session()->get_token(), 'U_MOVE' => '.php?id=' . $info_pics['id'] . '&token=' . AppContext::get_session()->get_token() . '&move=\' + this.options[this.selectedIndex].value', 'U_PREVIOUS' => '<a href="admin_gallery.php?cat=' . $id_category . '&id=' . $id_previous . '#pics_max" class="fa fa-arrow-left fa-2x"></a> <a href="admin_gallery.php?cat=' . $id_category . '&id=' . $id_previous . '#pics_max">' . $LANG['previous'] . '</a>', 'U_NEXT' => '<a href="admin_gallery.php?cat=' . $id_category . '&id=' . $id_next . '#pics_max">' . $LANG['next'] . '</a> <a href="admin_gallery.php?cat=' . $id_category . '&id=' . $id_next . '#pics_max" class="fa fa-arrow-right fa-2x"></a>')); //Affichage de la liste des miniatures sous l'image. $i = 0; foreach ($array_pics as $pics) { if ($i >= $pos_pics - $start_thumbnails && $i <= $pos_pics + $end_thumbnails) { $tpl->assign_block_vars('pics.pics_max.list_preview_pics', array('PICS' => $pics)); } $i++; } } } else { $j = 0; $result = PersistenceContext::get_querier()->select("SELECT g.id, g.idcat, g.name, g.path, g.timestamp, g.aprob, g.width, g.height, m.display_name, m.user_id, m.level, m.groups\n\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\tWHERE g.idcat = :idcat\n\t\t\tORDER BY g.timestamp\n\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('idcat' => $id_category, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); while ($row = $result->fetch()) { //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle. if (!file_exists('pics/thumbnails/' . $row['path'])) {
private function init_maintain_delay() { $date_lang = LangLoader::get('date-common'); $array_time = array(0 => '-1', 1 => '0', 2 => '60', 3 => '300', 4 => '900', 5 => '1800', 6 => '3600', 7 => '7200', 8 => '86400', 9 => '172800', 10 => '604800'); $array_delay = array(0 => LangLoader::get_message('unspecified', 'main'), 1 => '', 2 => '1 ' . $date_lang['minute'], 3 => '5 ' . $date_lang['minutes'], 4 => '15 ' . $date_lang['minutes'], 5 => '30 ' . $date_lang['minutes'], 6 => '1 ' . $date_lang['hour'], 7 => '2 ' . $date_lang['hours'], 8 => '1 ' . $date_lang['day'], 9 => '2 ' . $date_lang['days'], 10 => '1 ' . $date_lang['week']); if (!$this->maintain_config->is_unlimited_maintenance()) { $key = 0; $current_time = time(); $end_timestamp = $this->maintain_config->get_end_date()->get_timestamp(); for ($i = 10; $i >= 0; $i--) { $delay = $end_timestamp - $current_time - $array_time[$i]; if ($delay >= $array_time[$i]) { $key = $i; break; } } //Calcul du format de la date $array_release = array(Date::to_format($end_timestamp, 'Y', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 'n', Timezone::SITE_TIMEZONE) - 1, Date::to_format($end_timestamp, 'j', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 'G', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 'i', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 's', Timezone::SITE_TIMEZONE)); $array_now = array(Date::to_format(time(), 'Y', Timezone::SITE_TIMEZONE), Date::to_format(time(), 'n', Timezone::SITE_TIMEZONE) - 1, Date::to_format(time(), 'j', Timezone::SITE_TIMEZONE), Date::to_format(time(), 'G', Timezone::SITE_TIMEZONE), Date::to_format(time(), 'i', Timezone::SITE_TIMEZONE), Date::to_format(time(), 's', Timezone::SITE_TIMEZONE)); } else { $key = -1; $array_release = array('0', '0', '0', '0', '0', '0'); $array_now = array('0', '0', '0', '0', '0', '0'); } $this->view->put_all(array('MAINTAIN_NOW_FORMAT' => implode(',', $array_now), 'MAINTAIN_RELEASE_FORMAT' => implode(',', $array_release))); if ($this->maintain_config->get_display_duration() && !$this->maintain_config->is_unlimited_maintenance()) { $this->view->put_all(array('C_DISPLAY_DELAY' => true, 'DELAY' => isset($array_delay[$key + 1]) ? $array_delay[$key + 1] : '0')); } }
$checked_annonce = $type == 2 ? 'checked="ckecked"' : ''; //Liste des choix des sondages => 20 maxi $nbr_poll_field = 0; for ($i = 0; $i < 20; $i++) { $answer = retrieve(POST, 'a' . $i, '', TSTRING_UNCHANGE); if (!empty($answer)) { $tpl->assign_block_vars('answers_poll', array('ID' => $i, 'ANSWER' => $answer)); $nbr_poll_field++; } elseif ($i <= 5) { $tpl->assign_block_vars('answers_poll', array('ID' => $i, 'ANSWER' => '')); $nbr_poll_field++; } } //Type de réponses du sondage. $poll_type = retrieve(POST, 'poll_type', 0); $vars_tpl = array_merge($vars_tpl, array('TITLE' => $title, 'DESC' => $subtitle, 'CONTENTS' => $contents, 'QUESTION' => $question, 'IDM' => $id_post_msg, 'DATE' => $LANG['on'] . ' ' . Date::to_format(Date::DATE_NOW, Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'CONTENTS_PREVIEW' => FormatingHelper::second_parse(stripslashes(FormatingHelper::strparse($contents))), 'CHECKED_NORMAL' => $checked_normal, 'CHECKED_POSTIT' => $checked_postit, 'CHECKED_ANNONCE' => $checked_annonce, 'SELECTED_SIMPLE' => $poll_type == 0 ? 'checked="ckecked"' : '', 'SELECTED_MULTIPLE' => $poll_type == 1 ? 'checked="ckecked"' : '', 'NO_DISPLAY_POLL' => !empty($question) ? 'false' : 'true', 'NBR_POLL_FIELD' => $nbr_poll_field, 'C_FORUM_PREVIEW_MSG' => true, 'C_ADD_POLL_FIELD' => $nbr_poll_field <= 18 ? true : false, 'C_FORUM_POST_TYPE' => true, 'L_PREVIEW' => $LANG['preview'], 'L_TYPE' => '* ' . $LANG['type'], 'L_DEFAULT' => $LANG['default'], 'L_POST_IT' => $LANG['forum_postit'], 'L_ANOUNCE' => $LANG['forum_announce'])); } //Listes les utilisateurs en lignes. list($users_list, $total_admin, $total_modo, $total_member, $total_visit, $total_online) = forum_list_user_online("AND s.location_script LIKE '" . "/forum/%'"); $vars_tpl = array_merge($vars_tpl, array('C_USER_CONNECTED' => AppContext::get_current_user()->check_level(User::MEMBER_LEVEL), 'TOTAL_ONLINE' => $total_online, 'USERS_ONLINE' => $total_online - $total_visit == 0 ? '<em>' . $LANG['no_member_online'] . '</em>' : $users_list, 'ADMIN' => $total_admin, 'MODO' => $total_modo, 'MEMBER' => $total_member, 'GUEST' => $total_visit, 'L_USER' => $total_online > 1 ? $LANG['user_s'] : $LANG['user'], 'L_ADMIN' => $total_admin > 1 ? $LANG['admin_s'] : $LANG['admin'], 'L_MODO' => $total_modo > 1 ? $LANG['modo_s'] : $LANG['modo'], 'L_MEMBER' => $total_member > 1 ? $LANG['member_s'] : $LANG['member'], 'L_GUEST' => $total_visit > 1 ? $LANG['guest_s'] : $LANG['guest'], 'L_AND' => $LANG['and'], 'L_ONLINE' => strtolower($LANG['online']))); $tpl->put_all($vars_tpl); $tpl_top->put_all($vars_tpl); $tpl_bottom->put_all($vars_tpl); $tpl->put('forum_top', $tpl_top); $tpl->put('forum_bottom', $tpl_bottom); $tpl->display(); } elseif (!empty($id_post_msg) && !empty($post_topic)) { try { $msg = PersistenceContext::get_querier()->select_single_row(PREFIX . 'forum_msg', array('idtopic', 'user_id', 'timestamp', 'contents'), 'WHERE id=:id', array('id' => $id_post_msg)); } catch (RowNotFoundException $e) { $error_controller = PHPBoostErrors::unexisting_element();
private function build_view() { global $LANG, $Bread_crumb; load_module_lang('gallery'); $g_idpics = retrieve(GET, 'id', 0); $g_views = retrieve(GET, 'views', false); $g_notes = retrieve(GET, 'notes', false); $g_sort = retrieve(GET, 'sort', ''); $g_sort = !empty($g_sort) ? 'sort=' . $g_sort : ''; //Récupération du mode d'ordonnement. if (preg_match('`([a-z]+)_([a-z]+)`', $g_sort, $array_match)) { $g_type = $array_match[1]; $g_mode = $array_match[2]; } else { list($g_type, $g_mode) = array('date', 'desc'); } $comments_topic = new GalleryCommentsTopic(); $config = GalleryConfig::load(); $category = $this->get_category(); $categories = GalleryService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id()); $authorized_categories = GalleryService::get_authorized_categories($category->get_id()); $Gallery = new Gallery(); $nbr_pics = $this->db_querier->count(GallerySetup::$gallery_table, 'WHERE idcat=:idcat AND aprob = 1', array('idcat' => $category->get_id())); $total_cat = count($categories); //On crée une pagination si le nombre de catégories est trop important. $page = AppContext::get_request()->get_getint('p', 1); $pagination = new ModulePagination($page, $total_cat, $config->get_categories_number_per_page()); $pagination->set_url(new Url('/gallery/gallery.php?p=%d&cat=' . $category->get_id() . '&id=' . $g_idpics . '&' . $g_sort)); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } //Colonnes des catégories. $nbr_column_cats = $total_cat > $config->get_columns_number() ? $config->get_columns_number() : $total_cat; $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1; $column_width_cats = floor(100 / $nbr_column_cats); //Colonnes des images. $nbr_column_pics = $nbr_pics > $config->get_columns_number() ? $config->get_columns_number() : $nbr_pics; $nbr_column_pics = !empty($nbr_column_pics) ? $nbr_column_pics : 1; $column_width_pics = floor(100 / $nbr_column_pics); $is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL); $is_modo = GalleryAuthorizationsService::check_authorizations($category->get_id())->moderation(); $module_data_path = $this->tpl->get_pictures_data_path(); $rewrite_title = Url::encode_rewrite($category->get_name()); ##### Catégorie disponibles ##### $nbr_cat_displayed = 0; if ($total_cat > 0 && empty($g_idpics)) { $this->tpl->put('C_GALLERY_CATS', true); $j = 0; $result = $this->db_querier->select('SELECT @id_cat:= gallery_cats.id, gallery_cats.*, (SELECT COUNT(*) FROM ' . GallerySetup::$gallery_table . ' WHERE idcat IN ( @id_cat, (SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' WHERE id_parent = @id_cat), (SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' parents INNER JOIN ' . GallerySetup::$gallery_cats_table . ' childs ON parents.id = childs.id_parent WHERE parents.id_parent = @id_cat) ) AND aprob = 1 ) AS nbr_pics FROM ' . GallerySetup::$gallery_cats_table . ' gallery_cats WHERE id_parent = :id_category AND id IN :authorized_categories ORDER BY id_parent, c_order LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); while ($row = $result->fetch()) { $category_image = new Url($row['image']); $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'PICTURES_NUMBER' => sprintf($LANG['nbr_pics_info'], $row['nbr_pics']), 'U_CATEGORY' => GalleryUrlBuilder::get_link_cat($row['id'], $row['name']))); $nbr_cat_displayed++; } $result->dispose(); } $category_description = FormatingHelper::second_parse($category->get_description()); $this->tpl->put_all(array('C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'ARRAY_JS' => '', 'NBR_PICS' => 0, 'MAX_START' => 0, 'START_THUMB' => 0, 'END_THUMB' => 0, 'COLUMNS_NUMBER' => $nbr_column_pics, 'CATS_COLUMNS_WIDTH' => $column_width_cats, 'COLUMN_WIDTH_PICS' => $column_width_pics, 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? GalleryUrlBuilder::configuration()->rel() : GalleryUrlBuilder::edit_category($category->get_id())->rel(), 'CAT_ID' => $category->get_id(), 'DISPLAY_MODE' => $config->get_pics_enlargement_mode(), 'GALLERY' => $category->get_id() != Category::ROOT_CATEGORY ? $this->lang['module_title'] . ' - ' . $category->get_name() : $this->lang['module_title'], 'HEIGHT_MAX' => $config->get_mini_max_height(), 'WIDTH_MAX' => $column_width_pics, 'MODULE_DATA_PATH' => $module_data_path, 'L_APROB' => $LANG['aprob'], 'L_UNAPROB' => $LANG['unaprob'], 'L_FILE_FORBIDDEN_CHARS' => $LANG['file_forbidden_chars'], 'L_TOTAL_IMG' => $category->get_id() != Category::ROOT_CATEGORY ? sprintf($LANG['total_img_cat'], $nbr_pics) : '', 'L_ADD_IMG' => $LANG['add_pic'], 'L_GALLERY' => $this->lang['module_title'], 'L_CATEGORIES' => $category->get_id_parent() >= 0 ? $LANG['sub_album'] : $LANG['album'], 'L_NAME' => $LANG['name'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_MOVETO' => $LANG['moveto'], 'L_DELETE' => LangLoader::get_message('delete', 'common'), 'L_SUBMIT' => $LANG['submit'], 'L_ALREADY_VOTED' => $LANG['already_vote'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common') . (isset($LANG[$g_type]) ? ' ' . strtolower($LANG[$g_type]) : ''), 'L_DIRECTION' => $LANG['direction'], 'L_DISPLAY' => LangLoader::get_message('display', 'common'), 'U_INDEX' => url('.php'), 'U_BEST_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?views=1&cat=' . $category->get_id(), '-' . $category->get_id() . '.php?views=1'), 'U_BEST_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?notes=1&cat=' . $category->get_id(), '-' . $category->get_id() . '.php?notes=1'), 'U_ASC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&sort=' . $g_type . '_' . 'asc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'asc'), 'U_DESC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&sort=' . $g_type . '_' . 'desc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'desc'), 'U_ORDER_BY_NAME' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=name_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=name_desc'), 'U_ORDER_BY_DATE' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=date_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=date_desc'), 'U_ORDER_BY_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=views_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=views_desc'), 'U_ORDER_BY_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=notes_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=notes_desc'), 'U_ORDER_BY_COM' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=com_desc&cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=com_desc'), 'L_BEST_VIEWS' => $LANG['best_views'], 'L_BEST_NOTES' => $LANG['best_notes'], 'L_ASC' => $LANG['asc'], 'L_DESC' => $LANG['desc'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_VIEWS' => $LANG['views'], 'L_NOTES' => LangLoader::get_message('notes', 'common'), 'L_COM' => $LANG['com_s'])); ##### Affichage des photos ##### if ($nbr_pics > 0) { switch ($g_type) { case 'name': $sort_type = 'g.name'; break; case 'date': $sort_type = 'g.timestamp'; break; case 'views': $sort_type = 'g.views'; break; case 'notes': $sort_type = 'notes.average_notes'; break; case 'com': $sort_type = 'com.number_comments'; break; default: $sort_type = 'g.timestamp'; } switch ($g_mode) { case 'desc': $sort_mode = 'DESC'; break; case 'asc': $sort_mode = 'ASC'; break; default: $sort_mode = 'DESC'; } $g_sql_sort = ' ORDER BY ' . $sort_type . ' ' . $sort_mode; if ($g_views) { $g_sql_sort = ' ORDER BY g.views DESC'; } elseif ($g_notes) { $g_sql_sort = ' ORDER BY notes.average_notes DESC'; } $this->tpl->put('C_GALLERY_PICS', true); //Affichage d'une photo demandée. if (!empty($g_idpics)) { $info_pics = $this->db_querier->select_single_row_query("SELECT g.*, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.id = :id AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'id' => $g_idpics)); if (!empty($info_pics['id'])) { $Bread_crumb->add(stripslashes($info_pics['name']), PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $info_pics['idcat'] . '&id=' . $info_pics['id'], '-' . $info_pics['idcat'] . '-' . $info_pics['id'] . '.php')); //Affichage miniatures. $id_previous = 0; $id_next = 0; $nbr_pics_display_before = floor(($nbr_column_pics - 1) / 2); //Nombres de photos de chaque côté de la miniature de la photo affichée. $nbr_pics_display_after = $nbr_column_pics - 1 - floor($nbr_pics_display_before); list($i, $reach_pics_pos, $pos_pics, $thumbnails_before, $thumbnails_after, $start_thumbnails, $end_thumbnails) = array(0, false, 0, 0, 0, $nbr_pics_display_before, $nbr_pics_display_after); $array_pics = array(); $array_js = 'var array_pics = new Array();'; $result = $this->db_querier->select("SELECT g.id, g.idcat, g.path\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('idcat' => $category->get_id())); while ($row = $result->fetch()) { //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle. if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) { $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']); } //Redimensionnement + création miniature //Affichage de la liste des miniatures sous l'image. $array_pics[] = '<td class="center" style="height:' . ($config->get_mini_max_height() + 16) . 'px"><span id="thumb' . $i . '"><a href="gallery' . url('.php?cat=' . $row['idcat'] . '&id=' . $row['id'] . '&sort=' . $g_sort, '-' . $row['idcat'] . '-' . $row['id'] . '.php?sort=' . $g_sort) . '#pics_max' . '"><img src="pics/thumbnails/' . $row['path'] . '" alt="' . $row['path'] . '" /></a></span></td>'; if ($row['id'] == $g_idpics) { $reach_pics_pos = true; $pos_pics = $i; } else { if (!$reach_pics_pos) { $thumbnails_before++; $id_previous = $row['id']; } else { $thumbnails_after++; if (empty($id_next)) { $id_next = $row['id']; } } } $array_js .= 'array_pics[' . $i . '] = new Array();' . "\n"; $array_js .= 'array_pics[' . $i . '][\'link\'] = \'' . GalleryUrlBuilder::get_link_item($row['idcat'], $row['id']) . '#pics_max' . "';\n"; $array_js .= 'array_pics[' . $i . '][\'path\'] = \'' . $row['path'] . "';\n"; $i++; } $result->dispose(); $activ_note = $config->is_notation_enabled() && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL); if ($activ_note) { //Affichage notation. $notation = new Notation(); $notation->set_module_name('gallery'); $notation->set_id_in_module($info_pics['id']); $notation->set_notation_scale($config->get_notation_scale()); $notation->set_number_notes($info_pics['number_notes']); $notation->set_average_notes($info_pics['average_notes']); $notation->set_user_already_noted(!empty($info_pics['note'])); } if ($thumbnails_before < $nbr_pics_display_before) { $end_thumbnails += $nbr_pics_display_before - $thumbnails_before; } if ($thumbnails_after < $nbr_pics_display_after) { $start_thumbnails += $nbr_pics_display_after - $thumbnails_after; } $html_protected_name = $info_pics['name']; $comments_topic->set_id_in_module($info_pics['id']); $comments_topic->set_url(new Url('/gallery/gallery.php?cat=' . $category->get_id() . '&id=' . $g_idpics . '&com=0')); //Liste des catégories. $search_category_children_options = new SearchCategoryChildrensOptions(); $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS); $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS); $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($info_pics['id'] . 'cat', '', $info_pics['idcat'], $search_category_children_options); $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options'); $method->setAccessible(true); $categories_tree_options = $method->invoke($categories_tree); $cat_list = ''; foreach ($categories_tree_options as $option) { $cat_list .= $option->display()->render(); } $group_color = User::get_group_color($info_pics['groups'], $info_pics['level']); //Affichage de l'image et de ses informations. $this->tpl->put_all(array('C_GALLERY_PICS_MAX' => true, 'C_GALLERY_PICS_MODO' => $is_modo, 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_TITLE_ENABLED' => $config->is_title_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'ID' => $info_pics['id'], 'NAME' => '<span id="fi_' . $info_pics['id'] . '">' . stripslashes($info_pics['name']) . '</span> <span id="fi' . $info_pics['id'] . '"></span>', 'POSTOR' => '<a class="small ' . UserService::get_level_class($info_pics['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($info_pics['user_id'])->rel() . '">' . $info_pics['display_name'] . '</a>', 'DATE' => Date::to_format($info_pics['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'VIEWS' => $info_pics['views'] + 1, 'DIMENSION' => $info_pics['width'] . ' x ' . $info_pics['height'], 'SIZE' => NumberHelper::round($info_pics['weight'] / 1024, 1), 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $info_pics['id']), 'KERNEL_NOTATION' => $activ_note ? NotationService::display_active_image($notation) : '', 'COLSPAN' => $config->get_columns_number() + 2, 'CAT' => $cat_list, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'IMG_APROB' => $info_pics['aprob'] == 1 ? 'fa fa-eye-slash' : 'fa fa-eye', 'ARRAY_JS' => $array_js, 'NBR_PICS' => $i - 1, 'MAX_START' => $i - 1 - $nbr_column_pics, 'START_THUMB' => $pos_pics - $start_thumbnails > 0 ? $pos_pics - $start_thumbnails : 0, 'END_THUMB' => $pos_pics + $end_thumbnails, 'L_KB' => LangLoader::get_message('unit.kilobytes', 'common'), 'L_INFORMATIONS' => $LANG['informations'], 'L_NAME' => $LANG['name'], 'L_POSTOR' => $LANG['postor'], 'L_VIEWS' => $LANG['views'], 'L_ADD_ON' => $LANG['add_on'], 'L_DIMENSION' => $LANG['dimension'], 'L_SIZE' => $LANG['size'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_APROB_IMG' => $info_pics['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'L_THUMBNAILS' => $LANG['thumbnails'], 'U_DEL' => url('gallery.php?del=' . $info_pics['id'] . '&token=' . AppContext::get_session()->get_token() . '&cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $info_pics['id'] . '&token=' . AppContext::get_session()->get_token() . '&move=\' + this.options[this.selectedIndex].value'), 'U_PREVIOUS' => $pos_pics > 0 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max"><i class="fa fa-arrow-left fa-2x"></i></a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max">' . $LANG['previous'] . '</a>' : '', 'U_NEXT' => $pos_pics < $i - 1 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max">' . $LANG['next'] . '</a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max"><i class="fa fa-arrow-right fa-2x"></i></a>' : '', 'U_LEFT_THUMBNAILS' => $pos_pics - $start_thumbnails > 0 ? '<span id="display_left"><a href="javascript:display_thumbnails(\'left\')"><i class="fa fa-arrow-left fa-2x"></i></a></span>' : '<span id="display_left"></span>', 'U_RIGHT_THUMBNAILS' => $pos_pics - $start_thumbnails <= $i - 1 - $nbr_column_pics ? '<span id="display_right"><a href="javascript:display_thumbnails(\'right\')"><i class="fa fa-arrow-right fa-2x"></i></a></span>' : '<span id="display_right"></span>', 'U_COMMENTS' => GalleryUrlBuilder::get_link_item($info_pics['idcat'], $info_pics['id'], 0, $g_sort) . '#comments-list', 'U_IMG_MAX' => 'show_pics.php?id=' . $info_pics['id'] . '&cat=' . $info_pics['idcat'])); //Affichage de la liste des miniatures sous l'image. $i = 0; foreach ($array_pics as $pics) { if ($i >= $pos_pics - $start_thumbnails && $i <= $pos_pics + $end_thumbnails) { $this->tpl->assign_block_vars('list_preview_pics', array('PICS' => $pics)); } $i++; } //Commentaires if (AppContext::get_request()->get_getint('com', 0) == 0 && $config->are_comments_enabled()) { $this->tpl->put_all(array('COMMENTS' => CommentsService::display($comments_topic)->render())); } } } else { $sort = retrieve(GET, 'sort', ''); //On crée une pagination si le nombre de photos est trop important. $page = AppContext::get_request()->get_getint('pp', 1); $pagination = new ModulePagination($page, $nbr_pics, $config->get_pics_number_per_page()); $pagination->set_url(new Url('/gallery/gallery.php?pp=%d' . (!empty($sort) ? '&sort=' . $sort : '') . '&cat=' . $category->get_id())); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $this->tpl->put_all(array('C_GALLERY_MODO' => $is_modo, 'C_PICTURE_NAME_DISPLAYED' => $config->is_title_enabled(), 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_VIEW' => $LANG['view'], 'L_VIEWS' => $LANG['views'])); $is_connected = AppContext::get_current_user()->check_level(User::MEMBER_LEVEL); $j = 0; $result = $this->db_querier->select("SELECT g.id, g.idcat, g.name, g.path, g.timestamp, g.aprob, g.width, g.height, g.user_id, g.views, g.aprob, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t" . $g_sql_sort . "\n\t\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); while ($row = $result->fetch()) { //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle. if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) { $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']); } //Redimensionnement + création miniature $onclick = ''; //Affichage de l'image en grand. if ($config->get_pics_enlargement_mode() == GalleryConfig::FULL_SCREEN) { $display_link = PATH_TO_ROOT . '/gallery/pics/' . $row['path'] . '" onmousedown="increment_view(' . $row['id'] . ');" title="' . str_replace('"', '', stripslashes($row['name'])); } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::POPUP) { $onclick = 'increment_view(' . $row['id'] . ');display_pics_popup(\'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&cat=' . $row['idcat']) . '\', \'' . $row['width'] . '\', \'' . $row['height'] . '\');return false;'; $display_link = ''; } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::RESIZE) { $onclick = 'increment_view(' . $row['id'] . ');display_pics(' . $row['id'] . ', \'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&cat=' . $row['idcat']) . '\');return false;'; $display_link = ''; } else { $onclick = true; $display_link = url('gallery.php?cat=' . $row['idcat'] . '&id=' . $row['id'], 'gallery-' . $row['idcat'] . '-' . $row['id'] . '.php') . '#pics_max'; } //Liste des catégories. $search_category_children_options = new SearchCategoryChildrensOptions(); $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS); $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS); $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($row['id'] . 'cat', '', $row['idcat'], $search_category_children_options); $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options'); $method->setAccessible(true); $categories_tree_options = $method->invoke($categories_tree); $cat_list = ''; foreach ($categories_tree_options as $option) { $cat_list .= $option->display()->render(); } $notation = new Notation(); $notation->set_module_name('gallery'); $notation->set_notation_scale($config->get_notation_scale()); $notation->set_id_in_module($row['id']); $notation->set_number_notes($row['number_notes']); $notation->set_average_notes($row['average_notes']); $notation->set_user_already_noted(!empty($row['note'])); $group_color = User::get_group_color($row['groups'], $row['level']); $comments_topic->set_id_in_module($row['id']); $html_protected_name = $row['name']; $this->tpl->assign_block_vars('pics_list', array('C_IMG_APROB' => $row['aprob'] == 1, 'C_OPEN_TR' => is_int($j++ / $nbr_column_pics), 'C_CLOSE_TR' => is_int($j / $nbr_column_pics), 'ID' => $row['id'], 'APROB' => $row['aprob'], 'PATH' => $row['path'], 'NAME' => stripslashes($row['name']), 'SHORT_NAME' => TextHelper::wordwrap_html(stripslashes($row['name']), 22, ' '), 'POSTOR' => $LANG['by'] . (!empty($row['display_name']) ? ' <a class="small ' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '">' . $row['display_name'] . '</a>' : ' ' . $LANG['guest']), 'VIEWS' => $row['views'], 'L_VIEWS' => $row['views'] > 1 ? $LANG['views'] : $LANG['view'], 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $row['id']), 'KERNEL_NOTATION' => $config->is_notation_enabled() && $is_connected ? NotationService::display_active_image($notation) : NotationService::display_static_image($notation), 'CAT' => $cat_list, 'ONCLICK' => $onclick, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'L_APROB_IMG' => $row['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'U_PICTURE_LINK' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&id=' . $row['id'], '-' . $row['idcat'] . '-' . $row['id'] . '.php'), 'U_PICTURE' => PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'], 'U_DEL' => url('gallery.php?del=' . $row['id'] . '&token=' . AppContext::get_session()->get_token() . '&cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $row['id'] . '&token=' . AppContext::get_session()->get_token() . '&move=\' + this.options[this.selectedIndex].value'), 'U_DISPLAY' => $display_link, 'U_COMMENTS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&id=' . $row['id'] . '&com=0', '-' . $row['idcat'] . '-' . $row['id'] . '.php?com=0') . '#comments-list')); } $result->dispose(); //Création des cellules du tableau si besoin est. while (!is_int($j / $nbr_column_pics)) { $this->tpl->assign_block_vars('end_table', array('TD_END' => '<td class="td-end" style="width:' . $column_width_pics . '%"> </td>', 'TR_END' => is_int(++$j / $nbr_column_pics) ? '</tr>' : '')); } } } }
private function build_view() { global $LANG, $MEDIA_LANG; require_once PATH_TO_ROOT . '/media/media_constant.php'; load_module_lang('media'); $config = MediaConfig::load(); $category = $this->get_category(); $authorized_categories = MediaService::get_authorized_categories($category->get_id()); //Contenu de la catégorie $page = AppContext::get_request()->get_getint('p', 1); $subcategories_page = AppContext::get_request()->get_getint('subcategories_page', 1); $get_sort = retrieve(GET, 'sort', ''); $get_mode = retrieve(GET, 'mode', ''); $mode = $get_mode == 'asc' ? 'ASC' : 'DESC'; $unget = !empty($get_sort) && !empty($mode) ? '?sort=' . $get_sort . '&mode=' . $get_mode : ''; //On crée une pagination si le nombre de sous-catégories est trop important. $subcategories_number = count(MediaService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id())); $pagination = new ModulePagination($subcategories_page, $subcategories_number, $config->get_categories_number_per_page()); $pagination->set_url(new Url('/media/media.php' . (!empty($unget) ? $unget . '&' : '?') . 'cat=' . $category->get_id() . '&p=' . $page . '&subcategories_page=%d')); if ($pagination->current_page_is_empty() && $subcategories_page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } //Children categories $result = PersistenceContext::get_querier()->select('SELECT @id_cat:= media_cats.id, media_cats.*, (SELECT COUNT(*) FROM ' . MediaSetup::$media_table . ' WHERE idcat IN ( @id_cat, (SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . MediaSetup::$media_cats_table . ' WHERE id_parent = @id_cat), (SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . MediaSetup::$media_cats_table . ' parents INNER JOIN ' . MediaSetup::$media_cats_table . ' childs ON parents.id = childs.id_parent WHERE parents.id_parent = @id_cat) ) AND infos = :status ) AS mediafiles_number FROM ' . MediaSetup::$media_cats_table . ' media_cats WHERE id_parent = :id_category AND id IN :authorized_categories ORDER BY id_parent, c_order LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $category->get_id(), 'status' => MEDIA_STATUS_APROBED, 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from())); $nbr_cat_displayed = 0; while ($row = $result->fetch()) { $category_image = new Url($row['image']); $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'MEDIAFILES_NUMBER' => sprintf($row['mediafiles_number'] > 1 ? $MEDIA_LANG['num_medias'] : $MEDIA_LANG['num_media'], $row['mediafiles_number']), 'U_CATEGORY' => MediaUrlBuilder::display_category($row['id'], $row['rewrited_name'])->rel())); $nbr_cat_displayed++; } $result->dispose(); $nbr_column_cats = $nbr_cat_displayed > $config->get_columns_number_per_line() ? $config->get_columns_number_per_line() : $nbr_cat_displayed; $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1; $cats_columns_width = floor(100 / $nbr_column_cats); $category_description = FormatingHelper::second_parse($category->get_description()); $this->tpl->put_all(array('C_CATEGORIES' => true, 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_MODO' => MediaAuthorizationsService::check_authorizations($category->get_id())->moderation(), 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'L_UNAPROBED' => $MEDIA_LANG['unaprobed_media_short'], 'L_BY' => $MEDIA_LANG['media_added_by'], 'CATS_COLUMNS_WIDTH' => $cats_columns_width, 'CATEGORY_NAME' => $category->get_id() == Category::ROOT_CATEGORY ? LangLoader::get_message('module_title', 'common', 'media') : $category->get_name(), 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? MediaUrlBuilder::configuration()->rel() : MediaUrlBuilder::edit_category($category->get_id())->rel(), 'ID_CAT' => $category->get_id())); $selected_fields = array('alpha' => '', 'date' => '', 'nbr' => '', 'note' => '', 'com' => '', 'asc' => '', 'desc' => ''); switch ($get_sort) { case 'alpha': $sort = 'name'; $selected_fields['alpha'] = ' selected="selected"'; break; default: case 'date': $sort = 'timestamp'; $selected_fields['date'] = ' selected="selected"'; break; case 'nbr': $sort = 'counter'; $selected_fields['nbr'] = ' selected="selected"'; break; case 'note': $sort = 'average_notes'; $selected_fields['note'] = ' selected="selected"'; break; case 'com': $sort = 'com.number_comments'; $selected_fields['com'] = ' selected="selected"'; break; } if ($mode == 'ASC') { $selected_fields['asc'] = ' selected="selected"'; } else { $selected_fields['desc'] = ' selected="selected"'; } $this->tpl->put_all(array('C_DISPLAY_NOTATION' => $config->is_notation_enabled(), 'C_DISPLAY_COMMENTS' => $config->are_comments_enabled(), 'L_ALPHA' => $MEDIA_LANG['sort_title'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_NBR' => $MEDIA_LANG['sort_popularity'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_DESC' => $LANG['desc'], 'L_ASC' => $LANG['asc'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common'), 'SELECTED_ALPHA' => $selected_fields['alpha'], 'SELECTED_DATE' => $selected_fields['date'], 'SELECTED_NBR' => $selected_fields['nbr'], 'SELECTED_NOTE' => $selected_fields['note'], 'SELECTED_COM' => $selected_fields['com'], 'SELECTED_ASC' => $selected_fields['asc'], 'SELECTED_DESC' => $selected_fields['desc'])); $condition = 'WHERE idcat = :idcat AND infos = :status'; $parameters = array('idcat' => $category->get_id(), 'status' => MEDIA_STATUS_APROBED); //On crée une pagination si le nombre de fichiers est trop important. $mediafiles_number = MediaService::count($condition, $parameters); $pagination = new ModulePagination($page, $mediafiles_number, $config->get_items_number_per_page()); $pagination->set_url(new Url('/media/media.php' . (!empty($unget) ? $unget . '&' : '?') . 'cat=' . $category->get_id() . '&p=%d&subcategories_page=' . $subcategories_page)); if ($pagination->current_page_is_empty() && $page > 1) { $error_controller = PHPBoostErrors::unexisting_page(); DispatchManager::redirect($error_controller); } $notation = new Notation(); $notation->set_module_name('media'); $notation->set_notation_scale($config->get_notation_scale()); $result = PersistenceContext::get_querier()->select("SELECT v.id, v.iduser, v.name, v.timestamp, v.counter, v.infos, v.contents, mb.display_name, mb.groups, mb.level, notes.average_notes, com.number_comments\n\t\t\tFROM " . PREFIX . "media AS v\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " AS mb ON v.iduser = mb.user_id\n\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON v.id = notes.id_in_module AND notes.module_name = 'media'\n\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON v.id = com.id_in_module AND com.module_id = 'media'\n\t\t\t" . $condition . "\n\t\t\tORDER BY " . $sort . " " . $mode . "\n\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array_merge($parameters, array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()))); $this->tpl->put_all(array('C_FILES' => $result->get_rows_count() > 0, 'C_DISPLAY_NO_FILE_MSG' => $result->get_rows_count() == 0 && $category->get_id() != Category::ROOT_CATEGORY, 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'TARGET_ON_CHANGE_ORDER' => ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? 'media-0-' . $category->get_id() . '.php?' : 'media.php?cat=' . $category->get_id() . '&')); while ($row = $result->fetch()) { $notation->set_id_in_module($row['id']); $group_color = User::get_group_color($row['groups'], $row['level']); $this->tpl->assign_block_vars('file', array('ID' => $row['id'], 'NAME' => $row['name'], 'IMG_NAME' => str_replace('"', '\\"', $row['name']), 'C_DESCRIPTION' => !empty($row['contents']), 'DESCRIPTION' => stripslashes(FormatingHelper::second_parse($row['contents'])), 'POSTER' => $MEDIA_LANG['media_added_by'] . ' : ' . !empty($row['display_name']) ? '<a href="' . UserUrlBuilder::profile($row['iduser'])->rel() . '" class="' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $row['display_name'] . '</a>' : $LANG['guest'], 'DATE' => sprintf($MEDIA_LANG['add_on_date'], Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR)), 'COUNT' => sprintf($MEDIA_LANG['view_n_times'], $row['counter']), 'NOTE' => NotationService::display_static_image($notation), 'U_MEDIA_LINK' => PATH_TO_ROOT . '/media/' . url('media.php?id=' . $row['id'], 'media-' . $row['id'] . '-' . $category->get_id() . '+' . Url::encode_rewrite($row['name']) . '.php'), 'U_ADMIN_UNVISIBLE_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?unvisible=' . $row['id'] . '&token=' . AppContext::get_session()->get_token()), 'U_ADMIN_EDIT_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?edit=' . $row['id']), 'U_ADMIN_DELETE_MEDIA' => PATH_TO_ROOT . url('/media/media_action.php?del=' . $row['id'] . '&token=' . AppContext::get_session()->get_token()), 'U_COM_LINK' => '<a href="' . PATH_TO_ROOT . '/media/media' . url('.php?id=' . $row['id'] . '&com=0', '-' . $row['id'] . '-' . $category->get_id() . '+' . Url::encode_rewrite($row['name']) . '.php?com=0') . '">' . CommentsService::get_number_and_lang_comments('media', $row['id']) . '</a>')); } $result->dispose(); }
protected function display_site_maintenance() { //Users not authorized cannot come here parent::process_site_maintenance(); $template = new FileTemplate('maintain.tpl'); $maintenance_config = MaintenanceConfig::load(); if ($maintenance_config->is_under_maintenance() && $maintenance_config->get_display_duration_for_admin()) { $date_lang = LangLoader::get('date-common'); //Durée de la maintenance. $array_time = array(-1, 60, 300, 600, 900, 1800, 3600, 7200, 10800, 14400, 18000, 21600, 25200, 28800, 57600, 86400, 172800, 604800); $array_delay = array(LangLoader::get_message('unspecified', 'main'), '1 ' . $date_lang['minute'], '5 ' . $date_lang['minutes'], '10 ' . $date_lang['minutes'], '15 ' . $date_lang['minutes'], '30 ' . $date_lang['minutes'], '1 ' . $date_lang['hour'], '2 ' . $date_lang['hours'], '3 ' . $date_lang['hours'], '4 ' . $date_lang['hours'], '5 ' . $date_lang['hours'], '6 ' . $date_lang['hours'], '7 ' . $date_lang['hours'], '8 ' . $date_lang['hours'], '16 ' . $date_lang['hours'], '1 ' . $date_lang['day'], '2 ' . $date_lang['hours'], '1 ' . $date_lang['week']); //Retourne le délai de maintenance le plus proche. if (!$maintenance_config->is_unlimited_maintenance()) { $key_delay = 0; $current_time = time(); $array_size = count($array_time) - 1; $end_timestamp = $maintenance_config->get_end_date()->get_timestamp(); for ($i = $array_size; $i >= 1; $i--) { if ($end_timestamp - $current_time - $array_time[$i] < 0 && $end_timestamp - $current_time - $array_time[$i - 1] > 0) { $key_delay = $i - 1; break; } } //Calcul du format de la date $array_release = array(Date::to_format($end_timestamp, 'Y', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 'n', Timezone::SITE_TIMEZONE) - 1, Date::to_format($end_timestamp, 'j', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 'G', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 'i', Timezone::SITE_TIMEZONE), Date::to_format($end_timestamp, 's', Timezone::SITE_TIMEZONE)); $array_now = array(Date::to_format(time(), 'Y', Timezone::SITE_TIMEZONE), Date::to_format(time(), 'n', Timezone::SITE_TIMEZONE) - 1, Date::to_format(time(), 'j', Timezone::SITE_TIMEZONE), Date::to_format(time(), 'G', Timezone::SITE_TIMEZONE), Date::to_format(time(), 'i', Timezone::SITE_TIMEZONE), Date::to_format(time(), 's', Timezone::SITE_TIMEZONE)); } else { $key_delay = 0; $array_release = array('0', '0', '0', '0', '0', '0'); $array_now = array('0', '0', '0', '0', '0', '0'); } $template->put_all(array('C_ALERT_MAINTAIN' => true, 'C_MAINTAIN_DELAY' => true, 'UNSPECIFIED' => $maintenance_config->is_unlimited_maintenance() ? 0 : 1, 'DELAY' => isset($array_delay[$key_delay]) ? $array_delay[$key_delay] : '0', 'MAINTAIN_RELEASE_FORMAT' => implode(',', $array_release), 'MAINTAIN_NOW_FORMAT' => implode(',', $array_now), 'L_MAINTAIN_DELAY' => self::$main_lang['maintain_delay'], 'L_LOADING' => self::$main_lang['loading'], 'L_DAYS' => $date_lang['days'], 'L_HOURS' => $date_lang['hours'], 'L_MIN' => $date_lang['minutes'], 'L_SEC' => $date_lang['seconds'])); } return $template; }
} $user_accounts_config = UserAccountsConfig::load(); //Avatar if (empty($row['user_avatar'])) { $user_avatar = $user_accounts_config->is_default_avatar_enabled() == '1' ? '<img src="../templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name() . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" />' : ''; } else { $user_avatar = '<img src="' . Url::to_rel($row['user_avatar']) . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '"/>'; } //Affichage du nombre de message. if ($row['posted_msg'] >= 1) { $posted_msg = '<a href="' . UserUrlBuilder::messages($row['user_id'])->rel() . '" class="small">' . $LANG['message_s'] . '</a>: ' . $row['posted_msg']; } else { $posted_msg = !$is_guest ? '<a href="' . PATH_TO_ROOT . '/forum/membermsg' . url('.php?id=' . $row['user_id'], '') . '" class="small">' . $LANG['message'] . '</a>: 0' : $LANG['message'] . ': 0'; } $user_sign_field = $extended_fields_cache->get_extended_field_by_field_name('user_sign'); $tpl->assign_block_vars('msg', array('ID' => $row['id'], 'CLASS_COLOR' => $j % 2 == 0 ? '' : 2, 'FORUM_ONLINE_STATUT_USER' => !empty($row['connect']) ? 'online' : 'offline', 'FORUM_USER_LOGIN' => TextHelper::wordwrap_html($row['login'], 13), 'FORUM_MSG_DATE' => $LANG['on'] . ' ' . Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'FORUM_MSG_CONTENTS' => FormatingHelper::second_parse(stripslashes($row['contents'])), 'FORUM_USER_EDITOR_LOGIN' => $row['login_edit'], 'FORUM_USER_EDITOR_DATE' => Date::to_format($row['timestamp_edit'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'USER_RANK' => $row['warning_percentage'] < '100' || time() - $row['delay_banned'] < 0 ? $user_rank : LangLoader::get_message('banned', 'user-common'), 'USER_IMG_ASSOC' => $user_assoc_img, 'USER_AVATAR' => $user_avatar, 'USER_GROUP' => $user_groups, 'USER_DATE' => !$is_guest ? $LANG['registered_on'] . ': ' . Date::to_format($row['registered'], Date::FORMAT_DAY_MONTH_YEAR) : '', 'USER_MSG' => !$is_guest ? $posted_msg : '', 'USER_MAIL' => !empty($row['email']) && $row['show_email'] == '1' ? '<a href="mailto:' . $row['email'] . '" class="basic-button smaller">Mail</a>' : '', 'USER_SIGN' => !empty($row['user_sign']) && !empty($user_sign_field) && $user_sign_field['display'] ? '____________________<br />' . FormatingHelper::second_parse($row['user_sign']) : '', 'USER_WARNING' => $row['warning_percentage'], 'L_FORUM_QUOTE_LAST_MSG' => $quote_last_msg == 1 && $i == 0 ? $LANG['forum_quote_last_msg'] : '', 'C_USER_ONLINE' => !empty($row['connect']), 'C_FORUM_USER_LOGIN' => !empty($row['login']), 'C_FORUM_MSG_EDIT' => $edit, 'C_FORUM_MSG_DEL' => $del, 'C_FORUM_MSG_DEL_MSG' => !$first_message, 'C_FORUM_MSG_CUT' => $cut, 'C_FORUM_USER_EDITOR' => $row['timestamp_edit'] > 0 && $config->is_edit_mark_enabled(), 'C_FORUM_USER_EDITOR_LOGIN' => !empty($row['login_edit']), 'C_FORUM_MODERATOR' => $moderator, 'U_FORUM_USER_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel(), 'U_FORUM_MSG_EDIT' => url('.php?new=msg&idm=' . $row['id'] . '&id=' . $topic['idcat'] . '&idt=' . $id_get), 'U_FORUM_USER_EDITOR_PROFILE' => UserUrlBuilder::profile($row['user_id_edit'])->rel(), 'U_FORUM_MSG_DEL' => url('.php?del=1&idm=' . $row['id'] . '&token=' . AppContext::get_session()->get_token()), 'U_FORUM_WARNING' => url('.php?action=warning&id=' . $row['user_id']), 'U_FORUM_PUNISHEMENT' => url('.php?action=punish&id=' . $row['user_id']), 'U_FORUM_MSG_CUT' => url('.php?idm=' . $row['id']), 'U_VARS_ANCRE' => url('.php?id=' . $id_get . (!empty($page) ? '&pt=' . $page : ''), '-' . $id_get . (!empty($page) ? '-' . $page : '') . $rewrited_title . '.php'), 'U_VARS_QUOTE' => url('.php?quote=' . $row['id'] . '&id=' . $id_get . (!empty($page) ? '&pt=' . $page : ''), '-' . $id_get . (!empty($page) ? '-' . $page : '-0') . '-0-' . $row['id'] . $rewrited_title . '.php'), 'USER_PM' => !$is_guest && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL) ? '<a href="' . UserUrlBuilder::personnal_message($row['user_id'])->rel() . '" class="basic-button smaller">MP</a>' : '')); foreach ($displayed_extended_fields as $field_type) { $field = $extended_fields_cache->get_extended_field_by_field_name($field_type); if (!empty($row[$field_type]) && !empty($field) && $field['display']) { $button = ''; if ($field['regex'] == 4) { foreach (MemberShortTextExtendedField::$brands_pictures_list as $id => $parameters) { if (strstr($row[$field_type], $id)) { $button = '<a href="mailto:' . $row[$field_type] . '" class="basic-button smaller"><i class="fa ' . $parameters['picture'] . '"></i> ' . $parameters['title'] . '</a>'; } } } else { if ($field['regex'] == 5) { $button = '<a href="' . $row[$field_type] . '" class="basic-button smaller">' . LangLoader::get_message('regex.website', 'admin-user-common') . '</a>'; foreach (MemberShortTextExtendedField::$brands_pictures_list as $id => $parameters) { if (strstr($row[$field_type], $id)) {