function get_user_nav_menu_items() { global $db, $luna_config, $luna_user; $items = array(); if ($luna_user['is_guest']) { $items['guest'] = array('register' => array('url' => 'register.php', 'title' => __('Register', 'luna')), 'login' => array('url' => '#', 'title' => __('Login', 'luna'))); } else { if ($luna_user['is_admmod']) { $items['backstage'] = array('url' => 'backstage/', 'title' => __('Backstage', 'luna')); } // Check for new notifications $result = $db->query('SELECT COUNT(id) FROM ' . $db->prefix . 'notifications WHERE viewed = 0 AND user_id = ' . $luna_user['id']) or error('Unable to load notifications', __FILE__, __LINE__, $db->error()); $num_notifications = intval($db->result($result)); $items['notifications'] = array('url' => 'notifications.php', 'title' => $num_notifications > 0 ? __('Notifications', 'luna') : __('No new notifications', 'luna'), 'num' => $num_notifications, 'flyout' => 1 == $luna_config['o_notification_flyout']); if ($luna_config['o_enable_inbox'] == '1' && $luna_user['g_inbox'] == '1' && $luna_user['use_inbox'] == '1') { // Check for new messages $result = $db->query('SELECT COUNT(id) FROM ' . $db->prefix . 'messages WHERE showed=0 AND show_message=1 AND owner=' . $luna_user['id']) or error('Unable to check the availibility of new messages', __FILE__, __LINE__, $db->error()); $num_new_inbox = intval($db->result($result)); $items['inbox'] = array('url' => 'inbox.php', 'title' => 'Inbox', 'num' => $num_new_inbox); } $items['user'] = array('profile' => array('url' => 'profile.php?id=' . $luna_user['id'], 'title' => '<span class="fa fa-fw fa-user"></span> ' . __('Profile', 'luna')), 'settings' => array('url' => 'settings.php', 'title' => '<span class="fa fa-fw fa-cogs"></span> ' . __('Settings', 'luna')), 'help' => array('url' => 'help.php', 'title' => '<span class="fa fa-fw fa-info-circle"></span> ' . __('Help', 'luna')), 'logout' => array('url' => 'login.php?action=out&id=' . $luna_user['id'] . '&csrf_token=' . luna_csrf_token(), 'title' => '<span class="fa fa-fw fa-sign-out"></span> ' . __('Logout', 'luna'))); } return $items; }
function draw_mark_read($class, $page) { global $luna_user, $id; if (!empty($class)) { $classes = ' class="' . $class . '"'; } if ($page == 'index') { $url = 'misc.php?action=markread&csrf_token=' . luna_csrf_token(); } elseif ($page == 'forumview') { $url = 'misc.php?action=markforumread&fid=' . $id; } if (!$luna_user['is_guest']) { echo '<a' . $classes . ' href="' . $url . '">' . __('Mark as read', 'luna') . '</a>'; } }
function load_admin_nav($section, $page) { global $luna_user, $luna_config, $is_admin; // What page are we on? if ($page == 'index') { $page_title = '<span class="fa fa-fw fa-tachometer"></span> ' . __('Backstage', 'luna'); } elseif ($page == 'stats') { $page_title = '<span class="fa fa-fw fa-info-circle"></span> ' . __('System info', 'luna'); } elseif ($page == 'update') { $page_title = '<span class="fa fa-fw fa-cloud-upload"></span> ' . __('Luna software update', 'luna'); } elseif ($page == 'about') { $page_title = '<span class="fa fa-fw fa-moon-o"></span> ' . __('About Luna', 'luna'); } elseif ($page == 'board') { $page_title = '<span class="fa fa-fw fa-sort-amount-desc"></span> ' . __('Board', 'luna'); } elseif ($page == 'moderate') { $page_title = '<span class="fa fa-fw fa-tasks"></span> ' . __('Moderate', 'luna'); } elseif ($page == 'censoring') { $page_title = '<span class="fa fa-fw fa-eye-slash"></span> ' . __('Censoring', 'luna'); } elseif ($page == 'reports') { $page_title = '<span class="fa fa-fw fa-exclamation-triangle"></span> ' . __('Reports', 'luna'); } elseif ($page == 'users') { $page_title = '<span class="fa fa-fw fa-search"></span> ' . __('Search', 'luna'); } elseif ($page == 'tools') { $page_title = '<span class="fa fa-fw fa-wrench"></span> ' . __('Tools', 'luna'); } elseif ($page == 'ranks') { $page_title = '<span class="fa fa-fw fa-chevron-up"></span> ' . __('Ranks', 'luna'); } elseif ($page == 'groups') { $page_title = '<span class="fa fa-fw fa-group"></span> ' . __('Groups', 'luna'); } elseif ($page == 'permissions') { $page_title = '<span class="fa fa-fw fa-check-circle"></span> ' . __('Permissions', 'luna'); } elseif ($page == 'bans') { $page_title = '<span class="fa fa-fw fa-ban"></span> ' . __('Bans', 'luna'); } elseif ($page == 'settings') { $page_title = '<span class="fa fa-fw fa-cogs"></span> ' . __('Settings', 'luna'); } elseif ($page == 'features') { $page_title = '<span class="fa fa-fw fa-sliders"></span> ' . __('Features', 'luna'); } elseif ($page == 'appearance') { $page_title = '<span class="fa fa-fw fa-eye"></span> ' . __('Appearance', 'luna'); } elseif ($page == 'registration') { $page_title = '<span class="fa fa-fw fa-plus-circle"></span> ' . __('Registration', 'luna'); } elseif ($page == 'email') { $page_title = '<span class="fa fa-fw fa-envelope"></span> ' . __('Email', 'luna'); } elseif ($page == 'menu') { $page_title = '<span class="fa fa-fw fa-bars"></span> ' . __('Menu', 'luna'); } elseif ($page == 'theme') { $page_title = '<span class="fa fa-fw fa-paint-brush"></span> ' . __('Theme', 'luna'); } elseif ($page == 'maintenance') { $page_title = '<span class="fa fa-fw fa-coffee"></span> ' . __('Maintenance', 'luna'); } elseif ($page == 'prune') { $page_title = '<span class="fa fa-fw fa-recycle"></span> ' . __('Prune', 'luna'); } elseif ($page == 'database') { $page_title = '<span class="fa fa-fw fa-database"></span> ' . __('Database management', 'luna'); } elseif ($page == 'info') { $page_title = '<span class="fa fa-fw fa-info-circle"></span> ' . __('Info', 'luna'); } else { $page_title = $page; } ?> <nav class="navbar navbar-fixed-top navbar-default" role="navigation"> <div class="container navbar-container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="../index.php"><span class="fa fa-fw fa-arrow-left hidden-xs"></span><span class="visible-xs-inline"><?php echo $page_title; ?> </span></a> </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li class="<?php if ($section == 'backstage') { echo 'active'; } ?> "><a href="index.php"><span class="fa fa-fw fa-dashboard"></span> <?php _e('Backstage', 'luna'); ?> </a></li> <?php if ($is_admin) { ?> <li class="<?php if ($section == 'content') { echo 'active'; } ?> "><a href="board.php"><span class="fa fa-fw fa-file"></span> <?php _e('Content', 'luna'); ?> </a></li> <?php } else { ?> <li class="<?php if ($section == 'content') { echo 'active'; } ?> "><a href="reports.php"><span class="fa fa-fw fa-file"></span> <?php _e('Content', 'luna'); ?> </a></li> <?php } ?> <li class="<?php if ($section == 'users') { echo 'active'; } ?> "><a href="users.php"><span class="fa fa-fw fa-users"></span> <?php _e('Users', 'luna'); ?> </a></li> <?php if ($is_admin) { ?> <li class="<?php if ($section == 'settings') { echo 'active'; } ?> "><a href="settings.php"><span class="fa fa-fw fa-cog"></span> <?php _e('Settings', 'luna'); ?> </a></li><?php } ?> <?php if ($is_admin) { ?> <li class="<?php if ($section == 'maintenance') { echo 'active'; } ?> "><a href="maintenance.php"><span class="fa fa-fw fa-coffee"></span> <?php _e('Maintenance', 'luna'); ?> </a></li> <?php } // See if there are any plugins $plugins = forum_list_plugins($is_admin); // Did we find any plugins? if (!empty($plugins)) { ?> <li class="dropdown<?php if ($section == ' extensions') { echo 'active'; } ?> "> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <span class="fa fa-fw fa-cogs"></span> <?php _e('Extensions', 'luna'); ?> <span class="fa fa-fw fa-angle-down"> </a> <ul class="dropdown-menu"> <?php foreach ($plugins as $plugin_name => $plugin) { echo "\t\t\t\t\t" . '<li><a href="loader.php?plugin=' . $plugin_name . '">' . str_replace('_', ' ', $plugin) . '</a></li>' . "\n"; } ?> </ul> </li> <?php } ?> </ul> <?php $logout_url = '../login.php?action=out&id=' . $luna_user['id'] . '&csrf_token=' . luna_csrf_token(); ?> <ul class="nav navbar-nav navbar-right"> <li class="dropdown usermenu"> <a href="../profile.php?id=<?php echo $luna_user['id']; ?> " class="dropdown-toggle dropdown-user" data-toggle="dropdown"> <?php echo draw_user_avatar($luna_user['id'], true, 'avatar'); ?> <span class="hidden-lg hidden-md hidden-sm"> <?php echo luna_htmlspecialchars($luna_user['username']); ?> </span> </a> <ul class="dropdown-menu"> <li><a href="../profile.php?id=<?php echo $luna_user['id']; ?> "><?php _e('Profile', 'luna'); ?> </a></li> <li><a href="../settings.php?id=<?php echo '' . $luna_user['id']; ?> "><?php _e('Settings', 'luna'); ?> </a></li> <li class="divider"></li> <li><a href="../help.php"><?php _e('Help', 'luna'); ?> </a></li> <li><a href="http://getluna.org"><?php _e('Support', 'luna'); ?> </a></li> <li class="divider"></li> <li><a href="<?php echo $logout_url; ?> "><?php _e('Logout', 'luna'); ?> </a></li> </ul> </li> <li id="navlogout" class="hide-if-js"> <a href="<?php echo $logout_url; ?> " title="<?php echo $item['logout']['title']; ?> "> <span class="fa fa-fw fa-sign-out"></span> </a> </li> </ul> </div> </div> </nav> <div class="jumbotron jumboheader"> <div class="container"> <div class="row"> <h2 class="hidden-xs"> <?php echo $page_title; if ($luna_config['o_update_ring'] > 1) { echo '<span class="pull-right" style="font-size: 70%;">Core ' . Version::LUNA_CORE_VERSION . '</span>'; } ?> </h2> <?php if ($section == 'backstage') { ?> <ul class="nav nav-tabs" role="tablist"> <li<?php if ($page == 'index') { echo ' class="active"'; } ?> ><a href="index.php"><span class="fa fa-fw fa-tachometer"></span><span class="hidden-xs"> <?php _e('Backstage', 'luna'); ?> </span></a></li> <li<?php if ($page == 'stats') { echo ' class="active"'; } ?> ><a href="system.php"><span class="fa fa-fw fa-info-circle"></span><span class="hidden-xs"> <?php _e('System info', 'luna'); ?> </span></a></li> <li<?php if ($page == 'update') { echo ' class="active"'; } ?> ><a href="update.php"><span class="fa fa-fw fa-cloud-upload"></span><span class="hidden-xs"> <?php _e('Update', 'luna'); ?> </span></a></li> <li class="pull-right<?php if ($page == 'about') { echo ' active'; } ?> "><a href="about.php"><span class="fa fa-fw fa-moon-o"></span><span class="hidden-xs"> <?php _e('About', 'luna'); ?> </span></a></li> </ul> <?php } if ($section == 'content') { ?> <ul class="nav nav-tabs" role="tablist"> <li<?php if ($page == 'board') { echo ' class="active"'; } ?> ><a href="board.php"><span class="fa fa-fw fa-sort-amount-desc"></span><span class="hidden-xs"> <?php _e('Board', 'luna'); ?> </span></a></li> <li<?php if ($page == 'censoring') { echo ' class="active"'; } ?> ><a href="censoring.php"><span class="fa fa-fw fa-eye-slash"></span><span class="hidden-xs"> <?php _e('Censoring', 'luna'); ?> </span></a></li> <li<?php if ($page == 'reports') { echo ' class="active"'; } ?> ><a href="reports.php"><span class="fa fa-fw fa-exclamation-triangle"></span><span class="hidden-xs"> <?php _e('Reports', 'luna'); ?> </span></a></li> </ul> <?php } if ($section == 'users') { ?> <ul class="nav nav-tabs" role="tablist"> <li<?php if ($page == 'users') { echo ' class="active"'; } ?> ><a href="users.php"><span class="fa fa-fw fa-search"></span><span class="hidden-xs"> <?php _e('Search', 'luna'); ?> </span></a></li> <li<?php if ($page == 'tools') { echo ' class="active"'; } ?> ><a href="tools.php"><span class="fa fa-fw fa-wrench"></span><span class="hidden-xs"> <?php _e('Tools', 'luna'); ?> </span></a></li> <li<?php if ($page == 'ranks') { echo ' class="active"'; } ?> ><a href="ranks.php"><span class="fa fa-fw fa-chevron-up"></span><span class="hidden-xs"> <?php _e('Ranks', 'luna'); ?> </span></a></li> <li<?php if ($page == 'groups') { echo ' class="active"'; } ?> ><a href="groups.php"><span class="fa fa-fw fa-group"></span><span class="hidden-xs"> <?php _e('Groups', 'luna'); ?> </span></a></li> <li<?php if ($page == 'permissions') { echo ' class="active"'; } ?> ><a href="permissions.php"><span class="fa fa-fw fa-check-circle"></span><span class="hidden-xs"> <?php _e('Permissions', 'luna'); ?> </span></a></li> <li<?php if ($page == 'bans') { echo ' class="active"'; } ?> ><a href="bans.php"><span class="fa fa-fw fa-ban"></span><span class="hidden-xs"> <?php _e('Bans', 'luna'); ?> </span></a></li> </ul> <?php } if ($section == 'settings') { ?> <ul class="nav nav-tabs" role="tablist"> <li<?php if ($page == 'settings') { echo ' class="active"'; } ?> ><a href="settings.php"><span class="fa fa-fw fa-cogs"></span><span class="hidden-xs"> <?php _e('Settings', 'luna'); ?> </span></a></li> <li<?php if ($page == 'features') { echo ' class="active"'; } ?> ><a href="features.php"><span class="fa fa-fw fa-sliders"></span><span class="hidden-xs"> <?php _e('Features', 'luna'); ?> </span></a></li> <li<?php if ($page == 'appearance') { echo ' class="active"'; } ?> ><a href="appearance.php"><span class="fa fa-fw fa-eye"></span><span class="hidden-xs"> <?php _e('Appearance', 'luna'); ?> </span></a></li> <li<?php if ($page == 'registration') { echo ' class="active"'; } ?> ><a href="registration.php"><span class="fa fa-fw fa-plus-circle"></span><span class="hidden-xs"> <?php _e('Registration', 'luna'); ?> </span></a></li> <li<?php if ($page == 'email') { echo ' class="active"'; } ?> ><a href="email.php"><span class="fa fa-fw fa-envelope"></span><span class="hidden-xs"> <?php _e('Email', 'luna'); ?> </span></a></li> <li<?php if ($page == 'menu') { echo ' class="active"'; } ?> ><a href="menu.php"><span class="fa fa-fw fa-bars"></span><span class="hidden-xs"> <?php _e('Menu', 'luna'); ?> </span></a></li> <li<?php if ($page == 'theme') { echo ' class="active"'; } ?> ><a href="theme.php"><span class="fa fa-fw fa-paint-brush"></span><span class="hidden-xs"> <?php _e('Theme', 'luna'); ?> </span></a></li> </ul> <?php } if ($section == 'maintenance') { ?> <ul class="nav nav-tabs" role="tablist"> <li<?php if ($page == 'maintenance') { echo ' class="active"'; } ?> ><a href="maintenance.php"><span class="fa fa-fw fa-coffee"></span><span class="hidden-xs"> <?php _e('Maintenance', 'luna'); ?> </span></a></li> <li<?php if ($page == 'prune') { echo ' class="active"'; } ?> ><a href="prune.php"><span class="fa fa-fw fa-recycle"></span><span class="hidden-xs"> <?php _e('Prune', 'luna'); ?> </span></a></li> <li<?php if ($page == 'database') { echo ' class="active"'; } ?> ><a href="database.php"><span class="fa fa-fw fa-database"></span><span class="hidden-xs"> <?php _e('Database', 'luna'); ?> </span></a></li> </ul> <?php } ?> </div> </div> </div> <div class="content"> <div class="container"> <?php }
function check_csrf($token) { if (!isset($token) || $token != luna_csrf_token()) { message(__('Bad CSRF hash. You were referred to this page from an unauthorized source.', 'luna'), false, '404 Not Found'); } }
if (!$pid) { define('LUNA_ALLOW_INDEX', 1); } define('LUNA_ACTIVE_PAGE', 'thread'); require load_page('header.php'); require LUNA_ROOT . 'include/parser.php'; $comment_count = 0; // Keep track of comment numbers // Retrieve a list of comment IDs, LIMIT is (really) expensive so we only fetch the IDs here then later fetch the remaining data if (!$luna_user['is_admmod']) { $result = $db->query('SELECT id FROM ' . $db->prefix . 'comments WHERE soft = 0 AND thread_id=' . $id . ' ORDER BY id LIMIT ' . $start_from . ',' . $luna_user['disp_comments']) or error('Unable to fetch comment IDs', __FILE__, __LINE__, $db->error()); } else { $result = $db->query('SELECT id FROM ' . $db->prefix . 'comments WHERE thread_id=' . $id . ' ORDER BY id LIMIT ' . $start_from . ',' . $luna_user['disp_comments']) or error('Unable to fetch comment IDs', __FILE__, __LINE__, $db->error()); } $comment_ids = array(); for ($i = 0; $cur_comment_id = $db->result($result, $i); $i++) { $comment_ids[] = $cur_comment_id; } $token_url = '&csrf_token=' . luna_csrf_token(); if (empty($comment_ids)) { error('The comment table and thread table seem to be out of sync!', __FILE__, __LINE__); } $cur_index = 1; require load_page('thread.php'); // Increment "num_views" for thread if ($luna_config['o_thread_views'] == '1') { $db->query('UPDATE ' . $db->prefix . 'threads SET num_views=num_views+1 WHERE id=' . $id) or error('Unable to update thread', __FILE__, __LINE__, $db->error()); } $forum_id = $cur_thread['forum_id']; $footer_style = 'thread'; require load_page('footer.php');
$temp = serialize(array('search_ids' => serialize($search_ids), 'num_hits' => $num_hits, 'sort_by' => $sort_by, 'sort_dir' => $sort_dir, 'show_as' => $show_as, 'search_type' => $search_type)); $search_id = mt_rand(1, 2147483647); $ident = $luna_user['is_guest'] ? get_remote_address() : $luna_user['username']; $db->query('INSERT INTO ' . $db->prefix . 'search_cache (id, ident, search_data) VALUES(' . $search_id . ', \'' . $db->escape($ident) . '\', \'' . $db->escape($temp) . '\')') or error('Unable to insert search results', __FILE__, __LINE__, $db->error()); if ($search_type[0] != 'action') { $db->end_transaction(); $db->close(); // Redirect the user to the cached result page header('Location: search.php?search_id=' . $search_id); exit; } } $forum_actions = array(); // If we're on the new comments search, display a "mark all as read" link if (!$luna_user['is_guest'] && $search_type[0] == 'action' && $search_type[1] == 'show_new') { $forum_actions[] = '<a href="misc.php?action=markread&csrf_token=' . luna_csrf_token() . '">' . __('Mark as read', 'luna') . '</a>'; } // Fetch results to display if (!empty($search_ids)) { switch ($sort_by) { case 1: $sort_by_sql = $show_as == 'threads' ? 't.commenter' : 'p.commenter'; break; case 2: $sort_by_sql = 't.subject'; break; case 3: $sort_by_sql = 't.forum_id'; break; default: $sort_by_sql = $show_as == 'threads' ? 't.last_comment' : 'p.commented';
// Check if the bans table was updated and regenerate the bans cache when needed if (isset($bans_updated)) { generate_bans_cache(); } } !empty($_GET['id']) ? redirect('settings.php?id=' . $id) : redirect('settings.php'); } if ($luna_user['g_set_title'] == '1') { $title_field = '<input type="text" class="form-control" name="title" value="' . luna_htmlspecialchars($user['title']) . '" maxlength="50" />'; } $avatar_field = '<a class="btn btn-primary" href="#" data-toggle="modal" data-target="#newavatar">' . __('Change avatar', 'luna') . '</a>'; $avatar_user = draw_user_avatar($id, true, 'visible-lg-inline'); $avatar_user_card = draw_user_avatar($id); $avatar_set = check_avatar($id); if ($avatar_user && $avatar_set) { $avatar_field .= ' <a class="btn btn-primary" href="settings.php?action=delete_avatar&id=' . $id . '&csrf_token=' . luna_csrf_token() . '">' . __('Delete avatar', 'luna') . '</a>'; } else { $avatar_field = '<a class="btn btn-primary" href="#" data-toggle="modal" data-target="#newavatar">' . __('Upload avatar', 'luna') . '</a>'; } if ($user['signature'] != '') { $signature_preview = $parsed_signature; } else { $signature_preview = __('No signature currently stored in profile.', 'luna'); } $user_username = luna_htmlspecialchars($user['username']); $user_usertitle = get_title($user); $page_title = array(luna_htmlspecialchars($luna_config['o_board_title']), __('Profile', 'luna'), __('Settings', 'luna')); define('LUNA_ACTIVE_PAGE', 'me'); require load_page('header.php'); require load_page('me-modals.php'); require load_page('settings.php');