Strona 1 z 1

Problem z cookie [Zewnętrzne logowanie + forum]

: 12 października 2011, 15:19
autor: mAsHERR
Witam,

Mam problem, ponieważ do swojego forum w phpbb3.0.9 dołożyłem Zewnętrzne logowanie.

http://www.nazwa_strony.pl/index.php - Zewnętrzne logowanie
http://www.ziip11.up4y.pl/forum/index.php - po porwanym zalogowaniu przenosi na forum

Wszystko ładnie działa tylko wyświetla mi błąd u góry strony:

Kod: Zaznacz cały

[phpBB Debug] PHP Warning: in file /includes/session.php on line 1035: Cannot modify header information - headers already sent by (output started at /home/użytkownik/domains/nazwa_strony.pl/public_html/index.php:3)
[phpBB Debug] PHP Warning: in file /includes/session.php on line 1035: Cannot modify header information - headers already sent by (output started at /home/użytkownik/domains/nazwa_strony.pl/public_html/index.php:3)
[phpBB Debug] PHP Warning: in file /includes/session.php on line 1035: Cannot modify header information - headers already sent by (output started at /home/użytkownik/domains/nazwa_strony.pl/public_html/index.php:3)
/includes/session.php on line 1035 zawieta:

Kod: Zaznacz cały

header('Set-Cookie: ' . $name_data . (($cookietime) ? '; expires=' . $expire : '') . '; path=' . $config['cookie_path'] . $domain . ((!$config['cookie_secure']) ? '' : '; secure') . '; HttpOnly', false);

kod mojego zewnętrznego logowania:

Kod: Zaznacz cały

<head>
<title>Nazwa_Strony</title>
<style type="text/css">
<!--
body,td,th {
	color: #FFFFFF;
}
body {
	background-color: #000000;
}
.styl1 {
	color: #FF0000;
	font-weight: bold;
}
-->
</style></head>

<body>
<p>
<?php
  define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
 
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

if($user->data['is_registered'])
{
echo '<br /><br /><br /><br /><br /><table width="200" border="0" align="center">
  <tr>
    <td><a href="http://www.nazwa_strony.pl/forum/index.php"><img src="przejdz_do_forum.png" width="454" height="71" /></a></td>
    <td><img src="logo3.png" width="267" height="425" /></td>
  </tr>
</table></a>';


}
  else if(isset($_POST['login']))
  {
  $username = request_var('username', '', true);
  $password = request_var('password', '', true);
  $autologin = (!empty($_POST['autologin'])) ? true : false;
  
  $result = $auth->login($username, $password, $autologin);
  
  if ($result['status'] == LOGIN_SUCCESS)
  {
  //User was successfully logged into phpBB
  $redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");
  
  // append/replace SID
  $redirect = reapply_sid($redirect);
  
  meta_refresh(0, $redirect);
  trigger_error('You have been logged in');
  }
  else
  {
  echo '

<p align="center"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />Podałeś/-aś złe dane użytkownika. <br /><br /><br />Spróbuj ponownie --> <a href="http://www.nazwa_strony.pl/index.php" class="styl1">POWRÓT</a> <--'; //User's login failed
    }
}
else
{
	echo ' <br />
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><img src="napis.png" width="652" height="227" /></p>
<form method="POST" action="">
  <p align="center">Login: 
          <input type="text" name="username" size="25">
        Hasło: 
        <input type="password" name="password" size="25"></p>
        <p align="center">
        <input type="submit" value="Zaloguj" name="login" />
        <a href="http://www.nazwa_strony.pl/forum/ucp.php?mode=register"><img src="zarejestruj.png" width="85" height="22" align="absmiddle" /></a>
        Zapamiętaj mnie: 
          <input type="checkbox" name="autologin">
        </p>
</form>';
		
}
?>
</body>
</html>

Z tego co wywnioskowałem to gryzą się ciasteczka. Gdy usunę linijkę 1035 z session.php to problem z wywalaniem błędu znika natomiast pojawia się błąd z "autologowaniem" na pierwszej, zewnętrznej stronie.

Mógłby mi ktos doradzić, pomóc jak to rozwiązać??

Re: Problem z cookie [Zewnętrzne logowanie + forum]

: 13 października 2011, 15:28
autor: jaroslw
Spróbuj wyciąć poniższy kod i wrzucić na sam początek pliku, nawet przed deklaracją DOCTYPE, tak by nagłówek został wysłany jako pierwszy:

