コード例 #1
0
function wpu_login_user_info($titleLoggedIn, $titleLoggedOut, $loginForm, $rankBlock, $newPosts, $write, $admin, $position, $before_title, $after_title)
{
    global $user, $db, $scriptPath, $wpSettings, $auth, $wpuAbs, $phpbb_sid, $wpSettings, $phpEx;
    if ($wpuAbs->ver == 'PHPBB2') {
        echo "Not phpBB2 compatible.";
        return false;
    }
    $wpu_usr = get_wpu_phpbb_username();
    if (!empty($user->data['is_registered'])) {
        echo $before_title . $titleLoggedIn . $after_title;
        //style for position sidebar/header
        $style = $position == "sidebar" ? 'display:block; margin:0 5px;' : 'float:left; display:inline; margin:0 5px;';
        if ($position == "sidebar") {
            echo '<p style="' . $style . '" class="wpu_username"><a href="' . add_trailing_slash($scriptPath) . 'ucp.php?i=164"><strong>' . $wpu_usr . '</strong></a></p>';
            echo '<p style="' . $style . '" class="wpu_avatar"><img src="' . get_avatar_reader() . '" alt="' . __(avatar) . '" /></p>';
        } else {
            echo '<p style="' . $style . '" class="wpu_avatar"><img src="' . get_avatar_reader() . '" alt="' . __(avatar) . '" /></p>';
            echo '<p style="' . $style . '" class="wpu_username"><a href="' . add_trailing_slash($scriptPath) . 'ucp.php?i=164"><strong>' . $wpu_usr . '</strong></a></p>';
        }
        if ($rankBlock) {
            wpu_phpbb_rankblock();
        }
        if ($newPosts) {
            echo '<p class="wpu_newposts">';
            wpu_newposts_link();
            echo '</p> ';
        }
        // Handle new PMs
        if ($user->data['user_new_privmsg']) {
            $l_message_new = $user->data['user_new_privmsg'] == 1 ? $wpuAbs->lang('NEW_PM') : $wpuAbs->lang('NEW_PMS');
            $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']);
            echo '<p class="wpu_pm"><a title="' . $l_privmsgs_text . '" href="' . add_trailing_slash($scriptPath) . 'ucp.php?i=pm&folder=inbox">' . $l_privmsgs_text . '</a></p>';
        } else {
            $l_privmsgs_text = $wpuAbs->lang('NO_NEW_PM');
            $s_privmsg_new = false;
            echo '<p class="wpu_pm"><a title="' . $l_privmsgs_text . '" href="' . add_trailing_slash($scriptPath) . 'ucp.php?i=pm&folder=inbox">' . $l_privmsgs_text . '</a></p>';
        }
        if ($write) {
            if (current_user_can('publish_posts')) {
                echo '<p class="wpu_write"><a href="' . $wpSettings['wpUri'] . 'wp-admin/post-new.php" title="' . __('Write a Post') . '">' . __('Write a Post') . '</a></p> ';
            }
        }
        if ($admin) {
            $connSettings = get_settings('wputd_connection');
            if (current_user_can('publish_posts')) {
                echo '<p class="wpu_siteadmin"><a href="' . $wpSettings['wpUri'] . 'wp-admin/" title="Admin Site">' . __('Dashboard') . '</a></p> ';
            }
            if ($auth->acl_get('a_')) {
                echo '<p class="wpu_forumadmin"><a href="' . $scriptPath . 'adm/index.php?' . $phpbb_sid . '" title="Admin Forum">' . $wpuAbs->lang('ACP') . '</a></p>';
            }
        }
        echo '<p class="wpu_logout">';
        wp_loginout();
        echo '</p> ';
    } else {
        echo $before_title . $titleLoggedOut . $after_title;
        if ($loginForm) {
            $login_link = $wpuAbs->ver == 'PHPBB2' ? 'login.' . $phpEx . '?redirect=wp-united-blog&amp;sid=' . $phpbb_sid : 'ucp.' . $phpEx . '?mode=login&amp;sid=' . $phpbb_sid . '&amp;redirect=http://' . $_SERVER['SERVER_NAME'] . '' . attribute_escape($_SERVER["REQUEST_URI"]);
            echo '<form method="post" action="' . add_trailing_slash($scriptPath) . $login_link . '">';
            echo '<p class="wpu_user"><label for="phpbb_username">' . $wpuAbs->lang('USERNAME') . '</label> <input tabindex="1" class="inputbox autowidth" type="text" name="username" id="phpbb_username"/></p>';
            echo '<p class="wpu_password"><label for="phpbb_password">' . $wpuAbs->lang('PASSWORD') . '</label> <input tabindex="2" class="inputbox autowidth" type="password" name="password" id="phpbb_password" maxlength="32" /></p>';
            if ($wpuAbs->config('allow_autologin')) {
                echo '<p class="wpu_remember"><input tabindex="3" type="checkbox" id="phpbb_autologin" name="autologin" /><label for="phpbb_autologin"> ' . $wpuAbs->lang('LOG_ME_IN') . '</label> </p>';
            }
            echo '<p class="wpu_login"><input type="submit" name="login" class="button1" value="' . $wpuAbs->lang('LOGIN') . '" /></p>';
            echo '<p class="wpu_signup"><a href="' . append_sid(add_trailing_slash($scriptPath) . "ucp.php?mode=register") . '">' . $wpuAbs->lang('REGISTER') . '</a></p>';
            echo '<p class="wpu_rempassword"><a href="' . append_sid(add_trailing_slash($scriptPath)) . 'ucp.php?mode=sendpassword">' . $wpuAbs->lang('FORGOT_PASS') . '</a></p>';
            echo '</form>';
        } else {
            echo '<p class="wpu_logout">';
            wp_loginout();
            echo '</p> ';
        }
    }
    if ($position == "header") {
        echo '<p style="clear:both;"></p>';
    }
}
コード例 #2
0
/**
 * Gets info about the current user, or a login form if they are logged out, without displaying it
 * @author Japgalaxy, updated by John Wells
 * @example wpu_login_user_info("before=<li>&after=</li>&showLoginForm=1&showRankBlock=1&showNewPosts=1&showWriteLink=1&showAdminLinks=1&showPMs=1&autoLogin=1");
 */
