Jak połączyć logowanie na strone bezposrednio z logowaniem

Tutaj udzielane jest wsparcie przy problemach związanych z instalacją, konwersją, aktualizacją oraz użytkowaniem phpBB 2.0.x.
spineless
Posty: 6
Rejestracja: 10 grudnia 2005, 20:22

Jak połączyć logowanie na strone bezposrednio z logowaniem

Post autor: spineless » 11 grudnia 2005, 12:24

na forum? Ma ktos jakies pomysly?

MdK
Zasłużony
Posty: 414
Rejestracja: 17 maja 2005, 18:02
Lokalizacja: Lubiewo
Kontakt:

Post autor: MdK » 11 grudnia 2005, 12:31


spineless
Posty: 6
Rejestracja: 10 grudnia 2005, 20:22

Post autor: spineless » 11 grudnia 2005, 20:31

Warning: Cannot modify header information - headers already sent by (output started at c:\usr\apache\httpd\html\index.php:3) in c:\usr\apache\httpd\html\forum\includes\sessions.php on line 258

Warning: Cannot modify header information - headers already sent by (output started at c:\usr\apache\httpd\html\index.php:3) in c:\usr\apache\httpd\html\forumincludes\sessions.php on line 259

Wlasciwie wszystko dziala (uzyty kod z podanego wyzej linku), ale te bledy pojawiaja sie na samym poczatku, pozniej po zalogowaniu znikaja. jak sie ich pozbyc?

spineless
Posty: 6
Rejestracja: 10 grudnia 2005, 20:22

Post autor: spineless » 11 grudnia 2005, 20:49

albo moze da sie wylaczyc wyswietlanie warnings na stronie?

MdK
Zasłużony
Posty: 414
Rejestracja: 17 maja 2005, 18:02
Lokalizacja: Lubiewo
Kontakt:

Post autor: MdK » 11 grudnia 2005, 20:55

Chyba, nie... Cos na pewno sknociłeś... Zobacz czy aby wszędize masz }, bo to zreguły powoduje takie błędy.

spineless
Posty: 6
Rejestracja: 10 grudnia 2005, 20:22

Post autor: spineless » 11 grudnia 2005, 21:03

$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
to mu sie nie podoba za bardzo.Tzn z tego powodu jest warning, bo jak wywale ten kod to nie ma bledu,ale .... nie mozna sie logowac albo jakwywale wszystko inne, to blad zostaje.

eeyore
Zasłużony
Posty: 158
Rejestracja: 15 maja 2005, 20:16
Kontakt:

Post autor: eeyore » 11 grudnia 2005, 21:22

Podaj adres... I plik z tym kodem...
"Trochę Względów, trochę Troski o Innych. W tym cała rzecz. Tak przynajmniej mówią." - Kłapouchy

spineless
Posty: 6
Rejestracja: 10 grudnia 2005, 20:22

Post autor: spineless » 11 grudnia 2005, 21:34

To jest caly plik. Nie mam adresu bo robie to lokalnie...narazie przynajemniej.
Po wyrzuceniu tych liniejek z session.php

setcookie($cookiename . '_data', serialize($sessiondata), $current_time + 31536000, $cookiepath, $cookiedomain, $cookiesecure);

setcookie($cookiename . '_sid', $session_id, 0, $cookiepath, $cookiedomain, $cookiesecure);

(forum/include/session.php), bledow nie mam jak na razie,ale nie wiem co mi nie bedzie dzialalo bez tych ciasteczek.

Kod: Zaznacz cały

<?php

define('IN_PHPBB', true);
$phpbb_root_path = './phpBB2/';
$page_path = 'index.php/';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
init_userprefs($userdata);

//zmienne odpowiadajace za statsy
$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];
//koniec zmienne odpowiadajace za statsy poczatek zmienne odp. za logowanie
$scfile=explode("/",$_SERVER['PHP_SELF']);
$redir = "../index.php";
?>


Statystyki:

<?php
echo("Użytkowników: ".$total_users."<br>Postów: ".$total_posts."<br>Ostatnio zarejestrowny: <a href=phpBB2/profile.php?mode=viewprofile&u=".$newest_uid.">".
$newest_user."</A>");