Kod: Zaznacz cały

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup(); 

Re: Problem z cookie [Zewnętrzne logowanie + forum]

: 13 października 2011, 21:35
autor: mAsHER
Niestety wyskakuje :

Kod: Zaznacz cały

Parse error: syntax error, unexpected '<' in /home/ziipupyp/domains/ziip11.up4y.pl/public_html/index.php on line 11
natomiast 11 linia index.php to jest:

Kod: Zaznacz cały

<head>

bo kod index.php jest:

Kod: Zaznacz cały

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup(); 
<head>
<title>Nazwa_Strony</title>
<style type="text/css">

Re: Problem z cookie [Zewnętrzne logowanie + forum]

: 13 października 2011, 21:40
autor: jaroslw
Zapomniałem o znaczniku zamykającym dla <?php. Dodaj po $user->setup(); znacznik ?>.

Re: Problem z cookie [Zewnętrzne logowanie + forum]

: 13 października 2011, 22:07
autor: mAsHER
dałem na sam poczatek i dalej to samo:/

Kod: Zaznacz cały

<?php
  define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
 
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
?>

Re: Problem z cookie [Zewnętrzne logowanie + forum]

: 15 października 2011, 09:49
autor: mAsHER
Wie ktos moze chociaz jak ukryć ten debugg ? Bo wszystko działa wporządku tylko, żeby nie każdy musial ogladac jak go wywala na stronie głównej :/

Re: Problem z cookie [Zewnętrzne logowanie + forum]

: 15 października 2011, 13:22
autor: jaroslw
Pokaż cały obecny kod. Lepiej problem rozwiązać, niż udawać, że go nie ma. Ewentualnie sprawdź czy w config.php nie masz dodatkowo włączonego trybu debugowania.

Re: Problem z cookie [Zewnętrzne logowanie + forum]

: 16 października 2011, 09:25
autor: mAsHER
To jest kod zewnętrznego logowania index.php

Kod: Zaznacz cały

<?php
  define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
 
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
<head>
<link rel="shortcut icon" href="forum/images/favicon.ico" type="image/x-icon" />
<title>Tytyl_strony</title>
<style type="text/css">
?>.
<!--
body,td,th {
	color: #FFFFFF;
}
body {
	background-color: #000000;
}
.styl1 {
	color: #FF0000;
	font-weight: bold;
}
-->
</style></head>

<body>
<p>

<?php
if($user->data['is_registered'])
{
echo '<br /><br /><br /><br /><br /><table width="200" border="0" align="center">
  <tr>
    <td><a href="http://www.nazwa_strony.pl/forum/index.php"><img src="przejdz2.png" width="454" height="71" /></a></td>
    <td><img src="logo3.png" width="267" height="425" /></td>
  </tr>
</table></a>';
$redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");
$redirect = reapply_sid($redirect);
meta_refresh(3, $redirect); 
}
  else if(isset($_POST['login']))
  {
  $username = request_var('username', '', true);
  $password = request_var('password', '', true);
  $autologin = (!empty($_POST['autologin'])) ? true : false;
  
  $result = $auth->login($username, $password, $autologin);
  
  if ($result['status'] == LOGIN_SUCCESS)
  {
  //User was successfully logged into phpBB
  $redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");
  
  // append/replace SID
  $redirect = reapply_sid($redirect);
  
  meta_refresh(0, $redirect);
  trigger_error('You have been logged in');
  }
  else
  {
  echo '

<p align="center"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />Podałeś/-aś złe dane użytkownika. <br /><br /><br />Spróbuj ponownie --> <a href="http://www.nazwa_strony.pl/index.php" class="styl1">POWRÓT</a> <--'; //User's login failed
    }
}
else
{
	echo ' <br />
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><img src="napis.png" width="652" height="227" /></p>
<form method="POST" action="">
  <p align="center">Login: 
          <input type="text" name="username" size="25">
        Hasło: 
        <input type="password" name="password" size="25"></p>
        <p align="center">
        <input type="submit" value="Zaloguj" name="login" />
        <a href="http://www.nazwa_strony.pl/forum/ucp.php?mode=register"><img src="zarejestruj.png" width="85" height="22" align="absmiddle" /></a>
        Zapamiętaj mnie: 
          <input type="checkbox" name="autologin">
        </p>
</form>';
		
}
?>
</body>
</html>
to jest kawałek config.php

