PDA

Zobacz pełną wersję : Logowanie z forum



szymo
21-03-2008, 17:25
Witam!
Mam trochę dziwny problem otóż mam pomost do forum Joomla!-przemo. I załatałem domyślny moduł logowania i wszystko działa jak należy, ale chcę korzystać z innego modułu logowania i tu zaczyna się problem. Mam moduł do logowania Core Design Login Form 1.0.1.pl i chciałbym żeby logując się tym modułem logowało się także na forum(tak jak jest w domyślnym module logowania). Próbowałem zmienić kod PHP tego modułu ale nie bardzo mi to wychodzi:( Mógłby mi ktoś pomóc? Byłbym bardzo wdzięczny.

Plik PHP z modułem Core Design Login Form 1.0.1.pl (/modules/mod_cdlogin.php)

<?php
/**
* Core Design Login Module based on Highslide JS, version 1.1.0, author Daniel Rataj
*
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

global $mosConfig_frontend_login, $mosConfig_live_site;

if ( $mosConfig_frontend_login != NULL && ($mosConfig_frontend_login === 0 || $mosConfig_frontend_login === '0')) {
return;
}
/***********************************************
funkcja mosHash - mieszanie
***********************************************/
if (!function_exists('mosHash')) {
function mosHash( $seed ) {
return md5( $GLOBALS['mosConfig_secret'] . md5( $seed ) );
}
}
/***********************************************
funkcja josSpoofValue - antyoszukiwacz
***********************************************/
if (!function_exists('josSpoofValue')) {
function josSpoofValue($alt=NULL) {
global $mainframe;

if ($alt) {
if ( $alt == 1 ) {
$random = date( 'Ymd' );
} else {
$random = $alt . date( 'Ymd' );
}
} else {
$random = date( 'dmY' );
}
// the prefix ensures that the hash is non-numeric
// otherwise it will be intercepted by globals.php
$validate = 'j' . mosHash( $mainframe->getCfg( 'db' ) . $random );

return $validate;
}
}

// url of current page that user will be returned to after login
if ($query_string = mosGetParam( $_SERVER, 'QUERY_STRING', '' )) {
$return = 'index.php?' . $query_string;
} else {
$return = 'index.php';
}

function cd_ifmambotload() {
global $database;

// load Highslide options from database
$query = "SELECT id, published"
. "\n FROM #__mambots"
. "\n WHERE element = 'coredesign'"
. "\n AND folder = 'system'"
;
$database->setQuery( $query );
$id = $database->loadResult();
$mambot = new mosMambot( $database );
$mambot->load( $id );
$params = new mosParameters( $mambot->params );

$param['write_html'] = $params->get( 'use_html', '0' );

if( !$mambot->published )
echo '<div style="color: red">Core Design mambot nie został opublikowany. </div>';
elseif ( !$param['write_html'] )
echo '<div style="color: red">Core Design mambot nie został aktywowany. Sprawdź ustawienia
bota!!! </div>';
return;
}

$registration_enabled = $mainframe->getCfg( 'allowUserRegistration' );
$message_login = $params->def( 'login_message', 0 );
$message_logout = $params->def( 'logout_message', 0 );
$login = $params->def( 'login', $return );
$logout = $params->def( 'logout', $return );
$name = $params->def( 'name', 1 );
$greeting = $params->def( 'greeting', 1 );
$pretext = $params->get( 'pretext' );
$posttext = $params->get( 'posttext' );
$posttext_style = $params->get( 'posttext_style', 0 );

//Highslide option
$moduletitle = $params->get( 'moduletitle' );
$closelabel = $params->get( 'closelabel' );
$mod_cdlogin_createaccount = $params->get( 'mod_cdlogin_createaccount' );
$mod_cdlogin_lostpassword = $params->get( 'mod_cdlogin_lostpassword' );
$mod_cdlogin_confirmlogout = $params->get( 'mod_cdlogin_confirmlogout' );
$mod_cdlogin_displayauthor = $params->get( 'mod_cdlogin_displayauthor', 1 );

$posttext_style = 1;
?>
<?php if ( $my->id ) {
// Logout output
// ie HTML when already logged in and trying to logout
if ( $name ) {
$name = $my->name;
} else {
$name = $my->username;
} ?>

<?php cd_ifmambotload(); ?>

<style type="text/css">@import "<?php echo $mosConfig_live_site; ?>/modules/mod_cdlogin/
mod_cdlogin.css";</style>
<div class="mod_cdlogin-logout-border-top"></div>
<div style="clear: both"></div>
<div class="mod_cdlogin-logout-greeting">

<?php
if ( $greeting ) {
echo _HI;
echo "<strong>";
echo $name;
echo "</strong>";
}
?>

</div>
<div>
<a href="#" onclick="return hs.htmlExpand(this, { contentId: 'highslide-html-logoutform' } )"
class="mod_cdlogin-logouttitle" title="<?php echo _BUTTON_LOGOUT; ?>">
<span> </span></a>
<div class="highslide-html-content" id="highslide-html-logoutform">
<div class="highslide-html-content-header">
<div class="highslide-move" title="">
<a href="#" onclick="return hs.close(this)" class="control" title="<?php echo $closelabel ?>"><?php
echo $closelabel ?></a>
</div>
</div>
<div class="highslide-body">
<p class="mod_cdlogin-bold"><?php echo $mod_cdlogin_confirmlogout ?> </p>
<div class="mod_cdlogin-logoutform"><form action="<?php echo sefRelToAbs( 'index.php?option=logout'
); ?>" method="post" name="logout">
<input type="submit" name="Submit" class="mod_cdlogin-logoutbutton" title="<?php echo
_BUTTON_LOGOUT; ?>" value="<?php echo _BUTTON_LOGOUT; ?>" />


<input type="hidden" name="option" value="logout" />
<input type="hidden" name="op2" value="logout" />
<input type="hidden" name="lang" value="<?php echo $mosConfig_lang; ?>" />
<input type="hidden" name="return" value="<?php echo htmlspecialchars( sefRelToAbs( $logout ) ); ?>"
/>
<input type="hidden" name="message" value="<?php echo htmlspecialchars( $message_logout ); ?>" />
</form>
</div>
</div>
</div>
</div>
<div style="clear: both"></div>
<div class="mod_cdlogin-logout-border-bottom"></div>
<?php
} else {
// Login output
// ie HTML when not logged in and trying to login
// used for spoof hardening
$validate = josSpoofValue(1);
?>
<?php cd_ifmambotload(); ?>
<style type="text/css">@import "<?php echo $mosConfig_live_site; ?>/modules/mod_cdlogin/
mod_cdlogin.css";</style>
<div class="mod_cdlogin-logout-border-top"></div>
<div style="clear: both"></div>
<div class="mod_cdlogin-login-box">
<div class="mod_cdlogin-login-mini"></div>
<a href="#" onclick="return hs.htmlExpand(this, { contentId: 'highslide-html-loginform' } )" title="
<?php echo $moduletitle ?>"><?php echo $moduletitle ?> </a>
</div>
<div style="clear: both"></div>
<div class="mod_cdlogin-logout-border-bottom"></div>

<div class="highslide-html-content" id="highslide-html-loginform">
<div class="highslide-html-content-header">
<div class="highslide-move" title="">
<a href="#" onclick="return hs.close(this)" class="control" title="<?php echo $closelabel ?>"><?php
echo $closelabel ?></a>
</div>
</div>
<div class="highslide-body">

<form action="<?php echo sefRelToAbs( 'index.php' ); ?>" method="post" name="loginForm" >
<?php
echo $pretext;
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<label for="mod_login_username">
<?php echo _USERNAME; ?>
</label>
<br />
<input name="username" id="mod_cdlogin_username" type="text" class="inputbox" alt="username" size="
10" />
<br />
<label for="mod_login_password">
<?php echo _PASSWORD; ?>
</label>
<br />
<input type="password" id="mod_cdlogin_password" name="passwd" class="inputbox" size="10" alt="
password" />
<br />
<div class="mod_cdlogin-form-submit">
<div class="mod_cdlogin-form-input">
<input type="checkbox" name="remember" id="mod_cdlogin_remember" class="inputbox" value="yes" alt="<
?php echo _REMEMBER_ME; ?>" title="<?php echo _REMEMBER_ME; ?>" />
<label for="mod_login_remember">
<?php echo _REMEMBER_ME; ?>
</label>
</div>
<input type="submit" name="Submit" class="mod_cdlogin-loginbutton" title="<?php echo _BUTTON_LOGIN;
?>" value="" />
</div>
</td>
</tr>
<tr>
<td>
<div style="text-align: center; padding-top: 10px">
<div style="margin: 0 auto">
<a href="<?php echo sefRelToAbs( 'index.php?option=com_registration&amp;task=lostPasswo rd' ); ?>"
title="<?php echo $mod_cdlogin_lostpassword; ?>" class="mod_cdlogin-lostpassword"><?php echo
$mod_cdlogin_lostpassword; ?> </a><span style="padding-left: 15px">
<a href="<?php echo sefRelToAbs( 'index.php?option=com_registration&amp;task=register' ); ?>"
title="<?php echo $mod_cdlogin_createaccount; ?>" class="mod_cdlogin-createaccount"><?php echo
$mod_cdlogin_createaccount; ?> </a>
</div>
</div>
</td>
</tr>
<?php
if ( $registration_enabled ) {
?>
<tr>
<td>

</td>
</tr>
<?php
}
?>
</table>
<div class="mod_imglogin"></div>
<?php
if ($posttext != '') {
if ($posttext_style == 1) {
?>
<div style="border: 1px solid rgb(128, 128, 128); padding: 2px;">
<?php echo $posttext; ?>
</div>
<?php
} else {
echo $posttext;
}
}
?>

<input type="hidden" name="option" value="login" />
<input type="hidden" name="op2" value="login" />
<input type="hidden" name="lang" value="<?php echo $mosConfig_lang; ?>" />
<input type="hidden" name="return" value="<?php echo htmlspecialchars( sefRelToAbs( $login ) ); ?>"
/>
<input type="hidden" name="message" value="<?php echo htmlspecialchars( $message_login ); ?>" />
<input type="hidden" name="force_session" value="1" />
<input type="hidden" name="<?php echo $validate; ?>" value="1" />
</form>
</div>
<?php if ($mod_cdlogin_displayauthor) { ?>
<div class="mod_cdtitle-designed">Designed by <a href="http://www.communicationpro.org" title="http:
//www.communicationpro.org" target="_blank">www.communicationpro.org</a> </div>
<?php } return; ?>
</div>
<?php
}
?>

