X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Frdf.class.php;h=477925a21e7ad0ef3df4062ba09818cd813765b1;hp=0552c368375b84d8f57f63f1b8f54952d7ea500a;hb=cca98f57dff720b174d21d071cee8303462485d7;hpb=75ad748a68473ace540251427a74fb781b1145e9 diff --git a/inc/rdf.class.php b/inc/rdf.class.php index 0552c36837..477925a21e 100644 --- a/inc/rdf.class.php +++ b/inc/rdf.class.php @@ -55,7 +55,7 @@ class fase4_rdf { var $_word_wrap = 0; /** - * Wether to recode \n ->
or not in description + * Wether to recode \n ->
or not in description * * @access private * @var boolean @@ -212,14 +212,14 @@ class fase4_rdf { * @var array */ var $_display_opt = array( - 'build' => '', - 'image' => '', - 'channel' => '', - 'textinput' => '', - 'cache_update' => '', - 'sitelink' => '', - 'refid' => '', - 'reflink' => '', + 'build' => "", + 'image' => "", + 'channel' => "", + 'textinput' => "", + 'cache_update' => "", + 'sitelink' => "", + 'refid' => "", + 'reflink' => "", ); /** @@ -447,16 +447,16 @@ class fase4_rdf { * This Method avtually parses the XML data. * * @access private - * @author Stefan Saasen + * @author Stefan Saasen * @param string $data RDF File XML Data - * @see _clear_Items() + * @see _clear_Items() */ function _parse_xRDF( $data ) { $this->_clear_Items(); $xml_parser = xml_parser_create(); xml_set_object($xml_parser,$this); - xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0); + xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0); xml_set_element_handler($xml_parser, "_startElement", "_endElement"); xml_set_character_data_handler($xml_parser, "_parseData"); if (!xml_parse($xml_parser, trim($data))) { @@ -550,8 +550,8 @@ class fase4_rdf { 'language'=>"", 'pubDate'=>"", 'lastBuildDate'=>"", - 'width'=>'', - 'height'=>'' + 'width'=>"", + 'height'=>"" ); } /** @@ -619,16 +619,16 @@ class fase4_rdf { $this->_parse_mode = "all"; } - if( !isset( $this->_depth[$parser] ) ) { - $this->_depth[$parser] = 0; + if( !isset( $this->_depth[$this->get_parser_id($parser)] ) ) { + $this->_depth[$this->get_parser_id($parser)] = 0; } - $this->_depth[$parser]++; + $this->_depth[$this->get_parser_id($parser)]++; array_push($this->_tags, $name); - if( !isset( $this->_cdepth[$parser] ) ) { - $this->_cdepth[$parser] = 0; + if( !isset( $this->_cdepth[$this->get_parser_id($parser)] ) ) { + $this->_cdepth[$this->get_parser_id($parser)] = 0; } - $this->_cdepth[$parser]++; + $this->_cdepth[$this->get_parser_id($parser)]++; array_push($this->_ctags, $name); } // END _startElement() @@ -686,9 +686,9 @@ class fase4_rdf { */ function _endElement($parser, $name) { array_pop($this->_tags); - $this->_depth[$parser]--; + $this->_depth[$this->get_parser_id($parser)]--; array_pop($this->_ctags); - $this->_cdepth[$parser]--; + $this->_cdepth[$this->get_parser_id($parser)]--; $this->_item["link"] = trim($this->_item["link"]); if ((!empty($this->_display_opt["refid"])) && (!empty($this->_item["link"]))) { @@ -760,7 +760,7 @@ class fase4_rdf { break; case "channel": - if(isset($this->_display_opt["channel"]) AND $this->_display_opt["channel"] != "hidden" AND $this->_item["title"] != "") { + if(isset($this->_display_opt["channel"]) AND $this->_display_opt["channel"] != "hidden" AND $this->_item["title"] != '') { $this->_output .= "\n"; $this->_output .= ''."\n"; $this->_output .= "\n"; @@ -850,6 +850,27 @@ class fase4_rdf { return $this->_array_textinput; } + /** + * Getter for parser id from resource + * + * @access private + * @author Roland Haeder + * @return int + */ + function get_parser_id ($parser) { + // Default is zero + $id = 0; + + // Is it a resource? + if (is_resource($parser)) { + // Cast the resource into id + $id = (int) $parser; + } // END - if + + // Return the id + return $id; + } + /** * This Method returns the data from . * @@ -890,17 +911,17 @@ class fase4_rdf { if ($clean) { $text = preg_replace("/^\s+/", "", $text)."\n"; if($this->_parse_mode == "all") { - if ( isset($this->_item[$this->_tags[$this->_depth[$parser]]]) && - $this->_item[$this->_tags[$this->_depth[$parser]]] ) { - $this->_item[$this->_tags[$this->_depth[$parser]]] .= $text; + if ( isset($this->_item[$this->_tags[$this->_depth[$this->get_parser_id($parser)]]]) && + $this->_item[$this->_tags[$this->_depth[$this->get_parser_id($parser)]]] ) { + $this->_item[$this->_tags[$this->_depth[$this->get_parser_id($parser)]]] .= $text; } else { - $this->_item[$this->_tags[$this->_depth[$parser]]] = $text; + $this->_item[$this->_tags[$this->_depth[$this->get_parser_id($parser)]]] = $text; } } elseif (isset($this->_parse_mode) && $this->_parse_mode == "channel") { - if ( isset($this->_citem[$this->_ctags[$this->_cdepth[$parser]]]) ) { - $this->_citem[$this->_ctags[$this->_cdepth[$parser]]] .= $text; + if ( isset($this->_citem[$this->_ctags[$this->_cdepth[$this->get_parser_id($parser)]]]) ) { + $this->_citem[$this->_ctags[$this->_cdepth[$this->get_parser_id($parser)]]] .= $text; } else { - $this->_citem[$this->_ctags[$this->_cdepth[$parser]]] = $text; + $this->_citem[$this->_ctags[$this->_cdepth[$this->get_parser_id($parser)]]] = $text; } } } @@ -1140,15 +1161,14 @@ class fase4_rdf { { $dir = dir($this->_cache_dir); while($file=$dir->read()) { - if($file!="." && $file!="..") { + // Exclude directories + if (is_file($dir->path.$file) && substr($file, -6, 6) != ".cache" && substr($file, -4, 4) != ".log") { if(!@unlink($dir->path.$file)) { - $this->_throw_exception( - "Unable to unlink ".$dir->path.$file - ."

Exception at Line: ".__LINE__ ); + $this->_throw_exception("Unable to unlink ".$dir->path.$file."
\n
\nException at Line: ".__LINE__ ); return false; - } - } - } + } // END - if + } // END - if + } // END - while $dir->close(); return true; } // END clear_cache() @@ -1164,8 +1184,8 @@ class fase4_rdf { function _cut_string( $string, $str_len = "30" ) { if(strlen(trim($string))>$str_len) { - $string = substr( trim($string) , 0, $str_len - 4); - $string .= " ..."; + $string = substr( trim($string) , 0, $str_len - 4); + $string .= " ..."; } return $string; } // END _cut_string() @@ -1180,12 +1200,12 @@ class fase4_rdf { function _garbage_collection() { srand((double) microtime() * 1000000); - if (rand(1, 100) <= $this->gc_probability) { + if (mt_rand(1, 100) <= $this->gc_probability) { $dir = dir($this->_cache_dir); while($file=$dir->read()) { - if($file!="." AND $file!=".." AND filemtime($dir->path.$file) <= time() - $this->_refresh ) { - @unlink($dir->path.$file); - } + if (is_file($dir->path.$file) && substr($file, -6, 6) != ".cache" && substr($file, -4, 4) != ".log" && filemtime($dir->path.$file) <= time() - $this->_refresh ) { + @unlink($dir->path.$file); + } // END - if } $dir->close(); } // END if @@ -1205,10 +1225,10 @@ class fase4_rdf { { $this->_use_proxy = true; - if ($phost != "") + if ($phost != '') $this->_phost = $phost; - if ($pport != "") + if ($pport != '') $this->_pport = $pport; } @@ -1224,10 +1244,10 @@ class fase4_rdf { { $this->_use_proxy_auth = true; - if ($pname != "") + if ($pname != '') $this->_pname = $pname; - if ($ppasswd != "") + if ($ppasswd != '') $this->_ppasswd = $ppasswd; } @@ -1335,6 +1355,7 @@ class fase4_rdf { fputs($fp, $request); $reply = ""; $isContent = false; $dummy = ""; // Read reply + $i=0; while ( !feof($fp) ) { $read = trim(fgets($fp, 4096)); if (substr($read, 0, 5) == "
".htmlspecialchars($this->_item["title"])."