1 (edited by Tubby 2006-11-03 22:07)

Topic: Login Block For Miniportal

This didnt fit in any of the other boards so i decided to post it in here. If you feel that there is a more suitable board for this topic then feel more than free to move it to the designated location. wink sorry if i have caused any trouble.

Just wanted to share this with you guys. If you are currently using the punbb miniportal located in the punres wiki then you may want to use this?

the main modification that this was built for can be located here: http://www.wiki.punres.org/Miniportal


create a new file under include/user and name it login.php

now apply this code to the file login.php:

<?php

// Show login if not logged in
if($pun_user['is_guest'])
{
    if(!isset($focus_element) || (isset($focus_element) && !in_array('login', $focus_element)))
    {odificat

    // Load the language files
    require PUN_ROOT.'lang/'.$pun_user['language'].'/common.php';
    require PUN_ROOT.'lang/'.$pun_user['language'].'/login.php';

    // Try to determine if the data in HTTP_REFERER is valid (if not, we redirect to index.php after login)
    $redirect_url = (isset($_SERVER['HTTP_REFERER']) && preg_match('#^'.preg_quote($pun_config['o_base_url']).'/(.*?)\.php#i', $_SERVER['HTTP_REFERER'])) ? htmlspecialchars($_SERVER['HTTP_REFERER']) : 'index.php';

    $required_fields = array('req_username' => $lang_common['Username'], 'req_password' => $lang_common['Password']);

?>
                  <div class="block">
<h2><span>Login</span></h2>
<div id="login" class="box">
<div class="inbox">             
        <div class="logintop">
            <form id="login" name="login" name="qpost" method="post" action="login.php?action=in" onsubmit="return process_form(this)">
<div style="text-align: center" class="inform">







                <p>
                    <input type="hidden" name="form_sent" value="1" />
                    <input type="hidden" name="redirect_url" value="<?php echo $redirect_url ?>" />
                     <?php echo $lang_common['Username'] ?><br />
                    <input type="text" name="req_username" size="16" maxlength="25" /><br /><br />
                     <?php echo $lang_common['Password'] ?><br />
 
 <input type="password" name="req_password" size="16" maxlength="16" wrap="virtual" onkeypress="if(event.keyCode==13) document.login.submit()" /><br /><br />
<input type="submit" name="login" value="<?php echo $lang_common['Login'] ?>" tabindex="3" /><br /><br />
                    <a href="register.php"><?php echo 'Register Now!'; ?></a>
                </p>

</div>
            </form>
        </div>
</div>
</div>
</div>
<?php
    }
}

Once you have done that all you have to do is call for it in the tpl file so open up the tpl file that handles your punbb miniportal and simply place:

<pun_include "login.php">

Somewhere along the sidebar. Once you have done that then your ready to go. The block will only be displayed for guests.

you may want to adjust your css at the top of the tpl file as well to suit the sidebar with this modification.

Re: Login Block For Miniportal

way cool! thanks for the update.

~James
FluxBB - Less is more

3

Re: Login Block For Miniportal

no problem....there will soon be a whole new modification for a more advanced punbb miniportal......it will have loads more blocks and features than the default punbb miniportal. Although the modification will be based on it tongue

4 (edited by Dr.Jeckyl 2006-11-04 07:54)

Re: Login Block For Miniportal

question: how would i get it to be displayed where the status is on my portal page here(under navlinks). i want it to be

username: |___________|    password: |___________|    |  Login  |      ie horizontal boxes.

right under where it says "You are not logged in." and when i'm logged in be replaced by :     
Logged in as Dr.Jeckyl
Last visit: Yesterday 03:09:34

my main.tpl:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html dir="<pun_content_direction>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<pun_char_encoding>" />
<pun_head>
</head>
<body>

<div id="punwrap">
<div id="pun<pun_page>" class="pun">

<div id="brdheader" class="block">
    <div class="box">
        <div id="brdtitle" class="inbox">
            <img src="img/freecss/logo.gif" alt="logo"/>
            <pun_desc>
        </div>
        <pun_navlinks>    
        <pun_status>
    </div>
</div>

<pun_announcement>

<pun_main>

<pun_footer>

</div>
</div>

</body>
</html>

did this make sense? any help is appreciated.

~James
FluxBB - Less is more

5 (edited by Dr.Jeckyl 2006-11-04 08:17)

Re: Login Block For Miniportal

....a few minutes later and some trial and error i think i figured it out.


in include/functions.php i edited out the links for register and login like so:

