get_title() public method

Uses , </span> or <span class='highlight'><dc:title></span> </div> </div> <div class="row doc-tags"> <div class="col-md-12"> <div class="tag-block tag-summary"> </div> <div class="tag-block tag-remarks"> </div> <div class="tag-block tag-exception"> </div> <div class="tag-block tag-see"> </div> <div class="tag-block tag-link"> </div> <div class="tag-block tag-deprecated"> </div> <div class="tag-block tag-since"> <div class="field"> Since: <span>1.0 (previously called `get_feed_title` since 0.8)</span> </div> </div> <div class="tag-block tag-author"> </div> </div> </div> <div class="row"> <div class="col-md-12" style="overflow: auto"> <table class="table table-striped"> <tr> <td colspan="3" class="rendered"> <span class="modifier">public</span > <span class="method-name"><a class="method-link" href="https://doc.hotexamples.com/de/class/-/SimplePie#method-get_title">get_title</a></span> ( ) : <span class="return-type"><a href="http://php.net/manual/en/language.types.string.php">string</a> | <a href="http://php.net/manual/en/language.types.null.php">null</a></span> </td> </tr> <tr> <td class="field-return">return</td> <td class="field-return-type"><a href="http://php.net/manual/en/language.types.string.php">string</a> | <a href="http://php.net/manual/en/language.types.null.php">null</a></td> <td></td> </tr> </table> </div> </div> </div> </div> </div> <div class="row" style="margin-bottom: 15px"> <div class="col-md-12"> <a class="btn btn-default" href="https://doc.hotexamples.com/de/class/-/SimplePie"> SimplePie Class Documentation </a> </div> </div> </div> <div id="ezoic-pub-ad-placeholder-106"> </div> <div class="example-item" id="0x98b48626b02cd4d293dadee22e0a3d19298c89fb1d77bebd829e560a648f35a8-68,,130,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #1</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_1" data-hash="0x98b48626b02cd4d293dadee22e0a3d19298c89fb1d77bebd829e560a648f35a8" data-area="68,,130,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '1')" class="rating-up btn btn-success" data-id="rating_1"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'1')" class="rating-down btn btn-danger" data-id="rating_1"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0x98b48626b02cd4d293dadee22e0a3d19298c89fb1d77bebd829e560a648f35a8-68,,130,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0x98b48626b02cd4d293dadee22e0a3d19298c89fb1d77bebd829e560a648f35a8&fullName=src%2FResources%2Fcontao%2FModuleRssReader.php&project=contao%2Fcore-bundle')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fcontao%2Fcore-bundle%2Fblob%2Fmaster%2Fsrc%2FResources%2Fcontao%2FModuleRssReader.php">ModuleRssReader.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fcontao%2Fcore-bundle">contao/core-bundle</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="1"> <pre class="line-numbers language-php" data-end="130" data-start="69" data-highlight="25,84"> /** * Generate the module */ protected function compile() { /** @var PageModel $objPage */ global $objPage; if ($this->rss_template != 'rss_default') { $this->strTemplate = $this->rss_template; /** @var FrontendTemplate|object $objTemplate */ $objTemplate = new \FrontendTemplate($this->strTemplate); $this->Template = $objTemplate; $this->Template->setData($this->arrData); } $this->Template->link = $this->objFeed->get_link(); $this->Template->title = $this->objFeed->get_title(); $this->Template->language = $this->objFeed->get_language(); $this->Template->description = $this->objFeed->get_description(); $this->Template->copyright = $this->objFeed->get_copyright(); // Add image if ($this->objFeed->get_image_url()) { $this->Template->image = true; $this->Template->src = $this->objFeed->get_image_url(); $this->Template->alt = $this->objFeed->get_image_title(); $this->Template->href = $this->objFeed->get_image_link(); $this->Template->height = $this->objFeed->get_image_height(); $this->Template->width = $this->objFeed->get_image_width(); } // Get the items (see #6107) $arrItems = array_slice($this->objFeed->get_items(0, intval($this->numberOfItems) + intval($this->skipFirst)), intval($this->skipFirst), intval($this->numberOfItems) ?: null); $limit = count($arrItems); $offset = 0; // Split pages if ($this->perPage > 0) { // Get the current page $id = 'page_r' . $this->id; $page = \Input::get($id) !== null ? \Input::get($id) : 1; // Do not index or cache the page if the page number is outside the range if ($page < 1 || $page > max(ceil(count($arrItems) / $this->perPage), 1)) { throw new PageNotFoundException('Page not found: ' . \Environment::get('uri')); } // Set limit and offset $offset = ($page - 1) * $this->perPage; $limit = $this->perPage + $offset; $objPagination = new \Pagination(count($arrItems), $this->perPage, \Config::get('maxPaginationLinks'), $id); $this->Template->pagination = $objPagination->generate("\n "); } $items = array(); $last = min($limit, count($arrItems)) - 1; /** @var \SimplePie_Item[] $arrItems */ for ($i = $offset, $c = count($arrItems); $i < $limit && $i < $c; $i++) { $items[$i] = array('link' => $arrItems[$i]->get_link(), 'title' => $arrItems[$i]->get_title(), 'permalink' => $arrItems[$i]->get_permalink(), 'description' => str_replace(array('<?', '?>'), array('&lt;?', '?&gt;'), $arrItems[$i]->get_description()), 'class' => ($i == 0 ? ' first' : '') . ($i == $last ? ' last' : '') . ($i % 2 == 0 ? ' even' : ' odd'), 'pubdate' => \Date::parse($objPage->datimFormat, $arrItems[$i]->get_date('U')), 'category' => $arrItems[$i]->get_category(0), 'object' => $arrItems[$i]); // Add author if (($objAuthor = $arrItems[$i]->get_author(0)) != false) { $items[$i]['author'] = trim($objAuthor->name . ' ' . $objAuthor->email); } // Add enclosure if (($objEnclosure = $arrItems[$i]->get_enclosure(0)) != false) { $items[$i]['enclosure'] = $objEnclosure->get_link(); } } $this->Template->items = array_values($items); }</pre> </div> </figure> </div> <div id="ezoic-pub-ad-placeholder-107"> <div style="text-align: center;margin-bottom: 10px"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- after-example-1 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3697522372581514" data-ad-slot="4981531786" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="example-item" id="0x8e618959ed8eb77e6cb52edb2069ba4a382bb09e219754197b7f3d7c59579c59-37,,85,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #2</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_2" data-hash="0x8e618959ed8eb77e6cb52edb2069ba4a382bb09e219754197b7f3d7c59579c59" data-area="37,,85,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '2')" class="rating-up btn btn-success" data-id="rating_2"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'2')" class="rating-down btn btn-danger" data-id="rating_2"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0x8e618959ed8eb77e6cb52edb2069ba4a382bb09e219754197b7f3d7c59579c59-37,,85,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0x8e618959ed8eb77e6cb52edb2069ba4a382bb09e219754197b7f3d7c59579c59&fullName=tags%2Fmyoos_2.1.4%2Fplanet%2Finc%2Fclass-feeds.php&project=BackupTheBerlios%2Foos-svn')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2FBackupTheBerlios%2Foos-svn%2Fblob%2Fmaster%2Ftags%2Fmyoos_2.1.4%2Fplanet%2Finc%2Fclass-feeds.php">class-feeds.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2FBackupTheBerlios%2Foos-svn">BackupTheBerlios/oos-svn</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="2"> <pre class="line-numbers language-php" data-end="85" data-start="38" data-highlight="79"> /** * Add a new feed to the database * * Adds the specified feed name and URL to the database. If no name is set * by the user, it fetches one from the feed. If the URL specified is a HTML * page and not a feed, it lets SimplePie do autodiscovery and uses the XML * url returned. * * @since 1.0 * * @param string $url URL to feed or website (if autodiscovering) * @param string $name Title/Name of feed * @param string $cat Category to add feed to * @return bool True if succeeded, false if failed */ public function add($url, $name = '', $cat = 'default') { if (empty($url)) { throw new Exception(_r("Couldn't add feed: No feed URL supplied"), Errors::get_code('admin.feeds.no_url')); } if (!preg_match('#https|http|feed#', $url)) { if (strpos($url, '://')) { throw new Exception(_r('Unsupported URL protocol'), Errors::get_code('admin.feeds.protocol_error')); } $url = 'http://' . $url; } require_once LILINA_INCPATH . '/contrib/simplepie/simplepie.inc'; $feed_info = new SimplePie(); $feed_info->set_useragent(LILINA_USERAGENT . ' SimplePie/' . SIMPLEPIE_BUILD); $feed_info->set_stupidly_fast(true); $feed_info->set_cache_location(get_option('cachedir')); $feed_info->set_favicon_handler(get_option('baseurl') . '/lilina-favicon.php'); $feed_info->set_feed_url($url); $feed_info->init(); $feed_error = $feed_info->error(); $feed_url = $feed_info->subscribe_url(); if (!empty($feed_error)) { throw new Exception(sprintf(_r("Couldn't add feed: %s is not a valid URL or the server could not be accessed. Additionally, no feeds could be found by autodiscovery."), $url), Errors::get_code('admin.feeds.invalid_url')); } if (empty($name)) { //Get it from the feed $name = $feed_info->get_title(); } $id = sha1($feed_url); $this->feeds[$id] = array('feed' => $feed_url, 'url' => $feed_info->get_link(), 'id' => $id, 'name' => $name, 'cat' => $cat, 'icon' => $feed_info->get_favicon()); $this->feeds[$id] = apply_filters('feed-create', $this->feeds[$id], $url); $this->save(); return array('msg' => sprintf(_r('Added feed "%1$s"'), $name), 'id' => $id); }</pre> </div> </figure> </div> <div id="ezoic-pub-ad-placeholder-108"> <div style="text-align: center;"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- after-example-2 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3697522372581514" data-ad-slot="7155150962" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="example-item" id="0x6deda3507880300ebc7e2f16f161c48bf8bc52f8359cb91480eacbcbd6d76c93-19,,73,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #3</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_3" data-hash="0x6deda3507880300ebc7e2f16f161c48bf8bc52f8359cb91480eacbcbd6d76c93" data-area="19,,73,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '3')" class="rating-up btn btn-success" data-id="rating_3"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'3')" class="rating-down btn btn-danger" data-id="rating_3"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0x6deda3507880300ebc7e2f16f161c48bf8bc52f8359cb91480eacbcbd6d76c93-19,,73,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0x6deda3507880300ebc7e2f16f161c48bf8bc52f8359cb91480eacbcbd6d76c93&fullName=extensions%2Fwikia%2FWikiaPhotoGalleryRSS.class.php&project=schwarer2006%2Fwikia')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fschwarer2006%2Fwikia%2Fblob%2Fmaster%2Fextensions%2Fwikia%2FWikiaPhotoGalleryRSS.class.php">WikiaPhotoGalleryRSS.class.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fschwarer2006%2Fwikia">schwarer2006/wikia</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="3"> <pre class="line-numbers language-php" data-end="73" data-start="20" data-highlight="36"> static function parseFeed($url, $omitDB = false) { global $wgOut; //reset array self::$data = array('feedTitle' => '', 'images' => array()); if (!$omitDB) { //check DB for this URL - we might have it already (background task will refresh it) $data = self::getDataByUrl($url); } if ($omitDB || is_null($data)) { //no data in DB - fetch from feed $itemCount = 0; $rssContent = Http::get($url); $feed = new SimplePie(); $feed->set_raw_data($rssContent); $feed->init(); self::$data['feedTitle'] = $feed->get_title(); foreach ($feed->get_items() as $item) { $enclosures = $item->get_enclosures(); $enclosuresFound = false; //we have enclosures - use them instead of content of feed (usually there are bigger image while content uses thumbnails) if (!is_null($enclosures)) { foreach ($enclosures as $enclosure) { $type = $enclosure->get_type(); if (!empty($type) && substr($type, 0, 6) === 'image/') { self::$data['images'][] = array('src' => $enclosure->get_link(), 'caption' => $item->get_title(), 'link' => $item->get_link()); $enclosuresFound = true; break; //one image per feed } } } //if enclosures has not been found or doesn't contain any images - use regular method if (!$enclosuresFound) { //look for <img /> tags $description = $item->get_description(); preg_match('/<img .*?src=([\'"])(.*?\\.(?:jpg|jpeg|gif|png))\\1/', $description, $matches); if (!empty($matches[2])) { self::$data['images'][] = array('src' => $matches[2], 'caption' => $item->get_title(), 'link' => $item->get_link()); } } if (count(self::$data['images']) >= 20 || ++$itemCount > 50) { break; //take up to 20 images, from up to 50 articles. } } //store data in DB only if valid rss (images found) if (count(self::$data['images'])) { self::setData($url, self::$data); } } else { self::$data = $data; } return self::$data; }</pre> </div> </figure> </div> <div id="ezoic-pub-ad-placeholder-109"> <div style="text-align: center;"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- after-example-3 --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3697522372581514" data-ad-slot="8699811701" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="example-item" id="0x1dae5c5c0e7a182607cfe7f8cdb71ee6cd08f42bee16791f15ab1be2d04c7ec1-7,,17,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #4</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_4" data-hash="0x1dae5c5c0e7a182607cfe7f8cdb71ee6cd08f42bee16791f15ab1be2d04c7ec1" data-area="7,,17,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '4')" class="rating-up btn btn-success" data-id="rating_4"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'4')" class="rating-down btn btn-danger" data-id="rating_4"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0x1dae5c5c0e7a182607cfe7f8cdb71ee6cd08f42bee16791f15ab1be2d04c7ec1-7,,17,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0x1dae5c5c0e7a182607cfe7f8cdb71ee6cd08f42bee16791f15ab1be2d04c7ec1&fullName=Rss.module.php&project=robrepp%2FStatusarchy')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Frobrepp%2FStatusarchy%2Fblob%2Fmaster%2FRss.module.php">Rss.module.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Frobrepp%2FStatusarchy">robrepp/Statusarchy</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="4"> <pre class="line-numbers language-php" data-end="17" data-start="8" data-highlight="14">function rss($url) { $feed = new SimplePie(); $feed->set_feed_url($url); $feed->handle_content_type(); // Display content: echo '<h2>' . $feed->get_title() . '<br />'; foreach ($feed->get_items() as $item) { echo $item->get_title(); } }</pre> </div> </figure> </div> <div id="ezoic-pub-ad-placeholder-110"> </div> <div class="example-item" id="0xd22c9b86220d63c68a1dab52b172d06052dffb7e620fbdf47cbd4883cb675605-28,,39,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #5</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_5" data-hash="0xd22c9b86220d63c68a1dab52b172d06052dffb7e620fbdf47cbd4883cb675605" data-area="28,,39,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '5')" class="rating-up btn btn-success" data-id="rating_5"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'5')" class="rating-down btn btn-danger" data-id="rating_5"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xd22c9b86220d63c68a1dab52b172d06052dffb7e620fbdf47cbd4883cb675605-28,,39,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xd22c9b86220d63c68a1dab52b172d06052dffb7e620fbdf47cbd4883cb675605&fullName=Feeds.php&project=jelek92%2Fecho')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fjelek92%2Fecho%2Fblob%2Fmaster%2FFeeds.php">Feeds.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fjelek92%2Fecho">jelek92/echo</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="5"> <pre class="line-numbers language-php" data-end="39" data-start="29" data-highlight="37"> static function add($url) { require_once 'lib/simplepie_1.3.compiled.php'; $feed = new SimplePie(); $feed->set_feed_url($_POST['url']); $feed->enable_cache(false); $feed->init(); $feed->handle_content_type(); $values = array(':id' => $feed->feed_url, ':site' => $feed->get_link(), ':title' => $feed->get_title()); $result = Feeds::$db->exec("INSERT OR IGNORE INTO feeds " . "(id, site_url, title) VALUES (:id, :site, :title)", $values); return $result == 0 ? FALSE : TRUE; }</pre> </div> </figure> </div> <div id="ezoic-pub-ad-placeholder-111"> </div> <div class="example-item" id="0x4e48f36ef1aae0e2297246570676ed31e7746a68f03a06430213ee5ccdd5d1be-27,,39,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #6</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_6" data-hash="0x4e48f36ef1aae0e2297246570676ed31e7746a68f03a06430213ee5ccdd5d1be" data-area="27,,39,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '6')" class="rating-up btn btn-success" data-id="rating_6"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'6')" class="rating-down btn btn-danger" data-id="rating_6"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0x4e48f36ef1aae0e2297246570676ed31e7746a68f03a06430213ee5ccdd5d1be-27,,39,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0x4e48f36ef1aae0e2297246570676ed31e7746a68f03a06430213ee5ccdd5d1be&fullName=application%2Fdefault%2FBlogController.php&project=baphled%2Fboodah')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fbaphled%2Fboodah%2Fblob%2Fmaster%2Fapplication%2Fdefault%2FBlogController.php">BlogController.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fbaphled%2Fboodah">baphled/boodah</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="6"> <pre class="line-numbers language-php" data-end="39" data-start="28" data-highlight="37"> function tagAction() { $tag = $this->_request->getParam('tag'); if (empty($tag)) { $this->_redirect('/index'); } $feed = new SimplePie("http://baphled.wordpress.com/tag/{$tag}/feed"); $feed->init(); $this->view->description = $feed->get_description(); $this->view->title = $feed->get_title(); $this->view->items = $feed->get_items(); $this->render('feed'); }</pre> </div> </figure> </div> <div class="example-item" id="0x769fd32707493ffe41f6bd229f3d7c7b4a459c82451cac2a380f6cba1c8959f8-16,,66,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #7</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_7" data-hash="0x769fd32707493ffe41f6bd229f3d7c7b4a459c82451cac2a380f6cba1c8959f8" data-area="16,,66,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '7')" class="rating-up btn btn-success" data-id="rating_7"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'7')" class="rating-down btn btn-danger" data-id="rating_7"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0x769fd32707493ffe41f6bd229f3d7c7b4a459c82451cac2a380f6cba1c8959f8-16,,66,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0x769fd32707493ffe41f6bd229f3d7c7b4a459c82451cac2a380f6cba1c8959f8&fullName=FeedsController.php&project=patrickmj%2FFeedImporter')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fpatrickmj%2FFeedImporter%2Fblob%2Fmaster%2FFeedsController.php">FeedsController.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fpatrickmj%2FFeedImporter">patrickmj/FeedImporter</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="7"> <pre class="line-numbers language-php" data-end="66" data-start="17" data-highlight="37"> public function addAction() { require_once PLUGIN_DIR . "/FeedImporter/libraries/SimplePie/simplepie.inc"; $feed = new SimplePie(); $varName = strtolower($this->_modelClass); $class = $this->_modelClass; $record = new FeedImporter_Feed(); //Need an id to work with the tags, so save it now, even though it might be sloppy/confusing $record->save(); if ($_GET['feed_url']) { $feed_url = $_GET['feed_url']; $debug = new stdClass(); $feed->set_feed_url($feed_url); // Run SimplePie. $feed->init(); $feed->handle_content_type(); if ($feed->error()) { $this->flash($feed->error()); //return here? } $debug->title = $feed->get_title(); $debug->description = $feed->get_description(); //Set up the tag configurations for the first import $import = new FeedImporter_Import(); $import->processFeedTags($feed, $record->id); $record->feed_url = $feed_url; $record->feed_title = $feed->get_title(); $record->feed_description = $feed->get_description(); } $record->save(); // Create a new FakeCron_Task for the feed $fc_task = new FakeCron_Task(); $fc_task->interval = 0; $fc_task->name = "Cron for feed " . $record->feed_title; $fc_task->plugin_class = "FeedImporter_FakeCronTask"; $fc_task->plugin_name = 'FeedImporter'; $fc_task->params = serialize(array($record->id)); $fc_task->save(); $record->task_id = $fc_task->id; $_POST['task_id'] = $fc_task->id; $this->view->assign(array($varName => $record)); try { if ($record->saveForm($_POST)) { $this->redirect->goto('browse'); } } catch (Omeka_Validator_Exception $e) { $this->flashValidationErrors($e); } catch (Exception $e) { $this->flash($e->getMessage()); } }</pre> </div> </figure> </div> <div class="example-item" id="0xfd227e50fba21405f908c0316d37fe55791f058cf5c77acfad7d73d9d81e3a51-134,,155,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #8</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_8" data-hash="0xfd227e50fba21405f908c0316d37fe55791f058cf5c77acfad7d73d9d81e3a51" data-area="134,,155,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '8')" class="rating-up btn btn-success" data-id="rating_8"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'8')" class="rating-down btn btn-danger" data-id="rating_8"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xfd227e50fba21405f908c0316d37fe55791f058cf5c77acfad7d73d9d81e3a51-134,,155,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xfd227e50fba21405f908c0316d37fe55791f058cf5c77acfad7d73d9d81e3a51&fullName=src%2FSearch%2FCollection%2FFeedCollection.php&project=cpliakas%2Ffeed-collection')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fcpliakas%2Ffeed-collection%2Fblob%2Fmaster%2Fsrc%2FSearch%2FCollection%2FFeedCollection.php">FeedCollection.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fcpliakas%2Ffeed-collection">cpliakas/feed-collection</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="8"> <pre class="line-numbers language-php" data-end="155" data-start="135" data-highlight="26,143"> /** * Implements CollectionAbstract::buildDocument(). * * @param IndexDocument $document * @param \SimplePie_Item $data */ public function buildDocument(IndexDocument $document, $data) { $document->source = $this->_feed->get_title(); $document->subject = $this->_feed->get_description(); $document->title = $data->get_title(); $document->link = $data->get_link(); $document->description = $data->get_description(); $document->creator = (array) $data->get_author(); $document->date = $data->get_date(); // PHP properties cannot have dashes (-), and the fields below have // dashes in the field name. $document->source_link = $this->_feed->get_link(); $document->getField('source_link')->setName('source-link'); $document->item_subject = $this->_feed->get_link(); $document->getField('item_subject')->setName('item-subject'); }</pre> </div> </figure> </div> <div class="example-item" id="0xdd26bf500d01df946236610cab0c17b1c9f8f9a3d3d6490c8a3bd6d475d0262f-34,,91,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #9</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_9" data-hash="0xdd26bf500d01df946236610cab0c17b1c9f8f9a3d3d6490c8a3bd6d475d0262f" data-area="34,,91,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '9')" class="rating-up btn btn-success" data-id="rating_9"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'9')" class="rating-down btn btn-danger" data-id="rating_9"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xdd26bf500d01df946236610cab0c17b1c9f8f9a3d3d6490c8a3bd6d475d0262f-34,,91,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xdd26bf500d01df946236610cab0c17b1c9f8f9a3d3d6490c8a3bd6d475d0262f&fullName=inc%2Fclass-feeds.php&project=JocelynDelalande%2FLilina')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2FJocelynDelalande%2FLilina%2Fblob%2Fmaster%2Finc%2Fclass-feeds.php">class-feeds.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2FJocelynDelalande%2FLilina">JocelynDelalande/Lilina</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="9"> <pre class="line-numbers language-php" data-end="91" data-start="35" data-highlight="80"> /** * Add a new feed to the database * * Adds the specified feed name and URL to the database. If no name is set * by the user, it fetches one from the feed. If the URL specified is a HTML * page and not a feed, it lets SimplePie do autodiscovery and uses the XML * url returned. * * @since 1.0 * * @param string $url URL to feed or website (if autodiscovering) * @param string $name Title/Name of feed * @param string $cat Category to add feed to * @return bool True if succeeded, false if failed */ public function add($url, $name = '', $cat = 'default') { if (empty($url)) { throw new Exception(_r("Couldn't add feed: No feed URL supplied"), Errors::get_code('admin.feeds.no_url')); } if (!preg_match('#https|http|feed#', $url)) { if (strpos($url, '://')) { throw new Exception(_r('Unsupported URL protocol'), Errors::get_code('admin.feeds.protocol_error')); } $url = 'http://' . $url; } $reporting = error_reporting(); error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR); require_once LILINA_INCPATH . '/contrib/simplepie.class.php'; // Need this for LILINA_USERAGENT class_exists('HTTPRequest'); require_once LILINA_INCPATH . '/core/class-httprequest.php'; $feed_info = new SimplePie(); $feed_info->set_useragent(LILINA_USERAGENT . ' SimplePie/' . SIMPLEPIE_BUILD); $feed_info->set_stupidly_fast(true); $feed_info->set_cache_location(get_option('cachedir')); $feed_info->set_feed_url($url); $feed_info->init(); $feed_error = $feed_info->error(); $feed_url = $feed_info->subscribe_url(); if (!empty($feed_error)) { throw new Exception(sprintf(_r("Couldn't add feed: %s is not a valid URL or the server could not be accessed. Additionally, no feeds could be found by autodiscovery."), $url), Errors::get_code('admin.feeds.invalid_url')); } if (empty($name)) { //Get it from the feed $name = $feed_info->get_title(); } $id = sha1($feed_url); // Do a naive check to see if the feed already exists if ($this->get($id) !== false) { throw new Exception(_r("Couldn't add feed: you have already added that feed"), Errors::get_code('admin.feeds.feed_already_exists')); } $this->feeds[$id] = array('feed' => $feed_url, 'url' => $feed_info->get_link(), 'id' => $id, 'name' => $name, 'cat' => $cat, 'icon' => self::discover_favicon($feed_info, $id)); $this->feeds[$id] = apply_filters('feed-create', $this->feeds[$id], $url, $feed_info); $this->save(); error_reporting($reporting); return array('msg' => sprintf(_r('Added feed "%1$s"'), $name), 'id' => $id); }</pre> </div> </figure> </div> <div class="example-item" id="0x000366d39073f2f71f6594e3217706986464f801ffac9ee99322d49110d9cfbe-11,,29,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #10</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_10" data-hash="0x000366d39073f2f71f6594e3217706986464f801ffac9ee99322d49110d9cfbe" data-area="11,,29,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '10')" class="rating-up btn btn-success" data-id="rating_10"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'10')" class="rating-down btn btn-danger" data-id="rating_10"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0x000366d39073f2f71f6594e3217706986464f801ffac9ee99322d49110d9cfbe-11,,29,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0x000366d39073f2f71f6594e3217706986464f801ffac9ee99322d49110d9cfbe&fullName=application%2FFeedreader.php&project=orazionelson%2Fcocktail')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Forazionelson%2Fcocktail%2Fblob%2Fmaster%2Fapplication%2FFeedreader.php">Feedreader.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Forazionelson%2Fcocktail">orazionelson/cocktail</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="10"> <pre class="line-numbers language-php" data-end="29" data-start="12" data-highlight="25"> public function index() { // Define Meta $this->title = "Feedreader"; $this->description = "A Feedreader for Cocktail"; $feed = new SimplePie(); $feed->set_feed_url($this->sources); $feed->set_cache_location($this->rss_cache); $feed->set_item_limit(5); $feed->init(); $feed->handle_content_type(); //Somedata for the page. $toView["date_format"] = $this->rss_date_format; $toView["title"] = $feed->get_title(); $toView["items"] = $feed->get_items(0, $this->limit); /*short cut to load->view("pages/page_name",$content,true)*/ $this->build_content($toView); $this->render_page(); }</pre> </div> </figure> </div> <div class="example-item" id="0xdb1b9e5a2a123539d9b19e8e0a0ec18f1cfb76786ac533feadd4585a106626b1-62,,82,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #11</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_11" data-hash="0xdb1b9e5a2a123539d9b19e8e0a0ec18f1cfb76786ac533feadd4585a106626b1" data-area="62,,82,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '11')" class="rating-up btn btn-success" data-id="rating_11"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'11')" class="rating-down btn btn-danger" data-id="rating_11"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xdb1b9e5a2a123539d9b19e8e0a0ec18f1cfb76786ac533feadd4585a106626b1-62,,82,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xdb1b9e5a2a123539d9b19e8e0a0ec18f1cfb76786ac533feadd4585a106626b1&fullName=wtorrent%2Fwt%2FFeeds.cls.php&project=santa01%2Fwtorrent')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fsanta01%2Fwtorrent%2Fblob%2Fmaster%2Fwtorrent%2Fwt%2FFeeds.cls.php">Feeds.cls.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fsanta01%2Fwtorrent">santa01/wtorrent</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="11"> <pre class="line-numbers language-php" data-end="82" data-start="63" data-highlight="81"> private function view() { $feeds = $this->_db->queryAll('SELECT id, url, title FROM feeds WHERE user = ? ORDER BY title, url', $this->getIdUser()); $this->info = array(); foreach ($feeds as $feed) { $pie = new SimplePie(); $pie->set_feed_url($feed['url']); $pie->set_cache_location(rtrim(DIR_TPL_COMPILE, '/')); $pie->init(); $pie->handle_content_type(); $items = $pie->get_items(0, self::FEED_MAX_ITEMS); $now = time(); for ($i = count($items) - 1; $i != 0; --$i) { $time = $items[$i]->get_date('U'); if ($time && $now - $time > self::FEED_MAX_DAYS * 86400) { array_pop($items); } } $this->info[] = array('title' => empty($feed['title']) ? $pie->get_title() : $feed['title'], 'id' => $feed['id'], 'description' => $pie->get_description(), 'news' => $items); } }</pre> </div> </figure> </div> <div class="example-item" id="0x8d29438bab1253ea23feb5be308f7e70a9ec36f76803308e4cda2146f3e44c3f-21,,59,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #12</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_12" data-hash="0x8d29438bab1253ea23feb5be308f7e70a9ec36f76803308e4cda2146f3e44c3f" data-area="21,,59,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '12')" class="rating-up btn btn-success" data-id="rating_12"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'12')" class="rating-down btn btn-danger" data-id="rating_12"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0x8d29438bab1253ea23feb5be308f7e70a9ec36f76803308e4cda2146f3e44c3f-21,,59,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0x8d29438bab1253ea23feb5be308f7e70a9ec36f76803308e4cda2146f3e44c3f&fullName=controllers%2Fsimplepie.php&project=vad%2Ftaolin')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fvad%2Ftaolin%2Fblob%2Fmaster%2Fcontrollers%2Fsimplepie.php">simplepie.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fvad%2Ftaolin">vad/taolin</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="12"> <pre class="line-numbers language-php" data-end="59" data-start="22" data-highlight="38"> function feed_paginate($feed_url, $start = 0, $limit = 5) { //make the cache dir if it doesn't exist if (!file_exists($this->cache)) { $folder = new Folder($this->cache, true); } //include the vendor class App::import('Vendor', 'simplepie/simplepie'); //setup SimplePie $feed = new SimplePie(); $feed->set_feed_url($feed_url); $feed->set_cache_location($this->cache); //retrieve the feed $feed->init(); //limits $max = $start + $limit; $items['title'] = $feed->get_title(); $items['image_url'] = $feed->get_image_url(); $items['image_height'] = $feed->get_image_height(); $items['image_width'] = $feed->get_image_width(); //$items['title'] = $feed->get_title(); //get the feed items $items['quantity'] = $feed->get_item_quantity(); if ($items['quantity'] < $start) { $items['items'] = false; return $items; } elseif ($items['quantity'] < $max) { $max = $items['quantity']; } for ($i = $start; $i < $max; $i++) { $items['items'][] = $feed->get_item($i); } //return if ($items) { return $items; } else { return false; } }</pre> </div> </figure> </div> <div class="example-item" id="0x9abc301cc3ac4127e934b7c3b09382a4541007a6b3d356bc291c5f000a540eb5-6,,29,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #13</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_13" data-hash="0x9abc301cc3ac4127e934b7c3b09382a4541007a6b3d356bc291c5f000a540eb5" data-area="6,,29,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '13')" class="rating-up btn btn-success" data-id="rating_13"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'13')" class="rating-down btn btn-danger" data-id="rating_13"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0x9abc301cc3ac4127e934b7c3b09382a4541007a6b3d356bc291c5f000a540eb5-6,,29,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0x9abc301cc3ac4127e934b7c3b09382a4541007a6b3d356bc291c5f000a540eb5&fullName=functions.php&project=vertino%2Fpez')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fvertino%2Fpez%2Fblob%2Fmaster%2Ffunctions.php">functions.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fvertino%2Fpez">vertino/pez</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="13"> <pre class="line-numbers language-php" data-end="29" data-start="7" data-highlight="24">function combine_feeds($feed_list, $max_items = 10, $delimiter = '~', $remove_html = true) { if (empty($feed_list)) { return false; } $combined_feed = array(); foreach ($feed_list as $url) { $feed = new SimplePie(); $feed->set_feed_url($url); $feed->set_cache_location(ABSPATH . '/cache'); //$feed->replace_headers(true); if ($remove_html) { $feed->strip_htmltags(array('img', 'a', 'object', 'embed', 'param', 'iframe', 'p', 'br', 'div', 'span', 'li', 'ul')); } $feed->set_output_encoding(CHARSET); $feed->init(); foreach ($feed->get_items(0, $max_items) as $item) { $combined_feed[$item->get_date('U') . $delimiter . $feed->get_title() . $delimiter . $url] = $item; } unset($feed); } krsort($combined_feed); return array_slice($combined_feed, 0, $max_items); }</pre> </div> </figure> </div> <div class="example-item" id="0xc097a92bce6cfda9cbe0079dc66255a4e5d9193d51eb26ab087fe21a94c2a0f5-188,,351,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #14</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_14" data-hash="0xc097a92bce6cfda9cbe0079dc66255a4e5d9193d51eb26ab087fe21a94c2a0f5" data-area="188,,351,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '14')" class="rating-up btn btn-success" data-id="rating_14"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'14')" class="rating-down btn btn-danger" data-id="rating_14"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xc097a92bce6cfda9cbe0079dc66255a4e5d9193d51eb26ab087fe21a94c2a0f5-188,,351,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xc097a92bce6cfda9cbe0079dc66255a4e5d9193d51eb26ab087fe21a94c2a0f5&fullName=core%2Ffeed.class.php&project=smbale%2Fopen-social-media-toolkit')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fsmbale%2Fopen-social-media-toolkit%2Fblob%2Fmaster%2Fcore%2Ffeed.class.php">feed.class.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fsmbale%2Fopen-social-media-toolkit">smbale/open-social-media-toolkit</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="14"> <pre class="line-numbers language-php" data-end="351" data-start="189" data-highlight="202"> function simpleProcessFeed($feed = NULL, $target = 'newswire') { $importLog = PATH_SERVER_LOGS . 'import.log'; // for bookmarks // process feed with simple pie require_once PATH_CORE . '/utilities/simplepie.inc'; // Create a new instance of the SimplePie object $sp = new SimplePie(); $sp->set_feed_url($feed->rss); $sp->set_cache_location(PATH_CACHE); $success = $sp->init(); $sp->handle_content_type(); if ($success) { echo '<h2>' . $sp->get_title() . '</h2><br />'; // set up a feedTime as a backup for feeds without dates in them $spTime = time(); $cnt = 0; // count headlines in feed foreach ($sp->get_items() as $item) { $spTime = $spTime - 60 * 15; // go fifteen minutes back for each feed item // clean up brand labels $itemTitle = $item->get_title(); $itemDescription = $item->get_content(); if ($author = $item->get_author()) { $authorName = $author->get_name(); } else { $authorName = ''; } // get the date $itemDate = $item->get_date('Y-m-d H:i:s'); if ($itemDate == '') { $itemDate = date('Y-m-d H:i:s', $spTime); } $itemLink = $item->get_permalink(); // skip open threads if (stristr($itemTitle, 'open thread') === FALSE) { switch ($target) { case 'newswire': $feedItem = $this->nwObj->serialize($itemTitle, $itemDescription, $feed->title, $itemLink, $itemDate, $feed->wireid, $feed->feedType, $feed->id); // load into newswire table $id = $this->nwObj->add($feedItem); // returns false on duplicate if ($id !== false) { echo 'insert ' . $itemTitle . '<br>'; if ($enclosure = $item->get_enclosure()) { // look up thumbnail switch ($spNotes) { default: // look for default image url $mediaUrl = $this->db->safe($enclosure->link); $imageUrl = $this->db->safe($enclosure->get_thumbnail()); $embed = $this->db->safe($enclosure->embed()); print_r($mediaUrl); echo '<br />'; print_r($imageUrl); echo '<br />'; var_dump($embed); echo '<br />'; $this->db->update("Newswire", "imageUrl='{$imageUrl}',mediaUrl='{$mediaUrl}',embed='{$embed}'", "id={$id}"); break; case 'inlineImage': // feeds like Countdown that embed the thumbnail incorrectly $embed = $enclosure->native_embed(); $link = $this->parseLink($embed); $this->db->update("Newswire", "imageUrl='{$link}'", "id={$id}"); break; } } // for new items - check for loadOption switch ($feed->loadOptions) { default: // none - do nothing break; case 'all': // add story to content table $this->loadStory($feedItem, $feed); break; case 'matches': // add story to content table if it matches one of our feeds if ($feed->feedType == 'bookmarks' and ($this->checkMatches($feedItem) or $this->checkKeywords($itemTitle, $itemDescription)) !== false) { $this->db->log('IMPORT:' . $itemTitle, $importLog); $this->loadStory($feedItem, $feed); } else { $this->db->log('No match:' . $itemTitle, $importLog); } break; } } break; case 'FeedMedia': // flickr atom is rss where best image is in content // echo 'title '.$itemTitle.'<br>'; // strip img tags for medium pics from itemDescription // echo 'descrip <pre>'.$itemDescription.'</pre><br>'; $imgList = $this->_parsePageImages($itemDescription); // var_dump($imgList); // echo 'link:'.$itemLink.'<br>'; if ($enclosure = $item->get_enclosure()) { // look up thumbnail switch ($spNotes) { default: // look for default image url $mediaUrl = $this->db->safe($enclosure->link); $imageUrl = $this->db->safe($enclosure->get_thumbnail()); $embed = $this->db->safe($enclosure->embed()); // print_r($mediaUrl); // echo '<br />'; // print_r($imageUrl); // echo '<br />'; // var_dump ($embed); // echo '<br />'; break; case 'inlineImage': // feeds like Countdown that embed the thumbnail incorrectly $embed = $enclosure->native_embed(); $link = $this->parseLink($embed); break; } } switch ($feed->specialType) { case 'flickrContent': $fmTable = new FeedMediaTable($this->db); $m = $fmTable->getRowObject(); $m->title = $itemTitle; $m->author = $authorName; $m->caption = nl2br(strip_tags($itemDescription)); $m->previewImageUrl = $imgList[0]['src']; $m->linkUrl = $itemLink; $m->imageUrl = $mediaUrl; $m->numLikes = 0; $m->numComments = 0; $m->fbId = 0; $m->t = $itemDate; $m->mediaType = 'image'; if (!$fmTable->isDup($m->linkUrl, $m->imageUrl) and $m->imageUrl != '') { switch ($feed->loadOptions) { default: if (!array_search($authorName, $this->authorList) or $authorName == '') { // only use each flickr photographer/author once per fetch $m->insert(); $this->authorList[] = $authorName; } break; case 'all': // load every image from this feed $m->insert(); $this->authorList[] = $authorName; break; } } break; } break; } } $cnt += 1; if ($cnt > 25) { break; } // only do this many headlines } } }</pre> </div> </figure> </div> <div class="example-item" id="0xd56ee2f6669ec83a60ac776793c1f4aa6f7934dbd1b8b21a63a8f97a46392369-324,,355,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #15</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_15" data-hash="0xd56ee2f6669ec83a60ac776793c1f4aa6f7934dbd1b8b21a63a8f97a46392369" data-area="324,,355,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '15')" class="rating-up btn btn-success" data-id="rating_15"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'15')" class="rating-down btn btn-danger" data-id="rating_15"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xd56ee2f6669ec83a60ac776793c1f4aa6f7934dbd1b8b21a63a8f97a46392369-324,,355,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xd56ee2f6669ec83a60ac776793c1f4aa6f7934dbd1b8b21a63a8f97a46392369&fullName=userfiles%2Fplugins%2Frss_grabber_model.php&project=Gninety%2FMicroweber')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2FGninety%2FMicroweber%2Fblob%2Fmaster%2Fuserfiles%2Fplugins%2Frss_grabber_model.php">rss_grabber_model.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2FGninety%2FMicroweber">Gninety/Microweber</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="15"> <pre class="line-numbers language-php" data-end="355" data-start="325" data-highlight="353"> function rssGetTitleFromFeedUrl($url) { require_once 'feedparser/simplepie.inc'; $criteria['feed_url'] = $url; if ($criteria['feed_url'] != '') { $link = $criteria['feed_url']; $linkbits = parse_url($link); $host = $linkbits['host']; //******************************************** //So now $host = www.url.com //All I have to do is remove the 'www.': //******************************************** // find pos of first dot if (stristr($host, 'www.') == true) { $dot_pos = strpos($host, '.', 0) + 1; // make a new substring $domain = substr($host, $dot_pos); } else { $domain = $host; } $criteria['feed_domain'] = $domain; } if (stristr($criteria['feed_url'], 'http') == true) { $feed = new SimplePie(); $feed->set_feed_url($criteria['feed_url']); $feed->enable_order_by_date(false); $feed->set_cache_location(CACHEDIR); $feed->init(); $criteria['feed_title'] = $feed->get_title(); } return trim($criteria['feed_title']); }</pre> </div> </figure> </div> <div class="example-item" id="0xcf611567c0d4c2c04d992254439492abcbd30da66b27f8ee1574d346e1ff9e96-114,,137,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #16</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_16" data-hash="0xcf611567c0d4c2c04d992254439492abcbd30da66b27f8ee1574d346e1ff9e96" data-area="114,,137,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '16')" class="rating-up btn btn-success" data-id="rating_16"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'16')" class="rating-down btn btn-danger" data-id="rating_16"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xcf611567c0d4c2c04d992254439492abcbd30da66b27f8ee1574d346e1ff9e96-114,,137,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xcf611567c0d4c2c04d992254439492abcbd30da66b27f8ee1574d346e1ff9e96&fullName=src%2Fcommon%2FWidget_Rss.class.php&project=pombredanne%2Ftuleap')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fpombredanne%2Ftuleap%2Fblob%2Fmaster%2Fsrc%2Fcommon%2FWidget_Rss.class.php">Widget_Rss.class.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fpombredanne%2Ftuleap">pombredanne/tuleap</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="16"> <pre class="line-numbers language-php" data-end="137" data-start="115" data-highlight="131"> function create($request) { $content_id = false; $vUrl = new Valid_String('url'); $vUrl->setErrorMessage("Can't add empty rss url"); $vUrl->required(); if ($request->validInArray('rss', $vUrl)) { $rss = $request->get('rss'); $vTitle = new Valid_String('title'); $vTitle->required(); if (!$request->validInArray('rss', $vTitle)) { require_once 'common/rss/libs/SimplePie/simplepie.inc'; if (!is_dir($GLOBALS['codendi_cache_dir'] . '/rss')) { mkdir($GLOBALS['codendi_cache_dir'] . '/rss'); } $rss_reader = new SimplePie($rss['url'], $GLOBALS['codendi_cache_dir'] . '/rss', null, $GLOBALS['sys_proxy']); $rss['title'] = $rss_reader->get_title(); } $sql = 'INSERT INTO widget_rss (owner_id, owner_type, title, url) VALUES (' . $this->owner_id . ", '" . $this->owner_type . "', '" . db_escape_string($rss['title']) . "', '" . db_escape_string($rss['url']) . "')"; $res = db_query($sql); $content_id = db_insertid($res); } return $content_id; }</pre> </div> </figure> </div> <div class="example-item" id="0xcdb0978f3f953c34dd9d05fcddf3dd99b638d64d664b445eaba0f030f17a0360-122,,283,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #17</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_17" data-hash="0xcdb0978f3f953c34dd9d05fcddf3dd99b638d64d664b445eaba0f030f17a0360" data-area="122,,283,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '17')" class="rating-up btn btn-success" data-id="rating_17"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'17')" class="rating-down btn btn-danger" data-id="rating_17"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xcdb0978f3f953c34dd9d05fcddf3dd99b638d64d664b445eaba0f030f17a0360-122,,283,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xcdb0978f3f953c34dd9d05fcddf3dd99b638d64d664b445eaba0f030f17a0360&fullName=application%2Frefresh.php&project=esironal%2Freaderself')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fesironal%2Freaderself%2Fblob%2Fmaster%2Fapplication%2Frefresh.php">refresh.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fesironal%2Freaderself">esironal/readerself</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="17"> <pre class="line-numbers language-php" data-end="283" data-start="123" data-highlight="224"> public function items() { if ($this->input->is_ajax_request()) { $this->readerself_library->set_template('_json'); $this->readerself_library->set_content_type('application/json'); $content = array(); } else { $this->readerself_library->set_template('_plain'); $this->readerself_library->set_content_type('text/plain'); $content = ''; } if ($this->input->is_cli_request() && !$this->config->item('refresh_by_cron')) { $content .= 'Refresh by cron disabled' . "\n"; } else { include_once 'thirdparty/simplepie/autoloader.php'; include_once 'thirdparty/simplepie/idn/idna_convert.class.php'; if ($this->config->item('facebook/enabled')) { include_once 'thirdparty/facebook/autoload.php'; $fb = new Facebook\Facebook(array('app_id' => $this->config->item('facebook/id'), 'app_secret' => $this->config->item('facebook/secret'))); $fbApp = $fb->getApp(); $accessToken = $fbApp->getAccessToken(); } $query = $this->db->query('SELECT fed.* FROM ' . $this->db->dbprefix('feeds') . ' AS fed WHERE fed.fed_nextcrawl IS NULL OR fed.fed_nextcrawl <= ? GROUP BY fed.fed_id HAVING (SELECT COUNT(DISTINCT(sub.mbr_id)) FROM ' . $this->db->dbprefix('subscriptions') . ' AS sub WHERE sub.fed_id = fed.fed_id) > 0', array(date('Y-m-d H:i:s'))); if ($query->num_rows() > 0) { $microtime_start = microtime(1); $errors = 0; foreach ($query->result() as $fed) { $parse_url = parse_url($fed->fed_link); if (isset($parse_url['host']) == 1 && $parse_url['host'] == 'www.facebook.com' && $this->config->item('facebook/enabled')) { try { $parts = explode('/', $parse_url['path']); $total_parts = count($parts); $last_part = $parts[$total_parts - 1]; $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', $last_part . '?fields=link,name,about'); $response = $fb->getClient()->sendRequest($request); $result = $response->getDecodedBody(); $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', $last_part . '?fields=feed{created_time,id,message,story,full_picture,place,type,status_type,link}'); $response = $fb->getClient()->sendRequest($request); $posts = $response->getDecodedBody(); $this->readerself_library->crawl_items_facebook($fed->fed_id, $posts['feed']['data']); $lastitem = $this->db->query('SELECT itm.itm_datecreated FROM ' . $this->db->dbprefix('items') . ' AS itm WHERE itm.fed_id = ? GROUP BY itm.itm_id ORDER BY itm.itm_id DESC LIMIT 0,1', array($fed->fed_id))->row(); $this->db->set('fed_title', $result['name']); $this->db->set('fed_url', $result['link']); $this->db->set('fed_link', $result['link']); if (isset($parse_url['host']) == 1) { $this->db->set('fed_host', $parse_url['host']); } $this->db->set('fed_description', $result['about']); $this->db->set('fed_lasterror', ''); $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s')); if ($lastitem) { $nextcrawl = ''; //older than 96 hours, next crawl in 12 hours if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24 * 96)) { $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 12); //older than 48 hours, next crawl in 6 hours } else { if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 48)) { $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 6); //older than 24 hours, next crawl in 3 hours } else { if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24)) { $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 3); } } } $this->db->set('fed_nextcrawl', $nextcrawl); } $this->db->where('fed_id', $fed->fed_id); $this->db->update('feeds'); } catch (Facebook\Exceptions\FacebookResponseException $e) { $errors++; $this->db->set('fed_lasterror', 'Graph returned an error: ' . $e->getMessage()); $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s')); $this->db->where('fed_id', $fed->fed_id); $this->db->update('feeds'); } catch (Facebook\Exceptions\FacebookSDKException $e) { $errors++; $this->db->set('fed_lasterror', 'Facebook SDK returned an error: ' . $e->getMessage()); $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s')); $this->db->where('fed_id', $fed->fed_id); $this->db->update('feeds'); } } else { $sp_feed = new SimplePie(); $sp_feed->set_feed_url(convert_to_ascii($fed->fed_link)); $sp_feed->enable_cache(false); $sp_feed->set_timeout(5); $sp_feed->force_feed(true); $sp_feed->init(); $sp_feed->handle_content_type(); if ($sp_feed->error()) { $errors++; $this->db->set('fed_lasterror', $sp_feed->error()); $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s')); $this->db->where('fed_id', $fed->fed_id); $this->db->update('feeds'); } else { $this->readerself_library->crawl_items($fed->fed_id, $sp_feed->get_items()); $lastitem = $this->db->query('SELECT itm.itm_datecreated FROM ' . $this->db->dbprefix('items') . ' AS itm WHERE itm.fed_id = ? GROUP BY itm.itm_id ORDER BY itm.itm_id DESC LIMIT 0,1', array($fed->fed_id))->row(); $parse_url = parse_url($sp_feed->get_link()); $this->db->set('fed_title', $sp_feed->get_title()); $this->db->set('fed_url', $sp_feed->get_link()); $this->db->set('fed_link', $sp_feed->subscribe_url()); if (isset($parse_url['host']) == 1) { $this->db->set('fed_host', $parse_url['host']); } if ($sp_feed->get_type() & SIMPLEPIE_TYPE_RSS_ALL) { $this->db->set('fed_type', 'rss'); } else { if ($sp_feed->get_type() & SIMPLEPIE_TYPE_ATOM_ALL) { $this->db->set('fed_type', 'atom'); } } if ($sp_feed->get_image_url()) { $this->db->set('fed_image', $sp_feed->get_image_url()); } $this->db->set('fed_description', $sp_feed->get_description()); $this->db->set('fed_lasterror', ''); $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s')); if ($lastitem) { $nextcrawl = ''; //older than 96 hours, next crawl in 12 hours if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24 * 96)) { $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 12); //older than 48 hours, next crawl in 6 hours } else { if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 48)) { $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 6); //older than 24 hours, next crawl in 3 hours } else { if ($lastitem->itm_datecreated < date('Y-m-d H:i:s', time() - 3600 * 24)) { $nextcrawl = date('Y-m-d H:i:s', time() + 3600 * 3); } } } $this->db->set('fed_nextcrawl', $nextcrawl); } $this->db->where('fed_id', $fed->fed_id); $this->db->update('feeds'); } $sp_feed->__destruct(); unset($sp_feed); } } $this->db->set('crr_time', microtime(1) - $microtime_start); if (function_exists('memory_get_peak_usage')) { $this->db->set('crr_memory', memory_get_peak_usage()); } $this->db->set('crr_feeds', $query->num_rows()); if ($errors > 0) { $this->db->set('crr_errors', $errors); } $this->db->set('crr_datecreated', date('Y-m-d H:i:s')); $this->db->insert('crawler'); if ($this->db->dbdriver == 'mysqli') { $this->db->query('OPTIMIZE TABLE categories, connections, enclosures, favorites, feeds, folders, history, items, members, share, subscriptions'); } } } $this->readerself_library->set_content($content); }</pre> </div> </figure> </div> <div class="example-item" id="0xc8d14f6f88c3c764fb98af6aacb14c799475e178f37eac860c30ef1c5f435af5-0,,30,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #18</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_18" data-hash="0xc8d14f6f88c3c764fb98af6aacb14c799475e178f37eac860c30ef1c5f435af5" data-area="0,,30,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '18')" class="rating-up btn btn-success" data-id="rating_18"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'18')" class="rating-down btn btn-danger" data-id="rating_18"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xc8d14f6f88c3c764fb98af6aacb14c799475e178f37eac860c30ef1c5f435af5-0,,30,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xc8d14f6f88c3c764fb98af6aacb14c799475e178f37eac860c30ef1c5f435af5&fullName=index.php&project=sampurtill%2FStanford-Daily-mobile')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fsampurtill%2FStanford-Daily-mobile%2Fblob%2Fmaster%2Findex.php">index.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fsampurtill%2FStanford-Daily-mobile">sampurtill/Stanford-Daily-mobile</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="18"> <pre class="line-numbers language-php" data-end="30" data-start="1" data-highlight="16"><?php require_once '../environment.php'; $sFeedUri = 'http://www.stanforddaily.com/feed/'; $SimplePie = new SimplePie(); $SimplePie->enable_cache(false); $SimplePie->set_feed_url($sFeedUri); $SimplePie->init(); $SimplePie->handle_content_type(); if ($SimplePie->error()) { // TODO: Delete that feed?? $SimplePie->__destruct(); continue; } $GLOBALS['aStories'] = array(); $sFeedTitle = $SimplePie->get_title(); foreach ($SimplePie->get_items() as $oItem) { $nTimestamp = strtotime($oItem->get_date()); // Don't import posts from the "FUTURE" if ($nTimestamp > time()) { continue; } // Set vars $sTitle = $oItem->get_title(); $sLink = $oItem->get_permalink(); // now get rid of the http://stanforddaily stuff $sLocalUri = mb_substr($sLink, 28); if (mb_strlen($sTitle) > 0) { $aStories[] = array('title' => $sTitle, 'authors' => $oItem->get_authors(), 'description' => $oItem->get_description(), 'url' => $sLink, 'local_uri' => $sLocalUri, 'published_at' => $nTimestamp); } }</pre> </div> </figure> </div> <div class="example-item" id="0xc867de624f61d4fccf2f3ec27e72761977ce50bf7425d9dda9658afabed4d72a-96,,124,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #19</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_19" data-hash="0xc867de624f61d4fccf2f3ec27e72761977ce50bf7425d9dda9658afabed4d72a" data-area="96,,124,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '19')" class="rating-up btn btn-success" data-id="rating_19"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'19')" class="rating-down btn btn-danger" data-id="rating_19"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xc867de624f61d4fccf2f3ec27e72761977ce50bf7425d9dda9658afabed4d72a-96,,124,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xc867de624f61d4fccf2f3ec27e72761977ce50bf7425d9dda9658afabed4d72a&fullName=feed.php&project=scarnago%2Fpipecode')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fscarnago%2Fpipecode%2Fblob%2Fmaster%2Ffeed.php">feed.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fscarnago%2Fpipecode">scarnago/pipecode</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="19"> <pre class="line-numbers language-php" data-end="124" data-start="97" data-highlight="108">function add_feed($uri) { if (db_has_rec("feed", array("uri" => $uri))) { //die("feed already exists [$uri]"); $feed = db_get_rec("feed", array("uri" => $uri)); return $feed["fid"]; } $data = download_feed($uri); $sp = new SimplePie(); $sp->set_raw_data($data); $sp->init(); $title = $sp->get_title(); $link = get_feed_link($sp, $uri); $count = $sp->get_item_quantity(); if (strlen($title) == 0 || $count == 0) { die("unable to parse feed [{$uri}]"); //die("unable to parse feed [$uri] data [$data]"); } $feed = array(); $feed["fid"] = 0; $feed["time"] = time(); $feed["uri"] = $uri; $feed["title"] = $title; $feed["link"] = $link; db_set_rec("feed", $feed); $feed = db_get_rec("feed", array("uri" => $uri)); save_feed($feed["fid"], $data); return $feed["fid"]; }</pre> </div> </figure> </div> <div class="example-item" id="0xc5c2f7cd4fb02e2a0e07825b328af282ac342dc8e08ea58fe7be3dbdc567ea1d-30,,60,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #20</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_20" data-hash="0xc5c2f7cd4fb02e2a0e07825b328af282ac342dc8e08ea58fe7be3dbdc567ea1d" data-area="30,,60,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '20')" class="rating-up btn btn-success" data-id="rating_20"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'20')" class="rating-down btn btn-danger" data-id="rating_20"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xc5c2f7cd4fb02e2a0e07825b328af282ac342dc8e08ea58fe7be3dbdc567ea1d-30,,60,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xc5c2f7cd4fb02e2a0e07825b328af282ac342dc8e08ea58fe7be3dbdc567ea1d&fullName=website%2Fsubscriptions.php&project=KasaiDot%2FFansubs.cat')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2FKasaiDot%2FFansubs.cat%2Fblob%2Fmaster%2Fwebsite%2Fsubscriptions.php">subscriptions.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2FKasaiDot%2FFansubs.cat">KasaiDot/Fansubs.cat</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="20"> <pre class="line-numbers language-php" data-end="60" data-start="31" data-highlight="48"> if (!isset($person['delete'])) { $newOpml->entries[] = $person; } } else { $newOpml->entries[] = $person; } } } // Add feed if (isset($_POST['add'])) { if ('http://' != $_POST['url']) { //autodiscover feed $feed = new SimplePie(); $feed->enable_cache(false); $feed->set_feed_url($_POST['url']); $feed->init(); $feed->handle_content_type(); $person['name'] = $feed->get_title(); $person['website'] = $feed->get_permalink(); $person['feed'] = $feed->feed_url; $oldOpml->entries[] = $person; $newOpml->entries = $oldOpml->entries; } } // Backup old OPML OpmlManager::backup(dirname(__FILE__) . '/../custom/people.opml'); // Save new OPML OpmlManager::save($newOpml, dirname(__FILE__) . '/../custom/people.opml'); } header("Location: index.php"); die;</pre> </div> </figure> </div> <div class="example-item" id="0xb7907539ed836312b55da12d4ede35e009fa52f9fa70c1bcdac45d0a65026530-275,,310,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #21</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_21" data-hash="0xb7907539ed836312b55da12d4ede35e009fa52f9fa70c1bcdac45d0a65026530" data-area="275,,310,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '21')" class="rating-up btn btn-success" data-id="rating_21"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'21')" class="rating-down btn btn-danger" data-id="rating_21"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xb7907539ed836312b55da12d4ede35e009fa52f9fa70c1bcdac45d0a65026530-275,,310,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xb7907539ed836312b55da12d4ede35e009fa52f9fa70c1bcdac45d0a65026530&fullName=pokemon%2Fapp%2Fcontrollers%2Frss.php&project=laiello%2Fmsgr')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Flaiello%2Fmsgr%2Fblob%2Fmaster%2Fpokemon%2Fapp%2Fcontrollers%2Frss.php">rss.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Flaiello%2Fmsgr">laiello/msgr</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="21"> <pre class="line-numbers language-php" data-end="310" data-start="276" data-highlight="284"> public function parse_single_feed($flux) { $feed = new SimplePie(); $feed->set_feed_url($_POST['url']); $feed->init(); if (!$feed->error()) { $feed->enable_cache(false); $feed->handle_content_type(); $feed_title = strip_tags($feed->get_title()); if (strlen($feed_title) > 50) { $feed_title = substr($feed_title, 0, 47) . '...'; } $exist = $this->getConnectionWrapper()->addFlux($_POST['url'], $feed_title, $feed->get_description()); $idFlux = $this->getConnectionWrapper()->getFluxId($feed_title); $this->NON_CLASSE = $this->getConnectionWrapper()->getFolderId($this->session_get("user_id", null), 'Non classé'); $this->getConnectionWrapper()->addAbonnement($this->session_get("user_id", null), $this->NON_CLASSE, $idFlux); if (!$exist) { foreach ($feed->get_items() as $item) { $item_title = strip_tags($item->get_title()); if (strlen($item_title) > 50) { $item_title = substr($item_title, 0, 47) . '...'; } $item_desc = $item->get_description(); if (strlen($item_desc) == 0) { $item_desc = 'Aucune description disponible: ' . $item->get_permalink(); } $item_content = $item->get_content(); if (strlen($item_content) == 0) { $item_content = 'Aucun contenu supplémentaire disponible: ' . $item->get_permalink(); } $this->getConnectionWrapper()->addArticle($idFlux, $item_title, $item->get_permalink(), $item_desc, $item_content, $item->get_date('Y-m-j G:i:s')); } } } $this->redirect_to('listing'); }</pre> </div> </figure> </div> <div class="example-item" id="0xf38cf8215b77c662ef3936a1ba4c2b891b75ab8f3d3f7c9c5b99899f729b579c-290,,660,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #22</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_22" data-hash="0xf38cf8215b77c662ef3936a1ba4c2b891b75ab8f3d3f7c9c5b99899f729b579c" data-area="290,,660,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '22')" class="rating-up btn btn-success" data-id="rating_22"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'22')" class="rating-down btn btn-danger" data-id="rating_22"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xf38cf8215b77c662ef3936a1ba4c2b891b75ab8f3d3f7c9c5b99899f729b579c-290,,660,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xf38cf8215b77c662ef3936a1ba4c2b891b75ab8f3d3f7c9c5b99899f729b579c&fullName=Scrape.php&project=robhell%2Ffriendica')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Frobhell%2Ffriendica%2Fblob%2Fmaster%2FScrape.php">Scrape.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Frobhell%2Ffriendica">robhell/friendica</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="22"> <pre class="line-numbers language-php" data-end="660" data-start="291" data-highlight="608">function probe_url($url, $mode = PROBE_NORMAL) { require_once 'include/email.php'; $result = array(); if (!$url) { return $result; } $network = null; $diaspora = false; $diaspora_base = ''; $diaspora_guid = ''; $diaspora_key = ''; $has_lrdd = false; $email_conversant = false; $twitter = strpos($url, 'twitter.com') !== false ? true : false; $at_addr = strpos($url, '@') !== false ? true : false; if (!$twitter) { if (strpos($url, 'mailto:') !== false && $at_addr) { $url = str_replace('mailto:', '', $url); $links = array(); } else { $links = lrdd($url); } if (count($links)) { $has_lrdd = true; logger('probe_url: found lrdd links: ' . print_r($links, true), LOGGER_DATA); foreach ($links as $link) { if ($link['@attributes']['rel'] === NAMESPACE_ZOT) { $zot = unamp($link['@attributes']['href']); } if ($link['@attributes']['rel'] === NAMESPACE_DFRN) { $dfrn = unamp($link['@attributes']['href']); } if ($link['@attributes']['rel'] === 'salmon') { $notify = unamp($link['@attributes']['href']); } if ($link['@attributes']['rel'] === NAMESPACE_FEED) { $poll = unamp($link['@attributes']['href']); } if ($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard') { $hcard = unamp($link['@attributes']['href']); } if ($link['@attributes']['rel'] === 'http://webfinger.net/rel/profile-page') { $profile = unamp($link['@attributes']['href']); } if ($link['@attributes']['rel'] === 'http://portablecontacts.net/spec/1.0') { $poco = unamp($link['@attributes']['href']); } if ($link['@attributes']['rel'] === 'http://joindiaspora.com/seed_location') { $diaspora_base = unamp($link['@attributes']['href']); $diaspora = true; } if ($link['@attributes']['rel'] === 'http://joindiaspora.com/guid') { $diaspora_guid = unamp($link['@attributes']['href']); $diaspora = true; } if ($link['@attributes']['rel'] === 'diaspora-public-key') { $diaspora_key = base64_decode(unamp($link['@attributes']['href'])); $pubkey = rsatopem($diaspora_key); $diaspora = true; } } // Status.Net can have more than one profile URL. We need to match the profile URL // to a contact on incoming messages to prevent spam, and we won't know which one // to match. So in case of two, one of them is stored as an alias. Only store URL's // and not webfinger user@host aliases. If they've got more than two non-email style // aliases, let's hope we're lucky and get one that matches the feed author-uri because // otherwise we're screwed. foreach ($links as $link) { if ($link['@attributes']['rel'] === 'alias') { if (strpos($link['@attributes']['href'], '@') === false) { if (isset($profile)) { if ($link['@attributes']['href'] !== $profile) { $alias = unamp($link['@attributes']['href']); } } else { $profile = unamp($link['@attributes']['href']); } } } } } elseif ($mode == PROBE_NORMAL) { // Check email $orig_url = $url; if (strpos($orig_url, '@') && validate_email($orig_url)) { $x = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval(local_user())); $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d AND `server` != '' LIMIT 1", intval(local_user())); if (count($x) && count($r)) { $mailbox = construct_mailbox_name($r[0]); $password = ''; openssl_private_decrypt(hex2bin($r[0]['pass']), $password, $x[0]['prvkey']); $mbox = email_connect($mailbox, $r[0]['user'], $password); if (!$mbox) { logger('probe_url: email_connect failed.'); } unset($password); } if ($mbox) { $msgs = email_poll($mbox, $orig_url); logger('probe_url: searching ' . $orig_url . ', ' . count($msgs) . ' messages found.', LOGGER_DEBUG); if (count($msgs)) { $addr = $orig_url; $network = NETWORK_MAIL; $name = substr($url, 0, strpos($url, '@')); $phost = substr($url, strpos($url, '@') + 1); $profile = 'http://' . $phost; // fix nick character range $vcard = array('fn' => $name, 'nick' => $name, 'photo' => avatar_img($url)); $notify = 'smtp ' . random_string(); $poll = 'email ' . random_string(); $priority = 0; $x = email_msg_meta($mbox, $msgs[0]); if (stristr($x->from, $orig_url)) { $adr = imap_rfc822_parse_adrlist($x->from, ''); } elseif (stristr($x->to, $orig_url)) { $adr = imap_rfc822_parse_adrlist($x->to, ''); } if (isset($adr)) { foreach ($adr as $feadr) { if (strcasecmp($feadr->mailbox, $name) == 0 && strcasecmp($feadr->host, $phost) == 0 && strlen($feadr->personal)) { $personal = imap_mime_header_decode($feadr->personal); $vcard['fn'] = ""; foreach ($personal as $perspart) { if ($perspart->charset != "default") { $vcard['fn'] .= iconv($perspart->charset, 'UTF-8//IGNORE', $perspart->text); } else { $vcard['fn'] .= $perspart->text; } } $vcard['fn'] = notags($vcard['fn']); } } } } imap_close($mbox); } } } } if ($mode == PROBE_NORMAL) { if (strlen($zot)) { $s = fetch_url($zot); if ($s) { $j = json_decode($s); if ($j) { $network = NETWORK_ZOT; $vcard = array('fn' => $j->fullname, 'nick' => $j->nickname, 'photo' => $j->photo); $profile = $j->url; $notify = $j->post; $pubkey = $j->pubkey; $poll = 'N/A'; } } } if (strlen($dfrn)) { $ret = scrape_dfrn($hcard ? $hcard : $dfrn); if (is_array($ret) && x($ret, 'dfrn-request')) { $network = NETWORK_DFRN; $request = $ret['dfrn-request']; $confirm = $ret['dfrn-confirm']; $notify = $ret['dfrn-notify']; $poll = $ret['dfrn-poll']; $vcard = array(); $vcard['fn'] = $ret['fn']; $vcard['nick'] = $ret['nick']; $vcard['photo'] = $ret['photo']; } } } if ($diaspora && $diaspora_base && $diaspora_guid) { if ($mode == PROBE_DIASPORA || !$notify) { $notify = $diaspora_base . 'receive/users/' . $diaspora_guid; $batch = $diaspora_base . 'receive/public'; } if (strpos($url, '@')) { $addr = str_replace('acct:', '', $url); } } if ($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) { if ($diaspora) { $network = NETWORK_DIASPORA; } elseif ($has_lrdd) { $network = NETWORK_OSTATUS; } $priority = 0; if ($hcard && !$vcard) { $vcard = scrape_vcard($hcard); // Google doesn't use absolute url in profile photos if (x($vcard, 'photo') && substr($vcard['photo'], 0, 1) == '/') { $h = @parse_url($hcard); if ($h) { $vcard['photo'] = $h['scheme'] . '://' . $h['host'] . $vcard['photo']; } } logger('probe_url: scrape_vcard: ' . print_r($vcard, true), LOGGER_DATA); } if ($twitter) { logger('twitter: setup'); $tid = basename($url); $tapi = 'https://api.twitter.com/1/statuses/user_timeline.rss'; if (intval($tid)) { $poll = $tapi . '?user_id=' . $tid; } else { $poll = $tapi . '?screen_name=' . $tid; } $profile = 'http://twitter.com/#!/' . $tid; $vcard['photo'] = 'https://api.twitter.com/1/users/profile_image/' . $tid; $vcard['nick'] = $tid; $vcard['fn'] = $tid . '@twitter'; } if (!x($vcard, 'fn')) { if (x($vcard, 'nick')) { $vcard['fn'] = $vcard['nick']; } } $check_feed = false; if ($twitter || !$poll) { $check_feed = true; } if (!isset($vcard) || !x($vcard, 'fn') || !$profile) { $check_feed = true; } if ($at_addr && !count($links)) { $check_feed = false; } if ($check_feed) { $feedret = scrape_feed($poll ? $poll : $url); logger('probe_url: scrape_feed ' . ($poll ? $poll : $url) . ' returns: ' . print_r($feedret, true), LOGGER_DATA); if (count($feedret) && ($feedret['feed_atom'] || $feedret['feed_rss'])) { $poll = x($feedret, 'feed_atom') ? unamp($feedret['feed_atom']) : unamp($feedret['feed_rss']); if (!x($vcard)) { $vcard = array(); } } if (x($feedret, 'photo') && !x($vcard, 'photo')) { $vcard['photo'] = $feedret['photo']; } require_once 'library/simplepie/simplepie.inc'; $feed = new SimplePie(); $xml = fetch_url($poll); logger('probe_url: fetch feed: ' . $poll . ' returns: ' . $xml, LOGGER_DATA); $a = get_app(); logger('probe_url: scrape_feed: headers: ' . $a->get_curl_headers(), LOGGER_DATA); $feed->set_raw_data($xml); $feed->init(); if ($feed->error()) { logger('probe_url: scrape_feed: Error parsing XML: ' . $feed->error()); } if (!x($vcard, 'photo')) { $vcard['photo'] = $feed->get_image_url(); } $author = $feed->get_author(); if ($author) { $vcard['fn'] = unxmlify(trim($author->get_name())); if (!$vcard['fn']) { $vcard['fn'] = trim(unxmlify($author->get_email())); } if (strpos($vcard['fn'], '@') !== false) { $vcard['fn'] = substr($vcard['fn'], 0, strpos($vcard['fn'], '@')); } $email = unxmlify($author->get_email()); if (!$profile && $author->get_link()) { $profile = trim(unxmlify($author->get_link())); } if (!$vcard['photo']) { $rawtags = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); if ($rawtags) { $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]; if (x($elems, 'link') && $elems['link'][0]['attribs']['']['rel'] === 'photo') { $vcard['photo'] = $elems['link'][0]['attribs']['']['href']; } } } } else { $item = $feed->get_item(0); if ($item) { $author = $item->get_author(); if ($author) { $vcard['fn'] = trim(unxmlify($author->get_name())); if (!$vcard['fn']) { $vcard['fn'] = trim(unxmlify($author->get_email())); } if (strpos($vcard['fn'], '@') !== false) { $vcard['fn'] = substr($vcard['fn'], 0, strpos($vcard['fn'], '@')); } $email = unxmlify($author->get_email()); if (!$profile && $author->get_link()) { $profile = trim(unxmlify($author->get_link())); } } if (!$vcard['photo']) { $rawmedia = $item->get_item_tags('http://search.yahoo.com/mrss/', 'thumbnail'); if ($rawmedia && $rawmedia[0]['attribs']['']['url']) { $vcard['photo'] = unxmlify($rawmedia[0]['attribs']['']['url']); } } if (!$vcard['photo']) { $rawtags = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); if ($rawtags) { $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]; if (x($elems, 'link') && $elems['link'][0]['attribs']['']['rel'] === 'photo') { $vcard['photo'] = $elems['link'][0]['attribs']['']['href']; } } } } } if (!$vcard['photo'] && strlen($email)) { $vcard['photo'] = avatar_img($email); } if ($poll === $profile) { $lnk = $feed->get_permalink(); } if (isset($lnk) && strlen($lnk)) { $profile = $lnk; } if (!x($vcard, 'fn')) { $vcard['fn'] = notags($feed->get_title()); } if (!x($vcard, 'fn')) { $vcard['fn'] = notags($feed->get_description()); } if (strpos($vcard['fn'], 'Twitter / ') !== false) { $vcard['fn'] = substr($vcard['fn'], strpos($vcard['fn'], '/') + 1); $vcard['fn'] = trim($vcard['fn']); } if (!x($vcard, 'nick')) { $vcard['nick'] = strtolower(notags(unxmlify($vcard['fn']))); if (strpos($vcard['nick'], ' ')) { $vcard['nick'] = trim(substr($vcard['nick'], 0, strpos($vcard['nick'], ' '))); } } if (!$network) { $network = NETWORK_FEED; } if (!$priority) { $priority = 2; } } } if (!x($vcard, 'photo')) { $a = get_app(); $vcard['photo'] = $a->get_baseurl() . '/images/person-175.jpg'; } if (!$profile) { $profile = $url; } // No human could be associated with this link, use the URL as the contact name if ($network === NETWORK_FEED && $poll && !x($vcard, 'fn')) { $vcard['fn'] = $url; } $vcard['fn'] = notags($vcard['fn']); $vcard['nick'] = str_replace(' ', '', notags($vcard['nick'])); $result['name'] = $vcard['fn']; $result['nick'] = $vcard['nick']; $result['url'] = $profile; $result['addr'] = $addr; $result['batch'] = $batch; $result['notify'] = $notify; $result['poll'] = $poll; $result['request'] = $request; $result['confirm'] = $confirm; $result['poco'] = $poco; $result['photo'] = $vcard['photo']; $result['priority'] = $priority; $result['network'] = $network; $result['alias'] = $alias; $result['pubkey'] = $pubkey; logger('probe_url: ' . print_r($result, true), LOGGER_DEBUG); return $result; }</pre> </div> </figure> </div> <div class="example-item" id="0xb7dc32928afc4b990d537ee22a4648ffb6a5b63f43cc6e8c53646f7232e9a1fa-2802,,2857,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #23</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_23" data-hash="0xb7dc32928afc4b990d537ee22a4648ffb6a5b63f43cc6e8c53646f7232e9a1fa" data-area="2802,,2857,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '23')" class="rating-up btn btn-success" data-id="rating_23"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'23')" class="rating-down btn btn-danger" data-id="rating_23"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xb7dc32928afc4b990d537ee22a4648ffb6a5b63f43cc6e8c53646f7232e9a1fa-2802,,2857,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xb7dc32928afc4b990d537ee22a4648ffb6a5b63f43cc6e8c53646f7232e9a1fa&fullName=boucles.php&project=anti-conformiste%2Fthelia1')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fanti-conformiste%2Fthelia1%2Fblob%2Fmaster%2Fboucles.php">boucles.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fanti-conformiste%2Fthelia1">anti-conformiste/thelia1</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="23"> <pre class="line-numbers language-php" data-end="2857" data-start="2803" data-highlight="2824">function boucleRSS($texte, $args) { @ini_set('default_socket_timeout', 5); // récupération des arguments $url = lireTag($args, "url", "string+\\/:."); $nb = lireTag($args, "nb", "int"); $deb = lireTag($args, "deb", "int"); $i = 0; $compt = 0; if ($url == "") { return; } $feed = new SimplePie(); $feed->set_feed_url($url); $rss_cache = 'client/cache/rss'; if (!is_dir($rss_cache)) { mkdir($rss_cache); } $feed->set_cache_location($rss_cache); $feed->init(); $feed->handle_content_type(); $chantitle = $feed->get_title(); $chanlink = $feed->get_permalink(); $res = ''; foreach ($feed->get_items() as $item) { if ($compt < $deb) { $compt++; continue; } $link = $item->get_permalink(); $title = strip_tags($item->get_title()); $author = strip_tags($item->get_author()); $description = strip_tags($item->get_description()); $dateh = $item->get_date('j F Y | g:i a'); $jour = $item->get_date('j'); $mois = $item->get_date('F'); $annee = $item->get_date('Y'); $heure = $item->get_date('g'); $minute = $item->get_date('i'); $seconde = $item->get_date('a'); $temp = str_replace("#SALON", "{$chantitle}", $texte); $temp = str_replace("#WEB", "{$chanlink}", $temp); $temp = str_replace("#TITRE", "{$title}", $temp); $temp = str_replace("#LIEN", "{$link}", $temp); $temp = str_replace("#DESCRIPTION", "{$description}", $temp); $temp = str_replace("#AUTEUR", "{$author}", $temp); $temp = str_replace("#DATE", "{$jour}/{$mois}/{$annee}", $temp); $temp = str_replace("#HEURE", "{$heure}:{$minute} {$seconde}", $temp); $i++; $res .= $temp; if ($i == $nb) { return $res; } } return $res; }</pre> </div> </figure> </div> <div class="example-item" id="0xbe16a16abae4d3684c3dff93ff566c0cffc6b1b90bc511a85571f7c950f827cd-11,,183,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #24</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_24" data-hash="0xbe16a16abae4d3684c3dff93ff566c0cffc6b1b90bc511a85571f7c950f827cd" data-area="11,,183,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '24')" class="rating-up btn btn-success" data-id="rating_24"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'24')" class="rating-down btn btn-danger" data-id="rating_24"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xbe16a16abae4d3684c3dff93ff566c0cffc6b1b90bc511a85571f7c950f827cd-11,,183,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xbe16a16abae4d3684c3dff93ff566c0cffc6b1b90bc511a85571f7c950f827cd&fullName=wp-content%2Fplugins%2Ffeedzy-rss-feeds-shortcode.php&project=fritzdenim%2FpangMoves')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Ffritzdenim%2FpangMoves%2Fblob%2Fmaster%2Fwp-content%2Fplugins%2Ffeedzy-rss-feeds-shortcode.php">feedzy-rss-feeds-shortcode.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Ffritzdenim%2FpangMoves">fritzdenim/pangMoves</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="24"> <pre class="line-numbers language-php" data-end="183" data-start="12" data-highlight="82">function feedzy_rss($atts, $content = '') { global $feedzyStyle; $feedzyStyle = true; $count = 0; //Load SimplePie if not already if (!class_exists('SimplePie')) { require_once ABSPATH . WPINC . '/class-feed.php'; } //Retrieve & extract shorcode parameters extract(shortcode_atts(array("feeds" => '', "max" => '5', "feed_title" => 'yes', "target" => '_blank', "title" => '', "meta" => 'yes', "summary" => 'yes', "summarylength" => '', "thumb" => 'yes', "default" => '', "size" => '', "keywords_title" => ''), $atts, 'feedzy_default')); //Use "shortcode_atts_feedzy_default" filter to edit shortcode parameters default values or add your owns. if (!empty($feeds)) { $feeds = rtrim($feeds, ','); $feeds = explode(',', $feeds); //Remove SSL from HTTP request to prevent fetching errors foreach ($feeds as $feed) { $feedURL[] = preg_replace("/^https:/i", "http:", $feed); } if (count($feedURL) === 1) { $feedURL = $feedURL[0]; } } if ($max == '0') { $max = '999'; } else { if (empty($max) || !ctype_digit($max)) { $max = '5'; } } if (empty($size) || !ctype_digit($size)) { $size = '150'; } $sizes = array('width' => $size, 'height' => $size); $sizes = apply_filters('feedzy_thumb_sizes', $sizes, $feedURL); if (!empty($title) && !ctype_digit($title)) { $title = ''; } if (!empty($keywords_title)) { $keywords_title = rtrim($keywords_title, ','); $keywords_title = array_map('trim', explode(',', $keywords_title)); } if (!empty($summarylength) && !ctype_digit($summarylength)) { $summarylength = ''; } if (!empty($default)) { $default = $default; } else { $default = apply_filters('feedzy_default_image', $default, $feedURL); } //Load SimplePie Instance $feed = new SimplePie(); $feed->set_feed_url($feedURL); $feed->enable_cache(true); $feed->enable_order_by_date(true); $feed->set_cache_class('WP_Feed_Cache'); $feed->set_file_class('WP_SimplePie_File'); $feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 7200, $feedURL)); do_action_ref_array('wp_feed_options', array($feed, $feedURL)); $feed->strip_comments(true); $feed->strip_htmltags(array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style')); $feed->init(); $feed->handle_content_type(); // Display the error message if ($feed->error()) { $content .= apply_filters('feedzy_default_error', $feed->error(), $feedURL); } $content .= '<div class="feedzy-rss">'; if ($feed_title == 'yes') { $content .= '<div class="rss_header">'; $content .= '<h2><a href="' . $feed->get_permalink() . '" class="rss_title">' . html_entity_decode($feed->get_title()) . '</a> <span class="rss_description"> ' . $feed->get_description() . '</span></h2>'; $content .= '</div>'; } $content .= '<ul>'; //Loop through RSS feed $items = apply_filters('feedzy_feed_items', $feed->get_items(), $feedURL); foreach ((array) $items as $item) { $continue = apply_filters('feedzy_item_keyword', true, $keywords_title, $item, $feedURL); if ($continue == true) { //Count items if ($count >= $max) { break; } $count++; //Fetch image thumbnail if ($thumb == 'yes' || $thumb == 'auto') { $thethumbnail = feedzy_retrieve_image($item); } $itemAttr = apply_filters('feedzy_item_attributes', $itemAttr = '', $sizes, $item, $feedURL); //Build element DOM $content .= '<li ' . $itemAttr . '>'; if ($thumb == 'yes' || $thumb == 'auto') { $contentThumb = ''; if (!empty($thethumbnail) && $thumb == 'auto' || $thumb == 'yes') { $contentThumb .= '<div class="rss_image" style="width:' . $sizes['width'] . 'px; height:' . $sizes['height'] . 'px;">'; $contentThumb .= '<a href="' . $item->get_permalink() . '" target="' . $target . '" title="' . $item->get_title() . '" >'; if (!empty($thethumbnail)) { $thethumbnail = feedzy_image_encode($thethumbnail); $contentThumb .= '<span class="default" style="width:' . $sizes['width'] . 'px; height:' . $sizes['height'] . 'px; background-image: url(' . $default . ');" alt="' . $item->get_title() . '"></span>'; $contentThumb .= '<span class="fetched" style="width:' . $sizes['width'] . 'px; height:' . $sizes['height'] . 'px; background-image: url(' . $thethumbnail . ');" alt="' . $item->get_title() . '"></span>'; } else { if (empty($thethumbnail) && $thumb == 'yes') { $contentThumb .= '<span style="width:' . $sizes['width'] . 'px; height:' . $sizes['height'] . 'px; background-image:url(' . $default . ');" alt="' . $item->get_title() . '"></span>'; } } $contentThumb .= '</a>'; $contentThumb .= '</div>'; } //Filter: feedzy_thumb_output $content .= apply_filters('feedzy_thumb_output', $contentThumb, $feedURL); } $contentTitle = ''; $contentTitle .= '<span class="title"><a href="' . $item->get_permalink() . '" target="' . $target . '">'; if (is_numeric($title) && strlen($item->get_title()) > $title) { $contentTitle .= preg_replace('/\\s+?(\\S+)?$/', '', substr($item->get_title(), 0, $title)) . '...'; } else { $contentTitle .= $item->get_title(); } $contentTitle .= '</a></span>'; //Filter: feedzy_title_output $content .= apply_filters('feedzy_title_output', $contentTitle, $feedURL); $content .= '<div class="rss_content">'; //Define Meta args $metaArgs = array('author' => true, 'date' => true, 'date_format' => get_option('date_format'), 'time_format' => get_option('time_format')); //Filter: feedzy_meta_args $metaArgs = apply_filters('feedzy_meta_args', $metaArgs, $feedURL); if ($meta == 'yes' && ($metaArgs['author'] || $metaArgs['date'])) { $contentMeta = ''; $contentMeta .= '<small>' . __('Posted', 'feedzy_rss_translate') . ' '; if ($item->get_author() && $metaArgs['author']) { $author = $item->get_author(); if (!($authorName = $author->get_name())) { $authorName = $author->get_email(); } if ($authorName) { $domain = parse_url($item->get_permalink()); $contentMeta .= __('by', 'feedzy_rss_translate') . ' <a href="http://' . $domain['host'] . '" target="' . $target . '" title="' . $domain['host'] . '" >' . $authorName . '</a> '; } } if ($metaArgs['date']) { $contentMeta .= __('on', 'feedzy_rss_translate') . ' ' . date_i18n($metaArgs['date_format'], $item->get_date('U')); $contentMeta .= ' '; $contentMeta .= __('at', 'feedzy_rss_translate') . ' ' . date_i18n($metaArgs['time_format'], $item->get_date('U')); } $contentMeta .= '</small>'; //Filter: feedzy_meta_output $content .= apply_filters('feedzy_meta_output', $contentMeta, $feedURL); } if ($summary == 'yes') { $contentSummary = ''; $contentSummary .= '<p>'; //Filter: feedzy_summary_input $description = $item->get_description(); $description = apply_filters('feedzy_summary_input', $description, $item->get_content(), $feedURL); if (is_numeric($summarylength) && strlen($description) > $summarylength) { $contentSummary .= preg_replace('/\\s+?(\\S+)?$/', '', substr($description, 0, $summarylength)) . ' […]'; } else { $contentSummary .= $description . ' […]'; } $contentSummary .= '</p>'; //Filter: feedzy_summary_output $content .= apply_filters('feedzy_summary_output', $contentSummary, $item->get_permalink(), $feedURL); } $content .= '</div>'; $content .= '</li>'; } //endContinue } //endforeach $content .= '</ul>'; $content .= '</div>'; return apply_filters('feedzy_global_output', $content, $feedURL); }</pre> </div> </figure> </div> <div class="example-item" id="0xe32f0db3553b1094e2eb57ab56454b35461aea8dd48cab7ef3e939afecf4db0f-80,,125,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #25</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_25" data-hash="0xe32f0db3553b1094e2eb57ab56454b35461aea8dd48cab7ef3e939afecf4db0f" data-area="80,,125,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '25')" class="rating-up btn btn-success" data-id="rating_25"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'25')" class="rating-down btn btn-danger" data-id="rating_25"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xe32f0db3553b1094e2eb57ab56454b35461aea8dd48cab7ef3e939afecf4db0f-80,,125,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xe32f0db3553b1094e2eb57ab56454b35461aea8dd48cab7ef3e939afecf4db0f&fullName=tags%2Fmyoos_2.1.2%2Fplanet%2Finc%2Ffeed-functions.php&project=BackupTheBerlios%2Foos-svn')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2FBackupTheBerlios%2Foos-svn%2Fblob%2Fmaster%2Ftags%2Fmyoos_2.1.2%2Fplanet%2Finc%2Ffeed-functions.php">feed-functions.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2FBackupTheBerlios%2Foos-svn">BackupTheBerlios/oos-svn</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="25"> <pre class="line-numbers language-php" data-end="125" data-start="81" data-highlight="117">/** * Add a new feed to the database * * Adds the specified feed name and URL to the global <tt>$data</tt> array. If no name is set * by the user, it fetches one from the feed. If the URL specified is a HTML page and not a * feed, it lets SimplePie do autodiscovery and uses the XML url returned. * * @since 1.0 * @uses $data Contains all feeds, this is what we add the new feed to * * @param string $url URL to feed or website (if autodiscovering) * @param string $name Title/Name of feed * @param string $cat Category to add feed to * @param bool $return If true, return the new feed's details. Otherwise, use the global $data array * @return bool True if succeeded, false if failed */ function add_feed($url, $name = '', $cat = 'default', $return = false) { if (empty($url)) { throw new Exception(_r("Couldn't add feed: No feed URL supplied"), Errors::get_code('admin.feeds.no_url')); } require_once LILINA_INCPATH . '/contrib/simplepie/simplepie.inc'; $feed_info = new SimplePie(); $feed_info->set_useragent('Lilina/' . LILINA_CORE_VERSION . '; (' . get_option('baseurl') . '; http://getlilina.org/; Allow Like Gecko) SimplePie/' . SIMPLEPIE_BUILD); $feed_info->set_stupidly_fast(true); $feed_info->enable_cache(false); $feed_info->set_feed_url(urldecode($url)); $feed_info->init(); $feed_error = $feed_info->error(); $feed_url = $feed_info->subscribe_url(); if (!empty($feed_error)) { //No feeds autodiscovered; throw new Exception(sprintf(_r("Couldn't add feed: %s is not a valid URL or the server could not be accessed. Additionally, no feeds could be found by autodiscovery."), $url), Errors::get_code('admin.feeds.invalid_url')); } if (empty($name)) { //Get it from the feed $name = $feed_info->get_title(); } if ($return === true) { return array('feed' => $feed_url, 'url' => $feed_info->get_link(), 'name' => $name, 'cat' => $cat); } global $data; $data['feeds'][] = array('feed' => $feed_url, 'url' => $feed_info->get_link(), 'name' => $name, 'cat' => $cat); save_feeds(); return sprintf(_r('Added feed "%1$s"'), $name); }</pre> </div> </figure> </div> <div class="example-item" id="0xc292c5d83ab120b4fc142787a9935d44c12a136876b209ecd42afb9a42b7f197-18,,48,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #26</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_26" data-hash="0xc292c5d83ab120b4fc142787a9935d44c12a136876b209ecd42afb9a42b7f197" data-area="18,,48,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '26')" class="rating-up btn btn-success" data-id="rating_26"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'26')" class="rating-down btn btn-danger" data-id="rating_26"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xc292c5d83ab120b4fc142787a9935d44c12a136876b209ecd42afb9a42b7f197-18,,48,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xc292c5d83ab120b4fc142787a9935d44c12a136876b209ecd42afb9a42b7f197&fullName=mod%2Fwidget_manager%2Fviews%2Fdefault%2Fwidgets%2Fcontent.php&project=amcfarlane1251%2Fongarde')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Famcfarlane1251%2Fongarde%2Fblob%2Fmaster%2Fmod%2Fwidget_manager%2Fviews%2Fdefault%2Fwidgets%2Fcontent.php">content.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Famcfarlane1251%2Fongarde">amcfarlane1251/ongarde</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="26"> <pre class="line-numbers language-php" data-end="48" data-start="19" data-highlight="34"> $rss_count = 4; } if ($widget->post_date == "yes" || $widget->post_date == "friendly") { $post_date = "friendly"; } elseif ($widget->post_date == "date") { $post_date = "date"; } else { $post_date = false; } $feed = new SimplePie(); $feed->set_feed_url($feed_url); $feed->set_cache_location(WIDGETS_RSS_CACHE_LOCATION); $feed->set_cache_duration(WIDGETS_RSS_CACHE_DURATION); $feed->init(); $num_posts_in_feed = $feed->get_item_quantity($rss_count); if (($feed_title = $feed->get_title()) && $widget->show_feed_title == "yes") { echo "<h3><a href='" . $feed->get_permalink() . "' target='_blank'>" . $feed_title . "</a></h3>"; } $body = ""; if (empty($num_posts_in_feed)) { $body = elgg_echo('notfound'); } else { foreach ($feed->get_items(0, $num_posts_in_feed) as $item) { if ($excerpt) { $body .= "<div class='widgets_rss_feed_item'>"; $body .= "<div><a href='" . $item->get_permalink() . "' target='_blank'>" . $item->get_title() . "</a></div>"; if ($show_item_icon) { if ($enclosures = $item->get_enclosures()) { foreach ($enclosures as $enclosure) { if (substr($enclosure->type, 0, 6) == "image/") { $body .= "<a href='" . $item->get_permalink() . "' target='_blank'><img class='widgets_rss_feed_item_image' src='" . $enclosure->link . "' /></a>";</pre> </div> </figure> </div> <div class="example-item" id="0xf557be5cd94931de20efbd57d5c76d9640228981b2f778103efed15c751ae3ba-779,,908,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #27</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_27" data-hash="0xf557be5cd94931de20efbd57d5c76d9640228981b2f778103efed15c751ae3ba" data-area="779,,908,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '27')" class="rating-up btn btn-success" data-id="rating_27"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'27')" class="rating-down btn btn-danger" data-id="rating_27"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xf557be5cd94931de20efbd57d5c76d9640228981b2f778103efed15c751ae3ba-779,,908,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xf557be5cd94931de20efbd57d5c76d9640228981b2f778103efed15c751ae3ba&fullName=network.php&project=bashrc%2Fhubzilla')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fbashrc%2Fhubzilla%2Fblob%2Fmaster%2Fnetwork.php">network.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fbashrc%2Fhubzilla">bashrc/hubzilla</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="27"> <pre class="line-numbers language-php" data-end="908" data-start="780" data-highlight="823">function discover_by_url($url, $arr = null) { require_once 'library/HTML5/Parser.php'; $x = scrape_feed($url); if (!$x) { if (!$arr) { return false; } $network = $arr['network'] ? $arr['network'] : 'unknown'; $name = $arr['name'] ? $arr['name'] : 'unknown'; $photo = $arr['photo'] ? $arr['photo'] : ''; $addr = $arr['addr'] ? $arr['addr'] : ''; $guid = $url; } $profile = $url; logger('scrape_feed results: ' . print_r($x, true)); if ($x['feed_atom']) { $guid = $x['feed_atom']; } if ($x['feed_rss']) { $guid = $x['feed_rss']; } if (!$guid) { return false; } // try and discover stuff from the feeed require_once 'library/simplepie/simplepie.inc'; $feed = new SimplePie(); $level = 0; $x = z_fetch_url($guid, false, $level, array('novalidate' => true)); if (!$x['success']) { logger('probe_url: feed fetch failed for ' . $poll); return false; } $xml = $x['body']; logger('probe_url: fetch feed: ' . $guid . ' returns: ' . $xml, LOGGER_DATA); logger('probe_url: scrape_feed: headers: ' . $x['header'], LOGGER_DATA); // Don't try and parse an empty string $feed->set_raw_data($xml ? $xml : '<?xml version="1.0" encoding="utf-8" ?><xml></xml>'); $feed->init(); if ($feed->error()) { logger('probe_url: scrape_feed: Error parsing XML: ' . $feed->error()); } $name = unxmlify(trim($feed->get_title())); $photo = $feed->get_image_url(); $author = $feed->get_author(); if ($author) { if (!$name) { $name = unxmlify(trim($author->get_name())); } if (!$name) { $name = trim(unxmlify($author->get_email())); if (strpos($name, '@') !== false) { $name = substr($name, 0, strpos($name, '@')); } } if (!$profile && $author->get_link()) { $profile = trim(unxmlify($author->get_link())); } if (!$photo) { $rawtags = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); if ($rawtags) { $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]; if (x($elems, 'link') && $elems['link'][0]['attribs']['']['rel'] === 'photo') { $photo = $elems['link'][0]['attribs']['']['href']; } } } } else { $item = $feed->get_item(0); if ($item) { $author = $item->get_author(); if ($author) { if (!$name) { $name = trim(unxmlify($author->get_name())); if (!$name) { $name = trim(unxmlify($author->get_email())); } if (strpos($name, '@') !== false) { $name = substr($name, 0, strpos($name, '@')); } } if (!$profile && $author->get_link()) { $profile = trim(unxmlify($author->get_link())); } } if (!$photo) { $rawmedia = $item->get_item_tags('http://search.yahoo.com/mrss/', 'thumbnail'); if ($rawmedia && $rawmedia[0]['attribs']['']['url']) { $photo = unxmlify($rawmedia[0]['attribs']['']['url']); } } if (!$photo) { $rawtags = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); if ($rawtags) { $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]; if (x($elems, 'link') && $elems['link'][0]['attribs']['']['rel'] === 'photo') { $photo = $elems['link'][0]['attribs']['']['href']; } } } } } if ($poll === $profile) { $lnk = $feed->get_permalink(); } if (isset($lnk) && strlen($lnk)) { $profile = $lnk; } if (!$network) { $network = 'rss'; } if (!$name) { $name = notags($feed->get_description()); } if (!$guid) { return false; } $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($guid)); if ($r) { return true; } if (!$photo) { $photo = z_root() . '/images/rss_icon.png'; } $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_instance_url, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", dbesc($guid), dbesc($guid), dbesc($pubkey), dbesc($addr), dbesc($profile), dbesc($name), dbesc($network), dbesc(z_root()), dbesc(datetime_convert())); $photos = import_xchan_photo($photo, $guid); $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_hash = '%s'", dbesc(datetime_convert()), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc($photos[3]), dbesc($guid)); return true; }</pre> </div> </figure> </div> <div class="example-item" id="0xc46ff63c5d6173073f30d4075d8594e331dc063efc454380601308fd38ba92ed-36,,66,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #28</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_28" data-hash="0xc46ff63c5d6173073f30d4075d8594e331dc063efc454380601308fd38ba92ed" data-area="36,,66,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '28')" class="rating-up btn btn-success" data-id="rating_28"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'28')" class="rating-down btn btn-danger" data-id="rating_28"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xc46ff63c5d6173073f30d4075d8594e331dc063efc454380601308fd38ba92ed-36,,66,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xc46ff63c5d6173073f30d4075d8594e331dc063efc454380601308fd38ba92ed&fullName=index.php&project=parsinegar2015%2Fparsinegar')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fparsinegar2015%2Fparsinegar%2Fblob%2Fmaster%2Findex.php">index.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fparsinegar2015%2Fparsinegar">parsinegar2015/parsinegar</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="28"> <pre class="line-numbers language-php" data-end="66" data-start="37" data-highlight="52"><b>Enter Feed Url</b><br /> <input name="url" type="text" value="<?php echo $_POST['url']; ?> " style="width:400px;"><input name="Submit" type="submit" value="Get Feed"> </form> <?php if (isset($_POST['url']) && $_POST['url'] != "") { $url = $_POST['url']; include_once 'Simple/autoloader.php'; $feed = new SimplePie(); $feed->set_feed_url($url); $feed->enable_cache(false); $feed->set_output_encoding('Windows-1252'); $feed->init(); echo "<span><h1>" . $feed->get_title() . "</h1>"; echo "<b>" . $feed->get_description() . "</b></span><hr />"; $itemCount = $feed->get_item_quantity(); $items = $feed->get_items(); foreach ($items as $item) { ?> <div><a href="<?php echo $item->get_permalink(); ?> "><?php echo $item->get_title(); ?> </a><br /> <em style="font-size:.7em;color:#666666"><?php echo $item->get_date(); ?></pre> </div> </figure> </div> <div class="example-item" id="0xfea1d6e4179488256ad205b8e8f71b10b7be24b87175c229d09c85418364bc96-14,,44,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #29</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_29" data-hash="0xfea1d6e4179488256ad205b8e8f71b10b7be24b87175c229d09c85418364bc96" data-area="14,,44,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '29')" class="rating-up btn btn-success" data-id="rating_29"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'29')" class="rating-down btn btn-danger" data-id="rating_29"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xfea1d6e4179488256ad205b8e8f71b10b7be24b87175c229d09c85418364bc96-14,,44,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xfea1d6e4179488256ad205b8e8f71b10b7be24b87175c229d09c85418364bc96&fullName=simplepiegroupplugin%2Fviews%2Fdefault%2Fview.php&project=benced%2Felgg-simplepieextension')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fbenced%2Felgg-simplepieextension%2Fblob%2Fmaster%2Fsimplepiegroupplugin%2Fviews%2Fdefault%2Fview.php">view.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fbenced%2Felgg-simplepieextension">benced/elgg-simplepieextension</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="29"> <pre class="line-numbers language-php" data-end="44" data-start="15" data-highlight="30"> // doubles timeout if going through a proxy //$feed->set_timeout(20); $num_posts_in_feed = $feed->get_item_quantity(); // only display errors to profile owner if (get_loggedin_userid() == page_owner()) { if (!$num_posts_in_feed) { echo '<p>' . elgg_echo('simplepie:notfind') . '</p>'; } } ?> <div class="simplepie_blog_title"> <h2><a href="<?php echo $feed->get_permalink(); ?> "><?php echo $feed->get_title(); ?> </a></h2> </div> <?php if ($num_items > $num_posts_in_feed) { $num_items = $num_posts_in_feed; } foreach ($feed->get_items(0, $num_items) as $item) { ?> <div class="simplepie_item"> <div class="simplepie_title"> <h4><a href="<?php echo $item->get_permalink(); ?></pre> </div> </figure> </div> <div class="example-item" id="0xc52b18a0cc0e7dc0ebea170dc1b7a35860d2eecd2b4e885934bb7875b9a00d7b-48,,283,"> <div class="bs-example"> <div> <div class="bs-example-title">Beispiel #30</div> <div style="position: absolute;right: 15px;top: 10px;" id="rating_30" data-hash="0xc52b18a0cc0e7dc0ebea170dc1b7a35860d2eecd2b4e885934bb7875b9a00d7b" data-area="48,,283,"> <div class="rating-amount">0</div> <a title="Markieren Sie dieses Beispiel als gut" href="javascript:app.addRating(1, '30')" class="rating-up btn btn-success" data-id="rating_30"><i class="icon-button icon-thumbs-up"></i></a> <a title="Markieren Sie dieses Beispiel als schlecht" href="javascript:app.addRating(-1,'30')" class="rating-down btn btn-danger" data-id="rating_30"><i class="icon-button icon-thumbs-down"></i></a> </div> </div> <div style="display:flex;align-items: center;flex-wrap: wrap"> <div style="display: inline-block;margin-right: 10px"> <a class="btn btn-default" title="Direkter Link zu diesem Beispiel" href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html#0xc52b18a0cc0e7dc0ebea170dc1b7a35860d2eecd2b4e885934bb7875b9a00d7b-48,,283,"><i class="icon-button icon-link"></i></a> <a rel="nofollow" class="btn btn-default" href="javascript:app.open('https://hotexamples.com/de/site/file?hash=0xc52b18a0cc0e7dc0ebea170dc1b7a35860d2eecd2b4e885934bb7875b9a00d7b&fullName=application%2FSubscriptions.php&project=slowmotion%2Freaderself')">Datei anzeigen</a> </div> <div class="example-project-info"> <nobr> <span>Datei:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fslowmotion%2Freaderself%2Fblob%2Fmaster%2Fapplication%2FSubscriptions.php">Subscriptions.php</a> </nobr> <nobr> <span>Projekt:</span> <a target="_blank" rel="nofollow" href="https://hotexamples.com/de/site/redirect?url=https%3A%2F%2Fgithub.com%2Fslowmotion%2Freaderself">slowmotion/readerself</a> </nobr> </div> </div> </div> <figure class="highlight"> <div class="example" data-id="30"> <pre class="line-numbers language-php" data-end="283" data-start="49" data-highlight="225,249"> public function create() { if (!$this->axipi_session->userdata('mbr_id')) { redirect(base_url() . '?u=' . $this->input->get('u')); } $data = array(); $content = array(); $this->load->library(array('form_validation', 'analyzer_library')); if ($this->config->item('folders')) { $query = $this->db->query('SELECT flr.* FROM ' . $this->db->dbprefix('folders') . ' AS flr WHERE flr.mbr_id = ? GROUP BY flr.flr_id ORDER BY flr.flr_title ASC', array($this->member->mbr_id)); $data['folders'] = array(); $data['folders'][0] = $this->lang->line('no_folder'); if ($query->num_rows() > 0) { foreach ($query->result() as $flr) { $data['folders'][$flr->flr_id] = $flr->flr_title; } } } $this->form_validation->set_rules('url', 'lang:url_feed', 'required'); if ($this->config->item('folders')) { $this->form_validation->set_rules('folder', 'lang:folder', 'required'); } $this->form_validation->set_rules('priority', 'lang:priority', 'numeric'); //$this->form_validation->set_rules('direction', 'lang:direction', ''); $data['error'] = false; $data['feeds'] = array(); if ($this->input->post('url') && !$this->input->post('analyze_done')) { $this->analyzer_library->start($this->input->post('url')); $metas = $this->analyzer_library->metas; if (count($metas) > 0) { $data['feeds'][''] = '-'; foreach ($metas as $meta) { $add = true; $headers = get_headers($meta['href'], 1); if (isset($headers['Location']) == 1) { $meta['href'] = $headers['Location']; $headers = get_headers($meta['href'], 1); if (isset($headers['Location']) == 1) { $add = false; } } if ($add) { if ($meta['title'] == '') { $data['feeds'][$meta['href']] = $meta['href']; } else { $this->analyzer_library->encoding($meta['title']); $data['feeds'][$meta['href']] = $meta['title']; } } } } } if ($this->form_validation->run() == FALSE || count($data['feeds']) > 0) { $content = $this->load->view('subscriptions_create', $data, TRUE); } else { if ($this->config->item('folders')) { $folder = false; if ($this->input->post('folder')) { $query = $this->db->query('SELECT flr.* FROM ' . $this->db->dbprefix('folders') . ' AS flr WHERE flr.mbr_id = ? AND flr.flr_id = ? GROUP BY flr.flr_id', array($this->member->mbr_id, $this->input->post('folder'))); if ($query->num_rows() > 0) { $folder = $this->input->post('folder'); } } } $query = $this->db->query('SELECT fed.*, sub.sub_id FROM ' . $this->db->dbprefix('feeds') . ' AS fed LEFT JOIN ' . $this->db->dbprefix('subscriptions') . ' AS sub ON sub.fed_id = fed.fed_id AND sub.mbr_id = ? WHERE fed.fed_link = ? GROUP BY fed.fed_id', array($this->member->mbr_id, $this->input->post('url'))); if ($query->num_rows() == 0) { $parse_url = parse_url($this->input->post('url')); if (isset($parse_url['host']) == 1 && $parse_url['host'] == 'instagram.com' && $this->config->item('instagram/enabled')) { if ($this->config->item('instagram/access_token')) { $parts = explode('/', rtrim($parse_url['path'], '/')); $total_parts = count($parts); $last_part = $parts[$total_parts - 1]; $result = json_decode(file_get_contents('https://api.instagram.com/v1/users/search?q=' . $last_part . '&count=15&access_token=' . $this->config->item('instagram/access_token'))); if (count($result->data) == 0) { $data['error'] = 'User not found'; } else { $user_id = false; foreach ($result->data as $user) { if ($user->username == $last_part) { $user_id = $user->id; break; } } if (!$user_id) { $data['error'] = 'User not found'; } else { $result = json_decode(file_get_contents('https://api.instagram.com/v1/users/' . $user_id . '?access_token=' . $this->config->item('instagram/access_token'))); $this->db->set('fed_title', 'Instagram @' . $result->data->username); $this->db->set('fed_url', $this->input->post('url')); $this->db->set('fed_description', $result->data->bio); $this->db->set('fed_image', $result->data->profile_picture); $this->db->set('fed_link', $this->input->post('url')); if (isset($parse_url['host']) == 1) { $this->db->set('fed_host', $parse_url['host']); } $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s')); $this->db->set('fed_datecreated', date('Y-m-d H:i:s')); $this->db->insert('feeds'); $fed_id = $this->db->insert_id(); $this->db->set('mbr_id', $this->member->mbr_id); $this->db->set('fed_id', $fed_id); if ($this->config->item('folders')) { if ($folder) { $this->db->set('flr_id', $folder); } } $this->db->set('sub_priority', $this->input->post('priority')); $this->db->set('sub_direction', $this->input->post('direction')); $this->db->set('sub_datecreated', date('Y-m-d H:i:s')); $this->db->insert('subscriptions'); $sub_id = $this->db->insert_id(); $result = json_decode(file_get_contents('https://api.instagram.com/v1/users/' . $user_id . '/media/recent?access_token=' . $this->config->item('instagram/access_token'))); $this->readerself_library->crawl_items_instagram($fed_id, $result->data); } } } } else { if (isset($parse_url['host']) == 1 && $parse_url['host'] == 'www.facebook.com' && $this->config->item('facebook/enabled')) { include_once 'thirdparty/facebook/autoload.php'; $fb = new Facebook\Facebook(array('app_id' => $this->config->item('facebook/id'), 'app_secret' => $this->config->item('facebook/secret'))); $fbApp = $fb->getApp(); $accessToken = $fbApp->getAccessToken(); try { $parts = explode('/', rtrim($parse_url['path'], '/')); $total_parts = count($parts); $last_part = $parts[$total_parts - 1]; $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', $last_part . '?fields=link,name,about'); $response = $fb->getClient()->sendRequest($request); $result = $response->getDecodedBody(); $this->db->set('fed_title', $result['name']); $this->db->set('fed_url', $result['link']); $this->db->set('fed_description', $result['about']); $this->db->set('fed_link', $result['link']); if (isset($parse_url['host']) == 1) { $this->db->set('fed_host', $parse_url['host']); } $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s')); $this->db->set('fed_datecreated', date('Y-m-d H:i:s')); $this->db->insert('feeds'); $fed_id = $this->db->insert_id(); $this->db->set('mbr_id', $this->member->mbr_id); $this->db->set('fed_id', $fed_id); if ($this->config->item('folders')) { if ($folder) { $this->db->set('flr_id', $folder); } } $this->db->set('sub_priority', $this->input->post('priority')); $this->db->set('sub_direction', $this->input->post('direction')); $this->db->set('sub_datecreated', date('Y-m-d H:i:s')); $this->db->insert('subscriptions'); $sub_id = $this->db->insert_id(); $request = new Facebook\FacebookRequest($fbApp, $accessToken, 'GET', $last_part . '?fields=feed{created_time,id,message,story,full_picture,place,type,status_type,link}'); $response = $fb->getClient()->sendRequest($request); $posts = $response->getDecodedBody(); $this->readerself_library->crawl_items_facebook($fed_id, $posts['feed']['data']); redirect(base_url() . 'subscriptions/read/' . $sub_id); } catch (Facebook\Exceptions\FacebookResponseException $e) { $data['error'] = 'Graph returned an error: ' . $e->getMessage(); } catch (Facebook\Exceptions\FacebookSDKException $e) { $data['error'] = 'Facebook SDK returned an error: ' . $e->getMessage(); } } else { include_once 'thirdparty/simplepie/autoloader.php'; include_once 'thirdparty/simplepie/idn/idna_convert.class.php'; $sp_feed = new SimplePie(); $sp_feed->set_feed_url(convert_to_ascii($this->input->post('url'))); $sp_feed->enable_cache(false); $sp_feed->set_timeout(60); $sp_feed->force_feed(true); $sp_feed->init(); $sp_feed->handle_content_type(); if ($sp_feed->error()) { $data['error'] = $sp_feed->error(); } else { $parse_url = parse_url($sp_feed->get_link()); $this->db->set('fed_title', $sp_feed->get_title()); $this->db->set('fed_url', $sp_feed->get_link()); $this->db->set('fed_description', $sp_feed->get_description()); $this->db->set('fed_link', $sp_feed->subscribe_url()); if (isset($parse_url['host']) == 1) { $this->db->set('fed_host', $parse_url['host']); } $this->db->set('fed_lastcrawl', date('Y-m-d H:i:s')); $this->db->set('fed_datecreated', date('Y-m-d H:i:s')); $this->db->insert('feeds'); $fed_id = $this->db->insert_id(); $this->db->set('mbr_id', $this->member->mbr_id); $this->db->set('fed_id', $fed_id); if ($this->config->item('folders')) { if ($folder) { $this->db->set('flr_id', $folder); } } $this->db->set('sub_priority', $this->input->post('priority')); $this->db->set('sub_direction', $this->input->post('direction')); $this->db->set('sub_datecreated', date('Y-m-d H:i:s')); $this->db->insert('subscriptions'); $sub_id = $this->db->insert_id(); $data['sub_id'] = $sub_id; $data['fed_title'] = $sp_feed->get_title(); $this->readerself_library->crawl_items($fed_id, $sp_feed->get_items()); } $sp_feed->__destruct(); unset($sp_feed); } } } else { $fed = $query->row(); if (!$fed->sub_id) { $this->db->set('mbr_id', $this->member->mbr_id); $this->db->set('fed_id', $fed->fed_id); if ($this->config->item('folders')) { if ($folder) { $this->db->set('flr_id', $folder); } } $this->db->set('sub_priority', $this->input->post('priority')); $this->db->set('sub_direction', $this->input->post('direction')); $this->db->set('sub_datecreated', date('Y-m-d H:i:s')); $this->db->insert('subscriptions'); $sub_id = $this->db->insert_id(); } else { $sub_id = $fed->sub_id; } $data['sub_id'] = $sub_id; $data['fed_title'] = $fed->fed_title; } if ($data['error']) { $content = $this->load->view('subscriptions_create', $data, TRUE); } else { redirect(base_url() . 'subscriptions/read/' . $sub_id); } } $this->readerself_library->set_content($content); }</pre> </div> </figure> </div> <div id="all-examples"></div> </div> </div> </div> <div class="page-side-banner hidden-xs hidden-sm hidden-md" style="width:300px"> <div id="ezoic-pub-ad-placeholder-131"> <div class="fx" style="width:300px"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- right-sidebar-fx --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3697522372581514" data-ad-slot="8968655429" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> </div> </div> <footer class="footer"> <div class="container"> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://hotexamples.com/de/site/trends?type=php%7Cf">Top-Funktionen</a> | <a href="https://hotexamples.com/de/site/trends?type=php%7Cc"> Top-Klassen </a> | <a href="https://doc.hotexamples.com/de/doc/map">Dokumentation</a> | <a href="/site/privacy">Datenschutz-Bestimmungen</a> | <a href="https://cpp.hotexamples.com/direct-sales.html">Advertise with us</a> </div> </div> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://hotexamples.com/de/">PHP</a> | <a href="https://csharp.hotexamples.com/de/">C# (CSharp)</a> | <a href="https://java.hotexamples.com/de/">Java</a> | <a href="https://golang.hotexamples.com/de/">Golang</a> | <a href="https://cpp.hotexamples.com/de/">C++ (Cpp)</a> | <a href="https://python.hotexamples.com/de/">Python</a> | <a href="https://javascript.hotexamples.com/de/">JavaScript</a> | <a href="https://typescript.hotexamples.com/de/">TypeScript</a> </div> </div> <div class="row"> <div class="col-md-12" style="text-align: center"> <a href="https://hotexamples.com/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html">EN</a> | <a href="https://hotexamples.com/ru/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html">RU</a> | <a href="https://hotexamples.com/de/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html">DE</a> | <a href="https://hotexamples.com/fr/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html">FR</a> | <a href="https://hotexamples.com/es/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html">ES</a> | <a href="https://hotexamples.com/pt/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html">PT</a> | <a href="https://hotexamples.com/it/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html">IT</a> | <a href="https://hotexamples.com/jp/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html">JP</a> | <a href="https://hotexamples.com/zh/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html">ZH</a> | <a href="https://hotexamples.com/ko/examples/-/SimplePie/get_title/php-simplepie-get_title-method-examples.html">KO</a> </div> </div> <div class="row"> <div class="col-md-10 col-md-offset-1"> </div> <div class="col-md-1"> <!--LiveInternet counter--> <script type="text/javascript"><!-- document.write("<a href='//www.liveinternet.ru/click' " + "target=_blank><img src='//counter.yadro.ru/hit?t44.6;r" + escape(document.referrer) + ((typeof (screen) == "undefined") ? "" : ";s" + screen.width + "*" + screen.height + "*" + (screen.colorDepth ? screen.colorDepth : screen.pixelDepth)) + ";u" + escape(document.URL) + ";" + Math.random() + "' alt='' title='LiveInternet' " + "border='0' width='31' height='31'><\/a>"); //--></script><!--/LiveInternet--> </div> </div> </div> </footer> <script src="//ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="/assets/30dd86a6f06b64184847037c52c63e07aa3c9a26.js"></script> <script>jQuery(function ($) { jQuery('#search-form').yiiActiveForm([{"id":"searchform-lang","name":"lang","container":".field-searchform-lang","input":"#searchform-lang","enableAjaxValidation":true},{"id":"searchform-search","name":"search","container":".field-searchform-search","input":"#searchform-search","enableAjaxValidation":true,"validate":function (attribute, value, messages, deferred, $form) {yii.validation.required(value, messages, {"message":"Search darf nicht leer sein."});}}], []); });</script></body> </html>