Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('_JEXEC', 1);
- define('DS', DIRECTORY_SEPARATOR);
- define('TEMPLATEPATH', dirname(__file__));
- function countModules($condition)
- {
- global $db, $config, $template, $user, $auth, $cache, $starttime, $phpEx;
- $sql = 'SELECT block_enabled
- FROM ' . VERTEX_BLOCKS . '
- WHERE block_position LIKE "' . $condition . '"
- AND block_style_main = "basics"
- ORDER BY left_id ASC';
- $result = $db->sql_query($sql);
- $count = 0;
- $count = 1; //Add a little fix to show correct no.
- $result2 = $db->sql_fetchrow($result);
- while ($thecount = $db->sql_fetchrow($result)) {
- $count++;
- }
- $countme = $count;
- if ($countme >= 0)
- {
- return true;
- }
- }
- class Vertex
- {
- function pages_check($page_ids)
- {
- global $db, $auth, $user, $template;
- global $phpbb_root_path, $phpEx, $config;
- $script_name = str_replace('.' . $phpEx, '', $user->page['page_name']);
- $sql = 'SELECT page_id, page_name, page_tag
- FROM ' . VERTEX_PAGES . "
- ORDER BY page_id ASC";
- $result = $db->sql_query($sql);
- $check_page_options = '';
- while ($row = $db->sql_fetchrow($result)) {
- $selected = (in_array($row['page_id'], $page_ids, true)) ? $row['page_tag'] : '';
- if ($selected == $script_name) {
- $check_page_options = 'yes';
- }
- }
- $db->sql_freeresult($result);
- return $check_page_options;
- }
- function groups_check($group_ids)
- {
- global $db, $auth, $user, $template;
- global $phpbb_root_path, $phpEx, $config;
- $selected_groups = array();
- $selected_groups = explode(",", $group_ids);
- $sql = 'SELECT *
- FROM ' . USER_GROUP_TABLE . '
- WHERE ' . $db->sql_in_set('group_id', $selected_groups) . '
- AND user_id = ' . $user->data['user_id'];
- $db->sql_query($sql);
- $result = $db->sql_query_limit($sql, 1, 0);
- $is_in_group = $db->sql_fetchrow($result);
- return $is_in_group;
- }
- function build_login_module()
- {
- global $db, $auth, $user, $template, $topic_data, $forum_data;
- global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
- $built_login_module = '';
- if ($user->data['user_id'] != ANONYMOUS) {
- $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true,
- $user->session_id);
- $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']);
- $built_login_module .= '';
- } else {
- $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login');
- $l_login_logout = $user->lang['LOGIN'];
- $s_login_redirect = build_hidden_fields(array('redirect' => build_url()));
- $s_login_action = ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx",
- 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id));
- $l_username = $user->lang['USERNAME'];
- $l_password = $user->lang['PASSWORD'];
- $l_login = $user->lang['LOGIN'];
- $s_auto_login_enabled = ($config['allow_autologin']) ?
- '<label for="autologin-s5">REMEMBER ME<input type="checkbox" name="autologin" id="autologin-s5" /></label>' :
- '';
- $built_login_module .= '<form class="form-login" method="post" action="' . $s_login_action .
- '"><fieldset class="input">' . $l_username .
- ':<br /><input type="text" name="username" id="s5-username-mod" size="20" class="inputbox modlgn_username" title="' .
- $l_username . '" /> <br />' . $l_username .
- ':<br /><input type="password" name="password" id="s5-password-mod" size="20" class="inputbox modlgn_username" title="' .
- $l_password . '" />' . $s_auto_login_enabled .
- '<input type="submit" name="login" value="' . $l_login .
- '" class="button" /><div>' . $s_login_redirect . '</div></fieldset></form>';
- }
- $template->assign_var('VERTEX_LOGIN_MODULE', 'YES');
- return $built_login_module;
- }
- function build_user_module()
- {
- global $db, $auth, $user, $template, $topic_data, $forum_data;
- global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
- if ($user->data['user_id'] != ANONYMOUS) {
- $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true,
- $user->session_id);
- $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']);
- } else {
- $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login');
- $l_login_logout = $user->lang['LOGIN'];
- }
- $l_privmsgs_text = $l_privmsgs_text_unread = '';
- $s_privmsg_new = false;
- // Obtain number of new private messages if user is logged in
- if (!empty($user->data['is_registered'])) {
- if ($user->data['user_new_privmsg']) {
- $l_message_new = ($user->data['user_new_privmsg'] == 1) ? $user->lang['NEW_PM'] :
- $user->lang['NEW_PMS'];
- $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']);
- if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->
- data['session_last_visit']) {
- $sql = 'UPDATE ' . USERS_TABLE . '
- SET user_last_privmsg = ' . $user->data['session_last_visit'] .
- ' WHERE user_id = ' . $user->data['user_id'];
- $db->sql_query($sql);
- $s_privmsg_new = true;
- } else {
- $s_privmsg_new = false;
- }
- } else {
- $l_privmsgs_text = $user->lang['NO_NEW_PM'];
- $s_privmsg_new = false;
- }
- $l_privmsgs_text_unread = '';
- if ($user->data['user_unread_privmsg'] && $user->data['user_unread_privmsg'] !=
- $user->data['user_new_privmsg']) {
- $l_message_unread = ($user->data['user_unread_privmsg'] == 1) ? $user->lang['UNREAD_PM'] :
- $user->lang['UNREAD_PMS'];
- $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']);
- }
- }
- $u_index = append_sid("{$phpbb_root_path}index.$phpEx");
- $l_index = $user->lang['INDEX'];
- $s_is_bot = (!empty($user->data['is_bot'])) ? true : false;
- $s_user_logged_in = ($user->data['user_id'] != ANONYMOUS) ? true : false;
- $s_register_enabled = ($config['require_activation'] != USER_ACTIVATION_DISABLE) ? true : false;
- $u_restore_permissions = ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ?
- '<li class="parent item"><a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx",
- 'mode=restore_perm') . '"><span>' . $user->lang['RESTORE_PERMISSIONS'] .
- '</span></a></li>' : '';
- $u_mcp = ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ?
- '<li class="parent item"><a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx",
- 'i=main&mode=front', true, $user->session_id) . '"><span>' . $user->lang['MCP'] .
- '</span></a></li>' : '';
- $s_display_search = (!$config['load_search']) ? 0 : (isset($auth) ? ($auth->
- acl_get('u_search') && $auth->acl_getf_global('f_search')) : 1);
- $registration_link = '';
- if (!$s_is_bot) {
- if (!$s_user_logged_in && $s_register_enabled) {
- $registration_link = '<li class="parent item"><a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx",
- 'mode=register') . '" title="' . $user->lang['REGISTER'] .
- '" accesskey="e"><span>' . $user->lang['REGISTER'] . '</span></a></li>';
- }
- }
- $profile_link = '';
- if (!$s_is_bot && $s_user_logged_in) {
- $profile_link = '<li class="parent item"><a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx") .
- '" title="' . $user->lang['PROFILE'] . '" accesskey="e"><span>' . $user->lang['PROFILE'] .
- '</span></a></li>';
- }
- $search_link = '';
- $pm_info_link = '';
- if ($s_user_logged_in) {
- if ($s_display_search) {
- $u_search_self = append_sid("{$phpbb_root_path}search.$phpEx",
- 'search_id=egosearch');
- $search_link = '<li class="parent item"><a href="' . $u_search_self . '"><span>' .
- $user->lang['SEARCH_SELF'] . '</span></a></li>';
- }
- $s_user_new_privmsg = $user->data['user_new_privmsg'];
- $s_user_unread_privmsg = $user->data['user_unread_privmsg'];
- if ($s_user_new_privmsg || $s_user_unread_privmsg) {
- $pm_info_link = '<li class="parent item"><a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx",
- 'i=pm&folder=inbox') . '"><span>' . $l_privmsgs_text . '</span></a></li>';
- }
- }
- $built_user_module = '<ul class="menu"><li class="parent item"><a href="' . $u_index .
- '"><span>' . $l_index . '</span></a></li>' . $registration_link .
- '<li class="parent item"><a href="' . $u_login_logout . '" title="' . $l_login_logout .
- '" accesskey="x"><span>' . $l_login_logout . '</span></a></li>' . $profile_link .
- '' . $search_link . '' . $pm_info_link . '' . $u_mcp . '' . $u_restore_permissions .
- '</ul>';
- $template->assign_var('VERTEX_USER_MODULE', 'YES');
- return $built_user_module;
- }
- function build_actions_module()
- {
- global $db, $auth, $user, $template, $topic_data, $forum_data;
- global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
- $script_name = str_replace('.' . $phpEx, '', $user->page['page_name']);
- $s_display_search = (!$config['load_search']) ? 0 : (isset($auth) ? ($auth->
- acl_get('u_search') && $auth->acl_getf_global('f_search')) : 1);
- $s_user_logged_in = ($user->data['user_id'] != ANONYMOUS) ? true : false;
- $s_is_bot = (!empty($user->data['is_bot'])) ? true : false;
- $u_search_unanswered = append_sid("{$phpbb_root_path}search.$phpEx",
- 'search_id=unanswered');
- $u_search_active_topics = append_sid("{$phpbb_root_path}search.$phpEx",
- 'search_id=active_topics');
- $u_search_unread = append_sid("{$phpbb_root_path}search.$phpEx",
- 'search_id=unreadposts');
- $u_search_self = append_sid("{$phpbb_root_path}search.$phpEx",
- 'search_id=egosearch');
- $u_search_new = append_sid("{$phpbb_root_path}search.$phpEx",
- 'search_id=newposts');
- $actions_menu_link1 = '';
- $actions_menu_link2 = '';
- $actions_menu_link3 = '';
- $actions_menu_link4 = '';
- $actions_menu_link5 = '';
- $actions_menu_link6 = '';
- $actions_menu_link7 = '';
- $actions_menu_link8 = '';
- $actions_menu_link9 = '';
- $actions_menu_link10 = '';
- $actions_menu_link11 = '';
- $actions_menu_link12 = '';
- $actions_menu_link13 = '';
- $actions_menu_link14 = '';
- if ($s_display_search) {
- $actions_menu_link1 = '<li class="parent item"><a href="' . $u_search_unanswered .
- '"><span>' . $user->lang['SEARCH_UNANSWERED'] . '</span></a></li>';
- $actions_menu_link2 = '<li class="parent item"><a href="' . $u_search_active_topics .
- '"><span>' . $user->lang['SEARCH_ACTIVE_TOPICS'] . '</span></a></li>';
- if ($s_user_logged_in) {
- $actions_menu_link3 = '<li class="parent item"><a href="' . $u_search_unread .
- '"><span>' . $user->lang['SEARCH_UNREAD'] . '</span></a></li>';
- $actions_menu_link4 = '<li class="parent item"><a href="' . $u_search_self .
- '"><span>' . $user->lang['SEARCH_NEW'] . '</span></a></li>';
- $actions_menu_link5 = '<li class="parent item"><a href="' . $u_search_new .
- '"><span>' . $user->lang['SEARCH_SELF'] . '</span></a></li>';
- }
- }
- if ($script_name == 'viewforum') {
- $forum_id = request_var('f', 0);
- $s_watching_forum = array('link' => '', 'title' => '', 'is_watching' => false, );
- if (($config['email_enable'] || $config['jab_enable']) && $config['allow_forum_notify'] &&
- $forum_data['forum_type'] == FORUM_POST && $auth->acl_get('f_subscribe', $forum_id)) {
- $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : null;
- watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id,
- 0, $notify_status);
- }
- $s_watch_forum_link = $s_watching_forum['link'];
- $s_watch_forum_title = $s_watching_forum['title'];
- }
- if ($script_name == 'viewtopic') {
- $forum_id = request_var('f', 0);
- $topic_id = request_var('t', 0);
- $post_id = request_var('p', 0);
- $start = request_var('start', 0);
- $view = request_var('view', '');
- $s_watching_topic = array('link' => '', 'title' => '', 'is_watching' => false, );
- if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'] &&
- $user->data['is_registered']) {
- watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id,
- $topic_id, $topic_data['notify_status'], $start);
- // Reset forum notification if forum notify is set
- if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id)) {
- $s_watching_forum = $s_watching_topic;
- watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id,
- 0);
- }
- }
- // Post ordering options
- $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 =>
- $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'],
- 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->
- lang['1_YEAR']);
- $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'],
- 's' => $user->lang['SUBJECT']);
- $sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' =>
- 'p.post_time', 's' => array('p.post_subject', 'p.post_id'));
- $join_user_sql = array('a' => true, 't' => false, 's' => false);
- $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
- $highlight_match = $highlight = '';
- $viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" .
- (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" :
- '') . (($highlight_match) ? "&hilit=$highlight" : ''));
- $u_watch_topic = $s_watching_topic['link'];
- $u_bookmark_topic = ($user->data['is_registered'] && $config['allow_bookmarks']) ?
- $viewtopic_url . '&bookmark=1&hash=' . generate_link_hash("topic_$topic_id") :
- '';
- $u_bump_topic = (bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'],
- $topic_data['topic_poster'], $topic_data['topic_last_poster_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx",
- "mode=bump&f=$forum_id&t=$topic_id&hash=" . generate_link_hash("topic_$topic_id")) :
- '';
- $u_email_topic = ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ?
- append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&t=$topic_id") :
- '';
- $u_print_topic = ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url .
- '&view=print' : '';
- }
- $u_team = ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ?
- '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders');
- $u_delete_cookies = append_sid("{$phpbb_root_path}ucp.$phpEx",
- 'mode=delete_cookies');
- if (!$s_is_bot) {
- if ($script_name == 'viewforum') {
- if ($s_watch_forum_link) {
- $actions_menu_link6 = '<li class="parent item"><a href="' . $s_watch_forum_link .
- '" title="' . $s_watch_forum_title . '"><span>' . $s_watch_forum_title .
- '</span></a></li>';
- }
- }
- if ($script_name == 'viewtopic') {
- if ($u_watch_topic) {
- $actions_menu_link7 = '<li class="parent item"><a href="' . $u_watch_topic .
- '" title="' . $s_watching_topic['title'] . '"><span>' . $s_watching_topic['title'] .
- '</span></a></li>';
- }
- if ($u_bookmark_topic) {
- $actions_menu_link8 = '<li class="parent item"><a href="' . $u_bookmark_topic .
- '" title="' . $user->lang['BOOKMARK_TOPIC'] . '"><span>' . $user->lang['BOOKMARK_TOPIC'] .
- '</span></a></li>';
- }
- if ($u_bump_topic) {
- $actions_menu_link9 = '<li class="parent item"><a href="' . $u_bump_topic .
- '" title="' . $user->lang['BUMP_TOPIC'] . '"><span>' . $user->lang['BUMP_TOPIC'] .
- '</span></a></li>';
- }
- }
- $actions_menu_link14 = '<li class="parent item"><a href="' . $u_delete_cookies .
- '"><span>' . $user->lang['DELETE_COOKIES'] . '</span></a></li>';
- }
- if ($script_name == 'viewtopic') {
- if ($u_email_topic) {
- $actions_menu_link10 = '<li class="parent item"><a href="' . $u_email_topic .
- '" title="' . $user->lang['EMAIL_TOPIC'] . '"><span>' . $user->lang['EMAIL_TOPIC'] .
- '</span></a></li>';
- }
- if ($u_print_topic) {
- $actions_menu_link11 = '<li class="parent item"><a href="' . $u_print_topic .
- '" title="' . $user->lang['PRINT_TOPIC'] . '"><span>' . $user->lang['PRINT_TOPIC'] .
- '</span></a></li>';
- }
- }
- if ($u_team) {
- $actions_menu_link13 = '<li class="parent item"><a href="' . $u_team .
- '"><span>' . $user->lang['THE_TEAM'] . '</span></a></li>';
- }
- $built_actions_module = '<ul class="menu">' . $actions_menu_link1 . $actions_menu_link2 .
- $actions_menu_link3 . $actions_menu_link4 . $actions_menu_link5 . $actions_menu_link6 .
- $actions_menu_link7 . $actions_menu_link8 . $actions_menu_link9 . $actions_menu_link10 .
- $actions_menu_link11 . $actions_menu_link12 . $actions_menu_link13 . $actions_menu_link14 .
- '</ul>';
- $template->assign_var('VERTEX_ACTIONS_MODULE', 'YES');
- return $built_actions_module;
- }
- function build_whos_module()
- {
- global $db, $auth, $user, $template, $topic_data, $forum_data;
- global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
- if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) {
- $sql = 'SELECT group_id, group_name, group_colour, group_type
- FROM ' . GROUPS_TABLE . '
- WHERE group_legend = 1
- ORDER BY group_name ASC';
- } else {
- $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
- FROM ' . GROUPS_TABLE . ' g
- LEFT JOIN ' . USER_GROUP_TABLE . ' ug
- ON (
- g.group_id = ug.group_id
- AND ug.user_id = ' . $user->data['user_id'] . '
- AND ug.user_pending = 0
- )
- WHERE g.group_legend = 1
- AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] .
- ')
- ORDER BY g.group_name ASC';
- }
- $result = $db->sql_query($sql);
- $legend2 = array();
- while ($get = $db->sql_fetchrow($result)) {
- $colour_text = ($get['group_colour']) ? ' style="color:#' . $get['group_colour'] .
- '"' : '';
- $group_name = ($get['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $get['group_name']] :
- $get['group_name'];
- if ($get['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->
- acl_get('u_viewprofile'))) {
- $legend2[] = '<span' . $colour_text . '>' . $group_name . '</span>';
- } else {
- $legend2[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx",
- 'mode=group&g=' . $get['group_id']) . '">' . $group_name . '</a>';
- }
- }
- $db->sql_freeresult($result);
- $legend3 = implode(', ', $legend2);
- $legend4 = '<br /><em>' . $user->lang['LEGEND'] . ': ' . $legend3 . '</em>';
- // Get users online list ... if required
- $display_online_list = true;
- $item_id = 0;
- $item = 'forum';
- $l_online_users = $online_userlist = $l_online_record = $l_online_time = '';
- if ($config['load_online'] && $config['load_online_time'] && $display_online_list) {
- /**
- * Load online data:
- * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id.
- */
- $item_id = max($item_id, 0);
- $online_users = obtain_users_online($item_id, $item);
- $user_online_strings = obtain_users_online_string($online_users, $item_id, $item);
- $l_online_users = $user_online_strings['l_online_users'];
- $online_userlist = $user_online_strings['online_userlist'];
- $total_online_users = $online_users['total_online'];
- if ($total_online_users > $config['record_online_users']) {
- set_config('record_online_users', $total_online_users, true);
- set_config('record_online_date', time(), true);
- }
- $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'],
- $user->format_date($config['record_online_date'], false, true));
- $l_online_time = ($config['load_online_time'] == 1) ? 'VIEW_ONLINE_TIME' :
- 'VIEW_ONLINE_TIMES';
- $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']);
- }
- $u_view_online = ($auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd',
- 'a_userdel')) ? append_sid("{$phpbb_root_path}viewonline.$phpEx") : '';
- if ($u_view_online) {
- $who_module_title = '<a href="' . $u_view_online . '">' . $user->lang['WHO_IS_ONLINE'] .
- '</a>';
- } else {
- $who_module_title = $user->lang['WHO_IS_ONLINE'];
- }
- $built_whos_module = $who_module_title . '<p>' . $l_online_users . '(' . $l_online_time .
- ')<br />' . $l_online_record . '<br /> <br />' . $online_userlist . '</p>';
- $template->assign_var('VERTEX_WHO_MODULE', 'YES');
- return $built_whos_module;
- }
- function build_stats_module()
- {
- global $db, $auth, $user, $template, $topic_data, $forum_data;
- global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
- // Set some stats, get posts count from forums data if we... hum... retrieve all forums data
- $total_posts = $config['num_posts'];
- $total_topics = $config['num_topics'];
- $total_users = $config['num_users'];
- $l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
- $l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
- $l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' :
- 'TOTAL_TOPICS_OTHER';
- $s5_total_posts = sprintf($user->lang[$l_total_post_s], $total_posts);
- $s5_total_topics = sprintf($user->lang[$l_total_topic_s], $total_topics);
- $s5_total_users = sprintf($user->lang[$l_total_user_s], $total_users);
- $s5_newest_user = sprintf($user->lang['NEWEST_USER'], get_username_string('full',
- $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour']));
- $built_stats_module = '<p>' . $s5_total_posts . ' • ' . $s5_total_topics .
- ' • ' . $s5_total_users . ' • ' . $s5_newest_user . '</p>';
- $template->assign_var('VERTEX_STATS_MODULE', 'YES');
- return $built_stats_module;
- }
- function build_birthday_module()
- {
- global $db, $auth, $user, $template, $topic_data, $forum_data;
- global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
- $birthday_list = '';
- if ($config['load_birthdays'] && $config['allow_birthdays']) {
- $now = getdate(time() + $user->timezone + $user->dst - date('Z'));
- $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
- FROM ' . USERS_TABLE . ' u
- LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
- WHERE (b.ban_id IS NULL
- OR b.ban_exclude = 1)
- AND u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'],
- $now['mon'])) . "%'
- AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
- $result = $db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result)) {
- $birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full',
- $row['user_id'], $row['username'], $row['user_colour']);
- if ($age = (int)substr($row['user_birthday'], -4)) {
- $birthday_list .= ' (' . ($now['year'] - $age) . ')';
- }
- }
- $db->sql_freeresult($result);
- }
- if ($birthday_list) {
- $built_birthday_module = '<p>' . $user->lang['CONGRATULATIONS'] . ': <strong>' .
- $birthday_list . '</strong></p>';
- } else {
- $built_birthday_module = '<p>' . $user->lang['NO_BIRTHDAYS'] . '</p>';
- }
- $template->assign_var('VERTEX_BIRTHDAY_MODULE', 'YES');
- return $built_birthday_module;
- }
- function build_search_module()
- {
- global $db, $auth, $user, $template, $topic_data, $forum_data;
- global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
- $script_name = str_replace('.' . $phpEx, '', $user->page['page_name']);
- $forum_id = '';
- $topic_id = '';
- if ($script_name == 'viewforum') {
- $forum_id = request_var('f', 0);
- }
- if ($script_name == 'viewtopic') {
- $topic_id = request_var('t', 0);
- }
- if ($forum_id != '') {
- $built_search_module =
- '<div class="search-box2"><form action="./search.php?fid[]=' . $forum_id .
- '" id="forum-search2" method="post"><fieldset>
- <input type="text" onblur="if (this.value == \'\') this.value = \'Search this forum...\';" onclick="if (this.value == \'Search this forum...\') this.value = \'\';" value="Search this forum..." size="20" id="search_keywords2" name="keywords" class="inputbox search tiny" />
- <input type="submit" value="Search" class="button" />
- <input type="hidden" name="fid[]" value="' . $forum_id . '" />
- </fieldset>
- </form>
- </div>';
- $search_string = '?' . $forum_id . $topic_id;
- } elseif ($topic_id != '') {
- $built_search_module = '<div class="search-box2"><form action="./search.php?t=' .
- $topic_id . '" id="topic-search2" method="post">
- <fieldset>
- <input type="text" onblur="if(this.value==\'\')this.value=\'Search this topic...\';" onclick="if(this.value==\'Search this topic...\')this.value=\'\';" value="Search this topic..." size="20" id="search_keywords2" name="keywords" class="inputbox search tiny" />
- <input type="submit" value="Search" class="button" />
- <input type="hidden" name="t" value="' . $topic_id . '" />
- <input type="hidden" name="sf" value="msgonly" />
- </fieldset>
- </form>
- </div>';
- } else {
- $built_search_module = '<div class="search-box2"><form action="./search.php?t=' .
- $topic_id . '" id="site-search" method="post">
- <fieldset>
- <input type="text" onblur="if(this.value==\'\')this.value=\'Search this site...\';" onclick="if(this.value==\'Search this site...\')this.value=\'\';" value="Search this site..." size="20" id="search_keywords2" name="keywords" class="inputbox search tiny" />
- <input type="submit" value="Search" class="button" />
- <input type="hidden" name="t" value="' . $topic_id . '" />
- <input type="hidden" name="sf" value="msgonly" />
- </fieldset>
- </form>
- </div>';
- }
- $template->assign_var('VERTEX_SEARCH_MODULE', 'YES');
- return $built_search_module;
- }
- function buildVertexModule($position, $style, $title, $title2, $content, $show_title, $full_title, $type)
- {
- global $db, $config, $template, $user, $auth, $cache, $starttime, $phpEx;
- if ($type == 'round_box') {
- $builtVertexModule = '';
- $title_part1 = '';
- $title_part2 = '';
- $title_part3 = '';
- if ($style != '') {
- $split_title = split(' ', $title, 3);
- } else {
- $split_title = split(' ', $title, 2);
- }
- if (isset($split_title[0])) {
- $title_part1 = isset($split_title[0]) ? $split_title[0] : '';
- }
- if (isset($split_title[1])) {
- $title_part2 = isset($split_title[1]) ? $split_title[1] : '';
- }
- if (isset($split_title[2])) {
- $title_part3 = isset($split_title[2]) ? $split_title[2] : '';
- }
- $builtVertexModule .= '<div class="module_round_box_middle"><div><div><div>';
- if ($show_title == 1) {
- $builtVertexModule .= '<h3 class="s5_mod_h3' . $style .
- '"><span class="s5_mod_span1"><span class="s5_mod_span2"><span class="s5_mod_span3">';
- $builtVertexModule .= '<span class="s5_h3_first">' . $title_part1 . '</span> ' . $title_part2 .
- '';
- $builtVertexModule .= '';
- if ($title_part3 != '') {
- $vertexModule .= '<span class="s5_mod_h3' . $style .
- '"><span class="s5_suffix_word">' . $title_part3 . '</span></span>';
- }
- $builtVertexModule .= '</span></span></span></h3>';
- }
- $builtVertexModule .= $content;
- $builtVertexModule .= '</div></div></div></div>';
- }
- if ($type == 'notitlestyle') {
- $vertexModule = '';
- $title_part1 = '';
- $title_part2 = '';
- if ($style != '') {
- $split_title = split(' ', $title, 3);
- } else {
- $split_title = split(' ', $title, 2);
- }
- if (isset($split_title[0])) {
- $title_part1 = isset($split_title[0]) ? $split_title[0] : '';
- }
- if (isset($split_title[1])) {
- $title_part2 = isset($split_title[1]) ? $split_title[1] : '';
- }
- $vertexModule .= '<div class="module_round_box' . $style . '">';
- if ($show_title == 1) {
- $vertexModule .= '<h3 class="s5_mod_h3"><span class="s5_h3_first">' . $title_part1 .
- '</span> ' . $title_part2 . '</h3>';
- }
- $vertexModule .= '<div><div><div>' . $content . '</div></div></div></div>';
- }
- if ($type == 'vertex_sidebar') {
- $vertexModule = '';
- $title_part1 = '';
- $title_part2 = '';
- $title_part3 = '';
- if ($style != '') {
- $split_title = split(' ', $title, 3);
- } else {
- $split_title = split(' ', $title, 2);
- }
- if (isset($split_title[0])) {
- $title_part1 = isset($split_title[0]) ? $split_title[0] : '';
- }
- if (isset($split_title[1])) {
- $title_part2 = isset($split_title[1]) ? $split_title[1] : '';
- }
- if (isset($split_title[2])) {
- $title_part3 = isset($split_title[2]) ? $split_title[2] : '';
- }
- $vertexModule .= '<div class="module_round_box_middle"><div><div><div>';
- if ($show_title == 1) {
- $vertexModule .= '<h3 class="s5_mod_h3' . $style .
- '"><span class="s5_mod_span1"><span class="s5_mod_span2"><span class="s5_mod_span3">';
- $vertexModule .= '<span class="s5_h3_first">' . $title_part1 . '</span> ' . $title_part2 .
- '';
- $vertexModule .= '';
- if ($title_part3 != '') {
- $vertexModule .= '<span class="s5_mod_h3' . $style .
- '"><span class="s5_suffix_word">' . $title_part3 . '</span></span>';
- }
- $vertexModule .= '</span></span></span></h3>';
- }
- $vertexModule .= $content;
- $vertexModule .= '</div></div></div></div>';
- }
- return $builtVertexModule;
- }
- function build_vertex_block($type, $name, $style)
- {
- global $db, $config, $template, $user, $auth, $cache, $starttime, $phpEx;
- $sql = 'SELECT *
- FROM ' . VERTEX_BLOCKS . '
- WHERE block_position = "' . $name . '"
- AND block_style_main = "basics"
- ORDER BY left_id ASC';
- $result = $db->sql_query($sql);
- $vertexModule = '';
- while ($blockData = $db->sql_fetchrow($result)) {
- $is_enabled = ($blockData['block_enabled']) ? true : false;
- if ($is_enabled == true) {
- $selected_pages = explode(",", $blockData['block_show_pages']);
- $check_page = $this->pages_check($selected_pages, false);
- $is_on_page = $check_page;
- if ($is_on_page) {
- $is_in_group = $this->groups_check($blockData['block_show_group'], false);
- if ($is_in_group) {
- $block_content = '';
- if ($blockData['parse_bbc'] == 1) {
- $message_parser = new s5_parse_message($blockData['block_content']);
- $message_parser->parse($allow_bbcode, $allow_urls, $allow_smilies);
- $text_center = $message_parser->message;
- $bbcode_uid = $message_parser->bbcode_uid;
- $bbcode_bitfield = $message_parser->bbcode_bitfield;
- $bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
- $block_content = generate_text_for_display($text_center, $bbcode_uid, $bbcode_bitfield,
- $bbcode_options);
- } else {
- $block_content = htmlspecialchars_decode($blockData['block_content'], ENT_QUOTES);
- }
- $block_id = $blockData['block_id'];
- $block_position = $blockData['block_position'];
- $block_title = $blockData['block_title'];
- $block_show_title = $blockData['block_show_title'];
- $block_color = $blockData['block_color'];
- $block_style = $blockData['block_style'];
- $block_style_main = $blockData['block_style_main'];
- $block_width = $blockData['block_width'];
- $block_title2 = '';
- if ($blockData['block_full_title'] == true) {
- $show_title = '1';
- } else {
- $show_title = '0';
- }
- if ($blockData['block_style'] == 'login_block') {
- $login_module = $this->build_login_module();
- if ($block_show_title) {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $login_module, '1', false, $style);
- } else {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $login_module, '0', false, $style);
- }
- } elseif ($blockData['block_style'] == 'user_block') {
- $user_module = $this->build_user_module();
- if ($block_show_title) {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $user_module, '1', false, $style);
- } else {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $user_module, '0', false, $style);
- }
- } elseif ($blockData['block_style'] == 'actions_block') {
- $actions_module = $this->build_actions_module();
- if ($block_show_title) {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $actions_module, '1', false, $style);
- } else {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $actions_module, '0', false, $style);
- }
- } elseif ($blockData['block_style'] == 'who_block') {
- $who_module = $this->build_whos_module();
- if ($block_show_title) {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $who_module, '1', false, $style);
- } else {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $who_module, '0', false, $style);
- }
- } elseif ($blockData['block_style'] == 'stats_block') {
- $stats_module = $this->build_stats_module();
- if ($block_show_title) {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $stats_module, '1', false, $style);
- } else {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $stats_module, '0', false, $style);
- }
- } elseif ($blockData['block_style'] == 'birthday_block') {
- $birthday_module = $this->build_birthday_module();
- if ($block_show_title) {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $birthday_module, '1', false, $style);
- } else {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- '<h3>' . $user->lang['BIRTHDAYS'] . '</h3>' . $birthday_module, '0', false,
- 'default');
- }
- } elseif ($blockData['block_style'] == 'search_block') {
- $search_module = $this->build_search_module();
- if ($block_show_title) {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $search_module, '1', false, $style);
- } else {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $search_module, '0', false, 'default');
- }
- } else {
- if ($block_show_title) {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $block_content, '1', false, $style);
- } else {
- $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
- $block_content, '0', false, $style);
- }
- }
- }
- }
- }
- }
- $db->sql_freeresult($result);
- return $vertexModule;
- }
- function parseAttributes($string)
- {
- //Initialize variables
- $attr = array();
- $retarray = array();
- // Lets grab all the key/value pairs using a regular expression
- preg_match_all('/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr);
- if (is_array($attr)) {
- $numPairs = count($attr[1]);
- for ($i = 0; $i < $numPairs; $i++) {
- $retarray[$attr[1][$i]] = $attr[2][$i];
- }
- }
- return $retarray;
- }
- function parseTemplateFile($data)
- {
- $replace = array();
- $matches = array();
- if (preg_match_all('#<jdoc:include\ type="([^"]+)" (.*)\/>#iU', $data, $matches)) {
- $matches[0] = array_reverse($matches[0]);
- $matches[1] = array_reverse($matches[1]);
- $matches[2] = array_reverse($matches[2]);
- $count = count($matches[1]);
- for ($i = 0; $i < $count; $i++) {
- $attribs = Vertex::parseAttributes($matches[2][$i]);
- $type = $matches[1][$i];
- $name = isset($attribs['name']) ? $attribs['name'] : null;
- $style = isset($attribs['style']) ? $attribs['style'] : null;
- $replace[$i] = $this->build_vertex_block($type, $name, $style);
- }
- $data = str_replace($matches[0], $replace, $data);
- }
- return $data;
- }
- }
- ob_start();
- $template->display('body');
- $data = ob_get_contents();
- ob_end_clean();
- $vertex = new Vertex;
- $html = $data;
- $vertex = $vertex->parseTemplateFile($html);
- echo $vertex;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement