Napisałem sobie taki kod na zamiane na krótkie url'e:
  1. <?php
  2. function simple_uri() 
  3. {
  4. $uri="old";
  5. $path_info = getenv("PATH_INFO");
  6. $http_query = getenv("QUERY_STRING");
  7. $request_uri = getenv("REQUEST_URI");
  8.  
  9. if ($path_info!='') 
  10. {
  11. if ($http_query!='') {
  12. $uri = $path_info."?".$http_query;
  13. } else {
  14. $uri = basename($path_info);
  15. }
  16. } else {
  17. $uri = basename(getenv("REQUEST_URI"));
  18. }
  19.  
  20. if ($uri == "") {
  21. $uri = "index.php" ;
  22. }
  23. list($uri, $nothing) = explode("?",$uri);
  24. if ($uri == "user.php" || $uri == "admin.php") {
  25. $uri="old";
  26. } else {
  27. if (defined("LOADED_AS_MODULE")) {
  28. $uri="old";
  29. } else {
  30. $uri="new";
  31. }
  32. }
  33. return $uri;
  34. }
  35. function simplify_urls(&$s) 
  36. {
  37. $base_url = pnGetBaseURL();
  38.  
  39. function tyt($id, $tyt) {
  40. $tyts = str_replace(" ","-",$tyt);
  41. return '<a class="pn-title" href="'.$tyts.'-a'.$id.'.html">'.$tyt.'</a>';
  42. }
  43.  
  44. $s = preg_replace('|<a class="pn-title" href="($base_url)?modules.php?op=modload&(amp;)?name=News&(amp;)?file=article&(amp;)?sid=([0-9]+)&(amp;)?mode=thread&(amp;)?order=0&(amp;)?thold=0">(.+?)</a>|', tyt('5', '9'), $s);
  45.  
  46. return $s;
  47. }
  48.  
  49. ?>

Wszystko ładnie działa, oprócz tego że powstaje Nazwa Arta-a390.html zamiast Nazwa-Arta-a390.html. W czym tkwi problem? Zastosowałem przecież str_replace do zamiany spacji na -
Proszę o pomoc