Beispiel #1
0
function forum_check_guest_access_allowed()
{
    $result = forum_check_guest_access_allowed_ignore();
    if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) {
        return $result;
    }
    if (!user_guest_enabled() && $_SESSION['UID'] == 0) {
        return $result;
    }
    return true;
}
Beispiel #2
0
function stats_get_html()
{
    // Get webtag
    $webtag = get_webtag();
    // Current active user UID
    $uid = session::get_value('UID');
    // Number of active users
    $session_count = stats_get_active_session_count();
    // Number of recent posts.
    $recent_post_count = stats_get_recent_post_count();
    // Update the stats records.
    stats_update($session_count, $recent_post_count);
    // User Profile link
    $user_profile_link = '%s<a href="user_profile.php?webtag=%s&amp;uid=%s" target="_blank" class="popup 650x500"><span class="%s" title="%s">%s</span></a>';
    // Newest ser Profile link
    $new_user_profile_link = '<a href="user_profile.php?webtag=%s&amp;uid=%s" target="_blank" class="popup 650x500">%s</a>';
    // Search Engine Bot link
    $search_engine_bot_link = '<a href="%s" target="_blank"><span class="user_stats_normal">%s</span></a>';
    // Output the HTML.
    if ($user_stats = stats_get_active_user_list()) {
        $active_user_list_array = array();
        $html = "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"posthead\">\n";
        $html .= "  <tr>\n";
        $html .= "    <td width=\"35\">&nbsp;</td>\n";
        $html .= "    <td>&nbsp;</td>\n";
        $html .= "    <td width=\"35\">&nbsp;</td>\n";
        $html .= "  </tr>\n";
        $html .= "  <tr>\n";
        $html .= "    <td>&nbsp;</td>\n";
        $html .= "    <td>";
        if (forum_get_setting('guest_show_recent', 'Y') && user_guest_enabled()) {
            if ($user_stats['GUESTS'] != 1) {
                $active_user_list_array[] = sprintf(gettext("<b>%s</b> guests"), $user_stats['GUESTS']);
            } else {
                $active_user_list_array[] = gettext("<b>1</b> guest");
            }
        }
        if ($user_stats['USER_COUNT'] != 1) {
            $active_user_list_array[] = sprintf(gettext("<b>%s</b> members"), $user_stats['USER_COUNT']);
        } else {
            $active_user_list_array[] = gettext("<b>1</b> member");
        }
        if ($user_stats['ANON_USERS'] != 1) {
            $active_user_list_array[] = sprintf(gettext("<b>%s</b> anonymous members"), $user_stats['ANON_USERS']);
        } else {
            $active_user_list_array[] = gettext("<b>1</b> anonymous member");
        }
        $active_user_list = implode(", ", $active_user_list_array);
        $active_user_time = format_time_display(ini_get('session.gc_maxlifetime'), false);
        $html .= sprintf(gettext("%s active in the past %s."), $active_user_list, $active_user_time);
        $html .= " [ <a href=\"start.php?webtag={$webtag}&amp;show=visitors\" target=\"" . html_get_frame_name('main') . "\">" . gettext("View Complete List") . "</a> ]\n";
        $html .= "    </td>\n";
        $html .= "    <td width=\"35\">&nbsp;</td>\n";
        $html .= "  </tr>\n";
        if (sizeof($user_stats['USERS']) > 0) {
            $active_users_array = array();
            foreach ($user_stats['USERS'] as $user) {
                $active_user_title = '';
                $active_user_class = '';
                $active_user_avatar = '';
                if (isset($user['BOT_NAME']) && isset($user['BOT_URL'])) {
                    $active_user_display = word_filter_add_ob_tags($user['BOT_NAME'], true);
                    $active_user_display = sprintf($search_engine_bot_link, $user['BOT_URL'], $active_user_display);
                    $active_users_array[] = $active_user_display;
                } else {
                    $active_user_logon = format_user_name($user['LOGON'], $user['NICKNAME']);
                    $active_user_display = str_replace(" ", "&nbsp;", word_filter_add_ob_tags($active_user_logon, true));
                    if ($user['UID'] == $uid) {
                        if (isset($user['ANON_LOGON']) && $user['ANON_LOGON'] > USER_ANON_DISABLED) {
                            $active_user_title = gettext("You (Invisible)");
                            $active_user_class = 'user_stats_curuser';
                        } else {
                            $active_user_title = gettext("You");
                            $active_user_class = 'user_stats_curuser';
                        }
                    } else {
                        if (($user['RELATIONSHIP'] & USER_FRIEND) > 0) {
                            $active_user_title = gettext("Friend");
                            $active_user_class = 'user_stats_friend';
                        } else {
                            $active_user_class = 'user_stats_normal';
                        }
                    }
                    if (isset($user['AVATAR_URL']) && strlen($user['AVATAR_URL']) > 0) {
                        $active_user_avatar = sprintf('<a href="user_profile.php?webtag=%s&amp;uid=%s" target="_blank" class="popup 650x500">
                                                         <img src="%s" title="%s" alt="" border="0" width="16" height="16" />
                                                       </a>', $webtag, $user['UID'], $user['AVATAR_URL'], htmlentities_array($active_user_title));
                    } else {
                        if (isset($user['AVATAR_AID']) && is_md5($user['AVATAR_AID'])) {
                            $attachment = attachments_get_by_hash($user['AVATAR_AID']);
                            if (!($user_avatar_picture = attachments_make_link($attachment, false, false, false, false))) {
                                $active_user_avatar = sprintf('<a href="user_profile.php?webtag=%s&amp;uid=%s" target="_blank" class="popup 650x500">
                                                             <img src="%s&amp;avatar_picture" title="%s" alt="" border="0" width="16" height="16" />
                                                           </a>', $webtag, $user['UID'], $user_avatar_picture, htmlentities_array($active_user_title));
                            }
                        }
                    }
                    $active_users_array[] = sprintf($user_profile_link, $active_user_avatar, $webtag, $user['UID'], $active_user_class, $active_user_title, $active_user_display);
                }
            }
            $html .= "  <tr>\n";
            $html .= "    <td width=\"35\">&nbsp;</td>\n";
            $html .= "    <td>&nbsp;</td>\n";
            $html .= "    <td width=\"35\">&nbsp;</td>\n";
            $html .= "  </tr>\n";
            $html .= "  <tr>";
            $html .= "    <td>&nbsp;</td>\n";
            $html .= "    <td class=\"activeusers\">\n";
            $html .= "      " . implode(", ", $active_users_array) . "\n";
            $html .= "    </td>\n";
            $html .= "    <td width=\"35\">&nbsp;</td>\n";
            $html .= "  </tr>\n";
        }
        $html .= "  <tr>\n";
        $html .= "    <td width=\"35\">&nbsp;</td>\n";
        $html .= "    <td>&nbsp;</td>\n";
        $html .= "  </tr>\n";
        $html .= "</table>\n";
    }
    $thread_count = stats_get_thread_count();
    $post_count = stats_get_post_count();
    $html .= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"posthead\">\n";
    $html .= "  <tr>\n";
    $html .= "    <td width=\"35\">&nbsp;</td>\n";
    $html .= "    <td>";
    if ($thread_count != 1) {
        $num_threads_display = sprintf(gettext("<b>%s</b> threads"), number_format($thread_count, 0, ".", ","));
    } else {
        $num_threads_display = gettext("<b>1</b> thread");
    }
    if ($post_count != 1) {
        $num_posts_display = sprintf(gettext("<b>%s</b> posts"), number_format($post_count, 0, ".", ","));
    } else {
        $num_posts_display = gettext("<b>1</b> post");
    }
    $html .= sprintf(gettext("Our members have made a total of %s and %s."), $num_threads_display, $num_posts_display) . '<br />';
    $html .= "    <td width=\"35\">&nbsp;</td>\n";
    $html .= "  </tr>\n";
    $html .= "</table>\n";
    if ($longest_thread = stats_get_longest_thread()) {
        $html .= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"posthead\">\n";
        $html .= "  <tr>\n";
        $html .= "    <td width=\"35\">&nbsp;</td>\n";
        $html .= "    <td>";
        $longest_thread_title = word_filter_add_ob_tags($longest_thread['TITLE'], true);
        $longest_thread_link = sprintf("<a href=\"./index.php?webtag={$webtag}&amp;msg=%d.1\">%s</a>", $longest_thread['TID'], $longest_thread_title);
        $longest_thread_post_count = $longest_thread['LENGTH'] != 1 ? sprintf(gettext("<b>%s</b> posts"), $longest_thread['LENGTH']) : gettext("<b>1</b> post");
        $html .= sprintf(gettext("Longest thread is <b>%s</b> with %s."), $longest_thread_link, $longest_thread_post_count);
        $html .= "    </td>\n";
        $html .= "    <td width=\"35\">&nbsp;</td>\n";
        $html .= "  </tr>\n";
        $html .= "</table>\n";
    }
    $html .= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"posthead\">\n";
    $html .= "  <tr>\n";
    $html .= "    <td width=\"35\">&nbsp;</td>\n";
    $html .= "    <td>&nbsp;</td>\n";
    $html .= "    <td width=\"35\">&nbsp;</td>\n";
    $html .= "  </tr>\n";
    $html .= "</table>\n";
    $html .= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"posthead\">\n";
    $html .= "  <tr>\n";
    $html .= "    <td width=\"35\">&nbsp;</td>\n";
    $html .= "    <td>";
    if ($recent_post_count != 1) {
        $recent_post_count = number_format($recent_post_count, 0, ",", ",");
        $html .= sprintf(gettext("There have been <b>%s</b> posts made in the last 60 minutes."), $recent_post_count);
    } else {
        $html .= gettext("There has been <b>1</b> post made in the last 60 minutes.");
    }
    $html .= "    </td>\n";
    $html .= "    <td width=\"35\">&nbsp;</td>\n";
    $html .= "  </tr>\n";
    $html .= "</table>\n";
    if ($most_posts = stats_get_most_posts()) {
        if ($most_posts['MOST_POSTS_COUNT'] > 0 && $most_posts['MOST_POSTS_DATE'] > 0) {
            $html .= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"posthead\">\n";
            $html .= "  <tr>\n";
            $html .= "    <td width=\"35\">&nbsp;</td>\n";
            $html .= "    <td>";
            $post_stats_record_date = format_time($most_posts['MOST_POSTS_DATE']);
            $html .= sprintf(gettext("Most posts ever made in a single 60 minute period is <b>%s</b> on %s."), $most_posts['MOST_POSTS_COUNT'], $post_stats_record_date);
            $html .= "    </td>\n";
            $html .= "    <td width=\"35\">&nbsp;</td>\n";
            $html .= "  </tr>\n";
            $html .= "</table>\n";
        }
    }
    if ($user_count = user_count()) {
        $html .= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"posthead\">\n";
        $html .= "  <tr>\n";
        $html .= "    <td width=\"35\">&nbsp;</td>\n";
        $html .= "    <td>&nbsp;</td>\n";
        $html .= "    <td width=\"35\">&nbsp;</td>\n";
        $html .= "  </tr>\n";
        $html .= "  <tr>\n";
        $html .= "    <td width=\"35\">&nbsp;</td>\n";
        $html .= "    <td>";
        if ($user_count != 1) {
            if ($newest_member = stats_get_newest_user()) {
                $user_newest_display = word_filter_add_ob_tags(format_user_name($newest_member['LOGON'], $newest_member['NICKNAME']), true);
                $user_newest_profile_link = sprintf($new_user_profile_link, $webtag, $newest_member['UID'], $user_newest_display);
                $html .= sprintf(gettext("We have <b>%s</b> registered members and the newest member is <b>%s</b>."), $user_count, $user_newest_profile_link);
            } else {
                $html .= sprintf(gettext("We have %s registered members."), $user_count);
            }
        } else {
            $html .= gettext("We have one registered member.");
        }
        $html .= "    </td>\n";
        $html .= "    <td width=\"35\">&nbsp;</td>\n";
        $html .= "  </tr>\n";
        $html .= "</table>\n";
    }
    if ($most_users = stats_get_most_users()) {
        if ($most_users['MOST_USERS_COUNT'] > 0 && $most_users['MOST_USERS_DATE'] > 0) {
            $html .= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"posthead\">\n";
            $html .= "  <tr>\n";
            $html .= "    <td width=\"35\">&nbsp;</td>\n";
            $html .= "    <td>";
            $most_users_count = number_format($most_users['MOST_USERS_COUNT'], 0, ",", ",");
            $most_users_date = format_time($most_users['MOST_USERS_DATE']);
            $html .= sprintf(gettext("Most users ever online was <b>%s</b> on %s."), $most_users_count, $most_users_date);
            $html .= "    </td>\n";
            $html .= "    <td width=\"35\">&nbsp;</td>\n";
            $html .= "  </tr>\n";
            $html .= "</table>\n";
        }
    }
    $html .= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"posthead\">\n";
    $html .= "  <tr>\n";
    $html .= "    <td width=\"35\">&nbsp;</td>\n";
    $html .= "    <td>&nbsp;</td>\n";
    $html .= "    <td width=\"35\">&nbsp;</td>\n";
    $html .= "  </tr>\n";
    $html .= "</table>\n";
    $html .= "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"posthead\">\n";
    $html .= "  <tr>\n";
    $html .= "    <td width=\"35\">&nbsp;</td>\n";
    $html .= "    <td>&nbsp;</td>\n";
    $html .= "    <td width=\"35\">&nbsp;</td>\n";
    $html .= "  </tr>\n";
    $html .= "</table>\n";
    // Return the output buffer contents.
    return $html;
}
function visitor_log_get_recent()
{
    if (!($db = db::get())) {
        return false;
    }
    if (!($table_prefix = get_table_prefix())) {
        return false;
    }
    if (!($forum_fid = get_forum_fid())) {
        return false;
    }
    if (!isset($_SESSION['UID']) || !is_numeric($_SESSION['UID'])) {
        return false;
    }
    if (forum_get_setting('guest_show_recent', 'Y') && user_guest_enabled()) {
        $sql = "SELECT VISITOR_LOG.UID, USER.LOGON, USER.NICKNAME, ";
        $sql .= "USER_PEER.PEER_NICKNAME, SEARCH_ENGINE_BOTS.NAME, ";
        $sql .= "SEARCH_ENGINE_BOTS.URL, SEARCH_ENGINE_BOTS.SID, ";
        $sql .= "UNIX_TIMESTAMP(VISITOR_LOG.LAST_LOGON) AS LAST_LOGON,  ";
        $sql .= "COALESCE(USER_PREFS_FORUM.AVATAR_URL, USER_PREFS_GLOBAL.AVATAR_URL) AS AVATAR_URL, ";
        $sql .= "COALESCE(USER_PREFS_FORUM.AVATAR_AID, USER_PREFS_GLOBAL.AVATAR_AID) AS AVATAR_AID ";
        $sql .= "FROM VISITOR_LOG VISITOR_LOG ";
        $sql .= "LEFT JOIN USER USER ON (USER.UID = VISITOR_LOG.UID) ";
        $sql .= "LEFT JOIN `{$table_prefix}USER_PEER` USER_PEER ";
        $sql .= "ON (USER_PEER.PEER_UID = USER.UID AND USER_PEER.UID = '{$_SESSION['UID']}') ";
        $sql .= "LEFT JOIN USER_PREFS USER_PREFS_GLOBAL ON (USER_PREFS_GLOBAL.UID = USER.UID) ";
        $sql .= "LEFT JOIN `{$table_prefix}USER_PREFS` USER_PREFS_FORUM ";
        $sql .= "ON (USER_PREFS_FORUM.UID = USER.UID) ";
        $sql .= "LEFT JOIN SEARCH_ENGINE_BOTS ON (SEARCH_ENGINE_BOTS.SID = VISITOR_LOG.SID) ";
        $sql .= "WHERE VISITOR_LOG.LAST_LOGON IS NOT NULL AND VISITOR_LOG.LAST_LOGON > 0 ";
        $sql .= "AND VISITOR_LOG.FORUM = '{$forum_fid}' ";
        $sql .= "AND (USER_PREFS_GLOBAL.ANON_LOGON IS NULL OR USER_PREFS_GLOBAL.ANON_LOGON = 0) ";
        $sql .= "ORDER BY VISITOR_LOG.LAST_LOGON DESC LIMIT 10";
    } else {
        $sql = "SELECT VISITOR_LOG.UID, USER.LOGON, USER.NICKNAME, ";
        $sql .= "USER_PEER.PEER_NICKNAME, SEARCH_ENGINE_BOTS.NAME, ";
        $sql .= "SEARCH_ENGINE_BOTS.URL, SEARCH_ENGINE_BOTS.SID, ";
        $sql .= "UNIX_TIMESTAMP(VISITOR_LOG.LAST_LOGON) AS LAST_LOGON,  ";
        $sql .= "COALESCE(USER_PREFS_FORUM.AVATAR_URL, USER_PREFS_GLOBAL.AVATAR_URL) AS AVATAR_URL, ";
        $sql .= "COALESCE(USER_PREFS_FORUM.AVATAR_AID, USER_PREFS_GLOBAL.AVATAR_AID) AS AVATAR_AID ";
        $sql .= "FROM VISITOR_LOG VISITOR_LOG ";
        $sql .= "LEFT JOIN USER USER ON (USER.UID = VISITOR_LOG.UID) ";
        $sql .= "LEFT JOIN `{$table_prefix}USER_PEER` USER_PEER ";
        $sql .= "ON (USER_PEER.PEER_UID = USER.UID AND USER_PEER.UID = '{$_SESSION['UID']}') ";
        $sql .= "LEFT JOIN USER_PREFS USER_PREFS_GLOBAL ON (USER_PREFS_GLOBAL.UID = USER.UID) ";
        $sql .= "LEFT JOIN `{$table_prefix}USER_PREFS` USER_PREFS_FORUM ";
        $sql .= "ON (USER_PREFS_FORUM.UID = USER.UID) ";
        $sql .= "LEFT JOIN SEARCH_ENGINE_BOTS ON (SEARCH_ENGINE_BOTS.SID = VISITOR_LOG.SID) ";
        $sql .= "WHERE VISITOR_LOG.LAST_LOGON IS NOT NULL AND VISITOR_LOG.LAST_LOGON > 0 ";
        $sql .= "AND VISITOR_LOG.FORUM = '{$forum_fid}' AND VISITOR_LOG.UID > 0 ";
        $sql .= "AND (USER_PREFS_GLOBAL.ANON_LOGON IS NULL OR USER_PREFS_GLOBAL.ANON_LOGON = 0) ";
        $sql .= "ORDER BY VISITOR_LOG.LAST_LOGON DESC LIMIT 10";
    }
    if (!($result = $db->query($sql))) {
        return false;
    }
    if ($result->num_rows == 0) {
        return false;
    }
    $users_get_recent_array = array();
    while (($visitor_array = $result->fetch_assoc()) !== null) {
        if ($visitor_array['UID'] == 0) {
            $visitor_array['LOGON'] = gettext('Guest');
            $visitor_array['NICKNAME'] = gettext('Guest');
        } else {
            if (!isset($visitor_array['LOGON']) || is_null($visitor_array['LOGON'])) {
                $visitor_array['LOGON'] = gettext('Unknown User');
                $visitor_array['NICKNAME'] = "";
            }
        }
        if (isset($visitor_array['PEER_NICKNAME'])) {
            if (!is_null($visitor_array['PEER_NICKNAME']) && strlen($visitor_array['PEER_NICKNAME']) > 0) {
                $visitor_array['NICKNAME'] = $visitor_array['PEER_NICKNAME'];
            }
        }
        $users_get_recent_array[] = $visitor_array;
    }
    return $users_get_recent_array;
}
Beispiel #4
0
function logon_draw_form($logon_options)
{
    $webtag = get_webtag();
    forum_check_webtag_available($webtag);
    // Make sure logon form argument is valid.
    if (!is_numeric($logon_options)) {
        $logon_options = LOGON_FORM_DEFAULT;
    }
    // Check for previously failed logon.
    if (isset($_GET['logout_success']) && $_GET['logout_success'] == 'true') {
        html_display_success_msg(gettext("You have successfully logged out."), '500', 'center');
    } else {
        if (isset($_GET['logon_failed']) && !($logon_options & LOGON_FORM_SESSION_EXPIRED)) {
            html_display_error_msg(gettext("The username or password you supplied is not valid."), '500', 'center');
        }
    }
    // Get the original requested page url.
    $request_uri = get_request_uri();
    // If the request is for logon.php then we are performing
    // a normal login, otherwise potentially a failed session.
    if (stristr($request_uri, 'logon.php')) {
        echo "  <form accept-charset=\"utf-8\" name=\"logonform\" method=\"post\" action=\"{$request_uri}\" target=\"", html_get_top_frame_name(), "\">\n";
        echo "    ", form_csrf_token_field(), "\n";
    } else {
        echo "  <form accept-charset=\"utf-8\" name=\"logonform\" method=\"post\" action=\"{$request_uri}\" target=\"_self\">\n";
        echo "    ", form_csrf_token_field(), "\n";
    }
    // Check for any post data that we need to include in the form.
    unset($_POST['user_logon'], $_POST['user_password'], $_POST['logon'], $_POST['webtag'], $_POST['register']);
    // Add any post data into the form.
    if (isset($_POST) && is_array($_POST) && sizeof($_POST) > 0) {
        echo form_input_hidden_array($_POST);
    }
    echo "  ", form_input_hidden('webtag', htmlentities_array($webtag)), "\n";
    echo "  <br />\n";
    echo "  <table cellpadding=\"0\" cellspacing=\"0\" width=\"325\">\n";
    echo "    <tr>\n";
    echo "      <td align=\"left\">\n";
    echo "        <table class=\"box\" width=\"100%\">\n";
    echo "          <tr>\n";
    echo "            <td align=\"left\" class=\"posthead\">\n";
    echo "              <table class=\"posthead\" width=\"100%\">\n";
    echo "                <tr>\n";
    echo "                  <td align=\"left\" class=\"subhead\">", gettext("Logon"), "</td>\n";
    echo "                </tr>\n";
    echo "              </table>\n";
    echo "              <table class=\"posthead\" width=\"100%\">\n";
    echo "                <tr>\n";
    echo "                  <td align=\"center\">\n";
    echo "                    <table class=\"posthead\" width=\"95%\">\n";
    echo "                      <tr>\n";
    echo "                        <td align=\"right\" width=\"90\">", gettext("Username"), ":</td>\n";
    echo "                        <td align=\"left\">", form_input_text('user_logon', null, 24, 32, null, 'bhinputlogon'), "</td>\n";
    echo "                      </tr>\n";
    echo "                      <tr>\n";
    echo "                        <td align=\"right\" width=\"90\">", gettext("Password"), ":</td>\n";
    echo "                        <td align=\"left\">", form_input_password('user_password', null, 24, 32, null, 'bhinputlogon'), "</td>\n";
    echo "                      </tr>\n";
    if (!($logon_options & LOGON_FORM_HIDE_TICKBOX) && !($logon_options & LOGON_FORM_SESSION_EXPIRED)) {
        echo "                      <tr>\n";
        echo "                        <td align=\"left\" colspan=\"2\"><hr class=\"bhseparatorlogon\" /></td>\n";
        echo "                      </tr>\n";
        echo "                    </table>\n";
        echo "                    <table class=\"posthead\" width=\"95%\">\n";
        echo "                      <tr>\n";
        echo "                        <td align=\"right\" width=\"90\">", form_checkbox('user_remember', 'Y', null, html_get_cookie('user_logon') && html_get_cookie('user_token')), "</td>\n";
        echo "                        <td align=\"left\"><label for=\"user_remember\">", gettext("Remember me"), "</label></td>\n";
        echo "                      </tr>\n";
        echo "                      <tr>\n";
        echo "                        <td align=\"left\">&nbsp;</td>\n";
        echo "                        <td align=\"left\"><span class=\"bhinputlogon_warning\">", gettext("Not recommended for shared computers"), "</span></td>\n";
        echo "                      </tr>\n";
    }
    echo "                      <tr>\n";
    echo "                        <td align=\"left\">&nbsp;</td>\n";
    echo "                      </tr>\n";
    echo "                    </table>\n";
    echo "                  </td>\n";
    echo "                </tr>\n";
    echo "              </table>\n";
    echo "            </td>\n";
    echo "          </tr>\n";
    echo "        </table>\n";
    echo "      </td>\n";
    echo "    </tr>\n";
    echo "    <tr>\n";
    echo "      <td align=\"left\">&nbsp;</td>\n";
    echo "    </tr>\n";
    echo "    <tr>\n";
    echo "      <td align=\"center\" colspan=\"2\">", form_submit('logon', gettext("Logon")), "</td>\n";
    echo "    </tr>\n";
    echo "  </table>\n";
    echo "</form>\n";
    echo "<br />\n";
    if (!($logon_options & LOGON_FORM_HIDE_LINKS)) {
        echo "<hr class=\"bhlogonseparator\" />\n";
        if (user_guest_enabled()) {
            echo "<form accept-charset=\"utf-8\" name=\"guest\" action=\"logon.php?webtag={$webtag}\" method=\"post\" target=\"", html_get_top_frame_name(), "\">\n";
            echo "  ", form_csrf_token_field(), "\n";
            echo "  <p>", sprintf(gettext("Enter as a %s"), form_submit('guest_logon', gettext("Guest"))), "</p>\n";
            echo "</form>\n";
        }
        if (isset($_GET['final_uri']) && strlen(trim($_GET['final_uri'])) > 0) {
            $available_files_preg = implode("|^", array_map('preg_quote_callback', get_available_files()));
            if (preg_match("/^{$available_files_preg}/u", trim($_GET['final_uri'])) > 0) {
                $final_uri = href_cleanup_query_keys($_GET['final_uri']);
            }
        }
        if (isset($final_uri)) {
            $final_uri = rawurlencode($final_uri);
            $register_link = rawurlencode("register.php?webtag={$webtag}&final_uri={$final_uri}");
            $forgot_pw_link = rawurlencode("forgot_pw.php?webtag={$webtag}&final_uri={$final_uri}");
            echo "<p>", sprintf(gettext("Don't have an account? %s"), "<a href=\"index.php?webtag={$webtag}&amp;final_uri={$register_link}\" target=\"" . html_get_top_frame_name() . "\">" . gettext("Register now") . "</a>") . "</p>\n";
            echo "<hr class=\"bhlogonseparator\" />\n";
            echo "<h2>", gettext("Problems logging on?"), "</h2>\n";
            echo "<p><a href=\"logon.php?webtag={$webtag}&amp;delete_cookie=yes&amp;final_uri={$final_uri}\" target=\"", html_get_top_frame_name(), "\">", gettext("Delete Cookies"), "</a></p>\n";
            echo "<p><a href=\"index.php?webtag={$webtag}&amp;final_uri={$forgot_pw_link}\" target=\"", html_get_top_frame_name(), "\">", gettext("Forgotten your password?"), "</a></p>\n";
        } else {
            echo "<p>", sprintf(gettext("Don't have an account? %s"), "<a href=\"index.php?webtag={$webtag}&amp;final_uri=register.php%3Fwebtag%3D{$webtag}\" target=\"" . html_get_top_frame_name() . "\">" . gettext("Register now") . "</a>"), "</p>\n";
            echo "<hr class=\"bhlogonseparator\" />\n";
            echo "<h2>", gettext("Problems logging on?"), "</h2>\n";
            echo "<p><a href=\"logon.php?webtag={$webtag}&amp;delete_cookie=yes\" target=\"", html_get_top_frame_name(), "\">", gettext("Delete Cookies"), "</a></p>\n";
            echo "<p><a href=\"index.php?webtag={$webtag}&amp;final_uri=forgot_pw.php%3Fwebtag%3D{$webtag}\" target=\"", html_get_top_frame_name(), "\">", gettext("Forgotten your password?"), "</a></p>\n";
        }
        echo "<hr class=\"bhlogonseparator\" />\n";
        echo "<h2>", gettext("Using a mobile device?"), "</h2>\n";
        echo "<p><a href=\"index.php?webtag={$webtag}&amp;view=mobile\" target=\"", html_get_top_frame_name(), "\">", gettext("Mobile version"), "</a></p>\n";
    }
}
Beispiel #5
0
/**
 * @return string
 */
function stats_get_html()
{
    // Get webtag
    $webtag = get_webtag();
    // Validate the webtag
    forum_check_webtag_available($webtag);
    // Number of active users
    $session_count = stats_get_active_session_count();
    // Number of recent posts.
    $recent_post_count = stats_get_recent_post_count();
    // Update the stats records.
    stats_update($session_count, $recent_post_count);
    // User Profile link
    $user_profile_link = '%s&nbsp;<a href="user_profile.php?webtag=%s&amp;uid=%s" target="_blank" class="popup 650x500"><span class="%s" title="%s">%s</span></a>';
    // Newest user Profile link
    $new_user_profile_link = '<a href="user_profile.php?webtag=%s&amp;uid=%s" target="_blank" class="popup 650x500">%s</a>';
    // Search Engine Bot link
    $search_engine_bot_link = '<a href="%s" target="_blank"><span class="user_stats_normal">%s</span></a>';
    $html = "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" class=\"posthead\">\n";
    $html .= "  <tr>\n";
    $html .= "    <td rowspan=\"19\" width=\"35\">&nbsp;</td>\n";
    $html .= "    <td>&nbsp;</td>\n";
    $html .= "    <td rowspan=\"19\" width=\"35\">&nbsp;</td>\n";
    $html .= "  </tr>\n";
    // Output the HTML.
    if (($user_stats = stats_get_active_user_list()) !== false) {
        $user_list_array = array();
        $html .= "  <tr>\n";
        $html .= "    <td>";
        if (forum_get_setting('guest_show_recent', 'Y') && user_guest_enabled()) {
            if ($user_stats['GUESTS'] != 1) {
                $user_list_array[] = sprintf(gettext("<b>%s</b> guests"), format_number($user_stats['GUESTS']));
            } else {
                $user_list_array[] = gettext("<b>1</b> guest");
            }
        }
        if ($user_stats['USER_COUNT'] != 1) {
            $user_list_array[] = sprintf(gettext("<b>%s</b> members"), format_number($user_stats['USER_COUNT']));
        } else {
            $user_list_array[] = gettext("<b>1</b> member");
        }
        if ($user_stats['ANON_USERS'] != 1) {
            $user_list_array[] = sprintf(gettext("<b>%s</b> anonymous members"), format_number($user_stats['ANON_USERS']));
        } else {
            $user_list_array[] = gettext("<b>1</b> anonymous member");
        }
        $user_list = implode(", ", $user_list_array);
        $user_time = format_time_display(ini_get('session.gc_maxlifetime'), false);
        $html .= sprintf(gettext("%s active in the past %s."), $user_list, $user_time);
        $html .= " <a href=\"start.php?webtag={$webtag}&amp;show=visitors\" target=\"" . html_get_frame_name('main') . "\">" . gettext("View More Visitors") . "</a>\n";
        $html .= "    </td>\n";
        $html .= "  </tr>\n";
        if (sizeof($user_stats['USERS']) > 0) {
            $users_array = array();
            foreach ($user_stats['USERS'] as $user) {
                $user_avatar = '';
                if (isset($user['BOT_NAME']) && isset($user['BOT_URL'])) {
                    $user_display = word_filter_add_ob_tags($user['BOT_NAME'], true);
                    $user_display = sprintf($search_engine_bot_link, $user['BOT_URL'], $user_display);
                    $users_array[] = $user_display;
                } else {
                    $user_logon = format_user_name($user['LOGON'], $user['NICKNAME']);
                    $user_display = str_replace(" ", "&nbsp;", word_filter_add_ob_tags($user_logon, true));
                    if ($user['UID'] == $_SESSION['UID']) {
                        if (isset($user['ANON_LOGON']) && $user['ANON_LOGON'] > USER_ANON_DISABLED) {
                            $user_title = gettext("You (Invisible)");
                            $user_class = 'user_stats_curuser';
                        } else {
                            $user_title = gettext("You");
                            $user_class = 'user_stats_curuser';
                        }
                    } else {
                        if (($user['RELATIONSHIP'] & USER_FRIEND) > 0) {
                            $user_title = gettext("Friend");
                            $user_class = 'user_stats_friend';
                        } else {
                            $user_class = 'user_stats_normal';
                            $user_title = '';
                        }
                    }
                    if (isset($user['AVATAR_URL']) && filter_var($user['AVATAR_URL'], FILTER_VALIDATE_URL)) {
                        $user_avatar = html_style_image('profile_image profile_image_small', htmlentities_array($user_title), null, array('background-image' => sprintf("url('%s')", $user['AVATAR_URL'])));
                    } else {
                        if (isset($user['AVATAR_AID']) && is_numeric($user['AVATAR_AID'])) {
                            $attachment = attachments_get_by_aid($user['AVATAR_AID']);
                            if (($user_avatar_picture = attachments_make_link($attachment, false, false, false, false)) !== false) {
                                $user_avatar = html_style_image('profile_image profile_image_small', htmlentities_array($user_title), null, array('background-image' => sprintf("url('%s&amp;profile_picture')", $user_avatar_picture)));
                            }
                        }
                    }
                    $users_array[] = sprintf($user_profile_link, $user_avatar, $webtag, $user['UID'], $user_class, $user_title, $user_display);
                }
            }
            $html .= "  <tr>";
            $html .= "    <td class=\"activeusers\">\n";
            $html .= "      " . implode(", ", $users_array) . "\n";
            $html .= "    </td>\n";
            $html .= "  </tr>\n";
        }
        $html .= "  <tr>\n";
        $html .= "    <td>&nbsp;</td>\n";
        $html .= "  </tr>\n";
    }
    if (($users_birthdays_array = user_get_todays_birthdays()) !== false) {
        $html .= "  <tr>\n";
        $html .= "    <td>";
        if (count($users_birthdays_array) == 1) {
            $html .= gettext("<b>1</b> member is celebrating their birthday today:");
        } else {
            $html .= sprintf(gettext("<b>%d</b> members are celebrating their birthdays today:"), format_number(count($users_birthdays_array)));
        }
        $html .= "</td>\n";
        $html .= "  </tr>\n";
        $users_array = array();
        foreach ($users_birthdays_array as $user) {
            $user_avatar = '';
            $user_logon = format_user_name($user['LOGON'], $user['NICKNAME']);
            $user_display = str_replace(" ", "&nbsp;", word_filter_add_ob_tags($user_logon, true));
            if ($user['UID'] == $_SESSION['UID']) {
                $user_title = gettext("You");
                $user_class = 'user_stats_curuser';
            } else {
                if (($user['RELATIONSHIP'] & USER_FRIEND) > 0) {
                    $user_title = gettext("Friend");
                    $user_class = 'user_stats_friend';
                } else {
                    $user_class = 'user_stats_normal';
                    $user_title = '';
                }
            }
            if (isset($user['AVATAR_URL']) && filter_var($user['AVATAR_URL'], FILTER_VALIDATE_URL)) {
                $user_avatar = html_style_image('profile_image profile_image_small', htmlentities_array($user_title), null, array('background-image' => sprintf("url('%s')", $user['AVATAR_URL'])));
            } else {
                if (isset($user['AVATAR_AID']) && is_numeric($user['AVATAR_AID'])) {
                    $attachment = attachments_get_by_aid($user['AVATAR_AID']);
                    if (($user_avatar_picture = attachments_make_link($attachment, false, false, false, false)) !== false) {
                        $user_avatar = html_style_image('profile_image profile_image_small', htmlentities_array($user_title), null, array('background-image' => sprintf("url('%s&amp;profile_picture')", $user_avatar_picture)));
                    }
                }
            }
            $users_array[] = sprintf($user_profile_link, $user_avatar, $webtag, $user['UID'], $user_class, $user_title, $user_display);
        }
        $html .= "  <tr>\n";
        $html .= "    <td class=\"birthdayusers\">\n";
        $html .= "      " . implode(", ", $users_array) . "\n";
        $html .= "    </td>\n";
        $html .= "  </tr>\n";
        $html .= "  <tr>\n";
        $html .= "    <td>&nbsp;</td>\n";
        $html .= "  </tr>\n";
    }
    $thread_count = stats_get_thread_count();
    $post_count = stats_get_post_count();
    $html .= "  <tr>\n";
    $html .= "    <td>";
    if ($thread_count != 1) {
        $num_threads_display = sprintf(gettext("<b>%s</b> threads"), format_number($thread_count));
    } else {
        $num_threads_display = gettext("<b>1</b> thread");
    }
    if ($post_count != 1) {
        $num_posts_display = sprintf(gettext("<b>%s</b> posts"), format_number($post_count));
    } else {
        $num_posts_display = gettext("<b>1</b> post");
    }
    $html .= sprintf(gettext("Our members have made a total of %s and %s."), $num_threads_display, $num_posts_display) . '<br />';
    $html .= "  </tr>\n";
    $html .= "  <tr>\n";
    $html .= "    <td>&nbsp;</td>\n";
    $html .= "  </tr>\n";
    if (($longest_thread = stats_get_longest_thread()) !== false) {
        $html .= "  <tr>\n";
        $html .= "    <td>";
        $longest_thread_title = word_filter_add_ob_tags($longest_thread['TITLE'], true);
        $longest_thread_link = sprintf("<a href=\"index.php?webtag={$webtag}&amp;msg=%d.1\">%s</a>", $longest_thread['TID'], $longest_thread_title);
        $longest_thread_post_count = $longest_thread['LENGTH'] != 1 ? sprintf(gettext("<b>%s</b> posts"), format_number($longest_thread['LENGTH'])) : gettext("<b>1</b> post");
        $html .= sprintf(gettext("Longest thread is <b>%s</b> with %s."), $longest_thread_link, $longest_thread_post_count);
        $html .= "    </td>\n";
        $html .= "  </tr>\n";
    }
    if (($most_read_thread = stats_get_most_read_thread()) !== false) {
        $html .= "  <tr>\n";
        $html .= "    <td>";
        $most_read_thread_title = word_filter_add_ob_tags($most_read_thread['TITLE'], true);
        $most_read_thread_link = sprintf("<a href=\"index.php?webtag={$webtag}&amp;msg=%d.1\">%s</a>", $most_read_thread['TID'], $most_read_thread_title);
        $most_read_thread_view_count = $most_read_thread['VIEWCOUNT'] != 1 ? sprintf(gettext("<b>%s</b> views"), format_number($most_read_thread['VIEWCOUNT'])) : gettext("<b>1</b> view");
        $html .= sprintf(gettext("Most read thread is <b>%s</b> with %s."), $most_read_thread_link, $most_read_thread_view_count);
        $html .= "    </td>\n";
        $html .= "  </tr>\n";
    }
    $html .= "  <tr>\n";
    $html .= "    <td>&nbsp;</td>\n";
    $html .= "  </tr>\n";
    $html .= "  <tr>\n";
    $html .= "    <td>";
    if ($recent_post_count != 1) {
        $html .= sprintf(gettext("There have been <b>%s</b> posts made in the last 60 minutes."), format_number($recent_post_count));
    } else {
        $html .= gettext("There has been <b>1</b> post made in the last 60 minutes.");
    }
    $html .= "    </td>\n";
    $html .= "  </tr>\n";
    if (($most_posts = stats_get_most_posts()) !== false) {
        if ($most_posts['MOST_POSTS_COUNT'] > 0 && $most_posts['MOST_POSTS_DATE'] > 0) {
            $html .= "  <tr>\n";
            $html .= "    <td>";
            $html .= sprintf(gettext("Most posts ever made in a single 60 minute period is <b>%s</b> on %s."), format_number($most_posts['MOST_POSTS_COUNT']), format_date_time($most_posts['MOST_POSTS_DATE']));
            $html .= "    </td>\n";
            $html .= "  </tr>\n";
        }
    }
    if (($user_count = user_count()) !== false) {
        $html .= "  <tr>\n";
        $html .= "    <td>&nbsp;</td>\n";
        $html .= "  </tr>\n";
        $html .= "  <tr>\n";
        $html .= "    <td>";
        if ($user_count != 1) {
            if (($newest_member = stats_get_newest_user()) !== false) {
                $user_newest_display = word_filter_add_ob_tags(format_user_name($newest_member['LOGON'], $newest_member['NICKNAME']), true);
                $user_newest_profile_link = sprintf($new_user_profile_link, $webtag, $newest_member['UID'], $user_newest_display);
                $html .= sprintf(gettext("We have <b>%s</b> registered members and the newest member is <b>%s</b>."), format_number($user_count), $user_newest_profile_link);
            } else {
                $html .= sprintf(gettext("We have %s registered members."), $user_count);
            }
        } else {
            $html .= gettext("We have one registered member.");
        }
        $html .= "    </td>\n";
        $html .= "  </tr>\n";
    }
    if (($most_users = stats_get_most_users()) !== false) {
        if ($most_users['MOST_USERS_COUNT'] > 0 && $most_users['MOST_USERS_DATE'] > 0) {
            $html .= "  <tr>\n";
            $html .= "    <td>";
            $most_users_date = format_date_time($most_users['MOST_USERS_DATE']);
            $html .= sprintf(gettext("Most users ever online was <b>%s</b> on %s."), format_number($most_users['MOST_USERS_COUNT']), $most_users_date);
            $html .= "    </td>\n";
            $html .= "  </tr>\n";
        }
    }
    $html .= "  <tr>\n";
    $html .= "    <td>&nbsp;</td>\n";
    $html .= "  </tr>\n";
    $html .= "</table>\n";
    // Return the output buffer contents.
    return $html;
}