Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 44.06 KB | None | 0 0
  1. <?php
  2. define('_JEXEC', 1);
  3. define('DS', DIRECTORY_SEPARATOR);
  4. define('TEMPLATEPATH', dirname(__file__));
  5.  
  6.  
  7.  
  8. function countModules($condition)
  9. {
  10.     global $db, $config, $template, $user, $auth, $cache, $starttime, $phpEx;        
  11.        
  12.     $sql = 'SELECT block_enabled
  13.        FROM ' . VERTEX_BLOCKS . '
  14.        WHERE block_position LIKE "' . $condition . '"
  15.        AND block_style_main = "basics"
  16.        ORDER BY left_id ASC';
  17.     $result = $db->sql_query($sql);
  18.        
  19.     $count = 0;
  20.     $count = 1;  //Add a little fix to show correct no.
  21.     $result2 = $db->sql_fetchrow($result);
  22.        
  23.     while ($thecount = $db->sql_fetchrow($result)) {
  24.         $count++;
  25.     }
  26.     $countme = $count;
  27.     if ($countme >= 0)
  28.     {
  29.         return true;
  30.     }
  31. }
  32.  
  33. class Vertex
  34. {
  35.  
  36.     function pages_check($page_ids)
  37.     {
  38.         global $db, $auth, $user, $template;
  39.         global $phpbb_root_path, $phpEx, $config;
  40.  
  41.         $script_name = str_replace('.' . $phpEx, '', $user->page['page_name']);
  42.  
  43.         $sql = 'SELECT page_id, page_name, page_tag
  44.        FROM ' . VERTEX_PAGES . "
  45.        ORDER BY page_id ASC";
  46.         $result = $db->sql_query($sql);
  47.  
  48.         $check_page_options = '';
  49.  
  50.         while ($row = $db->sql_fetchrow($result)) {
  51.             $selected = (in_array($row['page_id'], $page_ids, true)) ? $row['page_tag'] : '';
  52.             if ($selected == $script_name) {
  53.                 $check_page_options = 'yes';
  54.             }
  55.         }
  56.         $db->sql_freeresult($result);
  57.  
  58.         return $check_page_options;
  59.     }
  60.    
  61.     function groups_check($group_ids)
  62.     {
  63.         global $db, $auth, $user, $template;
  64.         global $phpbb_root_path, $phpEx, $config;
  65.  
  66.         $selected_groups = array();
  67.         $selected_groups = explode(",", $group_ids);
  68.         $sql = 'SELECT *
  69.            FROM ' . USER_GROUP_TABLE . '
  70.            WHERE ' . $db->sql_in_set('group_id', $selected_groups) . '
  71.            AND user_id = ' . $user->data['user_id'];
  72.         $db->sql_query($sql);
  73.         $result = $db->sql_query_limit($sql, 1, 0);
  74.         $is_in_group = $db->sql_fetchrow($result);
  75.        
  76.         return $is_in_group;
  77.     }
  78.  
  79.     function build_login_module()
  80.     {
  81.         global $db, $auth, $user, $template, $topic_data, $forum_data;
  82.         global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
  83.        
  84.         $built_login_module = '';
  85.        
  86.         if ($user->data['user_id'] != ANONYMOUS) {
  87.             $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true,
  88.                 $user->session_id);
  89.             $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']);
  90.  
  91.             $built_login_module .= '';
  92.  
  93.         } else {
  94.             $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login');
  95.             $l_login_logout = $user->lang['LOGIN'];
  96.  
  97.             $s_login_redirect = build_hidden_fields(array('redirect' => build_url()));
  98.             $s_login_action = ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx",
  99.                 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id));
  100.             $l_username = $user->lang['USERNAME'];
  101.             $l_password = $user->lang['PASSWORD'];
  102.             $l_login = $user->lang['LOGIN'];
  103.             $s_auto_login_enabled = ($config['allow_autologin']) ?
  104.                 '<label for="autologin-s5">REMEMBER ME<input type="checkbox" name="autologin" id="autologin-s5" /></label>' :
  105.                 '';
  106.  
  107.             $built_login_module .= '<form class="form-login" method="post" action="' . $s_login_action .
  108.                 '"><fieldset class="input">' . $l_username .
  109.                 ':<br /><input type="text" name="username" id="s5-username-mod" size="20" class="inputbox modlgn_username" title="' .
  110.                 $l_username . '" /> <br />' . $l_username .
  111.                 ':<br /><input type="password" name="password" id="s5-password-mod" size="20" class="inputbox modlgn_username" title="' .
  112.                 $l_password . '" />' . $s_auto_login_enabled .
  113.                 '<input type="submit" name="login" value="' . $l_login .
  114.                 '" class="button" /><div>' . $s_login_redirect . '</div></fieldset></form>';
  115.         }
  116.  
  117.         $template->assign_var('VERTEX_LOGIN_MODULE', 'YES');
  118.  
  119.         return $built_login_module;
  120.     }
  121.  
  122.     function build_user_module()
  123.     {
  124.         global $db, $auth, $user, $template, $topic_data, $forum_data;
  125.         global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
  126.  
  127.         if ($user->data['user_id'] != ANONYMOUS) {
  128.             $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout', true,
  129.                 $user->session_id);
  130.             $l_login_logout = sprintf($user->lang['LOGOUT_USER'], $user->data['username']);
  131.         } else {
  132.             $u_login_logout = append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login');
  133.             $l_login_logout = $user->lang['LOGIN'];
  134.         }
  135.  
  136.         $l_privmsgs_text = $l_privmsgs_text_unread = '';
  137.         $s_privmsg_new = false;
  138.         // Obtain number of new private messages if user is logged in
  139.         if (!empty($user->data['is_registered'])) {
  140.             if ($user->data['user_new_privmsg']) {
  141.                 $l_message_new = ($user->data['user_new_privmsg'] == 1) ? $user->lang['NEW_PM'] :
  142.                     $user->lang['NEW_PMS'];
  143.                 $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']);
  144.  
  145.                 if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->
  146.                     data['session_last_visit']) {
  147.                     $sql = 'UPDATE ' . USERS_TABLE . '
  148.                    SET user_last_privmsg = ' . $user->data['session_last_visit'] .
  149.                         ' WHERE user_id = ' . $user->data['user_id'];
  150.                     $db->sql_query($sql);
  151.  
  152.                     $s_privmsg_new = true;
  153.                 } else {
  154.                     $s_privmsg_new = false;
  155.                 }
  156.             } else {
  157.                 $l_privmsgs_text = $user->lang['NO_NEW_PM'];
  158.                 $s_privmsg_new = false;
  159.             }
  160.  
  161.             $l_privmsgs_text_unread = '';
  162.  
  163.             if ($user->data['user_unread_privmsg'] && $user->data['user_unread_privmsg'] !=
  164.                 $user->data['user_new_privmsg']) {
  165.                 $l_message_unread = ($user->data['user_unread_privmsg'] == 1) ? $user->lang['UNREAD_PM'] :
  166.                     $user->lang['UNREAD_PMS'];
  167.                 $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']);
  168.             }
  169.         }
  170.  
  171.         $u_index = append_sid("{$phpbb_root_path}index.$phpEx");
  172.         $l_index = $user->lang['INDEX'];
  173.         $s_is_bot = (!empty($user->data['is_bot'])) ? true : false;
  174.         $s_user_logged_in = ($user->data['user_id'] != ANONYMOUS) ? true : false;
  175.         $s_register_enabled = ($config['require_activation'] != USER_ACTIVATION_DISABLE) ? true : false;
  176.         $u_restore_permissions = ($user->data['user_perm_from'] && $auth->acl_get('a_switchperm')) ?
  177.             '<li class="parent item"><a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx",
  178.             'mode=restore_perm') . '"><span>' . $user->lang['RESTORE_PERMISSIONS'] .
  179.             '</span></a></li>' : '';
  180.         $u_mcp = ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ?
  181.             '<li class="parent item"><a href="' . append_sid("{$phpbb_root_path}mcp.$phpEx",
  182.             'i=main&mode=front', true, $user->session_id) . '"><span>' . $user->lang['MCP'] .
  183.             '</span></a></li>' : '';
  184.         $s_display_search = (!$config['load_search']) ? 0 : (isset($auth) ? ($auth->
  185.             acl_get('u_search') && $auth->acl_getf_global('f_search')) : 1);
  186.  
  187.         $registration_link = '';
  188.         if (!$s_is_bot) {
  189.             if (!$s_user_logged_in && $s_register_enabled) {
  190.                 $registration_link = '<li class="parent item"><a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx",
  191.                     'mode=register') . '" title="' . $user->lang['REGISTER'] .
  192.                     '" accesskey="e"><span>' . $user->lang['REGISTER'] . '</span></a></li>';
  193.             }
  194.         }
  195.  
  196.         $profile_link = '';
  197.         if (!$s_is_bot && $s_user_logged_in) {
  198.             $profile_link = '<li class="parent item"><a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx") .
  199.                 '" title="' . $user->lang['PROFILE'] . '" accesskey="e"><span>' . $user->lang['PROFILE'] .
  200.                 '</span></a></li>';
  201.         }
  202.         $search_link = '';
  203.         $pm_info_link = '';
  204.  
  205.         if ($s_user_logged_in) {
  206.             if ($s_display_search) {
  207.                 $u_search_self = append_sid("{$phpbb_root_path}search.$phpEx",
  208.                     'search_id=egosearch');
  209.                 $search_link = '<li class="parent item"><a href="' . $u_search_self . '"><span>' .
  210.                     $user->lang['SEARCH_SELF'] . '</span></a></li>';
  211.             }
  212.             $s_user_new_privmsg = $user->data['user_new_privmsg'];
  213.             $s_user_unread_privmsg = $user->data['user_unread_privmsg'];
  214.             if ($s_user_new_privmsg || $s_user_unread_privmsg) {
  215.                 $pm_info_link = '<li class="parent item"><a href="' . append_sid("{$phpbb_root_path}ucp.$phpEx",
  216.                     'i=pm&folder=inbox') . '"><span>' . $l_privmsgs_text . '</span></a></li>';
  217.             }
  218.         }
  219.  
  220.         $built_user_module = '<ul class="menu"><li class="parent item"><a href="' . $u_index .
  221.             '"><span>' . $l_index . '</span></a></li>' . $registration_link .
  222.             '<li class="parent item"><a href="' . $u_login_logout . '" title="' . $l_login_logout .
  223.             '" accesskey="x"><span>' . $l_login_logout . '</span></a></li>' . $profile_link .
  224.             '' . $search_link . '' . $pm_info_link . '' . $u_mcp . '' . $u_restore_permissions .
  225.             '</ul>';
  226.  
  227.         $template->assign_var('VERTEX_USER_MODULE', 'YES');
  228.  
  229.         return $built_user_module;
  230.     }
  231.  
  232.     function build_actions_module()
  233.     {
  234.         global $db, $auth, $user, $template, $topic_data, $forum_data;
  235.         global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
  236.  
  237.         $script_name = str_replace('.' . $phpEx, '', $user->page['page_name']);
  238.         $s_display_search = (!$config['load_search']) ? 0 : (isset($auth) ? ($auth->
  239.             acl_get('u_search') && $auth->acl_getf_global('f_search')) : 1);
  240.         $s_user_logged_in = ($user->data['user_id'] != ANONYMOUS) ? true : false;
  241.         $s_is_bot = (!empty($user->data['is_bot'])) ? true : false;
  242.  
  243.         $u_search_unanswered = append_sid("{$phpbb_root_path}search.$phpEx",
  244.             'search_id=unanswered');
  245.         $u_search_active_topics = append_sid("{$phpbb_root_path}search.$phpEx",
  246.             'search_id=active_topics');
  247.         $u_search_unread = append_sid("{$phpbb_root_path}search.$phpEx",
  248.             'search_id=unreadposts');
  249.         $u_search_self = append_sid("{$phpbb_root_path}search.$phpEx",
  250.             'search_id=egosearch');
  251.         $u_search_new = append_sid("{$phpbb_root_path}search.$phpEx",
  252.             'search_id=newposts');
  253.  
  254.         $actions_menu_link1 = '';
  255.         $actions_menu_link2 = '';
  256.         $actions_menu_link3 = '';
  257.         $actions_menu_link4 = '';
  258.         $actions_menu_link5 = '';
  259.         $actions_menu_link6 = '';
  260.         $actions_menu_link7 = '';
  261.         $actions_menu_link8 = '';
  262.         $actions_menu_link9 = '';
  263.         $actions_menu_link10 = '';
  264.         $actions_menu_link11 = '';
  265.         $actions_menu_link12 = '';
  266.         $actions_menu_link13 = '';
  267.         $actions_menu_link14 = '';
  268.  
  269.         if ($s_display_search) {
  270.             $actions_menu_link1 = '<li class="parent item"><a href="' . $u_search_unanswered .
  271.                 '"><span>' . $user->lang['SEARCH_UNANSWERED'] . '</span></a></li>';
  272.             $actions_menu_link2 = '<li class="parent item"><a href="' . $u_search_active_topics .
  273.                 '"><span>' . $user->lang['SEARCH_ACTIVE_TOPICS'] . '</span></a></li>';
  274.             if ($s_user_logged_in) {
  275.                 $actions_menu_link3 = '<li class="parent item"><a href="' . $u_search_unread .
  276.                     '"><span>' . $user->lang['SEARCH_UNREAD'] . '</span></a></li>';
  277.                 $actions_menu_link4 = '<li class="parent item"><a href="' . $u_search_self .
  278.                     '"><span>' . $user->lang['SEARCH_NEW'] . '</span></a></li>';
  279.                 $actions_menu_link5 = '<li class="parent item"><a href="' . $u_search_new .
  280.                     '"><span>' . $user->lang['SEARCH_SELF'] . '</span></a></li>';
  281.             }
  282.         }
  283.  
  284.         if ($script_name == 'viewforum') {
  285.             $forum_id = request_var('f', 0);
  286.             $s_watching_forum = array('link' => '', 'title' => '', 'is_watching' => false, );
  287.  
  288.             if (($config['email_enable'] || $config['jab_enable']) && $config['allow_forum_notify'] &&
  289.                 $forum_data['forum_type'] == FORUM_POST && $auth->acl_get('f_subscribe', $forum_id)) {
  290.                 $notify_status = (isset($forum_data['notify_status'])) ? $forum_data['notify_status'] : null;
  291.                 watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id,
  292.                     0, $notify_status);
  293.             }
  294.             $s_watch_forum_link = $s_watching_forum['link'];
  295.             $s_watch_forum_title = $s_watching_forum['title'];
  296.         }
  297.  
  298.         if ($script_name == 'viewtopic') {
  299.             $forum_id = request_var('f', 0);
  300.             $topic_id = request_var('t', 0);
  301.             $post_id = request_var('p', 0);
  302.             $start = request_var('start', 0);
  303.             $view = request_var('view', '');
  304.             $s_watching_topic = array('link' => '', 'title' => '', 'is_watching' => false, );
  305.  
  306.             if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'] &&
  307.                 $user->data['is_registered']) {
  308.                 watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id,
  309.                     $topic_id, $topic_data['notify_status'], $start);
  310.  
  311.                 // Reset forum notification if forum notify is set
  312.                 if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id)) {
  313.                     $s_watching_forum = $s_watching_topic;
  314.                     watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id,
  315.                         0);
  316.                 }
  317.             }
  318.  
  319.             // Post ordering options
  320.             $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 =>
  321.                 $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'],
  322.                 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->
  323.                 lang['1_YEAR']);
  324.  
  325.             $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'],
  326.                 's' => $user->lang['SUBJECT']);
  327.             $sort_by_sql = array('a' => array('u.username_clean', 'p.post_id'), 't' =>
  328.                 'p.post_time', 's' => array('p.post_subject', 'p.post_id'));
  329.             $join_user_sql = array('a' => true, 't' => false, 's' => false);
  330.  
  331.             $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
  332.             $highlight_match = $highlight = '';
  333.  
  334.  
  335.             $viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" .
  336.                 (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" :
  337.                 '') . (($highlight_match) ? "&hilit=$highlight" : ''));
  338.             $u_watch_topic = $s_watching_topic['link'];
  339.             $u_bookmark_topic = ($user->data['is_registered'] && $config['allow_bookmarks']) ?
  340.                 $viewtopic_url . '&bookmark=1&hash=' . generate_link_hash("topic_$topic_id") :
  341.                 '';
  342.             $u_bump_topic = (bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'],
  343.                 $topic_data['topic_poster'], $topic_data['topic_last_poster_id'])) ? append_sid("{$phpbb_root_path}posting.$phpEx",
  344.                 "mode=bump&f=$forum_id&t=$topic_id&hash=" . generate_link_hash("topic_$topic_id")) :
  345.                 '';
  346.             $u_email_topic = ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ?
  347.                 append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&t=$topic_id") :
  348.                 '';
  349.             $u_print_topic = ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url .
  350.                 '&view=print' : '';
  351.         }
  352.  
  353.         $u_team = ($user->data['user_id'] != ANONYMOUS && !$auth->acl_get('u_viewprofile')) ?
  354.             '' : append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=leaders');
  355.         $u_delete_cookies = append_sid("{$phpbb_root_path}ucp.$phpEx",
  356.             'mode=delete_cookies');
  357.  
  358.         if (!$s_is_bot) {
  359.             if ($script_name == 'viewforum') {
  360.                 if ($s_watch_forum_link) {
  361.                     $actions_menu_link6 = '<li class="parent item"><a href="' . $s_watch_forum_link .
  362.                         '" title="' . $s_watch_forum_title . '"><span>' . $s_watch_forum_title .
  363.                         '</span></a></li>';
  364.                 }
  365.             }
  366.  
  367.             if ($script_name == 'viewtopic') {
  368.                 if ($u_watch_topic) {
  369.                     $actions_menu_link7 = '<li class="parent item"><a href="' . $u_watch_topic .
  370.                         '" title="' . $s_watching_topic['title'] . '"><span>' . $s_watching_topic['title'] .
  371.                         '</span></a></li>';
  372.                 }
  373.                 if ($u_bookmark_topic) {
  374.                     $actions_menu_link8 = '<li class="parent item"><a href="' . $u_bookmark_topic .
  375.                         '" title="' . $user->lang['BOOKMARK_TOPIC'] . '"><span>' . $user->lang['BOOKMARK_TOPIC'] .
  376.                         '</span></a></li>';
  377.                 }
  378.                 if ($u_bump_topic) {
  379.                     $actions_menu_link9 = '<li class="parent item"><a href="' . $u_bump_topic .
  380.                         '" title="' . $user->lang['BUMP_TOPIC'] . '"><span>' . $user->lang['BUMP_TOPIC'] .
  381.                         '</span></a></li>';
  382.                 }
  383.             }
  384.             $actions_menu_link14 = '<li class="parent item"><a href="' . $u_delete_cookies .
  385.                 '"><span>' . $user->lang['DELETE_COOKIES'] . '</span></a></li>';
  386.  
  387.         }
  388.  
  389.         if ($script_name == 'viewtopic') {
  390.             if ($u_email_topic) {
  391.                 $actions_menu_link10 = '<li class="parent item"><a href="' . $u_email_topic .
  392.                     '" title="' . $user->lang['EMAIL_TOPIC'] . '"><span>' . $user->lang['EMAIL_TOPIC'] .
  393.                     '</span></a></li>';
  394.             }
  395.             if ($u_print_topic) {
  396.                 $actions_menu_link11 = '<li class="parent item"><a href="' . $u_print_topic .
  397.                     '" title="' . $user->lang['PRINT_TOPIC'] . '"><span>' . $user->lang['PRINT_TOPIC'] .
  398.                     '</span></a></li>';
  399.             }
  400.         }
  401.  
  402.         if ($u_team) {
  403.             $actions_menu_link13 = '<li class="parent item"><a href="' . $u_team .
  404.                 '"><span>' . $user->lang['THE_TEAM'] . '</span></a></li>';
  405.         }
  406.  
  407.         $built_actions_module = '<ul class="menu">' . $actions_menu_link1 . $actions_menu_link2 .
  408.             $actions_menu_link3 . $actions_menu_link4 . $actions_menu_link5 . $actions_menu_link6 .
  409.             $actions_menu_link7 . $actions_menu_link8 . $actions_menu_link9 . $actions_menu_link10 .
  410.             $actions_menu_link11 . $actions_menu_link12 . $actions_menu_link13 . $actions_menu_link14 .
  411.             '</ul>';
  412.  
  413.         $template->assign_var('VERTEX_ACTIONS_MODULE', 'YES');
  414.  
  415.         return $built_actions_module;
  416.     }
  417.  
  418.  
  419.     function build_whos_module()
  420.     {
  421.         global $db, $auth, $user, $template, $topic_data, $forum_data;
  422.         global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
  423.  
  424.         if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) {
  425.             $sql = 'SELECT group_id, group_name, group_colour, group_type
  426.           FROM ' . GROUPS_TABLE . '
  427.           WHERE group_legend = 1
  428.           ORDER BY group_name ASC';
  429.         } else {
  430.             $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type
  431.           FROM ' . GROUPS_TABLE . ' g
  432.           LEFT JOIN ' . USER_GROUP_TABLE . ' ug
  433.             ON (
  434.                 g.group_id = ug.group_id
  435.                 AND ug.user_id = ' . $user->data['user_id'] . '
  436.                 AND ug.user_pending = 0
  437.             )
  438.         WHERE g.group_legend = 1
  439.             AND (g.group_type <> ' . GROUP_HIDDEN . ' OR ug.user_id = ' . $user->data['user_id'] .
  440.                 ')
  441.         ORDER BY g.group_name ASC';
  442.         }
  443.         $result = $db->sql_query($sql);
  444.  
  445.         $legend2 = array();
  446.         while ($get = $db->sql_fetchrow($result)) {
  447.             $colour_text = ($get['group_colour']) ? ' style="color:#' . $get['group_colour'] .
  448.                 '"' : '';
  449.             $group_name = ($get['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $get['group_name']] :
  450.                 $get['group_name'];
  451.  
  452.             if ($get['group_name'] == 'BOTS' || ($user->data['user_id'] != ANONYMOUS && !$auth->
  453.                 acl_get('u_viewprofile'))) {
  454.                 $legend2[] = '<span' . $colour_text . '>' . $group_name . '</span>';
  455.             } else {
  456.                 $legend2[] = '<a' . $colour_text . ' href="' . append_sid("{$phpbb_root_path}memberlist.$phpEx",
  457.                     'mode=group&g=' . $get['group_id']) . '">' . $group_name . '</a>';
  458.             }
  459.         }
  460.         $db->sql_freeresult($result);
  461.  
  462.         $legend3 = implode(', ', $legend2);
  463.         $legend4 = '<br /><em>' . $user->lang['LEGEND'] . ': ' . $legend3 . '</em>';
  464.  
  465.         // Get users online list ... if required
  466.         $display_online_list = true;
  467.         $item_id = 0;
  468.         $item = 'forum';
  469.         $l_online_users = $online_userlist = $l_online_record = $l_online_time = '';
  470.  
  471.         if ($config['load_online'] && $config['load_online_time'] && $display_online_list) {
  472.             /**
  473.              * Load online data:
  474.              * For obtaining another session column use $item and $item_id in the function-parameter, whereby the column is session_{$item}_id.
  475.              */
  476.             $item_id = max($item_id, 0);
  477.  
  478.             $online_users = obtain_users_online($item_id, $item);
  479.             $user_online_strings = obtain_users_online_string($online_users, $item_id, $item);
  480.  
  481.             $l_online_users = $user_online_strings['l_online_users'];
  482.             $online_userlist = $user_online_strings['online_userlist'];
  483.             $total_online_users = $online_users['total_online'];
  484.  
  485.             if ($total_online_users > $config['record_online_users']) {
  486.                 set_config('record_online_users', $total_online_users, true);
  487.                 set_config('record_online_date', time(), true);
  488.             }
  489.  
  490.             $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'],
  491.                 $user->format_date($config['record_online_date'], false, true));
  492.  
  493.             $l_online_time = ($config['load_online_time'] == 1) ? 'VIEW_ONLINE_TIME' :
  494.                 'VIEW_ONLINE_TIMES';
  495.             $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']);
  496.         }
  497.         $u_view_online = ($auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd',
  498.             'a_userdel')) ? append_sid("{$phpbb_root_path}viewonline.$phpEx") : '';
  499.  
  500.  
  501.         if ($u_view_online) {
  502.             $who_module_title = '<a href="' . $u_view_online . '">' . $user->lang['WHO_IS_ONLINE'] .
  503.                 '</a>';
  504.         } else {
  505.             $who_module_title = $user->lang['WHO_IS_ONLINE'];
  506.         }
  507.  
  508.         $built_whos_module = $who_module_title . '<p>' . $l_online_users . '(' . $l_online_time .
  509.             ')<br />' . $l_online_record . '<br /> <br />' . $online_userlist . '</p>';
  510.  
  511.         $template->assign_var('VERTEX_WHO_MODULE', 'YES');
  512.  
  513.         return $built_whos_module;
  514.     }
  515.  
  516.     function build_stats_module()
  517.     {
  518.         global $db, $auth, $user, $template, $topic_data, $forum_data;
  519.         global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
  520.  
  521.         // Set some stats, get posts count from forums data if we... hum... retrieve all forums data
  522.         $total_posts = $config['num_posts'];
  523.         $total_topics = $config['num_topics'];
  524.         $total_users = $config['num_users'];
  525.  
  526.         $l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
  527.         $l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
  528.         $l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' :
  529.             'TOTAL_TOPICS_OTHER';
  530.  
  531.  
  532.         $s5_total_posts = sprintf($user->lang[$l_total_post_s], $total_posts);
  533.         $s5_total_topics = sprintf($user->lang[$l_total_topic_s], $total_topics);
  534.         $s5_total_users = sprintf($user->lang[$l_total_user_s], $total_users);
  535.         $s5_newest_user = sprintf($user->lang['NEWEST_USER'], get_username_string('full',
  536.             $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour']));
  537.  
  538.         $built_stats_module = '<p>' . $s5_total_posts . ' &bull; ' . $s5_total_topics .
  539.             ' &bull; ' . $s5_total_users . ' &bull; ' . $s5_newest_user . '</p>';
  540.  
  541.         $template->assign_var('VERTEX_STATS_MODULE', 'YES');
  542.  
  543.         return $built_stats_module;
  544.     }
  545.  
  546.     function build_birthday_module()
  547.     {
  548.         global $db, $auth, $user, $template, $topic_data, $forum_data;
  549.         global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
  550.  
  551.         $birthday_list = '';
  552.         if ($config['load_birthdays'] && $config['allow_birthdays']) {
  553.             $now = getdate(time() + $user->timezone + $user->dst - date('Z'));
  554.             $sql = 'SELECT u.user_id, u.username, u.user_colour, u.user_birthday
  555.           FROM ' . USERS_TABLE . ' u
  556.           LEFT JOIN ' . BANLIST_TABLE . " b ON (u.user_id = b.ban_userid)
  557.           WHERE (b.ban_id IS NULL
  558.             OR b.ban_exclude = 1)
  559.             AND u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'],
  560.                 $now['mon'])) . "%'
  561.             AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')';
  562.             $result = $db->sql_query($sql);
  563.  
  564.             while ($row = $db->sql_fetchrow($result)) {
  565.                 $birthday_list .= (($birthday_list != '') ? ', ' : '') . get_username_string('full',
  566.                     $row['user_id'], $row['username'], $row['user_colour']);
  567.  
  568.                 if ($age = (int)substr($row['user_birthday'], -4)) {
  569.                     $birthday_list .= ' (' . ($now['year'] - $age) . ')';
  570.                 }
  571.             }
  572.             $db->sql_freeresult($result);
  573.         }
  574.  
  575.         if ($birthday_list) {
  576.             $built_birthday_module = '<p>' . $user->lang['CONGRATULATIONS'] . ': <strong>' .
  577.                 $birthday_list . '</strong></p>';
  578.         } else {
  579.             $built_birthday_module = '<p>' . $user->lang['NO_BIRTHDAYS'] . '</p>';
  580.         }
  581.  
  582.         $template->assign_var('VERTEX_BIRTHDAY_MODULE', 'YES');
  583.  
  584.         return $built_birthday_module;
  585.     }
  586.  
  587.     function build_search_module()
  588.     {
  589.         global $db, $auth, $user, $template, $topic_data, $forum_data;
  590.         global $phpbb_root_path, $phpEx, $config, $SID, $_SID, $mine;
  591.  
  592.         $script_name = str_replace('.' . $phpEx, '', $user->page['page_name']);
  593.  
  594.         $forum_id = '';
  595.         $topic_id = '';
  596.         if ($script_name == 'viewforum') {
  597.             $forum_id = request_var('f', 0);
  598.         }
  599.         if ($script_name == 'viewtopic') {
  600.             $topic_id = request_var('t', 0);
  601.         }
  602.  
  603.         if ($forum_id != '') {
  604.             $built_search_module =
  605.                 '<div class="search-box2"><form action="./search.php?fid[]=' . $forum_id .
  606.                 '" id="forum-search2" method="post"><fieldset>
  607.                 <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" />
  608.                 <input type="submit" value="Search" class="button" />
  609.                 <input type="hidden" name="fid[]" value="' . $forum_id . '" />
  610.             </fieldset>
  611.             </form>
  612.         </div>';
  613.             $search_string = '?' . $forum_id . $topic_id;
  614.         } elseif ($topic_id != '') {
  615.             $built_search_module = '<div class="search-box2"><form action="./search.php?t=' .
  616.                 $topic_id . '" id="topic-search2" method="post">
  617.             <fieldset>
  618.                 <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" />
  619.                 <input type="submit" value="Search" class="button" />
  620.                 <input type="hidden" name="t" value="' . $topic_id . '" />
  621.                 <input type="hidden" name="sf" value="msgonly" />
  622.             </fieldset>
  623.             </form>
  624.         </div>';
  625.         } else {
  626.             $built_search_module = '<div class="search-box2"><form action="./search.php?t=' .
  627.                 $topic_id . '" id="site-search" method="post">
  628.             <fieldset>
  629.                 <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" />
  630.                 <input type="submit" value="Search" class="button" />
  631.                 <input type="hidden" name="t" value="' . $topic_id . '" />
  632.                 <input type="hidden" name="sf" value="msgonly" />
  633.             </fieldset>
  634.             </form>
  635.         </div>';
  636.         }
  637.  
  638.         $template->assign_var('VERTEX_SEARCH_MODULE', 'YES');
  639.  
  640.         return $built_search_module;
  641.     }
  642.  
  643.  
  644.     function buildVertexModule($position, $style, $title, $title2, $content, $show_title, $full_title, $type)
  645.     {
  646.         global $db, $config, $template, $user, $auth, $cache, $starttime, $phpEx;
  647.         if ($type == 'round_box') {
  648.             $builtVertexModule = '';
  649.             $title_part1 = '';
  650.             $title_part2 = '';
  651.             $title_part3 = '';
  652.  
  653.             if ($style != '') {
  654.                 $split_title = split(' ', $title, 3);
  655.             } else {
  656.                 $split_title = split(' ', $title, 2);
  657.             }
  658.             if (isset($split_title[0])) {
  659.                 $title_part1 = isset($split_title[0]) ? $split_title[0] : '';
  660.             }
  661.             if (isset($split_title[1])) {
  662.                 $title_part2 = isset($split_title[1]) ? $split_title[1] : '';
  663.             }
  664.             if (isset($split_title[2])) {
  665.                 $title_part3 = isset($split_title[2]) ? $split_title[2] : '';
  666.             }
  667.  
  668.             $builtVertexModule .= '<div class="module_round_box_middle"><div><div><div>';
  669.  
  670.             if ($show_title == 1) {
  671.                 $builtVertexModule .= '<h3 class="s5_mod_h3' . $style .
  672.                     '"><span class="s5_mod_span1"><span class="s5_mod_span2"><span class="s5_mod_span3">';
  673.                 $builtVertexModule .= '<span class="s5_h3_first">' . $title_part1 . '</span> ' . $title_part2 .
  674.                     '';
  675.                 $builtVertexModule .= '';
  676.                 if ($title_part3 != '') {
  677.                     $vertexModule .= '<span class="s5_mod_h3' . $style .
  678.                         '"><span class="s5_suffix_word">' . $title_part3 . '</span></span>';
  679.                 }
  680.  
  681.                 $builtVertexModule .= '</span></span></span></h3>';
  682.             }
  683.  
  684.             $builtVertexModule .= $content;
  685.             $builtVertexModule .= '</div></div></div></div>';
  686.         }
  687.  
  688.         if ($type == 'notitlestyle') {
  689.             $vertexModule = '';
  690.             $title_part1 = '';
  691.             $title_part2 = '';
  692.             if ($style != '') {
  693.                 $split_title = split(' ', $title, 3);
  694.             } else {
  695.                 $split_title = split(' ', $title, 2);
  696.             }
  697.             if (isset($split_title[0])) {
  698.                 $title_part1 = isset($split_title[0]) ? $split_title[0] : '';
  699.             }
  700.             if (isset($split_title[1])) {
  701.                 $title_part2 = isset($split_title[1]) ? $split_title[1] : '';
  702.             }
  703.  
  704.             $vertexModule .= '<div class="module_round_box' . $style . '">';
  705.             if ($show_title == 1) {
  706.                 $vertexModule .= '<h3 class="s5_mod_h3"><span class="s5_h3_first">' . $title_part1 .
  707.                     '</span> ' . $title_part2 . '</h3>';
  708.             }
  709.             $vertexModule .= '<div><div><div>' . $content . '</div></div></div></div>';
  710.  
  711.         }
  712.  
  713.         if ($type == 'vertex_sidebar') {
  714.             $vertexModule = '';
  715.             $title_part1 = '';
  716.             $title_part2 = '';
  717.             $title_part3 = '';
  718.  
  719.             if ($style != '') {
  720.                 $split_title = split(' ', $title, 3);
  721.             } else {
  722.                 $split_title = split(' ', $title, 2);
  723.             }
  724.             if (isset($split_title[0])) {
  725.                 $title_part1 = isset($split_title[0]) ? $split_title[0] : '';
  726.             }
  727.             if (isset($split_title[1])) {
  728.                 $title_part2 = isset($split_title[1]) ? $split_title[1] : '';
  729.             }
  730.             if (isset($split_title[2])) {
  731.                 $title_part3 = isset($split_title[2]) ? $split_title[2] : '';
  732.             }
  733.  
  734.  
  735.             $vertexModule .= '<div class="module_round_box_middle"><div><div><div>';
  736.  
  737.             if ($show_title == 1) {
  738.                 $vertexModule .= '<h3 class="s5_mod_h3' . $style .
  739.                     '"><span class="s5_mod_span1"><span class="s5_mod_span2"><span class="s5_mod_span3">';
  740.                 $vertexModule .= '<span class="s5_h3_first">' . $title_part1 . '</span> ' . $title_part2 .
  741.                     '';
  742.                 $vertexModule .= '';
  743.                 if ($title_part3 != '') {
  744.                     $vertexModule .= '<span class="s5_mod_h3' . $style .
  745.                         '"><span class="s5_suffix_word">' . $title_part3 . '</span></span>';
  746.                 }
  747.  
  748.                 $vertexModule .= '</span></span></span></h3>';
  749.             }
  750.  
  751.             $vertexModule .= $content;
  752.             $vertexModule .= '</div></div></div></div>';
  753.  
  754.         }
  755.         return $builtVertexModule;
  756.     }
  757.  
  758.  
  759.     function build_vertex_block($type, $name, $style)
  760.     {
  761.         global $db, $config, $template, $user, $auth, $cache, $starttime, $phpEx;
  762.  
  763.         $sql = 'SELECT *
  764.        FROM ' . VERTEX_BLOCKS . '
  765.        WHERE block_position = "' . $name . '"
  766.        AND block_style_main = "basics"
  767.        ORDER BY left_id ASC';
  768.         $result = $db->sql_query($sql);
  769.        
  770.         $vertexModule = '';
  771.         while ($blockData = $db->sql_fetchrow($result)) {
  772.             $is_enabled = ($blockData['block_enabled']) ? true : false;
  773.             if ($is_enabled == true) {
  774.                
  775.                 $selected_pages = explode(",", $blockData['block_show_pages']);
  776.                 $check_page = $this->pages_check($selected_pages, false);
  777.                 $is_on_page = $check_page;
  778.  
  779.                 if ($is_on_page) {
  780.                    
  781.                     $is_in_group = $this->groups_check($blockData['block_show_group'], false);
  782.                    
  783.                    
  784.                     if ($is_in_group) {
  785.                    
  786.                     $block_content = '';
  787.                         if ($blockData['parse_bbc'] == 1) {
  788.                             $message_parser = new s5_parse_message($blockData['block_content']);
  789.                             $message_parser->parse($allow_bbcode, $allow_urls, $allow_smilies);
  790.                             $text_center = $message_parser->message;
  791.                             $bbcode_uid = $message_parser->bbcode_uid;
  792.                             $bbcode_bitfield = $message_parser->bbcode_bitfield;
  793.                             $bbcode_options = OPTION_FLAG_BBCODE + OPTION_FLAG_SMILIES + OPTION_FLAG_LINKS;
  794.                             $block_content = generate_text_for_display($text_center, $bbcode_uid, $bbcode_bitfield,
  795.                                 $bbcode_options);
  796.                         } else {
  797.                             $block_content = htmlspecialchars_decode($blockData['block_content'], ENT_QUOTES);
  798.                         }
  799.  
  800.                         $block_id = $blockData['block_id'];
  801.                         $block_position = $blockData['block_position'];
  802.                         $block_title = $blockData['block_title'];
  803.                         $block_show_title = $blockData['block_show_title'];
  804.                         $block_color = $blockData['block_color'];
  805.                         $block_style = $blockData['block_style'];
  806.                         $block_style_main = $blockData['block_style_main'];
  807.                         $block_width = $blockData['block_width'];
  808.  
  809.                         $block_title2 = '';
  810.  
  811.                         if ($blockData['block_full_title'] == true) {
  812.                             $show_title = '1';
  813.                         } else {
  814.                             $show_title = '0';
  815.                         }
  816.  
  817.                         if ($blockData['block_style'] == 'login_block') {
  818.                             $login_module = $this->build_login_module();
  819.                             if ($block_show_title) {
  820.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  821.                                     $login_module, '1', false, $style);
  822.                             } else {
  823.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  824.                                     $login_module, '0', false, $style);
  825.                             }
  826.                         } elseif ($blockData['block_style'] == 'user_block') {
  827.                             $user_module = $this->build_user_module();
  828.                             if ($block_show_title) {
  829.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  830.                                     $user_module, '1', false, $style);
  831.                             } else {
  832.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  833.                                     $user_module, '0', false, $style);
  834.                             }
  835.                         } elseif ($blockData['block_style'] == 'actions_block') {
  836.                             $actions_module = $this->build_actions_module();
  837.                             if ($block_show_title) {
  838.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  839.                                     $actions_module, '1', false, $style);
  840.                             } else {
  841.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  842.                                     $actions_module, '0', false, $style);
  843.                             }
  844.                         } elseif ($blockData['block_style'] == 'who_block') {
  845.                             $who_module = $this->build_whos_module();
  846.                             if ($block_show_title) {
  847.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  848.                                     $who_module, '1', false, $style);
  849.                             } else {
  850.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  851.                                     $who_module, '0', false, $style);
  852.                             }
  853.                         } elseif ($blockData['block_style'] == 'stats_block') {
  854.                             $stats_module = $this->build_stats_module();
  855.                             if ($block_show_title) {
  856.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  857.                                     $stats_module, '1', false, $style);
  858.                             } else {
  859.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  860.                                     $stats_module, '0', false, $style);
  861.                             }
  862.                         } elseif ($blockData['block_style'] == 'birthday_block') {
  863.                             $birthday_module = $this->build_birthday_module();
  864.                             if ($block_show_title) {
  865.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  866.                                     $birthday_module, '1', false, $style);
  867.                             } else {
  868.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  869.                                     '<h3>' . $user->lang['BIRTHDAYS'] . '</h3>' . $birthday_module, '0', false,
  870.                                     'default');
  871.                             }
  872.                         } elseif ($blockData['block_style'] == 'search_block') {
  873.                             $search_module = $this->build_search_module();
  874.                             if ($block_show_title) {
  875.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  876.                                     $search_module, '1', false, $style);
  877.                             } else {
  878.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  879.                                     $search_module, '0', false, 'default');
  880.                             }
  881.                         } else {
  882.                             if ($block_show_title) {
  883.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  884.                                     $block_content, '1', false, $style);
  885.                             } else {
  886.                                 $vertexModule .= $this->buildVertexModule(false, $block_color, $block_title, $block_title2,
  887.                                     $block_content, '0', false, $style);
  888.                             }
  889.                         }
  890.                     }
  891.                 }
  892.             }
  893.         }
  894.  
  895.         $db->sql_freeresult($result);
  896.         return $vertexModule;
  897.     }
  898.  
  899.  
  900.     function parseAttributes($string)
  901.     {
  902.         //Initialize variables
  903.         $attr = array();
  904.         $retarray = array();
  905.  
  906.         // Lets grab all the key/value pairs using a regular expression
  907.         preg_match_all('/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr);
  908.  
  909.         if (is_array($attr)) {
  910.             $numPairs = count($attr[1]);
  911.             for ($i = 0; $i < $numPairs; $i++) {
  912.                 $retarray[$attr[1][$i]] = $attr[2][$i];
  913.             }
  914.         }
  915.         return $retarray;
  916.     }
  917.  
  918.     function parseTemplateFile($data)
  919.     {
  920.         $replace = array();
  921.         $matches = array();
  922.         if (preg_match_all('#<jdoc:include\ type="([^"]+)" (.*)\/>#iU', $data, $matches)) {
  923.             $matches[0] = array_reverse($matches[0]);
  924.             $matches[1] = array_reverse($matches[1]);
  925.             $matches[2] = array_reverse($matches[2]);
  926.  
  927.             $count = count($matches[1]);
  928.            
  929.             for ($i = 0; $i < $count; $i++) {
  930.                 $attribs = Vertex::parseAttributes($matches[2][$i]);
  931.                 $type = $matches[1][$i];
  932.  
  933.                 $name = isset($attribs['name']) ? $attribs['name'] : null;
  934.                
  935.                 $style = isset($attribs['style']) ? $attribs['style'] : null;
  936.                 $replace[$i] = $this->build_vertex_block($type, $name, $style);
  937.             }
  938.            
  939.             $data = str_replace($matches[0], $replace, $data);
  940.         }
  941.  
  942.         return $data;
  943.     }
  944.  
  945.  
  946. }
  947.  
  948.  
  949. ob_start();
  950. $template->display('body');
  951. $data = ob_get_contents();
  952. ob_end_clean();
  953.  
  954. $vertex = new Vertex;
  955.  
  956. $html = $data;
  957.  
  958. $vertex = $vertex->parseTemplateFile($html);
  959. echo $vertex;
  960.  
  961. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement