Fehler bei Redirect (Mod: Login Redirection Suite)

Du hast Probleme beim Einbau oder bei der Benutzung eines Mods? In diesem Forum bist du richtig.
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.0, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
Antworten
jensdd
Mitglied
Beiträge: 82
Registriert: 16.08.2008 21:23
Wohnort: Dresden
Kontaktdaten:

Fehler bei Redirect (Mod: Login Redirection Suite)

Beitrag von jensdd »

Ich habe den Mod Login Redirection Suite von Phantomk eingebaut. Leider enthält die Weiterleitung noch einen Fehler:

websitename.de/forum/login.php?redirect=forumviewforum.php&f=6

Das rot markierte "forum" darf dort nicht stehen. Da das auf allen Seiten im Login und Logout passiert, vermute ich mal, dass der String falsch zusammengesetzt wird, weil mein Board nicht im Root-Verzeichnis, sondern eine Ebene tiefer im Ordner "forum" liegt.
Der Teil, der die URL ausliest und übergibt, befindet sich in der functions.php:

Code: Alles auswählen

//-- mod : Login Redirection Suite --------------------------------------------- 
//-- add 
function get_redirect($link=false, $amp=false) 
{ 
   global $HTTP_SERVER_VARS; 
   global $phpEx; 

   $url_page = ''; 

   // 
   // Borrowed code from login.php 
   // 
   $url_to = $HTTP_SERVER_VARS['QUERY_STRING']; 

   if ( preg_match("/^redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si", $url_to, $url_matches) ) 
   { 
      $url_to = ( !empty($url_matches[3]) ) ? $url_matches[3] : $url_matches[1]; 
      $url_match = explode('&', $url_to); 

      if ( count($url_match) > 1 ) 
      { 
         for ($i = 1; $i < count($url_match); $i++) 
         { 
            if ( !ereg("sid=", $url_match[$i]) ) 
            { 
               if ( $url_page != '' ) 
               { 
                  $url_page .= ( $amp ? '&' : '&' ); 
               } 

               $url_page .= $url_match[$i]; 
            } 
         } 

         $url_page = $url_match[0] . ( $link ? ( $amp ? '&' : '&' ) : '?' ) . $url_page; 
      } 
      else 
      { 
         $url_page = $url_match[0]; 
      } 
   } 
   else if ( preg_match("/^logout=true&redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si", $url_to, $url_matches) ) 
   { 
      $url_to = ( !empty($url_matches[3]) ) ? $url_matches[3] : $url_matches[1]; 
      $url_match = explode('&', $url_to); 

      if ( count($url_match) > 1 ) 
      { 
         for ($i = 1; $i < count($url_match); $i++) 
         { 
            if ( !ereg("sid=", $url_match[$i]) ) 
            { 
               if ( $url_page != '' ) 
               { 
                  $url_page .= ( $amp ? '&' : '&' ); 
               } 

               $url_page .= $url_match[$i]; 
            } 
         } 

         $url_page = $url_match[0] . ( $link ? ( $amp ? '&' : '&' ) : '?' ) . $url_page; 
      } 
      else 
      { 
         $url_page = $url_match[0]; 
      } 
   } 

   if ( strstr(urldecode($url_page), "\n") || strstr(urldecode($url_page), "\r") ) 
   { 
      message_die(GENERAL_ERROR, 'Tried to redirect to potentially insecure url.'); 
   } 

   if ( empty($url_page) ) 
   { 
      $url_page = "index." . $phpEx; 
   } 

   return $url_page; 
} 

function get_url($amp=false) 
{ 
   global $HTTP_POST_VARS, $HTTP_GET_VARS, $HTTP_SERVER_VARS; 
   global $board_config; 

   // 
   // Extract the query variables from the url 
   // 
   parse_str($HTTP_SERVER_VARS['QUERY_STRING'], $outputs); 

   foreach ($outputs as $var => $string) 
   { 
      // 
      // Remove the sid variable from the url 
      // 
      if ($string != $outputs['sid']) 
      { 
         $query_vars[] = $var . '=' . $string; 
      } 
   } 

   // 
   // Don't whine if thier is an error, any urls that don't have query's 
   // 
   $queryVars = @implode(( $amp ? '&' : '&' ), $query_vars); 

   // 
   // Replace the script_path with nothing since the link is always going to be in the same place as the path of the file 
   // 
   $php_self_var = str_replace($board_config['script_path'], '', $HTTP_SERVER_VARS['PHP_SELF']); 

   // 
   // Put the url back together 
   // 
   $url = (!empty($query_vars)) ? $php_self_var . ( $amp ? '&' : '&' ) . $queryVars : $php_self_var; 

   return $url; 
} 
//-- fin mod : Login Redirection Suite ----------------------------------------- 
Was muss ich am Code ändern? Ist sicher nur ne Kleinigkeit, aber ich bin PHP-Neuling ...
Vielen Dank vorab für eure Hilfe!!

Jens
jensdd
Mitglied
Beiträge: 82
Registriert: 16.08.2008 21:23
Wohnort: Dresden
Kontaktdaten:

Beitrag von jensdd »

Nach einigem Grübeln habe ich eine (nicht ganz saubere) Lösung gefunden. In der functions.php muss Folgendes ersetzt werden, um den Ordnernamen "forum" zu entfernen:

Code: Alles auswählen

	//
	// Replace the script_path with nothing since the link is always going to be in the same place as the path of the file
	//
	$php_self_var = str_replace($board_config['script_path'], '', $HTTP_SERVER_VARS['PHP_SELF']);
	$php_self_var = ltrim($php_self_var, "forum");
Außerdem habe ich zusätzlich zur Einbau-Beschreibung des Mods in der login.php noch einen weiterer Abschnitt (if ... else ...) ersetzt. Kann aber an meinem Orion-Board liegen, das nicht 1:1 identisch mit dem phpbb ist.
Die Weiterleitung nach dem Logout kann man individuell anpassen. Entweder zur letzten Seite zurück oder zum Portal bzw. Forenindex.
Jetzt, wo es funktioniert, eine feine Sache :wink:

Jens
Antworten

Zurück zu „phpBB 2.0: Mod Support“