PhpBB Wiki Integration2

From PHPBB用户手册

Jump to: navigation, search

打开phpbb的login.php, 添加如下两段

if (!$userdata['session_logged_in']) {
			if( isset($HTTP_POST_VARS['redirect']) || isset($HTTP_GET_VARS['redirect']) )
			{
				$forward_to = $HTTP_SERVER_VARS['QUERY_STRING'];
	
				if( preg_match("/^redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si", $forward_to, $forward_matches) )
				{
					$forward_to = ( !empty($forward_matches[3]) ) ? $forward_matches[3] : $forward_matches[1];
					$forward_match = explode('&', $forward_to);
	
					if(count($forward_match) > 1)
					{
						for($i = 0; $i < count($forward_match); $i++)
						{
							if( !ereg("sid=", $forward_match[$i]) )
							{
								if( $forward_page != '' )
								{
									$forward_page .= '_';
								}
								$forward_page .= $forward_match[$i];
							}
						}
					}
					else
					{
						$forward_page = $forward_match[0];
					}
				}
			}
			redirect('...$forward_page);
		}

if( isset($HTTP_POST_VARS['redirect']) || isset($HTTP_GET_VARS['redirect']) )
		{
			$forward_to = $HTTP_SERVER_VARS['QUERY_STRING'];
			if( preg_match("/redirect=([a-z0-9\.#\/\?&=\+\-_]+)/si", $forward_to, $forward_matches) )
			{
				$forward_to = ( !empty($forward_matches[3]) ) ? $forward_matches[3] : $forward_matches[1];
				$forward_match = explode('&', $forward_to);

				if(count($forward_match) > 1)
				{
					for($i = 0; $i < count($forward_match); $i++)
					{
						if( !ereg("sid=", $forward_match[$i]) )
						{
							if( $forward_page != '' )
							{
								$forward_page .= '_';
							}
							$forward_page .= $forward_match[$i];
						}
					}
				}
				else
				{
					$forward_page = $forward_match[0];
				}
			}
		}
		redirect('..'.$forward_page);