function build_modules_maps() { import('modules/modules_discovery_service'); $Modules = new ModulesDiscoveryService(); foreach ($Modules->get_available_modules('get_module_map') as $module) { $module_map = $module->get_module_map(SITE_MAP_AUTH_USER); $this->add($module_map); } }
function change_day() { global $Sql, $CONFIG_USER; #######Taches de maintenance####### $yesterday_timestamp = time() - 86400; $Sql->query_inject("INSERT INTO " . DB_TABLE_STATS . " (stats_year, stats_month, stats_day, nbr, pages, pages_detail) VALUES ('" . gmdate_format('Y', $yesterday_timestamp, TIMEZONE_SYSTEM) . "', '" . gmdate_format('m', $yesterday_timestamp, TIMEZONE_SYSTEM) . "', '" . gmdate_format('d', $yesterday_timestamp, TIMEZONE_SYSTEM) . "', 0, 0, '')", __LINE__, __FILE__); $last_stats = $Sql->insert_id("SELECT MAX(id) FROM " . PREFIX . "stats"); #######Statistiques####### $Sql->query_inject("UPDATE " . DB_TABLE_STATS_REFERER . " SET yesterday_visit = today_visit", __LINE__, __FILE__); $Sql->query_inject("UPDATE " . DB_TABLE_STATS_REFERER . " SET today_visit = 0, nbr_day = nbr_day + 1", __LINE__, __FILE__); $Sql->query_inject("DELETE FROM " . DB_TABLE_STATS_REFERER . " WHERE last_update < '" . (time() - 604800) . "'", __LINE__, __FILE__); $pages_displayed = pages_displayed(); import('io/filesystem/file'); $pages_file = new File(PATH_TO_ROOT . '/cache/pages.txt'); $pages_file->delete(); $total_visit = $Sql->query("SELECT total FROM " . DB_TABLE_VISIT_COUNTER . " WHERE id = 1", __LINE__, __FILE__); $Sql->query_inject("DELETE FROM " . DB_TABLE_VISIT_COUNTER . " WHERE id <> 1", __LINE__, __FILE__); $Sql->query_inject("UPDATE " . DB_TABLE_VISIT_COUNTER . " SET time = '" . gmdate_format('Y-m-d', time(), TIMEZONE_SYSTEM) . "', total = 1 WHERE id = 1", __LINE__, __FILE__); $Sql->query_inject("INSERT INTO " . DB_TABLE_VISIT_COUNTER . " (ip, time, total) VALUES('" . USER_IP . "', '" . gmdate_format('Y-m-d', time(), TIMEZONE_SYSTEM) . "', '0')", __LINE__, __FILE__); $Sql->query_inject("UPDATE " . DB_TABLE_STATS . " SET nbr = '" . $total_visit . "', pages = '" . array_sum($pages_displayed) . "', pages_detail = '" . addslashes(serialize($pages_displayed)) . "' WHERE id = '" . $last_stats . "'", __LINE__, __FILE__); Session::garbage_collector(); import('io/filesystem/folder'); $week = 3600 * 24 * 7; $cache_image_folder_path = new Folder(PATH_TO_ROOT . '/images/maths/'); foreach ($cache_image_folder_path->get_files('`\\.png$`') as $image) { if (time() - $image->get_last_modification_date() > $week) { $image->delete(); } } import('modules/modules_discovery_service'); $modules_loader = new ModulesDiscoveryService(); $modules = $modules_loader->get_available_modules('on_changeday'); foreach ($modules as $module) { if ($module->is_enabled()) { $module->functionality('on_changeday'); } } $CONFIG_USER['delay_unactiv_max'] = $CONFIG_USER['delay_unactiv_max'] * 3600 * 24; if (!empty($CONFIG_USER['delay_unactiv_max']) && $CONFIG_USER['activ_mbr'] != 2) { $Sql->query_inject("DELETE FROM " . DB_TABLE_MEMBER . " WHERE timestamp < '" . (time() - $CONFIG_USER['delay_unactiv_max']) . "' AND user_aprob = 0", __LINE__, __FILE__); } if ($CONFIG_USER['verif_code'] == '1') { $Sql->query_inject("DELETE FROM " . DB_TABLE_VERIF_CODE . " WHERE timestamp < '" . (time() - 3600 * 24) . "'", __LINE__, __FILE__); } import('core/updates'); new Updates(); }
function get_html_results(&$results, &$html_results, &$results_name) { global $CONFIG; $modules = new ModulesDiscoveryService(); $display_all_results = $results_name == 'all' ? true : false; $tpl_results = new Template('search/search_generic_pagination_results.tpl'); $tpl_results->assign_vars(array('RESULTS_NAME' => $results_name, 'C_ALL_RESULTS' => $display_all_results)); $nb_pages = round(count($results) / NB_RESULTS_PER_PAGE) + 1; $nb_results = count($results); if (!$display_all_results) { $module = $modules->get_module(strtolower($results_name)); $results_data = array(); $personnal_parse_results = $module->has_functionality('compute_search_results') && $module->has_functionality('parse_search_result'); if ($personnal_parse_results && $results_name != 'all') { $results_data = $module->functionality('compute_search_results', array('results' => $results)); $nb_results = min($nb_results, count($results_data)); } } for ($num_page = 0; $num_page < $nb_pages; $num_page++) { $tpl_results->assign_block_vars('page', array('NUM_PAGE' => $num_page, 'BLOCK_DISPLAY' => $num_page == 0 ? 'block' : 'none')); for ($i = 0; $i < NB_RESULTS_PER_PAGE; $i++) { $num_item = $num_page * NB_RESULTS_PER_PAGE + $i; if ($num_item >= $nb_results) { break; } if ($display_all_results || !$personnal_parse_results) { $tpl_result = new Template('search/search_generic_results.tpl'); if ($display_all_results) { $module = $modules->get_module($results[$num_item]['module']); $tpl_result->assign_vars(array('C_ALL_RESULTS' => true, 'L_MODULE_NAME' => $module->get_name())); } else { $tpl_result->assign_vars(array('C_ALL_RESULTS' => false, 'L_MODULE_NAME' => $module->get_name())); } $tpl_result->assign_vars(array('TITLE' => $results[$num_item]['title'], 'U_LINK' => url($results[$num_item]['link']))); $tpl_results->assign_block_vars('page.results', array('result' => $tpl_result->parse(TEMPLATE_STRING_MODE))); } else { $tpl_results->assign_block_vars('page.results', array('result' => $module->functionality('parse_search_result', $results_data[$num_item]))); } } } $html_results = $tpl_results->parse(TEMPLATE_STRING_MODE); }
$module_id = retrieve(GET, 'm', ''); if (!empty($module_id)) { $feed_name = retrieve(GET, 'name', DEFAULT_FEED_NAME); $category_id = retrieve(GET, 'cat', 0); $feed = null; switch (retrieve(GET, 'feed', 'rss')) { case 'atom': import('content/syndication/atom'); $feed = new ATOM($module_id, $feed_name, $category_id); break; default: import('content/syndication/rss'); $feed = new RSS($module_id, $feed_name, $category_id); break; } if ($feed != null && $feed->is_in_cache()) { echo $feed->read(); } else { import('modules/modules_discovery_service'); $modules_discovery_service = new ModulesDiscoveryService(); $module = $modules_discovery_service->get_module($module_id); if (is_object($module) && $module->got_error() == 0 && $module->has_functionality('get_feed_data_struct')) { $feed->load_data($module->get_feed_data_struct($category_id, $feed_name)); $feed->cache(); echo $feed->export(); } else { redirect('member/error.php?e=e_uninstalled_module'); } } } require_once PATH_TO_ROOT . '/kernel/footer_no_display.php';
function website_modules($menu_type = VERTICAL_MENU) { import('modules/modules_discovery_service'); $modules_menu = new LinksMenu('PHPBoost', '/', '', $menu_type); $modules_discovery_service = new ModulesDiscoveryService(); $modules = $modules_discovery_service->get_all_modules(); $sorted_modules = array(); foreach ($modules as $module) { $sorted_modules[$module->get_name()] = $module; } ksort($sorted_modules); foreach ($sorted_modules as $module) { $infos = $module->get_infos(); if (!empty($infos['infos']) && !empty($infos['infos']['starteable_page'])) { $img = ''; $img_url = PATH_TO_ROOT . '/' . $module->get_id() . '/' . $module->get_id(); import('io/filesystem/file'); foreach (array('_mini.png', '_mini.gif', '_mini.jpg') as $extension) { $file = new File($img_url . $extension); if ($file->exists()) { $img = '/' . $module->get_id() . '/' . $file->get_name(); break; } } $modules_menu->add(new LinksMenuLink($module->get_name(), '/' . $module->get_id() . '/' . $infos['infos']['starteable_page'], $img)); } } return $modules_menu; }
if (!$weighting) { $SEARCH_CONFIG['search_cache_time'] = isset($CONFIG['search_cache_time']) ? $CONFIG['search_cache_time'] : 15; $SEARCH_CONFIG['search_max_use'] = isset($CONFIG['search_max_use']) ? $CONFIG['search_max_use'] : 200; $SEARCH_CONFIG['nb_results_per_page'] = isset($SEARCH_CONFIG['nb_results_per_page']) ? $SEARCH_CONFIG['nb_results_per_page'] : 15; $SEARCH_CONFIG['unauthorized_modules'] = isset($SEARCH_CONFIG['unauthorized_modules']) && is_array($SEARCH_CONFIG['unauthorized_modules']) ? $SEARCH_CONFIG['unauthorized_modules'] : array(); $Modules = new ModulesDiscoveryService(); $searchModules = $Modules->get_available_modules('get_search_request'); foreach ($searchModules as $module) { if (in_array($module->get_id(), $SEARCH_CONFIG['unauthorized_modules'])) { $selected = ' selected="selected"'; } else { $selected = ''; } $Tpl->assign_block_vars('authorized_modules', array('MODULE' => $module->get_id(), 'SELECTED' => $selected, 'L_MODULE_NAME' => ucfirst($module->get_name()))); } $Tpl->assign_vars(array('L_CACHE_TIME' => $LANG['cache_time'], 'L_CACHE_TIME_EXPLAIN' => $LANG['cache_time_explain'], 'L_NB_RESULTS_P' => $LANG['nb_results_per_page'], 'L_MAX_USE' => $LANG['max_use'], 'L_MAX_USE_EXPLAIN' => $LANG['max_use_explain'], 'L_CLEAR_OUT_CACHE' => $LANG['clear_out_cache'], 'L_AUTHORIZED_MODULES' => $LANG['unauthorized_modules'], 'L_AUTHORIZED_MODULES_EXPLAIN' => $LANG['unauthorized_modules_explain'], 'L_SEARCH_CACHE' => $LANG['search_cache'], 'CACHE_TIME' => $SEARCH_CONFIG['search_cache_time'], 'MAX_USE' => $SEARCH_CONFIG['search_max_use'], 'NB_RESULTS_P' => $SEARCH_CONFIG['nb_results_per_page'])); } else { $modules = new ModulesDiscoveryService(); $all_modules = $modules->get_available_modules('get_search_request'); $authorized_modules = array_diff(array_keys($all_modules), $SEARCH_CONFIG['unauthorized_modules']); foreach ($authorized_modules as $module_id) { $module = $all_modules[$module_id]; if (!$module->got_error()) { $Tpl->assign_block_vars('weights', array('MODULE' => $module->get_id(), 'L_MODULE_NAME' => ucfirst($module->get_name()), 'WEIGHT' => !empty($SEARCH_CONFIG['modules_weighting']) && !empty($SEARCH_CONFIG['modules_weighting'][$module->get_id()]) ? $SEARCH_CONFIG['modules_weighting'][$module->get_id()] : 1)); } } $Tpl->assign_vars(array('L_MODULES' => $LANG['modules'], 'L_WEIGHTS' => $LANG['search_weights'], 'L_SEARCH_CONFIG_WEIGHTING_EXPLAIN' => $LANG['search_config_weighting_explain'])); } $Tpl->parse(); } require_once '../admin/admin_footer.php';
<?php require_once '../kernel/begin.php'; require_once '../news/news_begin.php'; require_once '../kernel/header.php'; $is_admin = $User->check_level(ADMIN_LEVEL); if (empty($idnews) && empty($idcat)) { import('modules/modules_discovery_service'); $modulesLoader = new ModulesDiscoveryService(); $module_name = 'news'; $module = $modulesLoader->get_module($module_name); if ($module->has_functionality('get_home_page')) { echo $module->functionality('get_home_page'); require_once '../kernel/footer.php'; exit; } elseif (!$no_alert_on_error) { global $Errorh; $Errorh->handler('Le module <strong>' . $module_name . '</strong> n\'a pas de fonction get_home_page!', E_USER_ERROR, __LINE__, __FILE__); exit; } } elseif (!empty($idnews)) { if (empty($news['id'])) { $Errorh->handler('e_unexist_news', E_USER_REDIRECT); } import('content/comments'); import('content/syndication/feed'); $tpl_news = new Template('news/news.tpl'); $next_news = $Sql->query_array(PREFIX . "news", "title", "id", "WHERE visible = 1 AND id > '" . $idnews . "' " . $Sql->limit(0, 1), __LINE__, __FILE__); $previous_news = $Sql->query_array(PREFIX . "news", "title", "id", "WHERE visible = 1 AND id < '" . $idnews . "' ORDER BY id DESC " . $Sql->limit(0, 1), __LINE__, __FILE__); $tpl_news->assign_vars(array('C_IS_ADMIN' => $is_admin, 'C_NEWS_BLOCK' => true, 'C_NEWS_NAVIGATION_LINKS' => true, 'C_PREVIOUS_NEWS' => !empty($previous_news['id']), 'C_NEXT_NEWS' => !empty($next_news['id']), 'TOKEN' => $Session->get_token(), 'PREVIOUS_NEWS' => $previous_news['title'], 'NEXT_NEWS' => $next_news['title'], 'U_PREVIOUS_NEWS' => url('.php?id=' . $previous_news['id'], '-0-' . $previous_news['id'] . '+' . url_encode_rewrite($previous_news['title']) . '.php'), 'U_NEXT_NEWS' => url('.php?id=' . $next_news['id'], '-0-' . $next_news['id'] . '+' . url_encode_rewrite($next_news['title']) . '.php'), 'L_SYNDICATION' => $LANG['syndication'], 'L_ALERT_DELETE_NEWS' => $LANG['alert_delete_news'], 'L_ON' => $LANG['on'], 'L_DELETE' => $LANG['delete'], 'L_EDIT' => $LANG['edit'])); $tpl_news->assign_block_vars('news', array('C_IMG' => !empty($news['img']), 'C_ICON' => !empty($news['icon']) && $CONFIG_NEWS['activ_icon'] == 1, 'ID' => $news['id'], 'IDCAT' => $news['idcat'], 'ICON' => second_parse_url($news['icon']), 'TITLE' => $news['title'], 'CONTENTS' => second_parse($news['contents']), 'EXTEND_CONTENTS' => second_parse($news['extend_contents']) . '<br /><br />', 'IMG' => second_parse_url($news['img']), 'IMG_DESC' => $news['alt'], 'PSEUDO' => $CONFIG_NEWS['display_author'] ? $news['login'] : '', 'DATE' => $CONFIG_NEWS['display_date'] ? $LANG['on'] . ': ' . gmdate_format('date_format_short', $news['timestamp']) : '', 'U_COM' => $CONFIG_NEWS['activ_com'] == 1 ? Comments::com_display_link($news['nbr_com'], '../news/news' . url('.php?cat=0&id=' . $idnews . '&com=0', '-0-' . $idnews . '+' . url_encode_rewrite($news['title']) . '.php?com=0'), $idnews, 'news') : '', 'U_USER_ID' => url('.php?id=' . $news['user_id'], '-' . $news['user_id'] . '.php'), 'U_NEWS_LINK' => url('.php?id=' . $news['id'], '-0-' . $news['id'] . '+' . url_encode_rewrite($news['title']) . '.php'), 'FEED_MENU' => Feed::get_feed_menu(FEED_URL)));
$array_location = array(BLOCK_POSITION__HEADER => $LANG['menu_header'], BLOCK_POSITION__SUB_HEADER => $LANG['menu_subheader'], BLOCK_POSITION__LEFT => $LANG['menu_left'], BLOCK_POSITION__TOP_CENTRAL => $LANG['menu_top_central'], BLOCK_POSITION__BOTTOM_CENTRAL => $LANG['menu_bottom_central'], BLOCK_POSITION__RIGHT => $LANG['menu_right'], BLOCK_POSITION__TOP_FOOTER => $LANG['menu_top_footer'], BLOCK_POSITION__FOOTER => $LANG['menu_footer']); $feed_url = ''; if ($edit) { $menu = MenuService::load($id); if (!of_class($menu, FEED_MENU__CLASS)) { redirect('menus.php'); } $block = $menu->get_block(); $feed_url = $menu->get_url(true); $tpl->assign_vars(array('IDMENU' => $id, 'NAME' => $menu->get_title(), 'AUTH_MENUS' => Authorizations::generate_select(AUTH_MENUS, $menu->get_auth()), 'C_ENABLED' => $menu->is_enabled(), 'C_EDIT' => true)); } else { $tpl->assign_vars(array('C_NEW' => true, 'C_ENABLED' => true, 'AUTH_MENUS' => Authorizations::generate_select(AUTH_MENUS, array(), array(-1 => true, 0 => true, 1 => true, 2 => true)))); } import('util/url'); import('modules/modules_discovery_service'); $modules = new ModulesDiscoveryService(); $feeds_modules = $modules->get_available_modules('get_feeds_list'); function build_feed_urls($elts, $module_id, &$feed_type, $level = 0) { $urls = array(); global $edit, $feed_url; static $already_selected = false; foreach ($elts as $elt) { $url = $elt->get_url($feed_type); if (!$already_selected && $edit && $feed_url == $url) { $selected = true; $already_selected = true; } else { $selected = false; } $urls[] = array('name' => $elt->get_category_name(), 'url' => $url, 'level' => $level, 'feed_name' => $feed_type, 'selected' => $selected);
function get_parsed($module_id, $name = DEFAULT_FEED_NAME, $idcat = 0, $tpl = false, $number = 10, $begin_at = 0) { if (of_class($tpl, 'template')) { $template = $tpl->copy(); } else { import('io/template'); $template = new Template($module_id . '/framework/content/syndication/feed.tpl'); if (gettype($tpl) == 'array') { $template->assign_vars($tpl); } } $feed_data_cache_file = FEEDS_PATH . $module_id . '_' . $name . '_' . $idcat . '.php'; $result = @(include $feed_data_cache_file); if ($result === false) { import('modules/modules_discovery_service'); $modules = new ModulesDiscoveryService(); $module = $modules->get_module($module_id); if ($module->got_error() || !$module->has_functionality('get_feed_data_struct')) { return ''; } $data = $module->functionality('get_feed_data_struct', $idcat); if (!$module->got_error()) { Feed::update_cache($module_id, $name, $data, $idcat); } } if (!DEBUG) { $result = @(include $feed_data_cache_file); } else { if (file_exists($feed_data_cache_file)) { $result = (include $feed_data_cache_file); } else { $result = FALSE; } } if ($result === false) { user_error(sprintf(ERROR_GETTING_CACHE, $module_id, $idcat), E_USER_WARNING); return ''; } $feed = new Feed($module_id, $name); $feed->load_data($__feed_object); return $feed->export($template, $number, $begin_at); }
<?php require_once '../kernel/begin.php'; $Bread_crumb->add($LANG['member_area'], 'member.php' . SID); $Bread_crumb->add($LANG['member_msg'], 'membermsg.php' . SID); define('TITLE', $LANG['member_msg']); require_once '../kernel/header.php'; $memberId = retrieve(GET, 'id', 0, TUNSIGNED_INT); $script = retrieve(GET, 'script', ''); if (!empty($memberId)) { $Template->set_filenames(array('membermsg' => 'member/membermsg.tpl')); import('modules/modules_discovery_service'); $modulesLoader = new ModulesDiscoveryService(); $modules = $modulesLoader->get_available_modules('get_member_msg_link'); foreach ($modules as $module) { $img = $module->functionality('get_member_msg_img'); $Template->assign_block_vars('available_modules_msg', array('NAME_USER_MSG' => $module->functionality('get_member_msg_name'), 'IMG_USER_MSG' => $img, 'C_IMG_USER_MSG' => !empty($img) ? true : false, 'U_LINK_USER_MSG' => $module->functionality('get_member_msg_link', array($memberId)))); } $Template->assign_vars(array('L_USER_MSG' => $LANG['member_msg'], 'L_USER_MSG_DISPLAY' => $LANG['member_msg_display'], 'L_COMMENTS' => $LANG['com_s'], 'L_BACK' => $LANG['back'], 'U_BACK' => url('.php?id=' . $memberId, '-' . $memberId . '.php'), 'U_USER_MSG' => url('.php?id=' . $memberId), 'U_COMMENTS' => url('.php?id=' . $memberId . '&script=com'))); if (!empty($script)) { import('util/pagination'); $Pagination = new Pagination(); $nbr_msg = $Sql->query("SELECT COUNT(*) FROM " . DB_TABLE_COM . " WHERE user_id = '" . $memberId . "'", __LINE__, __FILE__); $Template->assign_vars(array('C_START_MSG' => true, 'PAGINATION' => $Pagination->display('membermsg.php?pmsg=%d', $nbr_msg, 'pmsg', 25, 3), 'L_GO_MSG' => $LANG['go_msg'], 'L_ON' => $LANG['on'])); $result = $Sql->query_while("SELECT c.timestamp, c.script, c.path, m.login, s.user_id AS connect, c.contents\n\t\tFROM " . DB_TABLE_COM . " c\n\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = c.user_id\n\t\tLEFT JOIN " . DB_TABLE_SESSIONS . " s ON s.user_id = c.user_id AND s.session_time > '" . (time() - $CONFIG['site_session_invit']) . "'\n\t\tWHERE m.user_id = '" . $memberId . "'\n\t\tORDER BY c.timestamp DESC \n\t\t" . $Sql->limit($Pagination->get_first_msg(25, 'pmsg'), 25), __LINE__, __FILE__); $row = $Sql->fetch_assoc($result); while ($row = $Sql->fetch_assoc($result)) { $Template->assign_block_vars('msg_list', array('USER_PSEUDO' => '<a class="msg_link_pseudo" href="../member/member' . url('.php?id=' . $memberId, '-' . $memberId . '.php') . '"><span class="text_strong">' . wordwrap_html($row['login'], 13) . '</span></a>', 'USER_ONLINE' => '<img src="../templates/' . get_utheme() . '/images/' . (!empty($row['connect']) ? 'online' : 'offline') . '.png" alt="" class="valign_middle" />', 'DATE' => gmdate_format('date_format', $row['timestamp']), 'CONTENTS' => ucfirst(second_parse($row['contents'])), 'U_TITLE' => url($row['path'] . '#' . $row['script']))); } } $Template->pparse('membermsg');
<?php define('NO_SESSION_LOCATION', true); require_once '../kernel/begin.php'; load_module_lang('search'); $search_txt = retrieve(POST, 'q', ''); $module_id = strtolower(retrieve(POST, 'moduleName', '')); $id_search = retrieve(POST, 'idSearch', -1); $selected_modules = retrieve(POST, 'searched_modules', array()); import('modules/modules_discovery_service'); require_once PATH_TO_ROOT . '/search/search.inc.php'; $modules = new ModulesDiscoveryService(); $modules_args = array(); if ($id_search >= 0 && $module_id != '') { echo 'var syncErr = false;'; $search = new Search(); if (!$search->is_search_id_in_cache($id_search)) { $search_modules = array(); $all_search_modules = $modules->get_available_modules('get_search_request'); foreach ($all_search_modules as $search_module) { if (in_array($search_module->get_id(), $selected_modules)) { $search_modules[] = $search_module; } } $forms_module = $modules->get_available_modules('get_search_form', $search_modules); foreach ($search_modules as $module) { $modules_args[$module->get_id()] = array('search' => $search_txt); } foreach ($forms_module as $form_module) { if ($form_module->has_functionality('get_search_args')) { $form_module_args = $form_module->functionality('get_search_args');
function generate_all_modules() { global $MODULES; import('modules/modules_discovery_service'); $modulesLoader = new ModulesDiscoveryService(); $modules = $modulesLoader->get_available_modules('get_cache'); foreach ($modules as $module) { if ($MODULES[strtolower($module->id)]['activ'] == '1') { $this->write(strtolower($module->id), $module->functionality('get_cache')); } } }