X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=doc%2Fconvert.php;h=a7e08cbc3c12cba33a3e01b1bf135e499bb8d910;hb=9337670bd021202018213a156c0083dd72902571;hp=4de3b444f3e679931f815eaba758b658e937e1e6;hpb=172e482d9aa27d7866d7a38fea8be90182480b79;p=plcapi.git diff --git a/doc/convert.php b/doc/convert.php index 4de3b44..a7e08cb 100644 --- a/doc/convert.php +++ b/doc/convert.php @@ -1,57 +1,61 @@ load($doc); -$xsl = new DOMDocument; +$xsl = new DOMDocument(); $xsl->load($xss); // Configure the transformer -$proc = new XSLTProcessor; -if (version_compare(PHP_VERSION,'5.4',"<")) -{ - if(defined('XSL_SECPREF_WRITE_FILE')) +$proc = new XSLTProcessor(); +if (version_compare(PHP_VERSION, '5.4', "<")) { + if (defined('XSL_SECPREF_WRITE_FILE')) { ini_set("xsl.security_prefs", XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); -} -else -{ - $proc->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); + } +} else { + // the php online docs only mention setSecurityPrefs, but somehow some installs have setSecurityPreferences... + if (method_exists('XSLTProcessor', 'setSecurityPrefs')) { + $proc->setSecurityPrefs(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); + } else { + $proc->setSecurityPreferences(XSL_SECPREF_CREATE_DIRECTORY | XSL_SECPREF_WRITE_FILE); + } } $proc->importStyleSheet($xsl); // attach the xsl rules //if ($_SERVER['argc'] >= 4) //{ - if (is_dir($_SERVER['argv'][3])) - { - if (!$proc->setParameter('', 'base.dir', realpath($_SERVER['argv'][3]))) - echo "setting param base.dir KO\n"; - } - else - { - //echo "{$_SERVER['argv'][3]} is not a dir\n"; +if (is_dir($_SERVER['argv'][3])) { + if (!$proc->setParameter('', 'base.dir', realpath($_SERVER['argv'][3]))) { + echo "setting param base.dir KO\n"; } +} else { + //echo "{$_SERVER['argv'][3]} is not a dir\n"; +} //} $out = $proc->transformToXML($xml); -if (!is_dir($_SERVER['argv'][3])) +if (!is_dir($_SERVER['argv'][3])) { file_put_contents($_SERVER['argv'][3], $out); +} echo "OK\n";