Пример #1
0
 /**
  * read cache from a file
  *	@param $fn		filename to read from
  *	@param return	string from a file
  */
 function cacheRead($fn)
 {
     global $gConf;
     $f = fopen($gConf['dir']['xmlcache'] . $fn, "r");
     if (!$f) {
         $mk = new Mistake();
         $mk->log("ThingPage::readCache - can not open file({$gConf['dir']['xmlcache']}{$fn}) for reading");
         $mk->displayError("[L[Site is unavailable]]");
     }
     $s = '';
     while ($st = fread($f, 1024)) {
         $s .= $st;
     }
     fclose($f);
     return $s;
 }
Пример #2
0
 function process()
 {
     global $gConf;
     if ('client' == $gConf['xsl_mode']) {
         echo 'depricated';
         exit;
     }
     header($this->_header);
     // xml: string, xsl: file
     if (!($this->_mode & BXXSLTRANSFORM_XML_FILE) && $this->_mode & BXXSLTRANSFORM_XSL_FILE) {
         $args = array('/_xml' => $this->_xml);
         validate_unicode($this->_xml);
         if ((int) phpversion() >= 5) {
             $xml = new DOMDocument();
             if (!@$xml->loadXML($this->_xml)) {
                 $mk = new Mistake();
                 $mk->log("BxXslTransform::process - can not load xml:\n " . $this->_xml);
                 $mk->displayError("[L[Site is unavailable]]");
             }
             $xsl = new DomDocument();
             $xsl->load($this->_xsl);
             $proc = new XsltProcessor();
             $proc->importStyleSheet($xsl);
             $res = $proc->transformToXML($xml);
         } else {
             if (function_exists('domxml_xslt_stylesheet_file')) {
                 $xmldoc = new DomDocument($this->_xml);
                 $xsldoc = domxml_xslt_stylesheet_file($this->_xsl);
                 $result = $xsldoc->process($xmldoc);
                 $res = $xsldoc->result_dump_mem($result);
             } elseif (function_exists('xslt_create')) {
                 $xh = xslt_create();
                 xslt_setopt($xh, XSLT_SABOPT_IGNORE_DOC_NOT_FOUND);
                 $res = xslt_process($xh, 'arg:/_xml', $this->_xsl, NULL, $args);
                 xslt_free($xh);
             } else {
                 die('Server XSLT support is not enabled, try to use client XSL transformation http://your-domain/orca_folder/?xsl_mode=client');
             }
         }
         return $res;
     }
     // xml: file, xsl: file
     if ($this->_mode & BXXSLTRANSFORM_XML_FILE && $this->_mode & BXXSLTRANSFORM_XSL_FILE) {
         if ((int) phpversion() >= 5) {
             $xml = new DOMDocument();
             $xml->load($this->_xml);
             $xsl = new DomDocument();
             $xsl->load($this->_xsl);
             $proc = new XsltProcessor();
             $proc->importStyleSheet($xsl);
             $res = $proc->transformToXML($xml);
         } else {
             if (function_exists('domxml_xslt_stylesheet_file')) {
                 $xmldoc = new DomDocument($this->_xml);
                 $xsldoc = domxml_xslt_stylesheet_file($this->_xsl);
                 $result = $xsldoc->process($xmldoc);
                 $res = $xsldoc->result_dump_mem($result);
             } elseif (function_exists('xslt_create')) {
                 $xh = xslt_create();
                 $res = xslt_process($xh, $this->_xml, $this->_xsl, NULL, $args);
                 xslt_setopt($xh, XSLT_SABOPT_IGNORE_DOC_NOT_FOUND);
                 xslt_free($xh);
             } else {
                 die('XSLT support is not enabled');
             }
         }
         return $res;
         //return  `/opt/jre1.5.0_06/bin/java -jar /opt/saxon/saxon.jar -ds {$this->_xml} {$this->_xsl}`;
     }
     return "<h1>not supported</h1>";
 }
Пример #3
0
 function _read_file($url)
 {
     $h = @fopen($url, "r");
     if ($h) {
         $xml = '';
         while (!feof($h)) {
             $xml .= fread($h, 8192);
         }
         fclose($h);
     } elseif (function_exists('curl_init')) {
         $curl = curl_init();
         curl_setopt($curl, CURLOPT_URL, $url);
         curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($curl, CURLOPT_HEADER, false);
         $xml = curl_exec($curl);
         curl_close($curl);
         if (true === $xml) {
             $xml = '';
         }
     } else {
         $mk = new Mistake();
         $mk->log("Forum::_read_file - can not open {$url} for reading");
         $mk->displayError("Sorry, site is unavailable now, please try again later.");
     }
     return $xml;
 }
Пример #4
0
 function _read_integration_file($integration_file)
 {
     global $gConf;
     if ('url' == $gConf['integration']) {
         if (function_exists('curl_init')) {
             $curl = curl_init();
             curl_setopt($curl, CURLOPT_URL, $integration_file);
             curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($curl, CURLOPT_HEADER, false);
             $xml = curl_exec($curl);
             curl_close($curl);
             if (true === $xml) {
                 $xml = '';
             }
         } elseif ($h = @fopen($integration_file, "r")) {
             $xml = '';
             while (!feof($h)) {
                 $xml .= fread($h, 8192);
             }
             fclose($h);
         } else {
             $mk = new Mistake();
             $mk->log("Forum::_read_integration_file - can not open {$integration_file} for reading");
             $mk->displayError("[L[Site is unavailable]]");
         }
         return $xml;
     } else {
         $orca_integration_xml = '';
         $orca_integration_vars = $integration_file['vars'];
         include $integration_file['file'];
         return $orca_integration_xml;
     }
 }