From: <he...@us...> - 2004-12-06 13:12:58
|
Update of /cvsroot/gc-linux/htdocs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9869 Modified Files: docs Log Message: Modified code to not depend on external php_libxslt.so. (This fixes the web site after the move to the new web servers) Indentation changes. Index: docs =================================================================== RCS file: /cvsroot/gc-linux/htdocs/docs,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- docs 3 Mar 2004 12:25:16 -0000 1.2 +++ docs 6 Dec 2004 13:12:47 -0000 1.3 @@ -1,110 +1,93 @@ <? -if(!preg_match("/(\.[^\/]*?|\/)(\?.*)?$/", $_SERVER["REQUEST_URI"])) -{ - $new_uri = $_SERVER["REQUEST_URI"]; - $new_uri = preg_replace("/^([^\?]*?)(\?.*)?$/", - "\\1/\\2", - $new_uri); - header("Status: 301 Moved"); - header("Location: $new_uri"); - exit; +// 20041206 Albert Herranz + +if(!preg_match("/(\.[^\/]*?|\/)(\?.*)?$/", $_SERVER["REQUEST_URI"])) { + $new_uri = $_SERVER["REQUEST_URI"]; + $new_uri = preg_replace("/^([^\?]*?)(\?.*)?$/", + "\\1/\\2", + $new_uri); + header("Status: 301 Moved"); + header("Location: $new_uri"); + exit; } $lang_list = array ("en","de","es","fi","fr","it","nl","pl","se"); $doc_lang = array(); -if (!isset($lang)) - { - $lang = "en"; - } +if (!isset($lang)) { + $lang = "en"; +} $script_url = preg_replace("/^([^\?]*?)(\?.*)?$/", - "\\1", - $_SERVER["REQUEST_URI"]); + "\\1", + $_SERVER["REQUEST_URI"]); $script_name = $_SERVER["SCRIPT_NAME"]; - $pathinfo = preg_replace("'$script_name'", "", "$script_url",1); - $path = preg_split("/\//", "".$pathinfo); - $pathlen = count($path)-1; if (strlen($path[$pathlen])<2) { $path[$pathlen] ="index.xml"; } - -if ($pathlen > 0) -{ - if (strpos($path[$pathlen],"-")===false) - { +if ($pathlen > 0) { + if (strpos($path[$pathlen],"-")===false) { + $language = $lang; + $filename = $path[$pathlen]; + } else { + $start = strpos($path[$pathlen],"-")+1; + $language = substr($path[$pathlen],0,2); + $filename = substr($path[$pathlen],$start); + } +} else { + $filename = "index.xml"; $language = $lang; - $filename = $path[$pathlen]; - } - else - { - $start = strpos($path[$pathlen],"-")+1; - $language = substr($path[$pathlen],0,2); - $filename = substr($path[$pathlen],$start); - } - -} -else -{ - $filename = "index.xml"; - $language = $lang; } -for ($index=1;$index<$pathlen;$index++) -{ +for ($index=1;$index<$pathlen;$index++) { $filepath .= "/".$path[$index]; } $doc = $filename; $filename = ereg_replace(".html",".xml",$filename); + //echo "[language: $language]"; //echo "[filename: $filename]"; //echo "[path: $filepath]"; $root = "./xml"; -for ($index=0;$index<count($lang_list);$index++) - { - if (file_exists($root."/".$lang_list[$index].$filepath."/".$filename)) - { - array_push($doc_lang,$lang_list[$index]); - } - } +for ($index=0;$index<count($lang_list);$index++) { + if (file_exists($root."/".$lang_list[$index].$filepath."/".$filename)) { + array_push($doc_lang,$lang_list[$index]); + } +} reset($path); reset($doc_lang); $file .= $root; -if (!in_array($language,$doc_lang) && (count($doc_lang)!=0)) - { - $file .= "/en".$filepath."/".$filename; - } -else - { - $file .= "/".$language.$filepath."/".$filename; - } +if (!in_array($language,$doc_lang) && (count($doc_lang)!=0)) { + $file .= "/en".$filepath."/".$filename; +} else { + $file .= "/".$language.$filepath."/".$filename; +} //echo "[file to load: $file]"; -if (count($doc_lang)==0) { header("HTTP/1.0 404 Not Found"); exit(); } +if (count($doc_lang)==0) { + header("HTTP/1.0 404 Not Found"); + exit(); +} reset($path); -//dl("php_libxslt.so"); -dl("../../../../../home/groups/g/gc/gc-linux/php/php_libxslt.so"); -$xml = file_get_contents($file); -if (strstr($doc,"faq.html")===false) - { - $xsl = file_get_contents('./xml/en/iparticle.xsl'); - $title = get_title($xml); - } -else - { - $xsl = file_get_contents('./xml/en/faq.xsl'); - $title = "FAQ"; - } +$xml_file = $file; +$xml = file_get_contents($xml_file); +if (strstr($doc,"faq.html")===false) { + $xsl_file = './xml/en/iparticle.xsl'; + $title = get_title($xml); +} else { + $xsl_file = './xml/en/faq.xsl'; + $title = "FAQ"; +} ?> <html> @@ -148,14 +131,11 @@ exit(); } -print libxslt_transform($xml, $xsl); - -function file_get_contents($filename) { - $fd = fopen("$filename", "rb"); - $content = fread($fd, filesize($filename)); - fclose($fd); - return $content; -} +$xml = domxml_open_file($xml_file); +$xsl = domxml_xslt_stylesheet_file($xsl_file); + +$result = $xsl->process($xml); +print $result->dump_mem(); function get_title($str) { |