Esempio n. 1
0
 /**
  * Get text content with all links in src="..." and href="..." set to the adequat link according to the bid system
  * @access   private
  **/
 function _get_texthtml($config_webserver_ip, $content)
 {
     //get current path
     $current_path = substr($this->object->get_path(), 0, strrpos($this->object->get_path(), "/")) . "/";
     //initiate variables
     $html_org = eregi_replace("<head>", '<head><base target="_top">', $content);
     $html = $html_org;
     $url_org = array();
     $url_new = array();
     $url_map = array("src" => $config_webserver_ip . "/tools/get.php?object=", "data" => $config_webserver_ip . "/tools/get.php?object=", "code" => $config_webserver_ip . "/tools/get.php?object=", "link href" => $config_webserver_ip . "/tools/get.php?object=", "href" => $config_webserver_ip . "/index.php?object=", "action" => $config_webserver_ip . "/index.php?object=");
     //work through the whole html sourcecode until no href="..." or src="..." are left
     $transaction_key = 0;
     // hack
     while ($tag_open = strpos($html, '<') !== false) {
         $tag_close = strpos($html, '>', $tag_open);
         //get html entity
         $entity = substr($html, $tag_open, $tag_close - $tag_open + 1);
         //save entity that has a href or src in it
         if (eregi("(^link href|^href|^src|^action|^data|^code)*(link href|href|src|action|data|code)=[\"\\']([^\"^\\']*)", $entity, $regs)) {
             $scheme = $regs[2];
             $url = $regs[3];
             $split = parse_url($url);
             //only derive path if its a relative link
             if (!isset($split["scheme"]) && isset($split["path"])) {
                 $path = $this->_real_path($current_path . $split["path"]);
                 $transaction[$transaction_key] = steam_factory::path_to_object($this->steam->get_id(), $path);
                 //only save data if its a new one
                 if (!isset($url_org[$entity])) {
                     $url_org[$entity] = $entity;
                     $url_id[] = array("transaction" => $transaction[$transaction_key], "entity" => $entity, "scheme" => $scheme, "url" => $url);
                 }
                 $transaction_key++;
             }
         }
         //get html from the tag_close on to make sure the while stops sometime
         $html = substr($html, $tag_close);
     }
     if (!isset($url_id)) {
         return $html_org;
     }
     //build array for string replacment
     foreach ($url_id as $key => $data) {
         $object = $transaction[$key];
         // hack
         //if there is a valid object for that path build replace array field
         if (is_object($object)) {
             $path = $url_map[strtolower($data["scheme"])] . $object->get_id();
             $url_new[] = str_replace($data["url"], $path, $data["entity"]);
         } else {
             unset($url_org[$data["entity"]]);
             unset($url_id[$key]);
         }
     }
     //replace all links in html sourcecode
     $new_html = str_replace($url_org, $url_new, $html_org);
     if (mb_detect_encoding($new_html, 'UTF-8, ISO-8859-1') !== 'UTF-8') {
         $new_html = utf8_encode($new_html);
     }
     return $new_html;
 }
Esempio n. 2
0
 /**
  * Get XML content
  * @access   private
  **/
 function _get_textxml($config_webserver_ip, $content)
 {
     $module = new steam_object($this->steam->login_arguments[8]["libxslt"]->id, $this->steam->login_arguments[8]["libxslt"]->class);
     $result = $this->steam->_predefined_command($module, "run", array($content, $this->steam->get_attribute($this->object, "xsl:document"), array(1 => "1")), "objarg", 0);
     return $result;
 }