Templates vor ausgabe editieren

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

Templates vor ausgabe editieren

Beitrag von Rhisis »

Hallo,
ich hab folgende Änderung in der functions.php (ein paar andre Dateien auch editiert)

Code: Alles auswählen

function append_sid($url, $params = false, $is_amp = true, $session_id = false)
{
	global $_SID, $_EXTRA_URL, $phpbb_hook;
global $phpbb_root_path, $phpEx;
	if ($url === "{$phpbb_root_path}index.$phpEx")
	{
		return append_sid($phpbb_root_path);
	}

//if(stripos($params,"redirect") != false)
//{
//preg_match("/redirect(.*)$/",$params,$addit);
$params = preg_replace("/(?|&|&)redirect=(.*)$/","",$params);
//$addit="redirect".$addit[1];
//}
if(stripos($url,".php") != false ){//&& stripos($url,"adm/") == false){
$isphp = true;
}else{
$isphp = false;
}



if($isphp == true){
$url = str_replace(".php","", $url);
$url = str_replace("?",",", $url);
$url = str_replace("&",",", $url);
$url = str_replace("&",",", $url);
$url = str_replace("=",".", $url);
$params = str_replace("?",",", $params);
$params = str_replace("&",",", $params);
$params = str_replace("&",",", $params);
$params = str_replace("=",".", $params);
}
	// Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropiatly.
	// They could mimick most of what is within this function
	if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id))
	{
		if ($phpbb_hook->hook_return(__FUNCTION__))
		{
			return $phpbb_hook->hook_return_result(__FUNCTION__);
		}
	}


	// Assign sid if session id is not specified
if ($session_id === false)
{
   $session_id = $_SID;
}

global $user;
if ($user->data['user_id'] == ANONYMOUS OR $user->data['is_bot'] )
{
   $session_id = false;
}


	if($isphp == true){
  $amp_delim = ",";
  $url_delim = ",";
  $amp2_delim = ($is_amp) ? '&' : '&';
  $url2_delim = (strpos($url, '?') === false) ? '?' : $amp_delim;
  }else{
  $amp_delim = ($is_amp) ? '&' : '&';
	$url_delim = (strpos($url, '?') === false) ? '?' : $amp_delim;
  }
	// Appending custom url parameter?
	$append_url = (!empty($_EXTRA_URL)) ? implode($amp_delim, $_EXTRA_URL) : '';

	$anchor = '';
	if (strpos($url, '#') !== false)
	{
		list($url, $anchor) = explode('#', $url, 2);
		$anchor = '#' . $anchor;
	}
	else if (!is_array($params) && strpos($params, '#') !== false)
	{
		list($params, $anchor) = explode('#', $params, 2);
		$anchor = '#' . $anchor;
	}

	// Use the short variant if possible ;)
	if ($params === false)
	{
		// Append session id
		if (!$session_id)
		{
      if($isphp == true){
			return $url . (($append_url) ? $url_delim . $append_url : '') . ".html" . (($addit) ? "?".$addit : ''). $anchor;
			}else{
			return $url . (($append_url) ? $url_delim . $append_url : '') . $anchor;
			}
		}
		else
		{
      if($isphp == true){
			return $url . (($append_url) ? $url_delim . $append_url :'') ."html".(($addit) ? "?".$addit.$amp2_delim : "?").'sid=' . $session_id . $anchor;
			}else{
			return $url . (($append_url) ? $url_delim . $append_url . $amp_delim : $url_delim) . 'sid=' . $session_id . $anchor;
			}
		}
	}

	// Build string if parameters are specified as array
	if (is_array($params))
	{
		$output = array();

		foreach ($params as $key => $item)
		{
			if ($item === NULL)
			{
				continue;
			}

			if ($key == '#')
			{
				$anchor = '#' . $item;
				continue;
			}
      if($isphp == true){
			$output[] = $key . '_' . $item;
			}else{
			$output[] = $key . '=' . $item;
			}
		}

		$params = implode($amp_delim, $output);
	}

	// Append session id and parameters (even if they are empty)
	// If parameters are empty, the developer can still append his/her parameters without caring about the delimiter
	if($isphp == true){
	return $url . (($append_url) ? $url_delim . $append_url . $amp_delim : (($params) ? $url_delim : '')) . $params . ".html". (($addit) ? "?".$addit : "") . ((!$session_id) ? '' : (($addit) ? $amp2_delim : "?") . 'sid=' . $session_id) . $anchor;
  }else{
  return $url . (($append_url) ? $url_delim . $append_url . $amp_delim : $url_delim) . $params . ((!$session_id) ? '' : "?" . 'sid=' . $session_id) . $anchor;
  }
}
Nun werden die php dateien statt datei.php?foo=bar mit datei,foo.bar.html dargestellt. Und bei sid datei,foo.bar.html?sid=sid
Soweit läuft alles gut, aber es gibt ein paar dateien, die hängen nachträglich noch ein & an. Das wird dann datei,foo.bar.html&foo2=bar2 (geht nicht) oder datei,foo.bar.html?sid=sid&foo2=bar2 (geht(
Das kommt vorallem bei Umleitungen vor.
Da ich nicht jede php Datei durchgehen will, wollte ich mal fragen, ob es eine möglichkeit gibt den HTML code kurz vor der Ausgabe zu editieren (str_replace,preg_replace,...)

Gruß Rhisis
Antworten

Zurück zu „[3.0.x] Mod Support“