?>


Logowanie:

<?php

//link pierwszy LOGIN
if( $userdata['session_logged_in'] )

{
//powitanie
echo '<center><b>Witaj '.$userdata['username'].'</b></center><br>';
//edytuj profil
echo '   |  <A HREF="'.append_sid($phpbb_root_path.'profile.php?mode=editprofile').'">Edytuj profil</A><br>';

//kod odpowiadający za prywatne wiadomosci
if ( ($userdata['session_logged_in']) && (empty($gen_simple_header)) )
{
if ( $userdata['user_new_privmsg'] )
{
$l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms'];
$l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']);

if ( $userdata['user_last_privmsg'] > $userdata['user_lastvisit'] )
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_last_privmsg = " . $userdata['user_lastvisit'] . "
WHERE user_id = " . $userdata['user_id'];
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not update private message new/read time for user', '', __LINE__, __FILE__, $sql);
}

$s_privmsg_new = 1;
$icon_pm = $images['pm_new_msg'];
}
else
{
$s_privmsg_new = 0;
$icon_pm = $images['pm_new_msg'];
}
}
else
{
$l_privmsgs_text = $lang['No_new_pm'];

$s_privmsg_new = 0;
$icon_pm = $images['pm_no_new_msg'];
}

if ( $userdata['user_unread_privmsg'] )
{
$l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms'];
$l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']);
}
else
{
$l_privmsgs_text_unread = $lang['No_unread_pm'];
}
}
else
{
$icon_pm = $images['pm_no_new_msg'];
$l_privmsgs_text = $lang['Login_check_pm'];
$l_privmsgs_text_unread = '';
$s_privmsg_new = 0;
}
//link Prywatne Wiadomości
echo '   | <a href="'.append_sid("phpBB2/privmsg.".$phpEx."?folder=inbox") . '" onclick="jump_to_inbox();return false;" target="_new">'.$userdata['user_new_privmsg'].'</a><br>';
//link wyloguj
echo '   |  <a href="'.append_sid('phpBB2/login.php?logout=true&redirect='.$redir.'&sid='.$userdata['session_id']).'">Wyloguj</a><br>';

}
//to wszystko jak jesteśmy zalogowani, pokazuje opcje
else
//to wszystko jak nie jesteśmy zalogowni, pokazują sie formularze
{
echo '<center>
<form method="post" action="phpBB2/login.php" STYLE="display: inline" name="login">
<input width="100" height="16" type="text" name="username">
<input width="100" height="16" type="password" name="password">
<input type="hidden" name="redirect" value="../index.php">
<input type=hidden name=login value="login">
<input class="text" type="checkbox" name="autologin">Zamiętaj mnie<br>
<input width="53" height="14" type="submit" value="Zaloguj">
</form>';

//link zarejestruj
echo '<A HREF="'.append_sid($phpbb_root_path.'profile.php?mode=register').'" class=l>Rejestracja</a>';
//link zapomniałem hasła
echo '<A HREF="'.append_sid($phpbb_root_path.'profile.php?mode=sendpassword').'" class=l>Zapomniałem hasło</a>';
}
?>

MdK
Zasłużony
Posty: 414
Rejestracja: 17 maja 2005, 18:02
Lokalizacja: Lubiewo
Kontakt:

Post autor: MdK » 12 grudnia 2005, 16:39

Kod: Zaznacz cały

<?php 

define('IN_PHPBB', true); 
$phpbb_root_path = './phpBB2/'; 
$page_path = 'index.php/'; 
include($phpbb_root_path . 'extension.inc'); 
include($phpbb_root_path . 'common.'.$phpEx); 

$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length); 
init_userprefs($userdata); 

//zmienne odpowiadajace za statsy 
$total_posts = get_db_stat('postcount'); 
$total_users = get_db_stat('usercount'); 
$newest_userdata = get_db_stat('newestuser'); 
$newest_user = $newest_userdata['username']; 
$newest_uid = $newest_userdata['user_id']; 
//koniec zmienne odpowiadajace za statsy poczatek zmienne odp. za logowanie 
$scfile=explode("/",$_SERVER['PHP_SELF']); 
$redir = "../index.php"; 
?> 
Ten fragment daj na sam poczatek kodu storny (przed html).

