parse($fileContent); return $opml; } /** * @param Opml $opml * @param string $file */ public static function save($opml, $file) { $out = ''."\n"; $out.= ''."\n"; $out.= ''."\n"; $out.= ''.htmlspecialchars($opml->getTitle()).''."\n"; $out.= ''.gmdate('c').''."\n"; $out.= ''.gmdate('c').''."\n"; if ($opml->ownerName != '') { $out.= ''.htmlspecialchars($opml->ownerName).''."\n"; } if ($opml->ownerEmail != '') { $out.= ''.htmlspecialchars($opml->ownerEmail).''."\n"; } if ($opml->ownerId != '') { $out.= ''.htmlspecialchars($opml->ownerId).''."\n"; } $out.= 'http://opml.org/spec2.opml'."\n"; $out.= ''."\n"; $out.= ''."\n"; foreach ($opml->entries as $person) { $out .= sprintf( '', htmlspecialchars($person['name'], ENT_QUOTES), htmlspecialchars($person['website'], ENT_QUOTES), htmlspecialchars($person['feed'], ENT_QUOTES), htmlspecialchars($person['isDown'] ?? '', ENT_QUOTES) ) . "\n"; } $out.= ''."\n"; $out.= ''; file_put_contents($file, $out); } public static function backup($file) { copy($file, $file.'.bak'); } }