diff --git a/.gitignore b/.gitignore index b95a7fe..9b27ddc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -/.buildpath -/.project /log.html /globalsettings.php inc/log.html diff --git a/inc/Feed.php b/inc/Feed.php index 1c29aad..0e69c72 100755 --- a/inc/Feed.php +++ b/inc/Feed.php @@ -31,7 +31,7 @@ class Feed extends PhpObject $this->asChannel = $asChannel; //Items - $this->asItems = array(); + $this->removeItems(); array_walk($asItems, array($this, 'addItem')); } @@ -42,7 +42,7 @@ class Feed extends PhpObject curl_setopt($oCurl, CURLOPT_HEADER, false); curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true); curl_setopt($oCurl, CURLOPT_USERAGENT, array_key_exists('HTTP_USER_AGENT', $_SERVER)?$_SERVER['HTTP_USER_AGENT']:'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0'); - $fCookieJar = tempnam('/tmp','cookie'); + $fCookieJar = @tempnam('/tmp','cookie'); curl_setopt($oCurl, CURLOPT_COOKIESESSION, true); curl_setopt($oCurl, CURLOPT_COOKIEJAR, $fCookieJar); curl_setopt($oCurl, CURLOPT_COOKIEFILE, $fCookieJar); @@ -112,6 +112,12 @@ class Feed extends PhpObject return count($this->asItems) - 1; } + public function changeItem($iItemId, $asAttributes) { + if(array_key_exists($iItemId, $this->asItems)) { + $this->asItems[$iItemId] = array_merge($this->asItems[$iItemId], $asAttributes); + } + } + public function removeItem($iItemId) { $bExist = array_key_exists($iItemId, $this->asItems); @@ -119,6 +125,11 @@ class Feed extends PhpObject return $bExist; } + public function removeItems() + { + $this->asItems = []; + } + public function filterItems($sField, $sRegex) { $this->asItems = array_filter($this->asItems, function($asItem) use ($sField, $sRegex) { @@ -188,7 +199,7 @@ class Feed extends PhpObject $sRssItem .= array_key_exists('category', $asItem)?self::getHtml($asItem['category'], 'category'):''; $sRssItem .= self::getHtml(self::cleanRss($asItem['description']), 'description'); $sRssItem .= array_key_exists('pubDate', $asItem)?self::getHtml(self::getDate($asItem['pubDate']), 'pubDate'):''; - $sRssItem .= array_key_exists('guid', $asItem)?self::getHtml($asItem['guid'], 'guid', '', '', array('isPermaLink'=>'true')):''; + $sRssItem .= array_key_exists('guid', $asItem)?self::getHtml($asItem['guid'], 'guid', '', '', array('isPermaLink'=>'false')):''; return self::getHtml($sRssItem, 'item'); } diff --git a/inc/PhpObject.php b/inc/PhpObject.php index 38a48ae..547bfad 100644 --- a/inc/PhpObject.php +++ b/inc/PhpObject.php @@ -103,7 +103,7 @@ class PhpObject $this->asMessageStack[self::ERROR_TAB] ); } - else $asMessages = $this->asMessageStack[$sType]; + else $asMessages = $this->asMessageStack[$sType] ?? array(); $this->resetMessageStack($sType); return $this->glueMessages($asMessages); @@ -187,6 +187,4 @@ class PhpObject { $this->cleanMessageStack(); } -} - -?> \ No newline at end of file +} \ No newline at end of file