Kod: Zaznacz cały

<?php 

//link pierwszy LOGIN 
if( $userdata['session_logged_in'] ) 

{ 
//powitanie 
echo '<center><b>Witaj '.$userdata['username'].'</b></center><br>'; 
//edytuj profil 
echo '   |  <A HREF="'.append_sid($phpbb_root_path.'profile.php?mode=editprofile').'">Edytuj profil</A><br>'; 

//kod odpowiadający za prywatne wiadomosci 
if ( ($userdata['session_logged_in']) && (empty($gen_simple_header)) ) 
{ 
if ( $userdata['user_new_privmsg'] ) 
{ 
$l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms']; 
$l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']); 

if ( $userdata['user_last_privmsg'] > $userdata['user_lastvisit'] ) 
{ 
$sql = "UPDATE " . USERS_TABLE . " 
SET user_last_privmsg = " . $userdata['user_lastvisit'] . " 
WHERE user_id = " . $userdata['user_id']; 
if ( !$db->sql_query($sql) ) 
{ 
message_die(GENERAL_ERROR, 'Could not update private message new/read time for user', '', __LINE__, __FILE__, $sql); 
} 

$s_privmsg_new = 1; 
$icon_pm = $images['pm_new_msg']; 
} 
else 
{ 
$s_privmsg_new = 0; 
$icon_pm = $images['pm_new_msg']; 
} 
} 
else 
{ 
$l_privmsgs_text = $lang['No_new_pm']; 

$s_privmsg_new = 0; 
$icon_pm = $images['pm_no_new_msg']; 
} 

if ( $userdata['user_unread_privmsg'] ) 
{ 
$l_message_unread = ( $userdata['user_unread_privmsg'] == 1 ) ? $lang['Unread_pm'] : $lang['Unread_pms']; 
$l_privmsgs_text_unread = sprintf($l_message_unread, $userdata['user_unread_privmsg']); 
} 
else 
{ 
$l_privmsgs_text_unread = $lang['No_unread_pm']; 
} 
} 
else 
{ 
$icon_pm = $images['pm_no_new_msg']; 
$l_privmsgs_text = $lang['Login_check_pm']; 
$l_privmsgs_text_unread = ''; 
$s_privmsg_new = 0; 
} 
//link Prywatne Wiadomości 
echo '   | <a href="'.append_sid("phpBB2/privmsg.".$phpEx."?folder=inbox") . '" onclick="jump_to_inbox();return false;" target="_new">'.$userdata['user_new_privmsg'].'</a><br>'; 
//link wyloguj 
echo '   |  <a href="'.append_sid('phpBB2/login.php?logout=true&redirect='.$redir.'&sid='.$userdata['session_id']).'">Wyloguj</a><br>'; 

} 
//to wszystko jak jesteśmy zalogowani, pokazuje opcje 
else 
//to wszystko jak nie jesteśmy zalogowni, pokazują sie formularze 
{ 
echo '<center> 
<form method="post" action="phpBB2/login.php" STYLE="display: inline" name="login"> 
<input width="100" height="16" type="text" name="username"> 
<input width="100" height="16" type="password" name="password"> 
<input type="hidden" name="redirect" value="../index.php"> 
<input type=hidden name=login value="login"> 
<input class="text" type="checkbox" name="autologin">Zamiętaj mnie<br> 
<input width="53" height="14" type="submit" value="Zaloguj"> 
</form>'; 

//link zarejestruj 
echo '<A HREF="'.append_sid($phpbb_root_path.'profile.php?mode=register').'" class=l>Rejestracja</a>'; 
//link zapomniałem hasła 
echo '<A HREF="'.append_sid($phpbb_root_path.'profile.php?mode=sendpassword').'" class=l>Zapomniałem hasło</a>'; 
} 
?>
To w miejsce gdzie ma być okienko z logowaniem :)

Zablokowany

Wróć do „Pomoc”