public function execute(HTTPRequestCustom $request)
    {
        $id = $request->get_getint('id');
        $this->init();
        $extended_field = new ExtendedField();
        $extended_field->set_id($id);
        $exist_field = ExtendedFieldsDatabaseService::check_field_exist_by_id($extended_field);
        if ($exist_field) {
            $this->extended_field = ExtendedFieldsCache::load()->get_extended_field($id);
            $this->build_form($request);
        } else {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        $this->tpl = new StringTemplate('# INCLUDE MSG #
				# INCLUDE FORM #
				<script>
				jQuery(document).ready(function() {
				' . $this->get_events_select_type() . '});
				</script>');
        $this->tpl->add_lang($this->lang);
        $this->tpl->put_all(array('FIELD_TYPE' => $this->extended_field['field_type']));
        if ($this->submit_button->has_been_submited() && $this->form->validate()) {
            $extended_field = $this->save($id);
            $error = ExtendedFieldsService::get_error();
            if (!empty($error)) {
                $this->tpl->put('MSG', MessageHelper::display($error, MessageHelper::ERROR, 5));
            } else {
                AppContext::get_response()->redirect($this->form->get_value('referrer') ? $this->form->get_value('referrer') : AdminExtendedFieldsUrlBuilder::fields_list(), StringVars::replace_vars($this->lang['message.success.edit'], array('name' => $extended_field->get_name())));
            }
        }
        $this->tpl->put('FORM', $this->form->display());
        return new AdminExtendedFieldsDisplayResponse($this->tpl, $this->lang['extended-field-edit']);
    }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id)) {
         try {
             $this->weblink = WebService::get_weblink('WHERE web.id = :id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
     if ($this->weblink !== null && !DownloadAuthorizationsService::check_authorizations($this->weblink->get_id_category())->read()) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     } else {
         if ($this->weblink !== null && $this->weblink->is_visible()) {
             $this->weblink->set_number_views($this->weblink->get_number_views() + 1);
             WebService::update_number_views($this->weblink);
             WebCache::invalidate();
             AppContext::get_response()->redirect($this->weblink->get_url()->absolute());
         } else {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
 }
 private function check_page_exists()
 {
     if (!BugtrackerConfig::load()->are_stats_enabled()) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id) && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
         try {
             $this->downloadfile = DownloadService::get_downloadfile('WHERE download.id = :id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
     if ($this->downloadfile !== null && $this->downloadfile->is_visible()) {
         if (!PersistenceContext::get_querier()->row_exists(PREFIX . 'events', 'WHERE id_in_module=:id_in_module AND module=\'download\' AND current_status = 0', array('id_in_module' => $this->downloadfile->get_id()))) {
             $contribution = new Contribution();
             $contribution->set_id_in_module($this->downloadfile->get_id());
             $contribution->set_entitled(StringVars::replace_vars(LangLoader::get_message('contribution.deadlink', 'common'), array('link_name' => $this->downloadfile->get_name())));
             $contribution->set_fixing_url(DownloadUrlBuilder::edit($this->downloadfile->get_id())->relative());
             $contribution->set_description(LangLoader::get_message('contribution.deadlink_explain', 'common'));
             $contribution->set_poster_id(AppContext::get_current_user()->get_id());
             $contribution->set_module('download');
             $contribution->set_type('alert');
             $contribution->set_auth(Authorizations::capture_and_shift_bit_auth(DownloadService::get_categories_manager()->get_heritated_authorizations($this->downloadfile->get_id_category(), Category::MODERATION_AUTHORIZATIONS, Authorizations::AUTH_CHILD_PRIORITY), Category::MODERATION_AUTHORIZATIONS, Contribution::CONTRIBUTION_AUTH_BIT));
             ContributionService::save_contribution($contribution);
         }
         DispatchManager::redirect(new UserContributionSuccessController());
     } else {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
 }
 private function get_event($event_id)
 {
     try {
         $this->event = CalendarService::get_event('WHERE id_event = :id', array('id' => $event_id));
     } catch (RowNotFoundException $e) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
 }
 private function get_pagination($number_users_online)
 {
     $page = AppContext::get_request()->get_getint('page', 1);
     $pagination = new ModulePagination($page, $number_users_online, (int) $this->config->get_number_members_per_page());
     $pagination->set_url(OnlineUrlBuilder::home('%d'));
     if ($pagination->current_page_is_empty() && $page > 1) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
     return $pagination;
 }
 private function get_downloadfile(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id)) {
         try {
             $this->downloadfile = DownloadService::get_downloadfile('WHERE download.id=:id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
 }
 private function get_pagination()
 {
     $nbr_streams = PersistenceContext::get_querier()->count(NewsletterSetup::$newsletter_table_streams);
     $page = AppContext::get_request()->get_getint('page', 1);
     $pagination = new ModulePagination($page, $nbr_streams, $this->nbr_streams_per_page);
     $pagination->set_url(NewsletterUrlBuilder::home('%d'));
     if ($pagination->current_page_is_empty() && $page > 1) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
     return $pagination;
 }
 private function get_message(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id)) {
         try {
             return ShoutboxService::get_message('WHERE id=:id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
 }
 private function get_category()
 {
     if ($this->category === null) {
         $id = AppContext::get_request()->get_getint('id_category', 0);
         if (!empty($id)) {
             try {
                 $this->category = CalendarService::get_categories_manager()->get_categories_cache()->get_category($id);
             } catch (CategoryNotFoundException $e) {
                 $error_controller = PHPBoostErrors::unexisting_page();
                 DispatchManager::redirect($error_controller);
             }
         } else {
             $this->category = CalendarService::get_categories_manager()->get_categories_cache()->get_category(Category::ROOT_CATEGORY);
         }
     }
     return $this->category;
 }
 private function get_event()
 {
     if ($this->event === null) {
         $id = AppContext::get_request()->get_getint('id', 0);
         if (!empty($id)) {
             try {
                 $this->event = CalendarService::get_event('WHERE id_event = :id', array('id' => $id));
             } catch (RowNotFoundException $e) {
                 $error_controller = PHPBoostErrors::unexisting_page();
                 DispatchManager::redirect($error_controller);
             }
         } else {
             $this->event = new CalendarEvent();
         }
     }
     return $this->event;
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->init();
     $this->id = $request->get_value('id', null);
     if ($this->exists()) {
         $this->build_form();
         if ($this->submit_button->has_been_submited() && $this->form->validate()) {
             $this->uninstall($this->form->get_value('drop_files')->get_raw_value());
             AppContext::get_response()->redirect(AdminLangsUrlBuilder::list_installed_langs());
         }
         $this->tpl->put('FORM', $this->form->display());
         return new AdminLangsDisplayResponse($this->tpl, $this->lang['langs.delete_lang']);
     } else {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->init($request);
     $this->build_form();
     if ($this->request->get_bool('disconnect', false)) {
         AppContext::get_session()->csrf_get_protect();
         $session = AppContext::get_session();
         Session::delete($session);
         AppContext::get_response()->redirect($this->get_redirect_url());
     }
     if (AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
         if (!$this->maintain_config->is_under_maintenance() || $this->maintain_config->is_under_maintenance() && $this->maintain_config->is_authorized_in_maintenance()) {
             if ($this->request->get_value('redirect', '') || $this->redirect !== null) {
                 AppContext::get_response()->redirect($this->get_redirect_url());
             } else {
                 AppContext::get_response()->redirect(Environment::get_home_page());
             }
         }
     }
     $authenticate_type = $this->request->get_value('authenticate', false);
     if ($authenticate_type) {
         if ($authenticate_type == PHPBoostAuthenticationMethod::AUTHENTICATION_METHOD) {
             $login = $this->request->get_value('login', '');
             $password = $this->request->get_value('password', '');
             $autoconnect = $this->request->get_bool('autoconnect', false);
             $this->phpboost_authenticate($login, $password, $autoconnect);
         } else {
             try {
                 $authentication = AuthenticationService::get_authentication_method($authenticate_type);
             } catch (Exception $e) {
                 $error_controller = PHPBoostErrors::unexisting_page();
                 DispatchManager::redirect($error_controller);
             }
             $this->authenticate($authentication, true);
         }
     }
     if ($this->submit_button->has_been_submited() && $this->form->validate()) {
         $login = $this->form->get_value('login');
         $password = $this->form->get_value('password');
         $autoconnect = $this->form->get_value('autoconnect');
         $this->phpboost_authenticate($login, $password, $autoconnect);
     }
     $this->init_vars_template();
     return $this->build_view();
 }
 public function execute(HTTPRequestCustom $request)
 {
     $id = $request->get_getint('id', 0);
     if (!empty($id)) {
         try {
             $this->downloadfile = DownloadService::get_downloadfile('WHERE download.id = :id', array('id' => $id));
         } catch (RowNotFoundException $e) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
     if ($this->downloadfile !== null && !DownloadAuthorizationsService::check_authorizations($this->downloadfile->get_id_category())->read()) {
         $error_controller = PHPBoostErrors::user_not_authorized();
         DispatchManager::redirect($error_controller);
     } else {
         if ($this->downloadfile !== null && $this->downloadfile->is_visible()) {
             $this->downloadfile->set_number_downloads($this->downloadfile->get_number_downloads() + 1);
             DownloadService::update_number_downloads($this->downloadfile);
             DownloadCache::invalidate();
             $status = 200;
             $file_headers = get_headers($this->downloadfile->get_url()->absolute(), true);
             if (is_array($file_headers)) {
                 if (preg_match('/^HTTP\\/[12]\\.[01] (\\d\\d\\d)/', $file_headers[0], $matches)) {
                     $status = (int) $matches[1];
                 }
             }
             if ($status == 200) {
                 header('Content-Disposition: attachment; filename="' . urldecode(basename($this->downloadfile->get_url()->absolute())) . '"');
                 header('Content-Description: File Transfer');
                 header('Content-Transfer-Encoding: binary');
                 header('Accept-Ranges: bytes');
                 header('Content-Type: application/force-download');
                 set_time_limit(0);
                 readfile($this->downloadfile->get_url()->absolute());
             } else {
                 $error_controller = new UserErrorController(LangLoader::get_message('error', 'status-messages-common'), LangLoader::get_message('download.message.error.file_not_found', 'common', 'download'), UserErrorController::WARNING);
                 DispatchManager::redirect($error_controller);
             }
         } else {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
     }
 }
 private function build_form($request)
 {
     $field = $request->get_value('field', 'pseudo');
     $sort = $request->get_value('sort', 'top');
     $current_page = $request->get_int('page', 1);
     if (!NewsletterAuthorizationsService::id_stream($this->stream->get_id())->read_subscribers()) {
         NewsletterAuthorizationsService::get_errors()->read_subscribers();
     }
     $mode = $sort == 'top' ? 'ASC' : 'DESC';
     switch ($field) {
         case 'pseudo':
             $field_bdd = 'display_name';
             break;
         default:
             $field_bdd = 'display_name';
     }
     $subscribers_list = NewsletterService::list_subscribers_by_stream($this->stream->get_id());
     $nbr_subscribers = count($subscribers_list);
     $pagination = new ModulePagination($current_page, $nbr_subscribers, $this->nbr_subscribers_per_page);
     $pagination->set_url(NewsletterUrlBuilder::subscribers($this->stream->get_id(), $this->stream->get_rewrited_name(), $field, $sort, '%d'));
     if ($pagination->current_page_is_empty() && $current_page > 1) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
     $this->view->put_all(array('C_SUBSCRIBERS' => (int) $nbr_subscribers, 'C_SUBSCRIPTION' => NewsletterUrlBuilder::subscribe()->rel(), 'C_PAGINATION' => $pagination->has_several_pages(), 'SORT_PSEUDO_TOP' => NewsletterUrlBuilder::subscribers($this->stream->get_id(), $this->stream->get_rewrited_name(), 'pseudo', 'top', $current_page)->rel(), 'SORT_PSEUDO_BOTTOM' => NewsletterUrlBuilder::subscribers($this->stream->get_id(), $this->stream->get_rewrited_name(), 'pseudo', 'bottom', $current_page)->rel(), 'PAGINATION' => $pagination->display()));
     if (!empty($nbr_subscribers)) {
         $result = PersistenceContext::get_querier()->select("SELECT subscribers.id, subscribers.user_id, subscribers.mail, member.display_name, member.email\n\t\t\tFROM " . NewsletterSetup::$newsletter_table_subscribers . " subscribers\n\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " member ON subscribers.user_id = member.user_id\n\t\t\tWHERE subscribers.id IN :ids_list\n\t\t\tORDER BY " . $field_bdd . " " . $mode . "\n\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('ids_list' => array_keys($subscribers_list), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
         while ($row = $result->fetch()) {
             $pseudo = $row['user_id'] > 0 ? '<a href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '">' . $row['display_name'] . '</a>' : LangLoader::get_message('visitor', 'user-common');
             $mail = $row['user_id'] > 0 ? $row['email'] : $row['mail'];
             if (!empty($mail)) {
                 $this->view->assign_block_vars('subscribers_list', array('C_AUTH_MODO' => NewsletterAuthorizationsService::id_stream($this->stream->get_id())->moderation_subscribers(), 'C_EDIT' => $row['user_id'] == User::VISITOR_LEVEL, 'U_EDIT' => $row['user_id'] == User::VISITOR_LEVEL ? NewsletterUrlBuilder::edit_subscriber($row['id'])->rel() : '', 'U_DELETE' => NewsletterUrlBuilder::delete_subscriber($row['id'], $this->stream->get_id())->rel(), 'PSEUDO' => $pseudo, 'MAIL' => $mail));
             }
         }
         $result->dispose();
     }
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->init();
     try {
         $category = $this->get_category();
     } catch (CategoryNotFoundException $e) {
         $controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($controller);
     }
     $childrens = $this->get_category_childrens($category);
     if (empty($childrens) && !$this->get_category_items_exists($category)) {
         $this->get_categories_manager()->delete($this->get_category()->get_id());
         AppContext::get_response()->redirect($this->get_categories_management_url(), StringVars::replace_vars($this->get_success_message(), array('name' => $this->get_category()->get_name())));
     }
     $this->build_form();
     $tpl = new StringTemplate('# INCLUDE FORM #');
     $tpl->add_lang($this->lang);
     if ($this->submit_button->has_been_submited() && $this->form->validate()) {
         if ($this->form->get_value('delete_category_and_content')) {
             $this->get_categories_manager()->delete($this->get_category()->get_id());
             foreach ($childrens as $id => $category) {
                 $this->get_categories_manager()->delete($id);
             }
         } else {
             $id_parent = $this->form->get_value('move_in_other_cat')->get_raw_value();
             $this->get_categories_manager()->move_items_into_another($category, $id_parent);
             $childrens = $this->get_category_childrens($category, false);
             foreach ($childrens as $id => $category) {
                 $this->get_categories_manager()->move_into_another($category, $id_parent);
             }
             $this->get_categories_manager()->delete($this->get_category()->get_id());
         }
         AppContext::get_response()->redirect($this->get_categories_management_url(), StringVars::replace_vars($this->get_success_message(), array('name' => $this->get_category()->get_name())));
     }
     $tpl->put('FORM', $this->form->display());
     return $this->generate_response($tpl);
 }
示例#17
0
 *
 * 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';
$alert = retrieve(GET, 'id', 0);
$alert_post = retrieve(POST, 'id', 0);
$topic_id = !empty($alert) ? $alert : $alert_post;
try {
    $topic = PersistenceContext::get_querier()->select_single_row(PREFIX . 'forum_topics', array('idcat', 'title', 'subtitle'), 'WHERE id = :id', array('id' => $topic_id));
} catch (RowNotFoundException $e) {
    $error_controller = PHPBoostErrors::unexisting_page();
    DispatchManager::redirect($error_controller);
}
$category = ForumService::get_categories_manager()->get_categories_cache()->get_category($topic['idcat']);
$topic_name = !empty($topic['title']) ? stripslashes($topic['title']) : '';
$Bread_crumb->add($config->get_forum_name(), 'index.php');
$Bread_crumb->add($category->get_name(), 'forum' . url('.php?id=' . $topic['idcat'], '-' . $topic['idcat'] . '+' . $category->get_rewrited_name() . '.php'));
$Bread_crumb->add($topic['title'], 'topic' . url('.php?id=' . $alert, '-' . $alert . '-' . Url::encode_rewrite($topic_name) . '.php'));
$Bread_crumb->add($LANG['alert_topic'], '');
define('TITLE', $LANG['alert_topic']);
require_once '../kernel/header.php';
if (empty($alert) && empty($alert_post) || empty($topic['idcat'])) {
    AppContext::get_response()->redirect('/forum/index' . url('.php'));
}
if (!AppContext::get_current_user()->check_level(User::MEMBER_LEVEL)) {
    $error_controller = PHPBoostErrors::user_not_authorized();
 private function check_authorizations()
 {
     $weblink = $this->get_weblink();
     $not_authorized = !WebAuthorizationsService::check_authorizations($weblink->get_id_category())->moderation() && (!WebAuthorizationsService::check_authorizations($weblink->get_id_category())->write() && $weblink->get_author_user()->get_id() != AppContext::get_current_user()->get_id());
     switch ($weblink->get_approbation_type()) {
         case WebLink::APPROVAL_NOW:
             if (!WebAuthorizationsService::check_authorizations($weblink->get_id_category())->read() && $not_authorized) {
                 $error_controller = PHPBoostErrors::user_not_authorized();
                 DispatchManager::redirect($error_controller);
             }
             break;
         case WebLink::NOT_APPROVAL:
             if ($not_authorized) {
                 $error_controller = PHPBoostErrors::user_not_authorized();
                 DispatchManager::redirect($error_controller);
             }
             break;
         case WebLink::APPROVAL_DATE:
             if (!$weblink->is_visible() && $not_authorized) {
                 $error_controller = PHPBoostErrors::user_not_authorized();
                 DispatchManager::redirect($error_controller);
             }
             break;
         default:
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
             break;
     }
 }
 private function get_pagination($messages_number, $page)
 {
     $pagination = new ModulePagination($page, $messages_number, (int) GuestbookConfig::load()->get_items_per_page());
     $pagination->set_url(GuestbookUrlBuilder::home('%d'));
     if ($pagination->current_page_is_empty() && $page > 1) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
     return $pagination;
 }
 private function get_smiley()
 {
     if ($this->smiley === null) {
         $id = AppContext::get_request()->get_getint('id', 0);
         if (!empty($id)) {
             try {
                 $this->smiley = PersistenceContext::get_querier()->select_single_row(DB_TABLE_SMILEYS, array('idsmiley', 'code_smiley', 'url_smiley'), 'WHERE idsmiley = :id', array('id' => $id));
             } catch (RowNotFoundException $e) {
                 $error_controller = PHPBoostErrors::unexisting_page();
                 DispatchManager::redirect($error_controller);
             }
         } else {
             $this->smiley = array('idsmiley' => 0, 'code_smiley' => '', 'url_smiley' => '');
         }
     }
     return $this->smiley;
 }
 private function get_pagination($bugs_number, $page, $field, $sort, $filter, $filter_id)
 {
     $pagination = new ModulePagination($page, $bugs_number, (int) BugtrackerConfig::load()->get_items_per_page());
     $pagination->set_url(BugtrackerUrlBuilder::unsolved($field, $sort, '%d', $filter, $filter_id));
     if ($pagination->current_page_is_empty() && $page > 1) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
     return $pagination;
 }
    private function get_pagination($condition, $parameters, $page)
    {
        $result = PersistenceContext::get_querier()->select_single_row_query('SELECT COUNT(*) AS nbr_news
		FROM ' . NewsSetup::$news_table . ' news
		LEFT JOIN ' . DB_TABLE_KEYWORDS_RELATIONS . ' relation ON relation.module_id = \'news\' AND relation.id_in_module = news.id 
		' . $condition, $parameters);
        $pagination = new ModulePagination($page, $result['nbr_news'], (int) NewsConfig::load()->get_number_news_per_page());
        $pagination->set_url(NewsUrlBuilder::display_tag($this->get_keyword()->get_rewrited_name(), '%d'));
        if ($pagination->current_page_is_empty() && $page > 1) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        return $pagination;
    }
 private function get_pagination($condition, $parameters, $field, $mode, $page)
 {
     $downloadfiles_number = DownloadService::count($condition, $parameters);
     $pagination = new ModulePagination($page, $downloadfiles_number, (int) DownloadConfig::load()->get_items_number_per_page());
     $pagination->set_url(DownloadUrlBuilder::display_pending($field, $mode, '%d'));
     if ($pagination->current_page_is_empty() && $page > 1) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
     return $pagination;
 }
 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&amp;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'] . '&amp;y=' . $visit_year . '&amp;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'] . '&amp;y=' . $visit_year . '&amp;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;">&nbsp;</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 . '&amp;y=' . $visit_year . '&amp;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 . '&amp;y=' . $next_year . '&amp;visit=1', '-visit.php?m=' . $next_month . '&amp;y=' . $next_year), 'U_PREVIOUS_LINK' => url('.php?m=' . $previous_month . '&amp;y=' . $previous_year . '&amp;visit=1', '-visit.php?m=' . $previous_month . '&amp;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&amp;year=' . $year . '&amp;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;">&nbsp;</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&amp;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'] . '&amp;y=' . $pages_year . '&amp;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'] . '&amp;y=' . $pages_year . '&amp;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;">&nbsp;</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 . '&amp;y=' . $pages_year . '&amp;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 . '&amp;m=' . $next_month . '&amp;y=' . $next_year . '&amp;pages=1', '-pages.php?d=' . $next_day . '&amp;m=' . $next_month . '&amp;y=' . $next_year), 'U_PREVIOUS_LINK' => url('.php?d=' . $previous_day . '&amp;m=' . $previous_month . '&amp;y=' . $previous_year . '&amp;pages=1', '-pages.php?d=' . $previous_day . '&amp;m=' . $previous_month . '&amp;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&amp;year=' . $year . '&amp;month=' . $month . '&amp;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'] . '&amp;m=' . $row['stats_month'] . '&amp;y=' . $row['stats_year'] . '&amp;pages=1', '-pages.php?d=' . $row['stats_day'] . '&amp;m=' . $row['stats_month'] . '&amp;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 . '&amp;y=' . $next_year . '&amp;pages=1', '-pages.php?m=' . $next_month . '&amp;y=' . $next_year), 'U_PREVIOUS_LINK' => url('.php?m=' . $previous_month . '&amp;y=' . $previous_year . '&amp;pages=1', '-pages.php?m=' . $previous_month . '&amp;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&amp;year=' . $year . '&amp;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'] . '&amp;m=' . $row['stats_month'] . '&amp;y=' . $row['stats_year'] . '&amp;pages=1', '-pages.php?d=' . $row['stats_day'] . '&amp;m=' . $row['stats_month'] . '&amp;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;">&nbsp;</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&amp;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&amp;p=%d'));
         if ($pagination->current_page_is_empty() && $page > 1) {
             $error_controller = PHPBoostErrors::unexisting_page();
             DispatchManager::redirect($error_controller);
         }
         $result = $this->db_querier->select("SELECT id, count(*) as count, relative_url, SUM(total_visit) as total_visit, SUM(today_visit) as today_visit, SUM(yesterday_visit) as yesterday_visit, nbr_day, MAX(last_update) as last_update\r\n\t\t\t\tFROM " . PREFIX . "stats_referer\r\n\t\t\t\tWHERE type = 1\r\n\t\t\t\tGROUP BY relative_url\r\n\t\t\t\tORDER BY total_visit DESC\r\n\t\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
         while ($row = $result->fetch()) {
             $trend_parameters = get_trend_parameters($row['total_visit'], $row['nbr_day'], $row['yesterday_visit'], $row['today_visit']);
             $tpl->assign_block_vars('keyword_list', array('ID' => $row['id'], 'KEYWORD' => $row['relative_url'], 'IMG_MORE' => '<a class="fa fa-plus-square-o" style="cursor:pointer;" onclick="XMLHttpRequest_referer(' . $row['id'] . ')" id="img_url' . $row['id'] . '"></a>', 'NBR_LINKS' => $row['count'], 'TOTAL_VISIT' => $row['total_visit'], 'AVERAGE_VISIT' => $trend_parameters['average'], 'LAST_UPDATE' => Date::to_format($row['last_update'], Date::FORMAT_DAY_MONTH_YEAR), 'TREND' => ($trend_parameters['picture'] ? '<i class="fa fa-trend-' . $trend_parameters['picture'] . '"></i> ' : '') . '(' . $trend_parameters['sign'] . $trend_parameters['trend'] . '%)'));
         }
         $result->dispose();
         $tpl->put_all(array('C_STATS_KEYWORD' => true, 'C_KEYWORDS' => $nbr_keyword, 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_SEARCH_ENGINE' => $LANG['keyword_s'], 'L_TOTAL_VISIT' => $LANG['total_visit'], 'L_AVERAGE_VISIT' => $LANG['average_visit'], 'L_TREND' => $LANG['trend'], 'L_LAST_UPDATE' => $LANG['last_update'], 'L_NO_KEYWORD' => $LANG['no_keyword']));
     } elseif ($browser || $os || $user_lang) {
         $path = '../images/stats/';
         if (!empty($browser)) {
             $tpl->put_all(array('C_STATS_BROWSERS' => true, 'GRAPH_RESULT' => !file_exists('../cache/browsers.png') ? '<img src="display_stats.php?browsers=1" alt="' . $LANG['browser_s'] . '" />' : '<img src="../cache/browsers.png" alt="' . $LANG['browser_s'] . '" />', 'L_BROWSERS' => $LANG['browser_s'], 'L_COLORS' => $LANG['colors'], 'L_PERCENTAGE' => $LANG['percentage']));
             $stats_menu = 'browsers';
             $array_stats_info = $stats_array_browsers;
             $path = '../images/stats/browsers/';
         } elseif (!empty($os)) {
             $tpl->put_all(array('C_STATS_OS' => true, 'GRAPH_RESULT' => !file_exists('../cache/os.png') ? '<img src="display_stats.php?os=1" alt="' . $LANG['os'] . '" />' : '<img src="../cache/os.png" alt="' . $LANG['os'] . '" />', 'L_OS' => $LANG['os'], 'L_COLORS' => $LANG['colors'], 'L_PERCENTAGE' => $LANG['percentage']));
             $stats_menu = 'os';
             $array_stats_info = $stats_array_os;
             $path = '../images/stats/os/';
         } elseif (!empty($user_lang)) {
             $tpl->put_all(array('C_STATS_LANG' => true, 'GRAPH_RESULT' => !file_exists('../cache/lang.png') ? '<img src="display_stats.php?lang=1" alt="' . $LANG['stat_lang'] . '" />' : '<img src="../cache/lang.png" alt="' . $LANG['stat_lang'] . '" />', 'L_LANG' => $LANG['stat_lang'], 'L_COLORS' => $LANG['colors'], 'L_PERCENTAGE' => $LANG['percentage']));
             $stats_menu = 'lang';
             $array_stats_info = $stats_array_lang;
             $path = '../images/stats/countries/';
         }
         $Stats = new ImagesStats();
         $Stats->load_data(StatsSaver::retrieve_stats($stats_menu), 'ellipse', 5);
         //Tri décroissant.
         arsort($Stats->data_stats);
         //Traitement des données.
         $array_stats_tmp = array();
         $array_order = array();
         $percent_other = 0;
         foreach ($Stats->data_stats as $value_name => $angle_value) {
             if (!isset($array_stats_info[$value_name]) || $value_name == 'other') {
                 $value_name = 'other';
                 $angle_value += $percent_other;
                 $percent_other += $angle_value;
                 $stats_img = !empty($array_stats_info['other'][1]) ? '<img src="' . $path . $array_stats_info['other'][1] . '" alt="' . $LANG['other'] . '" />' : '<img src="' . TPL_PATH_TO_ROOT . '/images/stats/other.png" alt="' . $LANG['other'] . '" />';
                 $name_stats = $LANG['other'];
             } else {
                 $stats_img = !empty($array_stats_info[$value_name][1]) ? '<img src="' . $path . $array_stats_info[$value_name][1] . '" alt="' . $array_stats_info[$value_name][0] . '" />' : '-';
                 $name_stats = $array_stats_info[$value_name][0];
             }
             if (!isset($array_order[$value_name])) {
                 $array_color = $Stats->array_allocated_color[$Stats->image_color_allocate_dark(false, NO_ALLOCATE_COLOR)];
                 $array_stats_tmp[$value_name] = array($name_stats, $array_color, $stats_img);
                 $array_order[$value_name] = $angle_value;
             }
         }
         //Affichage.
         foreach ($array_order as $value_name => $angle_value) {
             $tpl->assign_block_vars('list', array('COLOR' => 'RGB(' . trim(implode(', ', $array_stats_tmp[$value_name][1]), ', ') . ')', 'IMG' => $array_stats_tmp[$value_name][2], 'L_NAME' => $array_stats_tmp[$value_name][0], 'PERCENT' => NumberHelper::round($angle_value / 3.6, 1)));
         }
     } else {
         $tpl->put_all(array('C_STATS_SITE' => true, 'START' => GeneralConfig::load()->get_site_install_date()->format(Date::FORMAT_DAY_MONTH_YEAR), 'VERSION' => GeneralConfig::load()->get_phpboost_major_version(), 'L_START' => $LANG['start'], 'L_VERSION' => $LANG['version']));
     }
     return $tpl;
 }
 private function get_pagination($condition, $parameters, $field, $mode, $page)
 {
     $number_articles = PersistenceContext::get_querier()->count(ArticlesSetup::$articles_table, $condition, $parameters);
     $pagination = new ModulePagination($page, $number_articles, (int) ArticlesConfig::load()->get_number_articles_per_page());
     $pagination->set_url(ArticlesUrlBuilder::display_pending_articles($field, $mode, '/%d'));
     if ($pagination->current_page_is_empty() && $page > 1) {
         $error_controller = PHPBoostErrors::unexisting_page();
         DispatchManager::redirect($error_controller);
     }
     return $pagination;
 }
 private function get_message()
 {
     if ($this->message === null) {
         $id = AppContext::get_request()->get_getint('id', 0);
         if (!empty($id)) {
             try {
                 $this->message = GuestbookService::get_message('WHERE id=:id', array('id' => $id));
             } catch (RowNotFoundException $e) {
                 $error_controller = PHPBoostErrors::unexisting_page();
                 DispatchManager::redirect($error_controller);
             }
         } else {
             $this->is_new_message = true;
             $this->message = new GuestbookMessage();
             $this->message->init_default_properties();
         }
     }
     return $this->message;
 }
 private function get_bug()
 {
     if ($this->bug === null) {
         $request = AppContext::get_request();
         $id = $request->get_getint('id', 0);
         if (!empty($id)) {
             try {
                 $this->bug = BugtrackerService::get_bug('WHERE id=:id', array('id' => $id));
             } catch (RowNotFoundException $e) {
                 $error_controller = PHPBoostErrors::unexisting_page();
                 DispatchManager::redirect($error_controller);
             }
         } else {
             $this->is_new_bug = true;
             $this->bug = new Bug();
             $this->bug->init_default_properties();
         }
     }
     return $this->bug;
 }
    private function get_pagination($condition, $parameters, $page)
    {
        $row = PersistenceContext::get_querier()->select_single_row_query('SELECT COUNT(*) AS events_number
		FROM ' . CalendarSetup::$calendar_events_table . ' event
		LEFT JOIN ' . CalendarSetup::$calendar_events_content_table . ' event_content ON event_content.id = event.content_id
		' . $condition, $parameters);
        $pagination = new ModulePagination($page, $row['events_number'], (int) CalendarConfig::load()->get_items_number_per_page());
        $pagination->set_url(CalendarUrlBuilder::display_pending_events('%d'));
        if ($pagination->current_page_is_empty() && $page > 1) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        return $pagination;
    }
 private function get_downloadfile()
 {
     if ($this->downloadfile === null) {
         $id = AppContext::get_request()->get_getint('id', 0);
         if (!empty($id)) {
             try {
                 $this->downloadfile = DownloadService::get_downloadfile('WHERE download.id=:id', array('id' => $id));
             } catch (RowNotFoundException $e) {
                 $error_controller = PHPBoostErrors::unexisting_page();
                 DispatchManager::redirect($error_controller);
             }
         } else {
             $this->is_new_downloadfile = true;
             $this->downloadfile = new DownloadFile();
             $this->downloadfile->init_default_properties(AppContext::get_request()->get_getint('id_category', Category::ROOT_CATEGORY));
         }
     }
     return $this->downloadfile;
 }
示例#30
0
        $number_comments = CommentsService::get_number_comments('pages', $page_infos['id']);
        $tpl->put_all(array('C_ACTIV_COM' => true, 'U_COM' => PagesUrlBuilder::get_link_item_com($page_infos['id']), 'L_COM' => $number_comments > 0 ? sprintf($LANG['pages_display_coms'], $number_comments) : $LANG['pages_post_com']));
    }
    //On compte le nombre de vus
    if ($page_infos['count_hits'] == 1) {
        PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "pages SET hits = hits + 1 WHERE id = " . $page_infos['id']);
    }
    $tpl->put_all(array('ID' => $page_infos['id'], 'TITLE' => stripslashes(stripslashes($page_infos['title'])), 'CONTENTS' => pages_second_parse($page_infos['contents']), 'COUNT_HITS' => $page_infos['count_hits'] ? sprintf($LANG['page_hits'], $page_infos['hits'] + 1) : '&nbsp;', 'L_LINKS' => $LANG['pages_links_list'], 'L_PAGE_OUTILS' => $LANG['pages_links_list']));
    $tpl->display();
} elseif ((!empty($encoded_title) || $id_com > 0) && $num_rows == 0) {
    $error_controller = PHPBoostErrors::unexisting_page();
    DispatchManager::redirect($error_controller);
} elseif ($id_com > 0) {
    //Commentaires activés pour cette page ?
    if ($page_infos['activ_com'] == 0) {
        DispatchManager::redirect(PHPBoostErrors::unexisting_page());
    }
    //Autorisation particulière ?
    $special_auth = !empty($page_infos['auth']);
    $array_auth = unserialize($page_infos['auth']);
    //Vérification de l'autorisation de voir la page
    if ($special_auth && !AppContext::get_current_user()->check_auth($array_auth, READ_PAGE) || !$special_auth && !AppContext::get_current_user()->check_auth($config_authorizations, READ_PAGE) && ($special_auth && !AppContext::get_current_user()->check_auth($array_auth, READ_COM)) || !$special_auth && !AppContext::get_current_user()->check_auth($config_authorizations, READ_COM)) {
        DispatchManager::redirect(PHPBoostErrors::user_not_authorized());
    }
    $tpl = new FileTemplate('pages/com.tpl');
    $comments_topic = new PagesCommentsTopic();
    $comments_topic->set_id_in_module($id_com);
    $comments_topic->set_url(new Url(PagesUrlBuilder::get_link_item_com($id_com, '%s')));
    $tpl->put_all(array('COMMENTS' => CommentsService::display($comments_topic)->render()));
    $tpl->display();
} else {