| 1 | <?php |
|---|
| 2 | /*********************************************************************** |
|---|
| 3 | |
|---|
| 4 | PunBB extension |
|---|
| 5 | Portal |
|---|
| 6 | Daris <daris91@gmail.com> |
|---|
| 7 | |
|---|
| 8 | ************************************************************************/ |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | // Make sure no one attempts to run this script "directly" |
|---|
| 12 | if (!defined('FORUM')) |
|---|
| 13 | exit; |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | // If user is logged display some informations about it |
|---|
| 17 | if (!$forum_user['is_guest']) |
|---|
| 18 | { |
|---|
| 19 | require FORUM_ROOT.'lang/'.$forum_user['language'].'/index.php'; |
|---|
| 20 | |
|---|
| 21 | $stats_list = $stats_online = array(); |
|---|
| 22 | |
|---|
| 23 | // Collect some statistics from the database |
|---|
| 24 | $query = array( |
|---|
| 25 | 'SELECT' => 'COUNT(u.id)-1', |
|---|
| 26 | 'FROM' => 'users AS u' |
|---|
| 27 | ); |
|---|
| 28 | |
|---|
| 29 | ($hook = get_hook('xn_portal_by_daris_wio_qr_get_user_count')) ? eval($hook) : null; |
|---|
| 30 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 31 | $stats['total_users'] = $forum_db->result($result); |
|---|
| 32 | |
|---|
| 33 | $query = array( |
|---|
| 34 | 'SELECT' => 'SUM(f.num_topics), SUM(f.num_posts)', |
|---|
| 35 | 'FROM' => 'forums AS f' |
|---|
| 36 | ); |
|---|
| 37 | |
|---|
| 38 | ($hook = get_hook('xn_portal_by_daris_wio_qr_get_post_stats')) ? eval($hook) : null; |
|---|
| 39 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 40 | list($stats['total_topics'], $stats['total_posts']) = $forum_db->fetch_row($result); |
|---|
| 41 | |
|---|
| 42 | $stats_list[] = '<li>'.$lang_portal['Users'].': <strong>'. $stats['total_users'].'</strong></li>'; |
|---|
| 43 | $stats_list[] = '<li>'.$lang_portal['Topics'].': <strong>'.intval($stats['total_topics']).'</strong></li>'; |
|---|
| 44 | $stats_list[] = '<li>'.$lang_portal['Posts'].': <strong>'.intval($stats['total_posts']).'</strong></li>'; |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | ($hook = get_hook('xn_portal_by_daris_wio_pre_users_online')) ? eval($hook) : null; |
|---|
| 48 | |
|---|
| 49 | if ($forum_config['o_users_online'] == '1') |
|---|
| 50 | { |
|---|
| 51 | // Fetch users online info and generate strings for output |
|---|
| 52 | $query = array( |
|---|
| 53 | 'SELECT' => 'o.user_id, o.ident', |
|---|
| 54 | 'FROM' => 'online AS o', |
|---|
| 55 | 'WHERE' => 'o.idle=0', |
|---|
| 56 | 'ORDER BY' => 'o.ident' |
|---|
| 57 | ); |
|---|
| 58 | ($hook = get_hook('xn_portal_by_daris_wio_qr_get_users_online')) ? eval($hook) : null; |
|---|
| 59 | $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); |
|---|
| 60 | $num_guests = 0; |
|---|
| 61 | $users = array(); |
|---|
| 62 | |
|---|
| 63 | while ($forum_user_online = $forum_db->fetch_assoc($result)) |
|---|
| 64 | { |
|---|
| 65 | ($hook = get_hook('xn_portal_by_daris_wio_add_online_user_loop')) ? eval($hook) : null; |
|---|
| 66 | |
|---|
| 67 | if ($forum_user_online['user_id'] > 1) |
|---|
| 68 | $users[] = '<a href="'.forum_link($forum_url['user'], $forum_user_online['user_id']).'">'.forum_htmlencode($forum_user_online['ident']).'</a>'; |
|---|
| 69 | else |
|---|
| 70 | ++$num_guests; |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | // If there are registered users logged in, list them |
|---|
| 74 | if (count($users) > 0) |
|---|
| 75 | $users_online = '<p><strong>'.$lang_portal['Online'].'</strong> '.implode(', ', $users).'</p>'; |
|---|
| 76 | |
|---|
| 77 | $stats_online[] = '<li>'.$lang_portal['Users online'].': <strong>'.count($users).'</strong></li>'; |
|---|
| 78 | $stats_online[] = '<li>'.$lang_portal['Guests online'].': <strong>'.$num_guests.'</strong></li>'; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | $avatar = generate_avatar_markup($forum_user['id']); |
|---|
| 82 | |
|---|
| 83 | ?> |
|---|
| 84 | <?php echo $lang_portal['Welcome'] ?>: <strong><?php echo forum_htmlencode($forum_user['username']) ?></strong> |
|---|
| 85 | <?php if ($avatar != '') : ?> |
|---|
| 86 | <p style="text-align: center"><?php echo $avatar ?></p> |
|---|
| 87 | <?php else : ?> |
|---|
| 88 | <br /> |
|---|
| 89 | <?php endif; ?> |
|---|
| 90 | <ul class="stats-online"> |
|---|
| 91 | <?php echo implode("\n\t\t\t", $stats_online) ?> |
|---|
| 92 | </ul> |
|---|
| 93 | |
|---|
| 94 | <?php if (isset($users_online)) : echo $users_online; endif; ?> |
|---|
| 95 | |
|---|
| 96 | <ul class="stats-num"> |
|---|
| 97 | <?php echo implode("\n\t\t\t", $stats_list) ?> |
|---|
| 98 | </ul> |
|---|
| 99 | |
|---|
| 100 | <?php |
|---|
| 101 | |
|---|
| 102 | } |
|---|
| 103 | // Else user is not logged, display login form |
|---|
| 104 | else |
|---|
| 105 | { |
|---|
| 106 | $cur_panel['title'] = $lang_common['Login']; |
|---|
| 107 | |
|---|
| 108 | require_once FORUM_ROOT.'lang/'.$forum_user['language'].'/login.php'; |
|---|
| 109 | $form_action = forum_link($forum_url['login']); |
|---|
| 110 | ?> |
|---|
| 111 | <?php echo $lang_portal['Welcome Guest'] ?><br /> |
|---|
| 112 | <?php echo $lang_portal['Please login'] ?><br /> |
|---|
| 113 | <br /> |
|---|
| 114 | <form method="post" action="<?php echo $form_action ?>"> |
|---|
| 115 | <div class="hidden"> |
|---|
| 116 | <input type="hidden" name="form_sent" value="1" /> |
|---|
| 117 | <input type="hidden" name="redirect_url" value="<?php echo get_current_url() ?>" /> |
|---|
| 118 | <input type="hidden" name="csrf_token" value="<?php echo generate_form_token($form_action) ?>" /> |
|---|
| 119 | </div> |
|---|
| 120 | <div class="panel-input"> |
|---|
| 121 | <?php echo $lang_login['Username'] ?><br /> |
|---|
| 122 | <input type="text" name="req_username" size="13" /> |
|---|
| 123 | </div> |
|---|
| 124 | <div class="panel-input"> |
|---|
| 125 | <?php echo $lang_login['Password'] ?><br /> |
|---|
| 126 | <input type="password" name="req_password" size="13" /> |
|---|
| 127 | </div> |
|---|
| 128 | <div> |
|---|
| 129 | <label for="fld-remember-me"><span class="fld-label"><?php echo $lang_login['Remember me'] ?></span> <input type="checkbox" id="fld-remember-me" name="save_pass" value="1" /></label> |
|---|
| 130 | </div> |
|---|
| 131 | <div> |
|---|
| 132 | <span class="submit"><input type="submit" name="login" value="<?php echo $lang_common['Login'] ?>" /></span> |
|---|
| 133 | </div> |
|---|
| 134 | </form> |
|---|
| 135 | <a href="<?php echo forum_link($forum_url['register']) ?>"><?php echo $lang_portal['Not registered yet'] ?></a><br /> |
|---|
| 136 | <a href="<?php echo forum_link($forum_url['request_password']) ?>"><?php echo $lang_portal['Forgotten your password'] ?></a> |
|---|
| 137 | <?php |
|---|
| 138 | |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | // this variable is also used for display statistics on forums page |
|---|
| 142 | unset($stats_list); |
|---|