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. 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.