function get_wpu_login_user_info($args)
{
    global $user_ID, $db, $auth, $phpbbForum, $wpUnited, $phpEx, $config;
    $defaults = array('before' => '<li>', 'after' => '</li>', 'showPMs' => 1, 'showLoginForm' => 1, 'showRankBlock' => 1, 'showNewPosts' => 1, 'showWriteLink' => 1, 'showAdminLinks' => 1, 'autoLogin' => 1);
    extract(_wpu_process_args($args, $defaults));
    $ret = '';
    get_currentuserinfo();
    $loggedIn = $phpbbForum->user_logged_in();
    $loginLang = $loggedIn ? sprintf($phpbbForum->lang['LOGOUT_USER'], $phpbbForum->get_username()) : $phpbbForum->lang['LOGIN'];
    $loginAction = $loggedIn ? '?mode=logout' : '?mode=login';
    if ($loggedIn) {
        $wpu_usr = get_wpu_phpbb_username();
        $colour = $phpbbForum->get_userdata('user_colour');
        $colour = $colour ? ' style="color: #' . $colour . '" ' : '';
        $ret .= _wpu_add_class($before, 'wpu-widget-lu-username') . '<a href="' . $phpbbForum->get_board_url() . 'ucp.' . $phpEx . '" ' . $colour . '><strong>' . $wpu_usr . '</strong></a>' . $after;
        $ret .= _wpu_add_class($before, 'wpu-widget-lu-avatar') . '<img src="' . get_avatar_reader() . '" alt="' . $phpbbForum->lang['USER_AVATAR'] . '" />' . $after;
        if ($showRankBlock) {
            $ret .= _wpu_add_class($before, 'wpu-widget-lu-rankblock') . get_wpu_phpbb_rankblock() . $after;
        }
        if ($showNewPosts) {
            $ret .= $before . get_wpu_newposts_link() . $after;
        }
        $fStateChanged = $phpbbForum->foreground();
        $admin = $auth->acl_get('a_');
        $autoLogin = $config['allow_autologin'];
        $PMs = $phpbbForum->get_user_pm_details();
        $phpbbForum->restore_state($fStateChanged);
        // Handle new PMs
        if ($showPMs) {
            if ($PMs['text']) {
                $ret .= _wpu_add_class($before, 'wpu-has-pms') . '<a title="' . $PMs['text'] . '" href="' . $phpbbForum->get_board_url() . 'ucp.' . $phpEx . '?i=pm&folder=inbox">' . $PMs['text'] . '</a>' . $after;
            } else {
                $ret .= _wpu_add_class($before, 'wpu-no-pms') . '<a title="' . $phpbbForum->lang['NO_NEW_PM'] . '" href="' . $phpbbForum->get_board_url() . 'ucp.' . $phpEx . '?i=pm&folder=inbox">' . $phpbbForum->lang['NO_NEW_PM'] . '</a>' . $after;
            }
        }
        if ($showWriteLink) {
            if (current_user_can('edit_posts')) {
                $ret .= $before . '<a href="' . $wpUnited->get_wp_base_url() . 'wp-admin/post-new.php" title="' . __('Write a Post', 'wp-united') . '">' . __('Write a Post', 'wp-united') . '</a>' . $after;
            }
        }
        if ($showAdminLinks) {
            if (current_user_can('read')) {
                $ret .= $before . '<a href="' . $wpUnited->get_wp_base_url() . 'wp-admin/" title="' . __('Dashboard', 'wp-united') . '">' . __('Dashboard', 'wp-united') . '</a>' . $after;
            }
            if ($admin) {
                $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . 'adm/index.' . $phpEx) . '" title="' . $phpbbForum->lang['ACP'] . '">' . $phpbbForum->lang['ACP'] . '</a>' . $after;
            }
        }
        $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . 'ucp.' . $phpEx . $loginAction) . '" title="' . $loginLang . '">' . $loginLang . '</a>' . $after;
    } else {
        if ($showLoginForm) {
            $redir = wpu_get_redirect_link();
            $login_link = $phpbbForum->append_sid('ucp.' . $phpEx . '?mode=login') . '&amp;redirect=' . $redir;
            $ret .= '<form class="wpuloginform" method="post" action="' . $phpbbForum->get_board_url() . $login_link . '">';
            $ret .= $before . '<label for="phpbb_username">' . $phpbbForum->lang['USERNAME'] . '</label> <input tabindex="1" class="inputbox autowidth" type="text" name="username" id="phpbb_username"/>' . $after;
            $ret .= $before . '<label for="phpbb_password">' . $phpbbForum->lang['PASSWORD'] . '</label> <input tabindex="2" class="inputbox autowidth" type="password" name="password" id="phpbb_password" maxlength="32" />' . $after;
            if ($autoLogin) {
                $ret .= $before . '<input tabindex="3" type="checkbox" id="phpbb_autologin" name="autologin" /><label for="phpbb_autologin"> ' . __('Remember me', 'wp-united') . '</label>' . $after;
            }
            $ret .= $before . '<input type="submit" name="login" class="wpuloginsubmit" value="' . __('Login') . '" />' . $after;
            $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . "ucp.php?mode=register") . '">' . __('Register', 'wp-united') . '</a>' . $after;
            $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . 'ucp.php?mode=sendpassword') . '">' . __('Forgot Password?', 'wp-united') . '</a>' . $after;
            $ret .= '</form>';
        } else {
            $ret .= $before . '<a href="' . $phpbbForum->append_sid($phpbbForum->get_board_url() . 'ucp.' . $phpEx . $loginAction) . '" title="' . $loginLang . '">' . $loginLang . '</a>';
        }
    }
    return $ret;
}