Kod: Zaznacz cały

@define('PHPBB_INSTALLED', true);
// @define('DEBUG', true);
// @define('DEBUG_EXTRA', true);

Re: Problem z cookie [Zewnętrzne logowanie + forum]

: 17 października 2011, 21:42
autor: jaroslw
Sprawdź:

Kod: Zaznacz cały

<?php
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
?>
<!DOCTYPE HTML>
<html>
<head>
<link rel="shortcut icon" href="forum/images/favicon.ico" type="image/x-icon" />
<title>Tytyl_strony</title>
<style type="text/css">
<!--
body,td,th {
   color: #FFFFFF;
}
body {
   background-color: #000000;
}
.styl1 {
   color: #FF0000;
   font-weight: bold;
}
-->
</style></head>

<body>
<p>

<?php
if($user->data['is_registered'])
{
echo '<br /><br /><br /><br /><br /><table width="200" border="0" align="center">
  <tr>
    <td><a href="http://www.nazwa_strony.pl/forum/index.php"><img src="przejdz2.png" width="454" height="71" /></a></td>
    <td><img src="logo3.png" width="267" height="425" /></td>
  </tr>
</table></a>';
$redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");
$redirect = reapply_sid($redirect);
meta_refresh(3, $redirect); 
}
  else if(isset($_POST['login']))
  {
  $username = request_var('username', '', true);
  $password = request_var('password', '', true);
  $autologin = (!empty($_POST['autologin'])) ? true : false;
  
  $result = $auth->login($username, $password, $autologin);
  
  if ($result['status'] == LOGIN_SUCCESS)
  {
  //User was successfully logged into phpBB
  $redirect = request_var('redirect', "{$phpbb_root_path}index.$phpEx");
  
  // append/replace SID
  $redirect = reapply_sid($redirect);
  
  meta_refresh(0, $redirect);
  trigger_error('You have been logged in');
  }
  else
  {
  echo '

<p align="center"><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />Podałeś/-aś złe dane użytkownika. <br /><br /><br />Spróbuj ponownie --> <a href="http://www.nazwa_strony.pl/index.php" class="styl1">POWRÓT</a> <--'; //User's login failed
    }
}
else
{
   echo ' <br />
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center"><img src="napis.png" width="652" height="227" /></p>
<form method="POST" action="">
  <p align="center">Login: 
          <input type="text" name="username" size="25">
        Hasło: 
        <input type="password" name="password" size="25"></p>
        <p align="center">
        <input type="submit" value="Zaloguj" name="login" />
        <a href="http://www.nazwa_strony.pl/forum/ucp.php?mode=register"><img src="zarejestruj.png" width="85" height="22" align="absmiddle" /></a>
        Zapamiętaj mnie: 
          <input type="checkbox" name="autologin">
        </p>
</form>';
      
}
?>
</body>
</html>

Re: Problem z cookie [Zewnętrzne logowanie + forum]

: 18 października 2011, 11:51
autor: mAsHER
niestety tez nic :/

Re: Problem z cookie [Zewnętrzne logowanie + forum]

: 14 grudnia 2011, 11:35
autor: trajano
A w jaki sposób najprościej podłączyć nowy panel z zalogowaniem siena forum? Chciałbym aby po zalogowaniu siena forum użytkownik miał możliwość dodawania filmów do swojej galerii, muszę napisać taki skrypt sam ale chciałbym to połączyć z logowaniem siędo forum, aby użytkownicy nie musieli po kilka razy logować się na stronie. Najprościej byłoby zrobić sprawdzenie ciasteczek ale pojęcia nie mam co dokładnie sprawdzić. Może ktoś mi pomóc? Jeszcze nie napisalem kodu dla galerii wideo.

Re: Problem z cookie [Zewnętrzne logowanie + forum]

: 16 grudnia 2011, 09:57
autor: jaroslw
Jeśli jeszcze nie zacząłeś pisać kodu, proponuję skorzystać z klas i funkcji dostępnych w phpBB. Przyda Ci się przede wszystkim klasa user. To powinno być pomocne:
http://wiki.phpbb.com/Using_phpBB3%27s_Basic_Functions
http://www.phpbb.com/kb/article/phpbb3- ... tegration/
http://www.phpbb.com/kb/article/phpbb3- ... tegration/