From 669a59ecfdc7d0c948544536eb552a37e5e1fb3c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 12 Sep 2008 12:19:18 +0000 Subject: [PATCH] Proxy support added to Wernis RSS feed --- .gitattributes | 1 - inc/modules/guest/what-my_weblog.php | 65 ------------------- inc/modules/guest/what-wernis_portal.php | 19 +++++- inc/rdf.class.php | 60 +++++++++++------ .../de/html/admin/admin_config_wernis.tpl | 4 +- 5 files changed, 59 insertions(+), 90 deletions(-) delete mode 100644 inc/modules/guest/what-my_weblog.php diff --git a/.gitattributes b/.gitattributes index c58bab216c..ee112d0aa8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -403,7 +403,6 @@ inc/modules/guest/what-impressum.php -text inc/modules/guest/what-infos.php -text inc/modules/guest/what-login.php -text inc/modules/guest/what-mediadata.php -text -inc/modules/guest/what-my_weblog.php -text inc/modules/guest/what-rallyes.php -text inc/modules/guest/what-register.php -text inc/modules/guest/what-sponsor_agb.php -text diff --git a/inc/modules/guest/what-my_weblog.php b/inc/modules/guest/what-my_weblog.php deleted file mode 100644 index b4c6f50c7b..0000000000 --- a/inc/modules/guest/what-my_weblog.php +++ /dev/null @@ -1,65 +0,0 @@ -"); -$rdf = new fase4_rdf; -$rdf->use_dynamic_display(false); -$rdf->set_CacheDir(PATH."cache/"); -$rdf->set_salt(SITE_KEY); -$rdf->set_Options( - array( - "textinput" => "hidden", - "sitelink" => "http://blog.mxchange.org" - ) -); -$rdf->set_max_item(10); -$rdf->parse_RDF("http://blog.mxchange.org/feed/"); -$rdf->finish(); -$rdf->clear_cache(); -OUTPUT_HTML(""); - -// -?> diff --git a/inc/modules/guest/what-wernis_portal.php b/inc/modules/guest/what-wernis_portal.php index 7a5df0860e..c48232b0b3 100644 --- a/inc/modules/guest/what-wernis_portal.php +++ b/inc/modules/guest/what-wernis_portal.php @@ -47,8 +47,9 @@ ADD_DESCR("guest", basename(__FILE__)); OUTPUT_HTML("
"); $rdf = new fase4_rdf; $rdf->use_dynamic_display(false); -$rdf->set_CacheDir(PATH."cache/"); +$rdf->set_CacheDir(PATH."inc/cache/"); $rdf->set_salt(SITE_KEY); +$rdf->set_max_item(10); $rdf->set_Options( array( "textinput" => "hidden", @@ -57,10 +58,22 @@ $rdf->set_Options( "reflink" => "/ref.php?refid=", ) ); -$rdf->set_max_item(10); + +// Use proxy? +if ((!empty($_CONFIG['proxy_host'])) && (!empty($_CONFIG['proxy_port']))) { + // Set proxy data + $rdf->set_proxy($_CONFIG['proxy_host'], $_CONFIG['proxy_port']); + + // Use auth? + if (!empty($_CONFIG['proxy_username'])) { + // Set auth data + $rdf->set_proxy_auth($_CONFIG['proxy_username'], $_CONFIG['proxy_password']); + } // END - if +} // END - if + $rdf->parse_RDF("http://www.wds66.com/rss.xml"); $rdf->finish(); -$rdf->clear_cache(); +// DISABLED: $rdf->clear_cache(); OUTPUT_HTML("
"); // diff --git a/inc/rdf.class.php b/inc/rdf.class.php index f0efb0c91a..350976fde6 100644 --- a/inc/rdf.class.php +++ b/inc/rdf.class.php @@ -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))) { @@ -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"]))) { @@ -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,7 +1161,8 @@ 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") { if(!@unlink($dir->path.$file)) { $this->_throw_exception( "Unable to unlink ".$dir->path.$file diff --git a/templates/de/html/admin/admin_config_wernis.tpl b/templates/de/html/admin/admin_config_wernis.tpl index 6c875cb104..9f45d20580 100644 --- a/templates/de/html/admin/admin_config_wernis.tpl +++ b/templates/de/html/admin/admin_config_wernis.tpl @@ -41,8 +41,8 @@ {--WERNIS_ADMIN_REFID--}:   + class="admin_normal" value="$content[refid]" size="5" + maxlength="20" />   -- 2.39.2