static function login_page() { global $phpbb_root_path; $page = basename($_SERVER['REQUEST_URI']); if (strpos($page, "wp-login.php") !== false && get_option('wpphpbbu_url', false) && !\wpphpbbu\User::is_user_logged_in() && strpos($page, 'loggedout') === false) { wp_redirect(get_option('wpphpbbu_url', false) . 'ucp.php?mode=login&redirect=' . urlencode(get_bloginfo('home')), 301); exit; //seriously, when documentation requires this one, it demonstrate how much it suxx } }
public function load_session_id() { global $user, $auth, $phpbb_container, $phpbb_extension_manager; $user->session_begin(); $auth->acl($user->data); if (!\wpphpbbu\User::is_user_logged_in()) { $userid = \wpphpbbu\User::get_userid(); // Get user ID // $user->setup(false,false); if ($userid > 0) { wp_clear_auth_cookie(); $wpuser = wp_set_current_user($userid); // Set the current user wp_set_auth_cookie($userid, true, false); } } // Return current user session id return $user->session_id; }
function render_posting_box_content($post = null) { $forums = (new \wpphpbbu\Forum(\wpphpbbu\User::get_userid()))->get_forum_list(); $selected = get_post_meta($post->ID, 'wpphpbbu_forums', true); (new \wpphpbbu\widgets\ForumSelector())->print_forum($forums, $selected); }
function widget($args, $instance) { extract($args); $title = $instance['wpphpbbu_meta_title']; $ucp_url = get_option('wpphpbbu_url') . 'ucp.php'; $admin_url = \wpphpbbu\Path::get_admin_link(); $mcp_url = \wpphpbbu\Path::get_mcp_link(); $permission_url = \wpphpbbu\Path::get_restore_permissions_link(); if (empty($title)) { $title = " "; } echo $before_widget . $before_title . $title . $after_title; ?> <ul> <?php if (\wpphpbbu\User::is_user_logged_in()) { ?> <li> <a href="<?php bloginfo('home'); ?> /wp-admin/"> <?php echo _e('Blog control panel', 'wpphpbbu'); ?> </a> </li> <li> <a href="<?php echo $ucp_url; ?> "> <?php echo _e('User control panel', 'wpphpbbu'); ?> </a> </li> <?php if (!empty($mcp_url)) { ?> <li> <a href="<?php echo $mcp_url; ?> "> <?php echo _e('Moderator control panel', 'wpphpbbu'); ?> </a> </li> <?php } if (!empty($admin_url)) { ?> <li> <a href="<?php echo $admin_url; ?> "> <?php echo _e('Forum administration', 'wpphpbbu'); ?> </a> </li> <?php } if (!empty($permission_url)) { ?> <li> <a href="<?php echo $permission_url; ?> "> <?php echo _e('Restore permissions', 'wpphpbbu'); ?> </a> </li> <?php } ?> <li> <a href="<?php echo $ucp_url; ?> ?mode=logout&sid=<?php echo \wpphpbbu\Session::get_sessionid(); ?> "> <?php echo _e('Log out', 'wpphpbbu'); ?> </a> </li> <?php } else { ?> <li> <a href="<?php echo $ucp_url; ?> ?mode=sendpassword"> <?php echo _e('I forgot my password', 'wpphpbbu'); ?> </a> </li> <li> <a href="<?php echo $ucp_url; ?> ?mode=resend_act"> <?php echo _e('Resend activation email', 'wpphpbbu'); ?> </a> </li> <li> <a href="<?php echo $ucp_url; ?> ?mode=register"> <?php echo _e('Register new account', 'wpphpbbu'); ?> </a> </li> <?php } ?> <li> <a href="<?php echo $ucp_url; ?> ?mode=delete_cookies"> <?php echo _e('Delete site cookies', 'wpphpbbu'); ?> </a> </li> </ul> <?php echo $after_widget; }
function widget($args, $instance) { global $user, $auth, $phpbb_container; extract($args); $login_title = $instance['wpphpbbu_user_login_title']; $info_title = $instance['wpphpbbu_user_info_title']; $meta_links = $instance['wpphpbbu_user_show_meta']; $user_status = \wpphpbbu\User::is_user_logged_in(); $title = ''; if ($user_status == false) { $title = $login_title; } else { $title = $info_title; } $title = str_replace('{USERNAME}', trim($user->data['username']), $title); $forum_url = $ucp_url = get_option('wpphpbbu_url'); $ucp_url .= 'ucp.php'; echo $before_widget . $before_title . $title . $after_title; if ($user_status == false) { $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $meta_links = $instance['wpphpbbu_user_show_meta']; ?> <form action="<?php echo $ucp_url; ?> ?mode=login" method="post" class="wp_phpbb_bridge_login" id="login"> <?php if (get_option('wpphpbbu_width', '0') !== '0') { ?> <input type="hidden" name="wpphpbbu_elements_width" id="wpphpbbu_elements_width" value="<?php echo get_option('wpphpbbu_width'); ?> " /> <?php } ?> <label for="username"> <?php echo _e('Username:'******'wpphpbbu'); ?> </label> <br /> <input type="text" name="username" id="wpphpbbu_username" /> <br /> <label for="password"> <?php echo _e('Password:'******'wpphpbbu'); ?> </label> <br /> <input type="password" id="wpphpbbu_password" name="password" /> <br /> <label for="autologin"> <input type="checkbox" name="autologin" id="autologin" /> <?php echo _e('Remember me', 'wpphpbbu'); ?> </label> <br /> <label for="viewonline"> <input type="checkbox" name="viewonline" id="viewonline" /> <?php echo _e('Login as hidden', 'wpphpbbu'); ?> </label> <input type="hidden" name="redirect" value="<?php echo $redirect; ?> " /> <br /> <input type="submit" name="login" id="wpphpbbu_login" value="<?php echo _e('Login', 'wpphpbbu'); ?> " /> <?php if ($meta_links == "yes") { ?> <br /> <a href="<?php echo $ucp_url; ?> ?mode=sendpassword"> <?php echo _e('I forgot my password', 'wpphpbbu'); ?> </a> <br /> <a href="<?php echo $ucp_url; ?> ?mode=register"> <?php echo _e('Register new account', 'wpphpbbu'); ?> </a> <?php } ?> </form> <?php } else { $avatar = \wpphpbbu\User::get_avatar(); $admin_url = \wpphpbbu\Path::get_admin_link(); $mcp_url = \wpphpbbu\Path::get_mcp_link(); $options = get_option('widget_wpb_user'); $meta_links = $instance['wpphpbbu_user_show_meta']; if ($avatar) { ?> <a href="<?php echo $ucp_url; ?> " title="<?php _e('User control panel', 'wpphpbbu'); ?> "> <?php echo $avatar; ?> </a> <?php } ?> <ul id="wp_phpbb_bridge_options"> <li> <?php _e('Total posts', 'wpphpbbu'); ?> : <a href="<?php echo $forum_url; ?> search.php?search_id=egosearch"> <?php echo number_format($user->data['user_posts']); ?> </a> </li> <li> <?php _e("New PM's", 'wpphpbbu'); ?> : <a href="<?php echo $ucp_url; ?> ?i=pm&folder=inbox"> <?php echo number_format($user->data['user_new_privmsg']); ?> </a> </li> <li> <?php _e("Unread PMs", 'wpphpbbu'); ?> : <a href="<?php echo $ucp_url; ?> ?i=pm&folder=inbox"> <?php echo number_format($user->data['user_unread_privmsg']); ?> </a> </li> <?php if ($meta_links == "yes") { if (!empty($admin_url)) { ?> <li> <a href="<?php echo $admin_url; ?> "> <?php _e('Forum administration', 'wpphpbbu'); ?> </a> </li> <?php } } if (\wpphpbbu\User::is_user_logged_in()) { ?> <li> <a href="<?php echo get_option('home'); ?> /wp-admin/"> <?php echo _e('Blog control panel', 'wpphpbbu'); ?> </a> </li> <li> <a href="<?php echo $ucp_url; ?> "> <?php echo _e('User control panel', 'wpphpbbu'); ?> </a> </li> <?php if (!empty($mcp_url)) { ?> <li> <a href="<?php echo $mcp_url; ?> "> <?php echo _e('Moderator control panel', 'wpphpbbu'); ?> </a> </li> <?php } if (!empty($permission_url)) { ?> <li> <a href="<?php echo $permission_url; ?> "> <?php echo _e('Restore permissions', 'wpphpbbu'); ?> </a> </li> <?php } ?> <li> <a href="<?php echo $ucp_url; ?> ?mode=logout&sid=<?php echo \wpphpbbu\Session::get_sessionid(); ?> "> <?php echo _e('Log out', 'wpphpbbu'); ?> </a> </li> <?php } else { ?> <li> <a href="<?php echo $ucp_url; ?> ?mode=sendpassword"> <?php echo _e('I forgot my password', 'wpphpbbu'); ?> </a> </li> <li> <a href="<?php echo $ucp_url; ?> ?mode=resend_act"> <?php echo _e('Resend activation email', 'wpphpbbu'); ?> </a> </li> <li> <a href="<?php echo $ucp_url; ?> ?mode=register"> <?php echo _e('Register new account', 'wpphpbbu'); ?> </a> </li> <?php } ?> </ul> <?php } echo $after_widget; }
function widget($args, $instance) { extract($args); $forum_url = $ucp_url = get_option('wpphpbbu_url'); $ucp_url .= 'ucp.php'; $search_url = $forum_url . 'search.php'; $member_url = $forum_url . 'memberlist.php'; $session_id = 'sid=' . \wpphpbbu\Session::get_sessionid(); $title = $instance['wpphpbbu_links_title']; $display_index = $instance['wpphpbbu_links_index']; $display_faq = $instance['wpphpbbu_faq']; $display_search = $instance['wpphpbbu_search']; $display_active_topics = $instance['wpphpbbu_active_topics']; $display_unanswered_posts = $instance['wpphpbbu_unanswered_posts']; $display_your_posts = $instance['wpphpbbu_your_posts']; $display_new_posts = $instance['wpphpbbu_new_posts']; $display_pms = $instance['wpphpbbu_pms']; $display_send_pm = $instance['wpphpbbu_send_pm']; $display_members = $instance['wpphpbbu_members']; $display_team = $instance['wpphpbbu_team']; $display_whos_online = $instance['wpphpbbu_whos_online']; echo $before_widget . $before_title . $title . $after_title . '<ul>'; if ($display_index == 'yes') { echo '<li><a href="' . $forum_url . '?' . $session_id . '">'; echo _e('Forum index', 'wpphpbbu'); echo '</a></li>'; } if ($display_faq == 'yes') { echo '<li><a href="' . $forum_url . 'faq.php?' . $session_id . '">'; echo _e('FAQ', 'wpphpbbu'); echo '</a></li>'; } if ($display_search == 'yes') { echo '<li><a href="' . $search_url . '?' . $session_id . '">'; echo _e('Forum search', 'wpphpbbu'); echo '</a></li>'; } if ($display_active_topics == 'yes') { echo '<li><a href="' . $search_url . '?search_id=active_topics&' . $session_id . '">'; echo _e('View active topics', 'wpphpbbu'); echo '</a></li>'; } if ($display_unanswered_posts == 'yes') { echo '<li><a href="' . $search_url . '?search_id=unanswered&' . $session_id . '">'; echo _e('View unanswered posts', 'wpphpbbu'); echo '</a></li>'; } if (\wpphpbbu\User::is_user_logged_in()) { if ($display_your_posts == 'yes') { echo '<li><a href="' . $search_url . '?search_id=egosearch&' . $session_id . '">'; echo _e('View your posts', 'wpphpbbu'); echo '</a></li>'; } if ($display_new_posts == 'yes') { echo '<li><a href="' . $search_url . '?search_id=newposts&' . $session_id . '">'; echo _e('View new posts', 'wpphpbbu'); echo '</a></li>'; } if ($display_pms == 'yes') { echo '<li><a href="' . $ucp_url . '?i=pm&folder=inbox&' . $session_id . '">'; echo _e('Private messages', 'wpphpbbu'); echo '</a></li>'; } if ($display_send_pm == 'yes') { echo '<li><a href="' . $ucp_url . '?i=pm&mode=compose&' . $session_id . '">'; echo _e('Send private message', 'wpphpbbu'); echo '</a></li>'; } if ($display_members == 'yes') { echo '<li><a href="' . $member_url . '?' . $session_id . '">'; echo _e('Member list', 'wpphpbbu'); echo '</a></li>'; } if ($display_team == 'yes') { echo '<li><a href="' . $member_url . '?mode=leaders&' . $session_id . '">'; echo _e('The team', 'wpphpbbu'); echo '</a></li>'; } if ($display_whos_online == 'yes') { echo '<li><a href="' . $forum_url . 'viewonline.php?' . $session_id . '">'; echo _e('Who is online', 'wpphpbbu'); echo '</a></li>'; } } echo '</ul>' . $after_widget; }