szymo
21-03-2008, 17:26
I plik z domyślnym modułem logowania po załataniu:



<?php
/**
* @version $Id: mod_login.php 7211 2007-04-29 02:26:51Z robs $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_VALID_MOS' ) or die( 'Restricted access' );

global $mosConfig_frontend_login;

if ( $mosConfig_frontend_login != NULL && ($mosConfig_frontend_login === 0 || $mosConfig_frontend_login === '0')) {
return;
}

// url of current page that user will be returned to after login
if ($query_string = mosGetParam( $_SERVER, 'QUERY_STRING', '' )) {
$return = 'index.php?' . $query_string;
} else {
$return = 'index.php';
}

$registration_enabled = $mainframe->getCfg( 'allowUserRegistration' );
$message_login = $params->def( 'login_message', 0 );
$message_logout = $params->def( 'logout_message', 0 );
$login = $params->def( 'login', $return );
$logout = $params->def( 'logout', $return );
$name = $params->def( 'name', 1 );
$greeting = $params->def( 'greeting', 1 );
$pretext = $params->get( 'pretext' );
$posttext = $params->get( 'posttext' );

if ( $my->id ) {
// Logout output
// ie HTML when already logged in and trying to logout
if ( $name ) {
$name = $my->name;
} else {
$name = $my->username;
}
?>

<?php
//joomla<->przemo start
$query = "SELECT par_value FROM #__jp_config WHERE par_name='forum_live'";
$database->setQuery( $query );
$forum_path_inlcude = $database->loadResult(); ?>
<form action="<?php echo $forum_path_inlcude; ?>/login.php" name="login" method="post" >
<?php //joomla<->przemo end ?>

<?php
if ( $greeting ) {
echo _HI;
echo $name;
}
?>
<br />

<div align="center">
<input type="submit" name="Submit" class="button" value="<?php echo _BUTTON_LOGOUT; ?>" />
</div>

<input type="hidden" name="logout_phpbb" value="yes" />
<input type="hidden" name="option" value="logout" />
<input type="hidden" name="op2" value="logout" />
<input type="hidden" name="lang" value="<?php echo $mosConfig_lang; ?>" />
<input type="hidden" name="return" value="<?php echo htmlspecialchars( sefRelToAbs( $logout ) ); ?>"
/>
<input type="hidden" name="message" value="<?php echo htmlspecialchars( $message_logout ); ?>" />
</form>
<?php
} else {
// Login output
// ie HTML when not logged in and trying to login
// used for spoof hardening
$validate = josSpoofValue(1);
?>

<?php //joomla<->przemo start
$query = "SELECT par_value FROM #__jp_config WHERE par_name='forum_live'";
$database->setQuery( $query );
$forum_path_inlcude = $database->loadResult(); ?>
<form action="<?php echo $forum_path_inlcude; ?>/login.php" method="post" name="login" >
<?php //joomla<->przemo end ?>

<?php
echo $pretext;
?>

<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<label for="mod_login_username">
<?php echo _USERNAME; ?>
</label>
<br />
<input name="username" id="mod_login_username" type="text" class="inputbox" alt="<?php echo
_USERNAME; ?>" size="10" />
<br />
<label for="mod_login_password">
<?php echo _PASSWORD; ?>
</label>
<br />
<input type="password" name="password" class="inputbox" size="10" alt="password" />
<input type="hidden" id="mod_login_password" name="passwd" class="inputbox" size="10" alt="<?php
echo _PASSWORD; ?>" />
<br />
<input type="checkbox" name="remember" id="mod_login_remember" class="inputbox" value="yes" alt="<?
php echo _REMEMBER_ME; ?>" />
<label for="mod_login_remember">
<?php echo _REMEMBER_ME; ?>
</label>
<br />
<input type="submit" class="mainoption" name="login" value="Login" />
</td>
</tr>
<tr>
<td>
<a href="<?php echo sefRelToAbs( 'index.php?option=com_registration&amp;task=lostPasswo rd' ); ?>">
<?php echo _LOST_PASSWORD; ?></a>
</td>
</tr>
<?php
if ( $registration_enabled ) {
?>
<tr>
<td>
<?php echo _NO_ACCOUNT; ?>
<a href="<?php echo sefRelToAbs( 'index.php?option=com_registration&amp;task=register' ); ?>">
<?php echo _CREATE_ACCOUNT; ?></a>
</td>
</tr>
<?php
}
?>
</table>
<?php
echo $posttext;
?>

<input type="hidden" name="option" value="login" />
<input type="hidden" name="op2" value="login" />
<input type="hidden" name="lang" value="<?php echo $mosConfig_lang; ?>" />
<input type="hidden" name="return" value="<?php echo htmlspecialchars( sefRelToAbs( $login ) ); ?>"
/>
<input type="hidden" name="message" value="<?php echo htmlspecialchars( $message_login ); ?>" />
<input type="hidden" name="force_session" value="1" />
<input type="hidden" name="<?php echo $validate; ?>" value="1" />
</form>
<?php
}
?>