function ui_login_status_bar($mode = 'xmlhttp') { if (login_checklogin()) { if ($_SESSION['cache']['lastupdate'] < time() - 20) { cache_update_all(); } $return .= '<ul>' . "\n"; /* Messages */ $return .= '<li class="photocomments">' . "\n"; if ($_SESSION['cache']['unread_photo_comments'] >= 1) { $return .= '<strong>' . $_SESSION['cache']['unread_photo_comments'] . ' <a href="/traffa/photos.php">kommentarer</a></strong><br />'; } else { $return .= $_SESSION['cache']['unread_photo_comments'] . ' <a href="/traffa/photos.php">kommentarer</a><br />'; } if ($_SESSION['notices']['unread_messages'] >= 1) { $return .= '<strong>' . $_SESSION['notices']['unread_messages'] . ' <a href="/traffa/messages.php">meddelanden</a></strong>'; } else { $return .= $_SESSION['notices']['unread_messages'] . ' <a href="/traffa/messages.php">meddelanden</a>'; } $return .= '</li>' . "\n\n"; /* Guestbook */ $msg_text = 'Gästbok'; $msg_color = 'grey'; if ($_SESSION['notices']['unread_gb_entries'] > 1) { $msg_text = '<strong>' . $_SESSION['notices']['unread_gb_entries'] . ' nya</strong>'; $msg_color = 'color'; } elseif ($_SESSION['notices']['unread_gb_entries'] == 1) { $msg_text = '<strong>Nytt inlägg</strong>'; $msg_color = 'color'; } $return .= '<li>' . "\n"; $return .= '<a href="/traffa/guestbook.php">' . "\n"; $return .= '<div class="icon">' . "\n"; $return .= '<img src="http://images.hamsterpaj.net/login_bar/guestbook_' . $msg_color . '.png" />' . "\n"; $return .= '</div>' . "\n"; $return .= $msg_text . "\n"; $return .= '</a>' . "\n"; $return .= '</li>' . "\n\n"; /* Forum notices */ $msg_text = 'Notiser'; $msg_color = 'grey'; if ($_SESSION['forum']['new_notices'] > 1) { $msg_text = '<strong>' . $_SESSION['forum']['new_notices'] . ' notiser</strong>'; $msg_color = 'color'; } elseif ($_SESSION['forum']['new_notices'] == 1) { $msg_text = '<strong>Ny notis</strong>'; $msg_color = 'color'; } $return .= '<li>' . "\n"; $return .= '<a href="/diskussionsforum/notiser.php">' . "\n"; $return .= '<div class="icon">' . "\n"; $return .= '<img src="http://images.hamsterpaj.net/login_bar/forum_' . $msg_color . '.png" />' . "\n"; $return .= '</div>' . "\n"; $return .= $msg_text . "\n"; $return .= '</a>' . "\n"; $return .= '</li>' . "\n\n"; /* Group notices */ $msg_text = 'Gruppinlägg'; $msg_color = 'grey'; if ($_SESSION['cache']['unread_group_notices'] > 1) { $msg_text = '<strong>' . $_SESSION['cache']['unread_group_notices'] . ' nya</strong>'; $msg_color = 'color'; } elseif ($_SESSION['cache']['unread_group_notices'] == 1) { $msg_text = '<strong>Nytt inlägg</strong>'; $msg_color = 'color'; } $return .= '<li>' . "\n"; $return .= '<a href="/traffa/groupnotices.php">' . "\n"; $return .= '<div class="icon">' . "\n"; $return .= '<img src="http://images.hamsterpaj.net/login_bar/buddies_' . $msg_color . '.png" />' . "\n"; $return .= '</div>' . "\n"; $return .= $msg_text . "\n"; $return .= '</a>' . "\n"; $return .= '</li>' . "\n\n"; $return .= '</ul>' . "\n"; $return .= '<div id="user_info">' . "\n"; $return .= '<a href="/traffa/profile.php?user_id=' . $_SESSION['login']['id'] . '" class="username">' . $_SESSION['login']['username'] . '</a><br />' . "\n"; $return .= '<span class="online_time">Online '; $online_secs = time() - $_SESSION['login']['lastlogon']; $online_days = floor($online_secs / 86400); $online_hrs = floor(($online_secs - $online_days * 86400) / 3600); $online_mins = floor($online_secs % 3600 / 60); if ($online_days == 1) { $return .= '1 d, '; } elseif ($online_days > 1) { $return .= $online_days . ' d '; } if ($online_hrs > 0) { $return .= $online_hrs . ' tim '; } if ($online_mins > 0) { $return .= $online_mins . ' min'; } elseif ($online_hrs == 0 && $online_days == 0 && $online_mins == 0) { $return .= '0 min'; } $return .= '</span>' . "\n"; $return .= '<a href="/installningar/generalsettings.php" class="settings">' . "\n"; $return .= 'Inställningar</a>' . "\n"; $return .= '<a href="/logout.php">' . "\n"; $return .= 'Logga ut</a>' . "\n"; $return .= '</div>' . "\n"; } else { $return = '<h3>Du har blivit utloggad</h3>' . "\n"; } return $return; }
function ui_notices_fetch() { if (login_checklogin()) { $notices = array(); if ($_SESSION['cache']['lastupdate'] < time() - 20) { cache_update_all(); } $notices['guestbook'] = $_SESSION['notices']['unread_gb_entries']; $notices['discussion_forum'] = array('new_notices' => $_SESSION['forum']['new_notices'], 'subscriptions' => array()); foreach ($_SESSION['forum']['subscriptions'] as $subscription) { if ($subscription['unread_posts'] > 0) { $notices['discussion_forum']['subscriptions'][] = $subscription; } } $notices['groups'] = array('unread_notices' => $_SESSION['cache']['unread_group_notices'], 'groups' => $_SESSION['cache']['group_notices']); $notices['photo_comments'] = $_SESSION['cache']['unread_photo_comments']; return $notices; } else { throw new Exception('Du har blivit utloggad. Logga in igen =D'); } }
<?php require '../include/core/common.php'; if (!login_checklogin()) { // Standard-code for "you're logged out". die('{ "logged_on": false }'); } if ($_SESSION['cache']['lastupdate'] < time() - 20) { cache_update_all(); } $output = array(); $output['new_messages'] = $_SESSION['notices']['unread_messages']; $output['new_guestbook_posts'] = $_SESSION['notices']['unread_gb_entries']; $output['forum_notices'] = $_SESSION['forum']['new_notices']; $output['group_notices'] = $_SESSION['cache']['unread_group_notices']; echo '{ "logged_on": true, "new_messages": ' . $output['new_messages'] . ', "new_guestbook_posts": ' . $output['new_guestbook_posts'] . ', "forum_notices": ' . $output['forum_notices'] . ', "group_notices": ' . $output['group_notices'] . ' }';