From bbedc03bda1b815185ec7b7ab0c59bb408077678 Mon Sep 17 00:00:00 2001 From: mariez Date: Sun, 18 Mar 2018 19:09:32 -0300 Subject: [PATCH] fix 0019115: Trevellin theme does not display the community feed --- footer_minified.inc | 8 +- onyx-rss.php | 385 -------------------------------------------- rssfeed.php | 49 ------ 3 files changed, 4 insertions(+), 438 deletions(-) delete mode 100644 onyx-rss.php delete mode 100644 rssfeed.php diff --git a/footer_minified.inc b/footer_minified.inc index 018ba08..f71b7f7 100644 --- a/footer_minified.inc +++ b/footer_minified.inc @@ -1,8 +1,8 @@ - +
+

+ @@ -31,4 +31,4 @@ $(document).ready(function(){ $('#edit_list_categories input.form-control').tagsinput('refresh'); }); - \ No newline at end of file + diff --git a/onyx-rss.php b/onyx-rss.php deleted file mode 100644 index 0144624..0000000 --- a/onyx-rss.php +++ /dev/null @@ -1,385 +0,0 @@ -PHP\'s XML Extension is not loaded or available.'); - define('ONYX_ERR_NOT_WRITEABLE', 'The specified cache directory is not writeable.'); - define('ONYX_ERR_INVALID_URI', 'The specified file could not be opened.'); - define('ONYX_ERR_INVALID_ITEM', 'Invalid item index specified.'); - define('ONYX_ERR_NO_STREAM', 'Could not open the specified file. Check the path, and make sure that you have write permissions to this file.'); - define('ONYX_META', 'meta'); - define('ONYX_ITEMS', 'items'); - define('ONYX_IMAGE', 'image'); - define('ONYX_TEXTINPUT', 'textinput'); - define('ONYX_NAMESPACES', 'namespaces'); - define('ONYX_CACHE_AGE', 'cache_age'); - define('ONYX_FETCH_ASSOC', 1); - define('ONYX_FETCH_OBJECT', 2); -} - -class ONYX_RSS -{ - public $parser; - public $conf; - public $rss; - public $data; - public $type; - public $lasterror; - /* For when PHP v.5 is released - * http://www.phpvolcano.com/eide/php5.php?page=variables - * private $parser; - * private $conf; - * private $rss; - * private $data; - * private $type; - */ - - // Forward compatibility with PHP v.5 - // http://www.phpvolcano.com/eide/php5.php?page=start - - public function __construct() - { - $this->conf = array(); - $this->conf['error'] = '
Error on line %s of '.__FILE__.': %s
'; - $this->conf['cache_path'] = dirname(__FILE__); - $this->conf['cache_time'] = 180; - $this->conf['debug_mode'] = true; - $this->conf['fetch_mode'] = ONYX_FETCH_ASSOC; - $this->lasterror = ''; - - if (!function_exists('xml_parser_create')) { - $this->raiseError((__LINE__ - 2), ONYX_ERR_NO_PARSER); - - return false; - } - - $this->parser = @xml_parser_create(); - if (!is_resource($this->parser)) { - $this->raiseError((__LINE__ - 3), ONYX_ERR_NO_PARSER); - - return false; - } - xml_set_object($this->parser, $this); - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false); - xml_set_element_handler($this->parser, 'tag_open', 'tag_close'); - xml_set_character_data_handler($this->parser, 'cdata'); - } - - public function parse($uri, $file = false, $time = false, $local = false) - { - $this->rss = array(); - $this->rss['cache_age'] = 0; - $this->rss['current_tag'] = ''; - $this->rss['index'] = 0; - $this->rss['output_index'] = -1; - $this->data = array(); - - if ($file) { - if (!is_writable($this->conf['cache_path'])) { - $this->raiseError((__LINE__ - 2), ONYX_ERR_NOT_WRITEABLE); - - return false; - } - $file = str_replace('//', '/', $this->conf['cache_path'].'/'.$file); - if (!$time) { - $time = $this->conf['cache_time']; - } - $this->rss['cache_age'] = file_exists($file) ? ceil((time() - filemtime($file)) / 60) : 0; - - clearstatcache(); - if (!$local && file_exists($file)) { - if (($mod = $this->mod_time($uri)) === false) { - $this->raiseError((__LINE__ - 2), ONYX_ERR_INVALID_URI); - - return false; - } else { - $mod = ($mod !== 0) ? strtotime($mod) : (time() + 3600); - } - } elseif ($local) { - $mod = (file_exists($file) && ($m = filemtime($uri))) ? $m : time() + 3600; - } - } - if (!$file || - ($file && !file_exists($file)) || - ($file && file_exists($file) && $time <= $this->rss['cache_age'] && $mod >= (time() - ($this->rss['cache_age'] * 60)))) { - clearstatcache(); - if (!($fp = @fopen($uri, 'r'))) { - $this->raiseError((__LINE__ - 2), ONYX_ERR_INVALID_URI); - - return false; - } - while ($chunk = fread($fp, 4096)) { - $parsedOkay = xml_parse($this->parser, $chunk, feof($fp)); - if (!$parsedOkay && xml_get_error_code($this->parser) != XML_ERROR_NONE) { - $this->raiseError((__LINE__ - 3), 'File has an XML error ('.xml_error_string(xml_get_error_code($this->parser)).' at line '.xml_get_current_line_number($this->parser).').'); - - return false; - } - } - fclose($fp); - clearstatcache(); - if ($file) { - if (!($cache = @fopen($file, 'w'))) { - $this->raiseError((__LINE__ - 2), 'Could not write to cache file ('.$file.'). The path may be invalid or you may not have write permissions.'); - - return false; - } - fwrite($cache, serialize($this->data)); - fclose($cache); - $this->rss['cache_age'] = 0; - } - } else { - clearstatcache(); - if (!($fp = @fopen($file, 'r'))) { - $this->raiseError((__LINE__ - 2), 'Could not read contents of cache file ('.$cache_file.').'); - - return false; - } - $this->data = unserialize(fread($fp, filesize($file))); - fclose($fp); - } - - return true; - } - - public function parseLocal($uri, $file = false, $time = false) - { - return $this->parse($uri, $file, $time, true); - } - - //private function tag_open($parser, $tag, $attrs) - - public function tag_open($parser, $tag, $attrs) - { - $this->rss['current_tag'] = $tag = strtolower($tag); - switch ($tag) { - case 'channel': - case 'image': - case 'textinput': - $this->type = $tag; - break; - case 'item': - $this->type = $tag; - ++$this->rss['index']; - break; - default: - break; - } - if (count($attrs)) { - foreach ($attrs as $k => $v) { - if (strpos($k, 'xmlns') !== false) { - $this->data['namespaces'][$k] = $v; - } - } - } - } - - //private function tag_close($parser, $tag){} - - public function tag_close($parser, $tag) - { - } - - //private function cdata($parser, $cdata) - - public function cdata($parser, $cdata) - { - if (strlen(trim($cdata)) && $cdata != "\n") { - switch ($this->type) { - case 'channel': - case 'image': - case 'textinput': - (!isset($this->data[$this->type][$this->rss['current_tag']]) || - !strlen($this->data[$this->type][$this->rss['current_tag']])) ? - $this->data[$this->type][$this->rss['current_tag']] = $cdata : - $this->data[$this->type][$this->rss['current_tag']] .= $cdata; - break; - case 'item': - (!isset($this->data['items'][$this->rss['index'] - 1][$this->rss['current_tag']]) || - !strlen($this->data['items'][$this->rss['index'] - 1][$this->rss['current_tag']])) ? - $this->data['items'][$this->rss['index'] - 1][$this->rss['current_tag']] = $cdata : - $this->data['items'][$this->rss['index'] - 1][$this->rss['current_tag']] .= $cdata; - break; - } - } - } - - public function getData($type) - { - if ($type == ONYX_META) { - return $this->conf['fetch_mode'] == 1 ? $this->data['channel'] : (object) $this->data['channel']; - } - if ($type == ONYX_IMAGE) { - return $this->conf['fetch_mode'] == 1 ? $this->data['image'] : (object) $this->data['image']; - } - if ($type == ONYX_TEXTINPUT) { - return $this->conf['fetch_mode'] == 1 ? $this->data['textinput'] : (object) $this->data['textinput']; - } - if ($type == ONYX_ITEMS) { - if ($this->conf['fetch_mode'] == 1) { - return $this->data['items']; - } - - $temp = array(); - for ($i = 0; $i < count($this->data['items']); ++$i) { - $temp[] = (object) $this->data['items'][$i]; - } - - return $temp; - } - if ($type == ONYX_NAMESPACES) { - return $this->conf['fetch_mode'] == 1 ? $this->data['namespaces'] : (object) $this->data['namespaces']; - } - if ($type == ONYX_CACHE_AGE) { - return $this->rss['cache_age']; - } - - return false; - } - - public function numItems() - { - return count($this->data['items']); - } - - public function getNextItem($max = false) - { - $type = $this->conf['fetch_mode']; - ++$this->rss['output_index']; - if (($max && $this->rss['output_index'] > $max) || !isset($this->data['items'][$this->rss['output_index']])) { - return false; - } - - return ($type == ONYX_FETCH_ASSOC) ? $this->data['items'][$this->rss['output_index']] : - (($type == ONYX_FETCH_OBJECT) ? (object) $this->data['items'][$this->rss['output_index']] : false); - } - - public function itemAt($num) - { - if (!isset($this->data['items'][$num])) { - $this->raiseError((__LINE__ - 3), ONYX_ERR_INVALID_ITEM); - - return false; - } - - $type = $this->conf['fetch_mode']; - - return ($type == ONYX_FETCH_ASSOC) ? $this->data['items'][$num] : - (($type == ONYX_FETCH_OBJECT) ? (object) $this->data['items'][$num] : false); - } - - public function startBuffer($file = false) - { - $this->conf['output_file'] = $file; - ob_start(); - } - - public function endBuffer() - { - if (!$this->conf['output_file']) { - ob_end_flush(); - } else { - if (!($fp = @fopen($this->conf['output_file'], 'w'))) { - $this->raiseError((__LINE__ - 2), ONYX_ERR_NO_STREAM); - ob_end_flush(); - - return; - } - fwrite($fp, ob_get_contents()); - fclose($fp); - chmod($this->conf['output_file'], 0666); - ob_end_clean(); - } - } - - //private function raiseError($line, $err) - - public function raiseError($line, $err) - { - if ($this->conf['debug_mode']) { - printf($this->conf['error'], $line, $err); - } else { - $this->lasterror = $err; - } - } - - public function setCachePath($path) - { - $this->conf['cache_path'] = $path; - } - - public function setExpiryTime($time) - { - $this->conf['cache_time'] = $time; - } - - public function setDebugMode($state) - { - $this->conf['debug_mode'] = (bool) $state; - } - - public function setFetchMode($mode) - { - $this->conf['fetch_mode'] = $mode; - } - - //private function mod_time($uri) - - public function mod_time($uri) - { - if (function_exists('version_compare') && version_compare(phpversion(), '4.3.0') >= 0) { - if (!($fp = @fopen($uri, 'r'))) { - return false; - } - - $meta = stream_get_meta_data($fp); - for ($j = 0; isset($meta['wrapper_data'][$j]); ++$j) { - if (strpos(strtolower($meta['wrapper_data'][$j]), 'last-modified') !== false) { - $modtime = substr($meta['wrapper_data'][$j], 15); - break; - } - } - fclose($fp); - } else { - $parts = parse_url($uri); - $host = $parts['host']; - $path = $parts['path']; - - if (!($fp = @fsockopen($host, 80))) { - return false; - } - - $req = "HEAD $path HTTP/1.1\r\nUser-Agent: PHP/".phpversion(); - $req .= "\r\nHost: $host\r\nAccept: */*\r\n\r\n"; - fwrite($fp, $req); - - while (!feof($fp)) { - $str = fgets($fp, 4096); - if (strpos(strtolower($str), 'last-modified') !== false) { - $modtime = substr($str, 15); - break; - } - } - fclose($fp); - } - - return (isset($modtime)) ? $modtime : 0; - } -} diff --git a/rssfeed.php b/rssfeed.php deleted file mode 100644 index c72504d..0000000 --- a/rssfeed.php +++ /dev/null @@ -1,49 +0,0 @@ -setDebugMode(false); - $rss->setCachePath($GLOBALS['tmpdir']); - $rss->setExpiryTime(1440); - $parseresult = $rss->parse('https://www.phplist.org/newslist/feed/', 'phplistnews'); - $count = 0; - if ($parseresult) { - while ($item = $rss->getNextItem()) { - $count++; - if ($count > $max) break; - $date = $item['pubdate']; - $date = str_replace('00:00:00 +0000', '', $date); - $date = str_replace('00:00:00 +0100', '', $date); - $date = str_replace('+0000', '', $date); - if (preg_match('/\d+:\d+:\d+/', $date, $regs)) { - $date = str_replace($regs[0], '', $date); - } - - ## remove the '

 

' in the descriptions - $desc = $item['description']; - $desc = str_replace('

 

', '', $desc); - $desc = ''; - - $news .= '
  • -
    '.$date.'
    '.$item['title'].' - '.$desc.' -
  • '; - } - } - - if (!empty($news)) { - print ''; - } -}