Planuję przeprojektować moją stronę, zrezygnować z Postnuke'a, a tym samym z forum jako modułu i przejść na phpBB2. Jednoczesnie nie chciałbym tracić linków z innych stron do mojego obecnego forum, dlatego mam taki problem do rozwiązania:
Do serwera przychodzi zapytanie: http://www.mojastrona.pl/index.php?name=PN...pic&p=3860#3860. Po zmianie na phpBB2 taka strona już nie istnieje, więc skrypt php, wyciąga 3860#3860 i konwertuje adres na: http://www.mojastrona.pl/phpbb2/viewtopic.php?p=3860#3860.
W innym wypadku Użytkownicy otrzymają komunikat o braku strony.
Czy macie moze jakiś pomysł na rozwiązanie tego problemu?
Znalazłem taki skrypt,
  1. <?php
  2. #usage:
  3. $r = new HTTPRequest('http://www.mojastrona.pl/phpbb2/viewtopic.php?p=3860#3860');
  4. echo $r->DownloadToString();
  5.  
  6. class HTTPRequest
  7. {
  8.  var $_fp; // HTTP socket
  9.  var $_url; // full URL
  10.  var $_host; // HTTP host
  11.  var $_protocol; // protocol (HTTP/HTTPS)
  12.  var $_uri; // request URI
  13.  var $_port; // port
  14.  
  15.  // scan url
  16.  function _scan_url()
  17.  {
  18.  $req = $this->_url;
  19.  
  20.  $pos = strpos($req, '://');
  21.  $this->_protocol = strtolower(substr($req, 0, $pos));
  22.  
  23.  $req = substr($req, $pos+3);
  24.  $pos = strpos($req, '/');
  25.  if($pos === false)
  26.  $pos = strlen($req);
  27.  $host = substr($req, 0, $pos);
  28.  
  29.  if(strpos($host, ':') !== false)
  30.  {
  31.  list($this->_host, $this->_port) = explode(':', $host);
  32.  }
  33.  else 
  34.  {
  35.  $this->_host = $host;
  36.  $this->_port = ($this->_protocol == 'https') ? 443 : 80;
  37.  }
  38.  
  39.  $this->_uri = substr($req, $pos);
  40.  if($this->_uri == '')
  41.  $this->_uri = '/';
  42.  }
  43.  
  44.  // constructor
  45.  function HTTPRequest($url)
  46.  {
  47.  $this->_url = $url;
  48.  $this->_scan_url();
  49.  }
  50.  
  51.  // download URL to string
  52.  function DownloadToString()
  53.  {
  54.  $crlf = "\r\n";
  55.  
  56.  // generate request
  57.  $req = 'GET ' . $this->_uri . ' HTTP/1.0' . $crlf
  58.  . 'Host: ' . $this->_host . $crlf
  59.  . $crlf;
  60.  
  61.  // fetch
  62.  $this->_fp = fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port);
  63.  fwrite($this->_fp, $req);
  64.  while(is_resource($this->_fp) && $this->_fp && !feof($this->_fp))
  65.  $response .= fread($this->_fp, 1024);
  66.  fclose($this->_fp);
  67.  
  68.  // split header and body
  69.  $pos = strpos($response, $crlf . $crlf);
  70.  if($pos === false)
  71.  return($response);
  72.  $header = substr($response, 0, $pos);
  73.  $body = substr($response, $pos + 2 * strlen($crlf));
  74.  
  75.  // parse headers
  76.  $headers = array();
  77.  $lines = explode($crlf, $header);
  78.  foreach($lines as $line)
  79.  if(($pos = strpos($line, ':')) !== false)
  80.  $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos+1));
  81.  
  82.  // redirection?
  83.  if(isset($headers['location']))
  84.  {
  85.  $http = new HTTPRequest($headers['location']);
  86.  return($http->DownloadToString($http));
  87.  }
  88.  else 
  89.  {
  90.  return($body);
  91.  }
  92.  }
  93. }
  94. ?> 

który wyświetli stronę zdefiniowaną w trzeciej linijce kodu. Wiem, że funkcja parse_url zwraca w tablicy asocjacyjnej wszystkie składowe przetwarzanego URL'a. W tym wypadku składową adresu query - po znaku ? czyli "?name=PNphpBB2&file=viewtopic&p=3860#3860" Niestety nie potrafie połączyć tego wszystkiego razem.
Proszę o pomoc.
Pozdrawiam