//
// Generate the "navigator" that appears at the top of every page
//
function generate_navlinks()
{
    global $pun_config, $lang_common, $pun_user;

    // Index and Userlist should always be displayed
    $links[] = '<li id="navindex"><a href="index.php">'.$lang_common['Index'].'</a>';
    $links[] = '<li id="navuserlist"><a href="userlist.php">'.$lang_common['User list'].'</a>';

    if ($pun_config['o_rules'] == '1')
        $links[] = '<li id="navrules"><a href="misc.php?action=rules">'.$lang_common['Rules'].'</a>';

    if ($pun_user['is_guest'])
    {
        if ($pun_user['g_search'] == '1')
            $links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';

        $links[] = '<li id="navregister">'.$lang_common[''].'</a>';
        $links[] = '<li id="navlogin">'.$lang_common[''].'</a>';

        $info = $lang_common['Not logged in'];
    }
    else
    {
        if ($pun_user['g_id'] > PUN_MOD)
        {
            if ($pun_user['g_search'] == '1')
                $links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';

            $links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
            $links[] = '<li id="navlogout"><a href="login.php?action=out&id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>';
        }
        else
        {
            $links[] = '<li id="navsearch"><a href="search.php">'.$lang_common['Search'].'</a>';
            $links[] = '<li id="navprofile"><a href="profile.php?id='.$pun_user['id'].'">'.$lang_common['Profile'].'</a>';
            $links[] = '<li id="navadmin"><a href="admin_index.php">'.$lang_common['Admin'].'</a>';
            $links[] = '<li id="navlogout"><a href="login.php?action=out&id='.$pun_user['id'].'">'.$lang_common['Logout'].'</a>';
        }
    }

and then in Tubby's login.php file i changed this:

<p>
                    <input type="hidden" name="form_sent" value="1" />
                    <input type="hidden" name="redirect_url" value="<?php echo $redirect_url ?>" />
                     <?php echo $lang_common['Username'] ?><br />
                    <input type="text" name="req_username" size="16" maxlength="25" /><br /><br />
                     <?php echo $lang_common['Password'] ?><br />
 
 <input type="password" name="req_password" size="16" maxlength="16" wrap="virtual" onkeypress="if(event.keyCode==13) document.login.submit()" /><br /><br />
<input type="submit" name="login" value="<?php echo $lang_common['Login'] ?>" tabindex="3" /><br /><br />
                    <a href="register.php"><?php echo 'Register Now!'; ?></a>
                </p>

to this:

                    <input type="hidden" name="form_sent" value="1" />
                    <input type="hidden" name="redirect_url" value="<?php echo $redirect_url ?>" />
                     <?php echo $lang_common['Username'] ?>
                    <input type="text" name="req_username" size="16" maxlength="25" />
                     <?php echo $lang_common['Password'] ?>
 
 <input type="password" name="req_password" size="16" maxlength="16" wrap="virtual" onkeypress="if(event.keyCode==13) document.login.submit()" />
<input type="submit" name="login" value="<?php echo $lang_common['Login'] ?>" tabindex="3" />
                    <a href="register.php"><?php echo 'Register Now!'; ?></a>

i'm sure it's pretty dirty but it's working. any fixes to make it more propper would be appreciated i'm sure.

~James
FluxBB - Less is more

6

Re: Login Block For Miniportal

I use that same miniportal setup and I have a login block on my left side. Different from this one, does anyone have this particular one up and running somewhere?  I'd like to see it and the differences in this one from the one I have right now.

7 (edited by Tubby 2006-11-06 23:56)

Re: Login Block For Miniportal

kato i can see that your login block is also a whos online block as well.......well to answer your question the difference is is that this block only appears when users are not logged in......once logged in the block jsut disappears.

In my opinion mine looks a little bit cleaner as well seeing as how the content of it is centered and contains <br />'s in the appropriate places. Idk its personal preference really.

8 (edited by Tubby 2006-11-07 00:20)

Re: Login Block For Miniportal

oh and jeckyl yes that would work properly but there is no need to remove the <p> tag just the <br />'s and maybe arrange it the way you want it such as spacing ect. You would also want to adjust the width of the box and simply include the file after <pun_status> in your header tongue btw my new modification has been released. Its called PunPortal. What it is is a more advanced portal page. Based off of the punbb miniportal. comes with feature filled blocks that collect statistics from the database. You can view the demo here: http://www.fatalgamers.org/forums/

Download it here: http://www.punres.org/viewtopic.php?id=2279

9

Re: Login Block For Miniportal

Tubby wrote:

oh and jeckyl yes that would work properly but there is no need to remove the <p> tag just the <br />'s and maybe arrange it the way you want it such as spacing ect. You would also want to adjust the width of the box and simply include the file after <pun_status> in your header tongue btw my new modification has been released. Its called PunPortal. What it is is a more advanced portal page. Based off of the punbb miniportal. comes with feature filled blocks that collect statistics from the database. You can view the demo here: http://www.fatalgamers.org/forums/

Download it here: http://www.punres.org/viewtopic.php?id=2279

I like it.  It looks nice.  I can't get to the download link right now and I think that's because of work, but are there other blocks as well as the ones on that demo or is it just the ones on the demo?  Which by the way, I like it.  Looks and feels pretty sharp I think.

10 (edited by helpme 2007-01-12 18:24)

Re: Login Block For Miniportal

nevermind