dolibarr 19.0.3
rssparser.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
28{
32 public $db;
33
37 public $error = '';
38
39 public $feed_version;
40
41 private $_format = '';
42 private $_urlRSS;
43 private $_language;
44 private $_generator;
45 private $_copyright;
46 private $_lastbuilddate;
47 private $_imageurl;
48 private $_link;
49 private $_title;
50 private $_description;
51 private $_lastfetchdate; // Last successful fetch
52 private $_rssarray = array();
53
54 private $current_namespace;
55 public $items = array();
56 public $current_item = array();
57 public $channel = array();
58 public $textinput = array();
59 public $image = array();
60
61 private $initem;
62 private $intextinput;
63 private $incontent;
64 private $inimage;
65 private $inchannel;
66
67 // For parsing with xmlparser
68 public $stack = array(); // parser stack
69 private $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
70
71
77 public function __construct($db)
78 {
79 $this->db = $db;
80 }
81
87 public function getFormat()
88 {
89 return $this->_format;
90 }
91
97 public function getUrlRss()
98 {
99 return $this->_urlRSS;
100 }
106 public function getLanguage()
107 {
108 return $this->_language;
109 }
115 public function getGenerator()
116 {
117 return $this->_generator;
118 }
124 public function getCopyright()
125 {
126 return $this->_copyright;
127 }
133 public function getLastBuildDate()
134 {
135 return $this->_lastbuilddate;
136 }
142 public function getImageUrl()
143 {
144 return $this->_imageurl;
145 }
151 public function getLink()
152 {
153 return $this->_link;
154 }
160 public function getTitle()
161 {
162 return $this->_title;
163 }
169 public function getDescription()
170 {
171 return $this->_description;
172 }
178 public function getLastFetchDate()
179 {
180 return $this->_lastfetchdate;
181 }
187 public function getItems()
188 {
189 return $this->_rssarray;
190 }
191
192
202 public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '')
203 {
204 global $conf;
205
206 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
207 include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
208
209 $rss = '';
210 $str = ''; // This will contain content of feed
211
212 // Check parameters
213 if (!dol_is_url($urlRSS)) {
214 $this->error = "ErrorBadUrl";
215 return -1;
216 }
217
218 $this->_urlRSS = $urlRSS;
219 $newpathofdestfile = $cachedir.'/'.dol_hash($this->_urlRSS, 3); // Force md5 hash (does not contain special chars)
220 $newmask = '0644';
221
222 //dol_syslog("RssPArser::parser parse url=".$urlRSS." => cache file=".$newpathofdestfile);
223 $nowgmt = dol_now();
224
225 // Search into cache
226 $foundintocache = 0;
227 if ($cachedelay > 0 && $cachedir) {
228 $filedate = dol_filemtime($newpathofdestfile);
229 if ($filedate >= ($nowgmt - $cachedelay)) {
230 //dol_syslog("RssParser::parser cache file ".$newpathofdestfile." is not older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we use it.");
231 $foundintocache = 1;
232
233 $this->_lastfetchdate = $filedate;
234 } else {
235 dol_syslog(get_class($this)."::parser cache file ".$newpathofdestfile." is not found or older than now - cachedelay (".$nowgmt." - ".$cachedelay.") so we can't use it.");
236 }
237 }
238
239 // Load file into $str
240 if ($foundintocache) { // Cache file found and is not too old
241 $str = file_get_contents($newpathofdestfile);
242 } else {
243 try {
244 $result = getURLContent($this->_urlRSS, 'GET', '', 1, array(), array('http', 'https'), 0);
245
246 if (!empty($result['content'])) {
247 $str = $result['content'];
248 } elseif (!empty($result['curl_error_msg'])) {
249 $this->error = 'Error retrieving URL '.$this->_urlRSS.' - '.$result['curl_error_msg'];
250 return -1;
251 }
252 } catch (Exception $e) {
253 $this->error = 'Error retrieving URL '.$this->_urlRSS.' - '.$e->getMessage();
254 return -2;
255 }
256 }
257
258 if ($str !== false) {
259 // Convert $str into xml
260 if (getDolGlobalString('EXTERNALRSS_USE_SIMPLEXML')) {
261 //print 'xx'.LIBXML_NOCDATA;
262 libxml_use_internal_errors(false);
263 if (LIBXML_VERSION < 20900) {
264 // Avoid load of external entities (security problem).
265 // Required only if LIBXML_VERSION < 20900
266 libxml_disable_entity_loader(true);
267 }
268
269 $rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA);
270 } else {
271 if (!function_exists('xml_parser_create')) {
272 $this->error = 'Function xml_parser_create are not supported by your PHP';
273 return -1;
274 }
275
276 try {
277 $xmlparser = xml_parser_create(null);
278
279 if (!is_resource($xmlparser) && !is_object($xmlparser)) {
280 $this->error = "ErrorFailedToCreateParser";
281 return -1;
282 }
283
284 xml_set_object($xmlparser, $this);
285 xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element');
286 xml_set_character_data_handler($xmlparser, 'feed_cdata');
287
288 $status = xml_parse($xmlparser, $str, false);
289
290 xml_parser_free($xmlparser);
291 $rss = $this;
292 //var_dump($status.' '.$rss->_format);exit;
293 } catch (Exception $e) {
294 $rss = null;
295 }
296 }
297 }
298
299 // If $rss loaded
300 if ($rss) {
301 // Save file into cache
302 if (empty($foundintocache) && $cachedir) {
303 dol_syslog(get_class($this)."::parser cache file ".$newpathofdestfile." is saved onto disk.");
304 if (!dol_is_dir($cachedir)) {
305 dol_mkdir($cachedir);
306 }
307 $fp = fopen($newpathofdestfile, 'w');
308 if ($fp) {
309 fwrite($fp, $str);
310 fclose($fp);
311 dolChmod($newpathofdestfile);
312
313 $this->_lastfetchdate = $nowgmt;
314 } else {
315 print 'Error, failed to open file '.$newpathofdestfile.' for write';
316 }
317 }
318
319 unset($str); // Free memory
320
321 if (empty($rss->_format)) { // If format not detected automatically
322 $rss->_format = 'rss';
323 if (empty($rss->channel)) {
324 $rss->_format = 'atom';
325 }
326 }
327
328 $items = array();
329
330 // Save description entries
331 if ($rss->_format == 'rss') {
332 //var_dump($rss);
333 if (getDolGlobalString('EXTERNALRSS_USE_SIMPLEXML')) {
334 if (!empty($rss->channel->language)) {
335 $this->_language = sanitizeVal((string) $rss->channel->language);
336 }
337 if (!empty($rss->channel->generator)) {
338 $this->_generator = sanitizeVal((string) $rss->channel->generator);
339 }
340 if (!empty($rss->channel->copyright)) {
341 $this->_copyright = sanitizeVal((string) $rss->channel->copyright);
342 }
343 if (!empty($rss->channel->lastbuilddate)) {
344 $this->_lastbuilddate = sanitizeVal((string) $rss->channel->lastbuilddate);
345 }
346 if (!empty($rss->channel->image->url[0])) {
347 $this->_imageurl = sanitizeVal((string) $rss->channel->image->url[0]);
348 }
349 if (!empty($rss->channel->link)) {
350 $this->_link = sanitizeVal((string) $rss->channel->link);
351 }
352 if (!empty($rss->channel->title)) {
353 $this->_title = sanitizeVal((string) $rss->channel->title);
354 }
355 if (!empty($rss->channel->description)) {
356 $this->_description = sanitizeVal((string) $rss->channel->description);
357 }
358 } else {
359 //var_dump($rss->channel);
360 if (!empty($rss->channel['language'])) {
361 $this->_language = sanitizeVal((string) $rss->channel['language']);
362 }
363 if (!empty($rss->channel['generator'])) {
364 $this->_generator = sanitizeVal((string) $rss->channel['generator']);
365 }
366 if (!empty($rss->channel['copyright'])) {
367 $this->_copyright = sanitizeVal((string) $rss->channel['copyright']);
368 }
369 if (!empty($rss->channel['lastbuilddate'])) {
370 $this->_lastbuilddate = sanitizeVal((string) $rss->channel['lastbuilddate']);
371 }
372 if (!empty($rss->image['url'])) {
373 $this->_imageurl = sanitizeVal((string) $rss->image['url']);
374 }
375 if (!empty($rss->channel['link'])) {
376 $this->_link = sanitizeVal((string) $rss->channel['link']);
377 }
378 if (!empty($rss->channel['title'])) {
379 $this->_title = sanitizeVal((string) $rss->channel['title']);
380 }
381 if (!empty($rss->channel['description'])) {
382 $this->_description = sanitizeVal((string) $rss->channel['description']);
383 }
384 }
385
386 if (getDolGlobalString('EXTERNALRSS_USE_SIMPLEXML')) {
387 $items = $rss->channel->item; // With simplexml
388 } else {
389 $items = $rss->items; // With xmlparse
390 }
391 //var_dump($items);exit;
392 } elseif ($rss->_format == 'atom') {
393 //var_dump($rss);
394 if (getDolGlobalString('EXTERNALRSS_USE_SIMPLEXML')) {
395 if (!empty($rss->generator)) {
396 $this->_generator = sanitizeVal((string) $rss->generator);
397 }
398 if (!empty($rss->lastbuilddate)) {
399 $this->_lastbuilddate = sanitizeVal((string) $rss->modified);
400 }
401 if (!empty($rss->link->href)) {
402 $this->_link = sanitizeVal((string) $rss->link->href);
403 }
404 if (!empty($rss->title)) {
405 $this->_title = sanitizeVal((string) $rss->title);
406 }
407 if (!empty($rss->description)) {
408 $this->_description = sanitizeVal((string) $rss->description);
409 }
410 } else {
411 //if (!empty($rss->channel['rss_language'])) $this->_language = (string) $rss->channel['rss_language'];
412 if (!empty($rss->channel['generator'])) {
413 $this->_generator = sanitizeVal((string) $rss->channel['generator']);
414 }
415 //if (!empty($rss->channel['rss_copyright'])) $this->_copyright = (string) $rss->channel['rss_copyright'];
416 if (!empty($rss->channel['modified'])) {
417 $this->_lastbuilddate = sanitizeVal((string) $rss->channel['modified']);
418 }
419 //if (!empty($rss->image['rss_url'])) $this->_imageurl = (string) $rss->image['rss_url'];
420 if (!empty($rss->channel['link'])) {
421 $this->_link = sanitizeVal((string) $rss->channel['link']);
422 }
423 if (!empty($rss->channel['title'])) {
424 $this->_title = sanitizeVal((string) $rss->channel['title']);
425 }
426 //if (!empty($rss->channel['rss_description'])) $this->_description = (string) $rss->channel['rss_description'];
427
428 if (!empty($rss->channel)) {
429 $this->_imageurl = sanitizeVal($this->getAtomImageUrl($rss->channel));
430 }
431 }
432 if (getDolGlobalString('EXTERNALRSS_USE_SIMPLEXML')) {
433 $tmprss = xml2php($rss);
434 $items = $tmprss['entry'];
435 } else {
436 // With simplexml
437 $items = $rss->items; // With xmlparse
438 }
439 //var_dump($items);exit;
440 }
441
442 $i = 0;
443
444 // Loop on each record
445 if (is_array($items)) {
446 foreach ($items as $item) {
447 //var_dump($item);exit;
448 if ($rss->_format == 'rss') {
449 if (getDolGlobalString('EXTERNALRSS_USE_SIMPLEXML')) {
450 $itemLink = sanitizeVal((string) $item->link);
451 $itemTitle = sanitizeVal((string) $item->title);
452 $itemDescription = sanitizeVal((string) $item->description);
453 $itemPubDate = sanitizeVal((string) $item->pubDate);
454 $itemId = '';
455 $itemAuthor = '';
456 } else {
457 $itemLink = sanitizeVal((string) $item['link']);
458 $itemTitle = sanitizeVal((string) $item['title']);
459 $itemDescription = sanitizeVal((string) $item['description']);
460 $itemPubDate = sanitizeVal((string) $item['pubdate']);
461 $itemId = sanitizeVal((string) $item['guid']);
462 $itemAuthor = sanitizeVal((string) ($item['author'] ?? ''));
463 }
464
465 // Loop on each category
466 $itemCategory = array();
467 if (!empty($item->category) && is_array($item->category)) {
468 foreach ($item->category as $cat) {
469 $itemCategory[] = (string) $cat;
470 }
471 }
472 } elseif ($rss->_format == 'atom') {
473 if (getDolGlobalString('EXTERNALRSS_USE_SIMPLEXML')) {
474 $itemLink = (isset($item['link']) ? sanitizeVal((string) $item['link']) : '');
475 $itemTitle = sanitizeVal((string) $item['title']);
476 $itemDescription = sanitizeVal($this->getAtomItemDescription($item));
477 $itemPubDate = sanitizeVal((string) $item['created']);
478 $itemId = sanitizeVal((string) $item['id']);
479 $itemAuthor = sanitizeVal((string) ($item['author'] ? $item['author'] : $item['author_name']));
480 } else {
481 $itemLink = (isset($item['link']) ? sanitizeVal((string) $item['link']) : '');
482 $itemTitle = sanitizeVal((string) $item['title']);
483 $itemDescription = sanitizeVal($this->getAtomItemDescription($item));
484 $itemPubDate = sanitizeVal((string) $item['created']);
485 $itemId = sanitizeVal((string) $item['id']);
486 $itemAuthor = sanitizeVal((string) ($item['author'] ? $item['author'] : $item['author_name']));
487 }
488 $itemCategory = array();
489 } else {
490 $itemCategory = array();
491 $itemLink = '';
492 $itemTitle = '';
493 $itemDescription = '';
494 $itemPubDate = '';
495 $itemId = '';
496 $itemAuthor = '';
497 print 'ErrorBadFeedFormat';
498 }
499
500 // Add record to result array
501 $this->_rssarray[$i] = array(
502 'link'=>$itemLink,
503 'title'=>$itemTitle,
504 'description'=>$itemDescription,
505 'pubDate'=>$itemPubDate,
506 'category'=>$itemCategory,
507 'id'=>$itemId,
508 'author'=>$itemAuthor
509 );
510 //var_dump($this->_rssarray);
511
512 $i++;
513
514 if ($i > $maxNb) {
515 break; // We get all records we want
516 }
517 }
518 }
519
520 return 1;
521 } else {
522 $this->error = 'ErrorFailedToLoadRSSFile';
523 return -1;
524 }
525 }
526
527
528
529 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
538 public function feed_start_element($p, $element, $attrs)
539 {
540 // phpcs:enable
541 $el = $element = strtolower($element);
542 $attrs = array_change_key_case($attrs, CASE_LOWER);
543
544 // check for a namespace, and split if found
545 $ns = false;
546 if (strpos($element, ':')) {
547 list($ns, $el) = explode(':', $element, 2);
548 }
549 if ($ns and $ns != 'rdf') {
550 $this->current_namespace = $ns;
551 }
552
553 // if feed type isn't set, then this is first element of feed identify feed from root element
554 if (empty($this->_format)) {
555 if ($el == 'rdf') {
556 $this->_format = 'rss';
557 $this->feed_version = '1.0';
558 } elseif ($el == 'rss') {
559 $this->_format = 'rss';
560 $this->feed_version = $attrs['version'];
561 } elseif ($el == 'feed') {
562 $this->_format = 'atom';
563 $this->feed_version = $attrs['version'];
564 $this->inchannel = true;
565 }
566 return;
567 }
568
569 if ($el == 'channel') {
570 $this->inchannel = true;
571 } elseif ($el == 'item' || $el == 'entry') {
572 $this->initem = true;
573 if (isset($attrs['rdf:about'])) {
574 $this->current_item['about'] = $attrs['rdf:about'];
575 }
576 } elseif ($this->_format == 'rss' && $this->current_namespace == '' && $el == 'textinput') {
577 // if we're in the default namespace of an RSS feed,
578 // record textinput or image fields
579 $this->intextinput = true;
580 } elseif ($this->_format == 'rss' && $this->current_namespace == '' && $el == 'image') {
581 $this->inimage = true;
582 } elseif ($this->_format == 'atom' && in_array($el, $this->_CONTENT_CONSTRUCTS)) {
583 // handle atom content constructs
584 // avoid clashing w/ RSS mod_content
585 if ($el == 'content') {
586 $el = 'atom_content';
587 }
588
589 $this->incontent = $el;
590 } elseif ($this->_format == 'atom' && $this->incontent) {
591 // if inside an Atom content construct (e.g. content or summary) field treat tags as text
592 // if tags are inlined, then flatten
593 $attrs_str = join(' ', array_map('map_attrs', array_keys($attrs), array_values($attrs)));
594
595 $this->append_content("<$element $attrs_str>");
596
597 array_unshift($this->stack, $el);
598 } elseif ($this->_format == 'atom' && $el == 'link') {
599 // Atom support many links per containging element.
600 // Magpie treats link elements of type rel='alternate'
601 // as being equivalent to RSS's simple link element.
602 if (isset($attrs['rel']) && $attrs['rel'] == 'alternate') {
603 $link_el = 'link';
604 } elseif (!isset($attrs['rel'])) {
605 $link_el = 'link';
606 } else {
607 $link_el = 'link_'.$attrs['rel'];
608 }
609
610 $this->append($link_el, $attrs['href']);
611 } else {
612 // set stack[0] to current element
613 array_unshift($this->stack, $el);
614 }
615 }
616
617
618 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
626 public function feed_cdata($p, $text)
627 {
628 // phpcs:enable
629 if ($this->_format == 'atom' and $this->incontent) {
630 $this->append_content($text);
631 } else {
632 $current_el = join('_', array_reverse($this->stack));
633 $this->append($current_el, $text);
634 }
635 }
636
637 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
645 public function feed_end_element($p, $el)
646 {
647 // phpcs:enable
648 $el = strtolower($el);
649
650 if ($el == 'item' or $el == 'entry') {
651 $this->items[] = $this->current_item;
652 $this->current_item = array();
653 $this->initem = false;
654 } elseif ($this->_format == 'rss' and $this->current_namespace == '' and $el == 'textinput') {
655 $this->intextinput = false;
656 } elseif ($this->_format == 'rss' and $this->current_namespace == '' and $el == 'image') {
657 $this->inimage = false;
658 } elseif ($this->_format == 'atom' and in_array($el, $this->_CONTENT_CONSTRUCTS)) {
659 $this->incontent = false;
660 } elseif ($el == 'channel' or $el == 'feed') {
661 $this->inchannel = false;
662 } elseif ($this->_format == 'atom' and $this->incontent) {
663 // balance tags properly
664 // note: i don't think this is actually neccessary
665 if ($this->stack[0] == $el) {
666 $this->append_content("</$el>");
667 } else {
668 $this->append_content("<$el />");
669 }
670
671 array_shift($this->stack);
672 } else {
673 array_shift($this->stack);
674 }
675
676 $this->current_namespace = false;
677 }
678
679
687 public function concat(&$str1, $str2 = "")
688 {
689 if (!isset($str1)) {
690 $str1 = "";
691 }
692 $str1 .= $str2;
693 return $str1;
694 }
695
696 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
703 public function append_content($text)
704 {
705 // phpcs:enable
706 if (!empty($this->initem)) {
707 $this->concat($this->current_item[$this->incontent], $text);
708 } elseif (!empty($this->inchannel)) {
709 $this->concat($this->channel[$this->incontent], $text);
710 }
711 }
712
720 public function append($el, $text)
721 {
722 if (!$el) {
723 return;
724 }
725 if (!empty($this->current_namespace)) {
726 if (!empty($this->initem)) {
727 $this->concat($this->current_item[$this->current_namespace][$el], $text);
728 } elseif (!empty($this->inchannel)) {
729 $this->concat($this->channel[$this->current_namespace][$el], $text);
730 } elseif (!empty($this->intextinput)) {
731 $this->concat($this->textinput[$this->current_namespace][$el], $text);
732 } elseif (!empty($this->inimage)) {
733 $this->concat($this->image[$this->current_namespace][$el], $text);
734 }
735 } else {
736 if (!empty($this->initem)) {
737 $this->concat($this->current_item[$el], $text);
738 } elseif (!empty($this->intextinput)) {
739 $this->concat($this->textinput[$el], $text);
740 } elseif (!empty($this->inimage)) {
741 $this->concat($this->image[$el], $text);
742 } elseif (!empty($this->inchannel)) {
743 $this->concat($this->channel[$el], $text);
744 }
745 }
746 }
747
755 private function getAtomItemDescription(array $item, $maxlength = 500)
756 {
757 $result = "";
758
759 if (isset($item['summary'])) {
760 $result = $item['summary'];
761 } elseif (isset($item['atom_content'])) {
762 $result = $item['atom_content'];
763 }
764
765 // remove all HTML elements that can possible break the maximum size of a tooltip,
766 // like headings, image, video etc. and allow only simple style elements
767 $result = strip_tags($result, "<br><p><ul><ol><li>");
768
769 $result = str_replace("\n", "", $result);
770
771 if (strlen($result) > $maxlength) {
772 $result = substr($result, 0, $maxlength);
773 $result .= "...";
774 }
775
776 return $result;
777 }
778
785 private function getAtomImageUrl(array $feed)
786 {
787 if (isset($feed['icon'])) {
788 return $feed['logo'];
789 }
790
791 if (isset($feed['icon'])) {
792 return $feed['logo'];
793 }
794
795 if (isset($feed['webfeeds:logo'])) {
796 return $feed['webfeeds:logo'];
797 }
798
799 if (isset($feed['webfeeds:icon'])) {
800 return $feed['webfeeds:icon'];
801 }
802
803 if (isset($feed['webfeeds:wordmark'])) {
804 return $feed['webfeeds:wordmark'];
805 }
806
807 return "";
808 }
809}
810
811
818function xml2php($xml)
819{
820 $fils = 0;
821 $tab = false;
822 $array = array();
823 foreach ($xml->children() as $key => $value) {
824 $child = xml2php($value);
825
826 //To deal with the attributes
827 foreach ($value->attributes() as $ak => $av) {
828 $child[$ak] = (string) $av;
829 }
830
831 //Let see if the new child is not in the array
832 if ($tab === false && in_array($key, array_keys($array))) {
833 //If this element is already in the array we will create an indexed array
834 $tmp = $array[$key];
835 $array[$key] = null;
836 $array[$key][] = $tmp;
837 $array[$key][] = $child;
838 $tab = true;
839 } elseif ($tab === true) {
840 //Add an element in an existing array
841 $array[$key][] = $child;
842 } else {
843 //Add a simple element
844 $array[$key] = $child;
845 }
846
847 $fils++;
848 }
849
850
851 if ($fils == 0) {
852 return (string) $xml;
853 }
854
855 return $array;
856}
Class to parse RSS files.
feed_start_element($p, $element, $attrs)
Triggered when opened tag is found.
getAtomItemDescription(array $item, $maxlength=500)
Return a description/summary for one item from a ATOM feed.
concat(&$str1, $str2="")
To concat 2 strings with no warning if an operand is not defined.
getImageUrl()
getImageUrl
feed_end_element($p, $el)
Triggered when closed tag is found.
__construct($db)
Constructor.
getLanguage()
getLanguage
getTitle()
getTitle
getLastBuildDate()
getLastBuildDate
getItems()
getItems
getLink()
getLink
getGenerator()
getGenerator
getCopyright()
getCopyright
feed_cdata($p, $text)
Triggered when CDATA is found.
getLastFetchDate()
getLastFetchDate
getUrlRss()
getUrlRss
parser($urlRSS, $maxNb=0, $cachedelay=60, $cachedir='')
Parse rss URL.
append_content($text)
Enter description here ...
append($el, $text)
smart append - field and namespace aware
getDescription()
getDescription
getFormat()
getFormat
getAtomImageUrl(array $feed)
Return a URL to a image of the given ATOM feed.
dol_filemtime($pathoffile)
Return time of a file.
dol_is_url($url)
Return if path is an URL.
dol_is_dir($folder)
Test if filename is a directory.
dolChmod($filepath, $newmask='')
Change mod of a file.
dol_now($mode='auto')
Return date for now.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
sanitizeVal($out='', $check='alphanohtml', $filter=null, $options=null)
Return a sanitized or empty value after checking value against a rule.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
getURLContent($url, $postorget='GET', $param='', $followlocation=1, $addheaders=array(), $allowedschemes=array('http', 'https'), $localurl=0, $ssl_verifypeer=-1)
Function to get a content from an URL (use proxy if proxy defined).
xml2php($xml)
Function to convert an XML object into an array.
dol_hash($chain, $type='0', $nosalt=0)
Returns a hash (non reversible encryption) of a string.