X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fclasses%2Frdf.class.php;h=d3d0f4529507feb6b63b9276709bf5c8a3ffb309;hb=2a3ba926e150b00158fea263240ea88f1894124f;hp=78c7e95fbbd267e132e9a4d5745f6161b6b44615;hpb=dba0db3d371da5a17ca7da6a8cde2596251660b7;p=mailer.git diff --git a/inc/classes/rdf.class.php b/inc/classes/rdf.class.php index 78c7e95fbb..d3d0f45295 100644 --- a/inc/classes/rdf.class.php +++ b/inc/classes/rdf.class.php @@ -61,7 +61,7 @@ class fase4_rdf { * @access private * @var boolean */ - var $_use_nl2br = true; + var $_use_nl2br = TRUE; /** * Sets the decoding mode of the read data (UTF8 scrambles some german umlauts here!) @@ -125,7 +125,7 @@ class fase4_rdf { * @see set_proxy() * @var bool */ - var $_use_proxy = false; + var $_use_proxy = FALSE; /** * just a flag for checking if proxy-support with authentication @@ -136,7 +136,7 @@ class fase4_rdf { * @see set_proxy() * @var boolean */ - var $_use_proxy_auth = false; + var $_use_proxy_auth = FALSE; /** * The time the Files will be cached (in seconds). @@ -160,10 +160,10 @@ class fase4_rdf { * @access private * @var boolean */ - var $_use_cached_file = true; + var $_use_cached_file = TRUE; /** - * (fast|normal) depends on _use_dynamic_display(). _use_dynamic_display( TRUE ) -> 'normal', otherwise 'fast' + * (fast|normal) depends on _use_dynamic_display(). _use_dynamic_display(TRUE) -> 'normal', otherwise 'fast' * * @access private * @var string @@ -192,7 +192,7 @@ class fase4_rdf { * @access private * @var boolean */ - var $_cache_dir_ok = false; + var $_cache_dir_ok = FALSE; /** * Type of the file to be parsed (RSS or RDF). @@ -239,7 +239,7 @@ class fase4_rdf { * @access private * @var array */ - var $_use_dynamic_display = false; + var $_use_dynamic_display = FALSE; /** * count @@ -255,7 +255,7 @@ class fase4_rdf { * @access private * @var boolean */ - var $_max_count = false; + var $_max_count = FALSE; /** * Array containing the content of @@ -311,7 +311,7 @@ class fase4_rdf { * @access private * @var array */ - var $_ctags = array( 'x' ); + var $_ctags = array('x'); /** * Array containing the Channel content. Just For internal XML Parser Purposes. @@ -335,7 +335,7 @@ class fase4_rdf { * @access private * @var array */ - var $_tags = array( 'x' ); // Array + var $_tags = array('x'); // Array /** * Garbage collection: probability in percent @@ -388,10 +388,10 @@ class fase4_rdf { * @access public * @author Stefan Saasen * @param string $rdf RDF File (Location) - * @return string Displays RDF Content ( using _display() ) + * @return string Displays RDF Content (using _display()) * @see _remote_file, cache() */ - function parse_RDF( $rdf ) + function parse_RDF($rdf) { unset($this->_array_item); $this->_remote_file = $rdf; @@ -401,7 +401,7 @@ class fase4_rdf { $this->out .= ""; $this->_output = ''; $this->_item_count = '0'; - return true; + return TRUE; } /** @@ -410,10 +410,10 @@ class fase4_rdf { * @access public * @author Stefan Saasen * @param string $rdf RDF File (Location) - * @return string Displays RDF Content ( using _display() ) + * @return string Displays RDF Content (using _display()) * @see _remote_file, cache() */ - function finish($return = false) { + function finish($return = FALSE) { $this->out = str_replace('$', '$', $this->out); if (!$return) { @@ -429,19 +429,19 @@ class fase4_rdf { * * In the first case the rdf/rss File will be stored locally, in the second case the html output of the specified source will be stored. * In this case you can not modify the display settings. - * processing time: ( 1.4792) --> remote file - * processing time: ( 0.0313) --> using 'normal cache' with display Modification turned on. - * processing time: ( 0.0019) --> using 'fast cache' + * processing time: (1.4792) --> remote file + * processing time: (0.0313) --> using 'normal cache' with display Modification turned on. + * processing time: (0.0019) --> using 'fast cache' * * @access public * @author Stefan Saasen * @param string $rdf RDF File (Location) - * @return string Displays RDF Content ( using _display() ) + * @return string Displays RDF Content (using _display()) * @see _remote_file, cache() */ - function use_dynamic_display( $bool ) { + function use_dynamic_display($bool) { $this->_use_dynamic_display = $bool; - return true; + return TRUE; } /** @@ -452,7 +452,7 @@ class fase4_rdf { * @param string $data RDF File XML Data * @see _clear_Items() */ - function _parse_xRDF( $data ) { + function _parse_xRDF($data) { $this->_clear_Items(); $xml_parser = xml_parser_create(); xml_set_object($xml_parser,$this); @@ -477,14 +477,14 @@ class fase4_rdf { * @return boolean * @see _refresh */ - function set_refresh( $seconds ) { + function set_refresh($seconds) { $this->_refresh = (time() - $seconds); - return true; + return TRUE; } - function set_salt( $saltPara ) { + function set_salt($saltPara) { $this->salt = $saltPara; - return true; + return TRUE; } /** @@ -496,10 +496,10 @@ class fase4_rdf { * @return boolean * @see _max_count, _endElement() */ - function set_max_item( $int ) + function set_max_item($int) { $this->_max_count = $int; - return true; + return TRUE; } /** @@ -511,9 +511,9 @@ class fase4_rdf { * @return boolean * @see _cache_dir */ - function set_CacheDir( $dir ) + function set_CacheDir($dir) { - if(substr($dir, -1) != '/') { + if (substr($dir, -1) != '/') { $dir = $dir.'/'; } $this->_cache_dir = $dir; @@ -526,10 +526,10 @@ class fase4_rdf { * @param string $msg Message to display on failure * @author Stefan Saasen */ - function _throw_exception( $msg ) + function _throw_exception($msg) { $this->out .= "
fase4 RDF Error: ".$msg."
"; - return true; + return TRUE; } /** @@ -539,7 +539,7 @@ class fase4_rdf { * @author Stefan Saasen * @see _item */ - function _clear_Items( ) { + function _clear_Items() { $this->_item = array( 'title' => '', 'link' => '', @@ -559,7 +559,7 @@ class fase4_rdf { * @author Stefan Saasen * @see _item */ - function _clear_cItems( ) { + function _clear_cItems() { $this->_citem = array( 'title' => '', 'link' => '', @@ -598,32 +598,32 @@ class fase4_rdf { */ function _startElement($parser, $name, $attrs) { // We have to determine, which type of xml data we have to parse - if($name == 'rss') { + if ($name == 'rss') { $this->_type = 'rss'; - } elseif($name == 'rdf:RDF' OR $name == 'rdf') { + } elseif ($name == 'rdf:RDF' || $name == 'rdf') { $this->_type = 'rdf'; } - if ( $name == 'channel' AND $this->_type != 'rdf' ) { + if ($name == 'channel' && $this->_type != 'rdf') { $this->_parse_mode = 'channel'; - } elseif ( ($name=='item') - ||($name=='image') - ||($name=='textinput') - ||(($name=='channel') && ($this->_type != 'rss')) ) { - if($this->_parse_mode=='channel') { - $this->_get_ChannelData( $parser ); + } elseif (($name == 'item') + || ($name == 'image') + || ($name == 'textinput') + || (($name == 'channel') && ($this->_type != 'rss'))) { + if ($this->_parse_mode == 'channel') { + $this->_get_ChannelData($parser); } $this->_parse_mode = 'all'; } - if( !isset( $this->_depth[$this->get_parser_id($parser)] ) ) { + if (!isset($this->_depth[$this->get_parser_id($parser)])) { $this->_depth[$this->get_parser_id($parser)] = '0'; } $this->_depth[$this->get_parser_id($parser)]++; array_push($this->_tags, $name); - if( !isset( $this->_cdepth[$this->get_parser_id($parser)] ) ) { + if (!isset($this->_cdepth[$this->get_parser_id($parser)])) { $this->_cdepth[$this->get_parser_id($parser)] = '0'; } $this->_cdepth[$this->get_parser_id($parser)]++; @@ -638,7 +638,7 @@ class fase4_rdf { * @param mixed $parser a reference to the XML parser calling the handler. * @see _output, _display_opt, _citem */ - function _get_ChannelData( $parser ) + function _get_ChannelData($parser) { $this->_citem['link'] = trim($this->_citem['link']); if (($this->_display_opt['sitelink'] == $this->_citem['link']) && (!empty($this->_display_opt['reflink'])) && (!empty($this->_display_opt['refid']))) @@ -646,7 +646,7 @@ class fase4_rdf { $this->_citem['link'] .= $this->_display_opt['reflink'].$this->_display_opt['refid']; } - if( empty($this->_display_opt['channel']) OR + if (empty($this->_display_opt['channel']) || $this->_display_opt['channel'] != 'hidden') { $this->_output .= "\n"; $this->_output .= "\n"; @@ -654,14 +654,14 @@ class fase4_rdf { $this->_output .= "\n"; $this->_output .= "\n"; $this->_output .= "\n"; $this->_output .= "\n"; @@ -695,15 +695,15 @@ class fase4_rdf { } switch ($name) { case 'item': - if(empty($this->_max_count) OR $this->_item_count < $this->_max_count) { - if($this->_item['title'] != $this->_item['description'] - AND $this->_item['description']) { + if (empty($this->_max_count) || $this->_item_count < $this->_max_count) { + if ($this->_item['title'] != $this->_item['description'] + && $this->_item['description']) { // word-wrapping added by Roland Haeder if (($this->_word_wrap > 0) && (strlen($this->_item['description']) > $this->_word_wrap)) { // Switch off _use_nl2br - $this->_use_nl2br = false; + $this->_use_nl2br = FALSE; // First remove all \n $this->_item['description'] = str_replace('\n', ' ', $this->_item['description']); // Wrap with
\n @@ -719,7 +719,7 @@ class fase4_rdf { if ($this->_use_nl2br) $this->_item['description'] = nl2br($this->_item['description']); $this->_output .= "
\n"; $this->_output .= "\n"; // we just display the
if there is a description @@ -727,7 +727,7 @@ class fase4_rdf { } else { $this->_output .= "\n"; } @@ -743,12 +743,12 @@ class fase4_rdf { break; case 'image': - if(isset($this->_display_opt['image']) && ($this->_display_opt['image'] != 'hidden') && $this->_item['url']) { + if (isset($this->_display_opt['image']) && ($this->_display_opt['image'] != 'hidden') && $this->_item['url']) { $this->_output .= "\n"; @@ -760,28 +760,28 @@ class fase4_rdf { 'height' => $this->_item['height'] ); $this->_clear_Items(); - } elseif( isset($this->_display_opt['image'] ) && ($this->_display_opt['image'] == 'hidden') ) { + } elseif (isset($this->_display_opt['image']) && ($this->_display_opt['image'] == 'hidden')) { $this->_clear_Items(); } 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']) && $this->_display_opt['channel'] != 'hidden' && $this->_item['title'] != '') { $this->_output .= "\n"; @@ -797,10 +797,10 @@ class fase4_rdf { break; case 'textinput': - if(isset($this->_display_opt['textinput']) && ($this->_display_opt['textinput'] != 'hidden') && $this->_item['name'] && $this->_item['link']) { + if (isset($this->_display_opt['textinput']) && ($this->_display_opt['textinput'] != 'hidden') && $this->_item['name'] && $this->_item['link']) { $this->_output .= "
".strip_tags($this->_citem['description'], ', ')."
 
\n"; - if(isset($this->_display_opt['build']) && $this->_display_opt['build'] != 'hidden') { - if($this->_citem['lastBuildDate']){$this->_output .= 'build: '. $this->_citem['lastBuildDate'].'
';} + if (isset($this->_display_opt['build']) && $this->_display_opt['build'] != 'hidden') { + if ($this->_citem['lastBuildDate']) { $this->_output .= 'build: '. $this->_citem['lastBuildDate'].'
';} } - if(isset($this->_display_opt['cache_update']) && $this->_display_opt['cache_update'] != 'hidden' && ( $_update = $this->get_cache_update_time()) ) { + if (isset($this->_display_opt['cache_update']) && $this->_display_opt['cache_update'] != 'hidden' && ($_update = $this->get_cache_update_time())) { $this->_output .= 'cache update: '.$_update."
\n"; } $this->_output .= "_citem['link']."\" "; - if(isset($this->_link_target)) { $this->_output .= "target=\"".$this->_link_target."\" "; } + if (isset($this->_link_target)) { $this->_output .= "target=\"".$this->_link_target."\" "; } $this->_output .= ">".$this->_cut_string($this->_citem['link']) . ''; $this->_output .= "

".$this->_item['description']."
\n"; $this->_output .= "_item["link"]."\" "; - if(isset($this->_link_target)) { $this->_output .= "target=\"".$this->_link_target."\" "; } + if (isset($this->_link_target)) { $this->_output .= "target=\"".$this->_link_target."\" "; } $this->_output .= ">".$this->_item["title"]."
\n"; $this->_output .= "_item['link']."\" "; - if(isset($this->_link_target)) { $this->_output .= "target=\"".$this->_link_target."\" "; } + if (isset($this->_link_target)) { $this->_output .= "target=\"".$this->_link_target."\" "; } $this->_output .= ">_item['url']."\""; - if(isset($this->_item['width']) && isset($this->_item['height'])) { + if (isset($this->_item['width']) && isset($this->_item['height'])) { $this->_output .= " width=\"".$this->_item['width']."\" height=\"".$this->_item['height']."\""; } $this->_output .= " alt=\"".$this->_item['title']."\" border=\"0\" />
\n"; $this->_output .= "\n"; $this->_output .= "\n"; $this->_output .= "\n"; $this->_output .= "\n"; $this->_output .= "\n"; $this->_output .= "
".htmlspecialchars($this->_item['title'])."
".strip_tags($this->_item['description'], ', ')."
 
\n"; - if($this->_display_opt['build'] != 'hidden') { - if($this->_item['lastBuildDate']){$this->_output .= 'build: '. $this->_item['lastBuildDate'].'
';} + if ($this->_display_opt['build'] != 'hidden') { + if ($this->_item['lastBuildDate']) { $this->_output .= 'build: '. $this->_item['lastBuildDate'].'
';} } - if($this->_display_opt['cache_update'] != 'hidden' && ( $_update = $this->get_cache_update_time()) ) { + if ($this->_display_opt['cache_update'] != 'hidden' && ($_update = $this->get_cache_update_time())) { $this->_output .= 'cache update: '.$_update."
\n"; } $this->_output .= "_item['link']."\" "; - if(isset($this->_link_target)) { $this->_output .= "target=\"".$this->_link_target."\" "; } + if (isset($this->_link_target)) { $this->_output .= "target=\"".$this->_link_target."\" "; } $this->_output .= ">".$this->_cut_string($this->_item['link'])."\n"; $this->_output .= "
\n"; $this->_output .= "
_item['link']."\" "; - if(isset($this->_link_target)) { $this->_output .= "target=\"".$this->_link_target."\" "; } + if (isset($this->_link_target)) { $this->_output .= "target=\"".$this->_link_target."\" "; } $this->_output .= "method=\"get\">\n"; $this->_output .= "
".$this->_item['title']."
"; $this->_output .= strip_tags($this->_item['description'], ', ')."

\n"; @@ -815,7 +815,7 @@ class fase4_rdf { 'description' => $this->_item['description'] ); $this->_clear_Items(); - } elseif( isset($this->_display_opt['textinput']) && ($this->_display_opt['textinput'] == 'hidden') ) { + } elseif (isset($this->_display_opt['textinput']) && ($this->_display_opt['textinput'] == 'hidden')) { $this->_clear_Items(); } @@ -831,7 +831,7 @@ class fase4_rdf { * @return array * @see _array_channel */ - function get_array_channel( ) + function get_array_channel() { return $this->_array_channel; } @@ -844,7 +844,7 @@ class fase4_rdf { * @return array * @see _array_item */ - function get_array_item( ) + function get_array_item() { return $this->_array_item; } @@ -857,7 +857,7 @@ class fase4_rdf { * @return array * @see _array_textinput */ - function get_array_textinput( ) + function get_array_textinput() { return $this->_array_textinput; } @@ -891,7 +891,7 @@ class fase4_rdf { * @return array * @see _array_image */ - function get_array_image( ) + function get_array_image() { return $this->_array_image; } @@ -922,15 +922,15 @@ class fase4_rdf { $clean = preg_replace("/\s/", "", $text); if ($clean) { $text = preg_replace("/^\s+/", "", $text)."\n"; - if($this->_parse_mode == 'all') { - if ( isset($this->_item[$this->_tags[$this->_depth[$this->get_parser_id($parser)]]]) && - $this->_item[$this->_tags[$this->_depth[$this->get_parser_id($parser)]]] ) { + if ($this->_parse_mode == 'all') { + 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[$this->get_parser_id($parser)]]] = $text; } } elseif (isset($this->_parse_mode) && $this->_parse_mode == 'channel') { - if ( isset($this->_citem[$this->_ctags[$this->_cdepth[$this->get_parser_id($parser)]]]) ) { + 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[$this->get_parser_id($parser)]]] = $text; @@ -948,14 +948,14 @@ class fase4_rdf { * @param array $options * @see _display_opt */ - function set_Options( $options = '' ) + function set_Options($options = '') { - if(is_array( $options )) { + if (is_array($options)) { $this->_display_opt = $options; - return true; + return TRUE; } else { unset($this->_display_opt); - return false; + return FALSE; } } @@ -967,10 +967,10 @@ class fase4_rdf { * @param int $width attribute width in tag * @see _table_width */ - function set_table_width( $width = 400 ) + function set_table_width($width = 400) { $this->_table_width = $width; - return true; + return TRUE; } /** @@ -1008,10 +1008,10 @@ class fase4_rdf { { // checks if the cache directory already exists // if not, the cache directory will be created - if(!$this->_cache_dir_ok) { + if (!$this->_cache_dir_ok) { $this->_create_cache_dir(); } - if($this->_use_dynamic_display == true) { + if ($this->_use_dynamic_display == TRUE) { $this->_cached_file = md5('dynamic'.$this->salt.$this->_remote_file) . '.cache'; $this->_cache_type = 'normal'; } else { @@ -1021,34 +1021,43 @@ class fase4_rdf { $_cache_f = $this->_cache_dir.$this->_cached_file; - if ( (!file_exists($_cache_f)) || (filemtime($_cache_f) < $this->_refresh) || (filesize($_cache_f) == 0)) { + if ((!file_exists($_cache_f)) || (filemtime($_cache_f) < $this->_refresh) || (filesize($_cache_f) == 0)) { // We have to parse the remote file - $this->_use_cached_file = false; + $this->_use_cached_file = FALSE; // --> we want to provide proper Information for Use in // get_cache_update_time() clearstatcache(); - if($this->_use_dynamic_display == true) { + if ($this->_use_dynamic_display == TRUE) { $_rdf = implode(' ', $this->_rdf_data()); // -> proxy - if(!$_rdf) { - $this->_throw_exception( $this->_remote_file.' is not available' ); + if (!$_rdf) { + $this->_throw_exception($this->_remote_file.' is not available'); } - $this->_parse_xRDF( $_rdf ); - $this->_update_cache( $_rdf ); + $this->_parse_xRDF($_rdf); + $this->_update_cache($_rdf); $data = $this->_output; } else { $_rdf = implode(' ', $this->_rdf_data()); // -> proxy - if(!$_rdf) { - $this->_throw_exception( $this->_remote_file.' is not available' ); + if (!$_rdf) { + $this->_throw_exception($this->_remote_file.' is not available'); } - $this->_parse_xRDF( $_rdf ); - $this->_update_cache( $this->_output ); + $this->_parse_xRDF($_rdf); + $this->_update_cache($this->_output); $data = $this->_output; } + } elseif (defined('__SECURITY') && function_exists('readFromFile')) { + // Use readFromFile() from mailer project + $this->_use_cached_file = TRUE; + if ($this->_use_dynamic_display == TRUE) { + $this->_parse_xRDF(readFromFile($_cache_f)); + $data = $this->_output; + } else { + $data = readFromFile($_cache_f); + } } else { // we can use the cached file - $this->_use_cached_file = true; - if($this->_use_dynamic_display == true) { - $this->_parse_xRDF( implode(' ', file($_cache_f)) ); + $this->_use_cached_file = TRUE; + if ($this->_use_dynamic_display == TRUE) { + $this->_parse_xRDF(implode(' ', file($_cache_f))); $data = $this->_output; } else { $data = implode(' ', file($_cache_f)); @@ -1069,28 +1078,28 @@ class fase4_rdf { function _create_cache_dir() { $path = ''; - if(!@is_dir($this->_cache_dir)) { + if (!is_dir($this->_cache_dir)) { $arr = explode('/', $this->_cache_dir); $c = count($arr); - if($arr[0]=='') { + if ($arr[0] == '') { $path = '/'; } for($i = '0';$i<$c;$i++) { - if($arr[$i]!='') { + if ($arr[$i]!='') { $path .= $arr[$i].'/'; - if(!@is_dir($path)) { - if(!@mkdir($path, 0777)) { + if (!is_dir($path)) { + if (!mkdir($path, 0777)) { $this->_throw_exception("failed to create directory:".$this->_cache_dir.".

Exception on Line: ".__LINE__); - return false; + return FALSE; } } } } - $this->_cache_dir_ok = true; - return true; + $this->_cache_dir_ok = TRUE; + return TRUE; } else { - $this->_cache_dir_ok = true; - return true; + $this->_cache_dir_ok = TRUE; + return TRUE; } } // END _create_cache_dir() @@ -1102,20 +1111,24 @@ class fase4_rdf { * @param string $rdf RDF File (Location) * @see _cache_dir, _cached_file, _throw_exception() */ - function _update_cache( $content = '' ) + function _update_cache($content = '') { - $_local = @fopen( $this->_cache_dir.$this->_cached_file, 'w' ); - if(!$_local) { - $this->_throw_exception( 'Cannot open '.$this->_cached_file.'

Exception at Line: '.__LINE__ ); - return false; + if (defined('__SECURITY') && function_exists('writeToFile')) { + // Use mailer-project function + return writeToFile($this->_cache_dir.$this->_cached_file, $content); } - if (fwrite( $_local, $content) === false) { - $this->_throw_exception( 'Cannot write to '.$this->_cached_file.'
Exeception at Line: '.__LINE__); - return false; + $_local = @fopen($this->_cache_dir.$this->_cached_file, 'w'); + if (!$_local) { + $this->_throw_exception('Cannot open '.$this->_cached_file.'

Exception at Line: '.__LINE__); + return FALSE; } - fclose( $_local ); - @chmod( $this->_cache_dir.$this->_cached_file, 0666); - return true; + if (fwrite($_local, $content) === FALSE) { + $this->_throw_exception('Cannot write to '.$this->_cached_file.'
Exeception at Line: '.__LINE__); + return FALSE; + } + fclose($_local); + @chmod($this->_cache_dir.$this->_cached_file, 0666); + return TRUE; } // END _update_cache() /** @@ -1137,7 +1150,7 @@ class fase4_rdf { * @access public * @author Stefan Saasen * @param string $rdf RDF File (Location) - * @return string Displays RDF Content ( using _display() ) + * @return string Displays RDF Content (using _display()) * @see _remote_file, cache() */ function get_CacheType() @@ -1175,14 +1188,17 @@ class fase4_rdf { while($file=$dir->read()) { // 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."
\n
\nException at Line: ".__LINE__ ); - return false; + if ((defined('__SECURITY') && function_exists('removeFile')) && (!removeFile($dir->path.$file))) { + $this->_throw_exception("removeFile() was unable to unlink ".$dir->path.$file."
\n
\nException at Line: ".__LINE__); + return FALSE; + } elseif (!unlink($dir->path.$file)) { + $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; + return TRUE; } // END clear_cache() /** @@ -1193,10 +1209,10 @@ class fase4_rdf { * @param int $str_len length of the returned String (overall length including '... ') * @return string Cut String */ - function _cut_string( $string, $str_len = '30' ) + function _cut_string($string, $str_len = '30') { - if(strlen(trim($string))>$str_len) { - $string = substr( trim($string) , 0, $str_len - 4); + if (strlen(trim($string))>$str_len) { + $string = substr(trim($string) , 0, $str_len - 4); $string .= ' ...'; } return $string; @@ -1215,7 +1231,7 @@ class fase4_rdf { if (mt_rand(1, 100) <= $this->gc_probability) { $dir = dir($this->_cache_dir); while($file=$dir->read()) { - if (is_file($dir->path.$file) && substr($file, -6, 6) != '.cache' && substr($file, -4, 4) != '.log' && filemtime($dir->path.$file) <= time() - $this->_refresh ) { + 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 } @@ -1235,7 +1251,7 @@ class fase4_rdf { */ function set_proxy($phost, $pport) { - $this->_use_proxy = true; + $this->_use_proxy = TRUE; if ($phost != '') $this->_phost = $phost; @@ -1252,9 +1268,9 @@ class fase4_rdf { * @param string $ppaswd Password * @author Marco Kraus */ - function set_proxy_auth( $pname, $ppasswd ) + function set_proxy_auth($pname, $ppasswd) { - $this->_use_proxy_auth = true; + $this->_use_proxy_auth = TRUE; if ($pname != '') $this->_pname = $pname; @@ -1277,15 +1293,17 @@ class fase4_rdf { */ function _rdf_data() { - if ( $this->_use_proxy == true ) - { + if (defined('__SECURITY') && function_exists('sendGetRequest')) { + // Use mailer-project instead (see http://mxchange.org) + $useable_data = sendGetRequest($this->_remote_file, array(), TRUE); + } elseif ($this->_use_proxy == TRUE) { // we need a raw socket here to connect to proxy $fp = fsockopen($this->_phost,$this->_pport); if (!$fp) { - $this->_throw_exception( $this->_remote_file.' is not available with proxy' ); + $this->_throw_exception($this->_remote_file.' is not available with proxy'); } else { - if ( $this->_use_proxy_auth == true ) { + if ($this->_use_proxy_auth == TRUE) { fputs($fp, "GET ".$this->_remote_file." HTTP/1.0\r\nUser-Agent: Fase4 RDF-Reader/1.40 modified by Quix0r\r\n\r\n"); } else { fputs($fp, "GET ".$this->_remote_file." HTTP/1.0\r\nUser-Agent: Fase4 RDF-Reader/1.40 modified by Quix0r\r\nProxy-Authorization: Basic ".base64_encode("$this->_pname:$this->_ppasswd") ."\r\n\r\n"); @@ -1293,7 +1311,7 @@ class fase4_rdf { } - for ( $i = '0'; !feof ($fp) ; $i++) + for ($i = '0'; !feof ($fp) ; $i++) { $usable_data[$i] = ""; $usable_data[$i] = fgets($fp,4096); @@ -1301,29 +1319,29 @@ class fase4_rdf { // PARSE HEADER ---- first line has to be _remote_file, 0, 7) != 'http://') { - $this->_throw_exception( 'Cannot find http:// in '.$this->_remote_file.'!' ); + $this->_throw_exception('Cannot find http:// in '.$this->_remote_file.'!'); return ''; } else { // Extract host information @@ -1358,22 +1376,22 @@ class fase4_rdf { // Start connection to server $fp = fsockopen($host, $port); if (!$fp) { - $this->_throw_exception( $this->_remote_file.' is maybe not available.' ); - return ''; + $this->_throw_exception($this->_remote_file.' is maybe not available.'); + return ''; } // Repare request line $request = sprintf("GET %s HTTP/1.0\r\nHost: %s\r\nUser-Agent: Fase4 RDF-Reader/1.40 modified by Quix0r\r\n\r\n", $get, $host); // Send request out fputs($fp, $request); - $reply = ''; $isContent = false; $dummy = ''; + $reply = ''; $isContent = FALSE; $dummy = ''; // Read reply $i=0; - while ( !feof($fp) ) { + while (!feof($fp)) { $read = trim(fgets($fp, 4096)); if (substr($read, 0, 5) == '