Войти
Введите цифры и буквы
<?php $feedURL = "http://newsstreet.ru/rss/content/2/feed.rss"; $channelTitle = "Новости, авторские переводы статей иностранной зарубежной прессы, обзоры иностранных зарубежных СМИ, личные и тематические блоги, комментарии, обсуждения, аналитика, новостной форум"; $channelDescription = "Новости, авторские переводы статей иностранной зарубежной прессы, обзоры иностранных зарубежных СМИ, личные и тематические блоги, комментарии, обсуждения, аналитика, новостной форум"; $channelImage = 'http://newsstreet.ru/site.gif'; $feed = file_get_contents($feedURL); $dom = new domDocument; $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $dom->loadXML($feed); if (!$dom) { echo "Error parsing original feed\n"; exit; } $rss = $dom->getElementsByTagName('rss')->item(0); $channel = $rss->getElementsByTagName('channel')->item(0); $title = $channel->getElementsByTagName('title')->item(0); if ($title->hasChildNodes()) { $title->removeChild($title->firstChild); } $title->appendChild(new DOMText($channelTitle)); $description = $channel->getElementsByTagName('description')->item(0); if ($description->hasChildNodes()) { $description->removeChild($description->firstChild); } $description->appendChild(new DOMText($channelDescription)); $firstItem = $channel->getElementsByTagName('item')->item(0); $image = $dom->createElement('image'); $imageUrl = $dom->createElement('url'); $imageUrl->appendChild(new DOMText($channelImage)); $imageAlt = $dom->createElement('title'); $imageAlt->appendChild(new DOMText($channelTitle)); $imageLink = $dom->createElement('link'); $imageLink->appendChild(new DOMText($feedURL)); $image->appendChild($imageUrl); $image->appendChild($imageAlt); $image->appendChild($imageLink); $channel->insertBefore($image, $firstItem); $toDelete = array(); $items = $channel->getElementsByTagName('item'); for ($i = 0; $i < $items->length; $i++) { $item = $items->item($i); $date = $item->getElementsByTagName('pubDate')->item(0)->textContent; $timediff = time() - strtotime($date); if ($timediff > 60*60*24*8) { $toDelete[] = $item; } else { $link = $item->getElementsByTagName('link')->item(0); $pdalink = $dom->createElement('pdalink'); $pdalink->appendChild(new DOMText($link->textContent)); $item->insertBefore($pdalink, $link); $item->removeChild($item->getElementsByTagName('category')->item(0)); $item->removeChild($item->getElementsByTagName('author')->item(0)); $pageContent = file_get_contents($link->textContent); if (preg_match("/class=\"con_text\"/", $pageContent, $matches, PREG_OFFSET_CAPTURE)) { if (preg_match("/<p/", $pageContent, $matches, PREG_OFFSET_CAPTURE, $matches[0][1])) { $h3Found = preg_match("/<h3>Похожие статьи:/", $pageContent, $h3matches, PREG_OFFSET_CAPTURE, $matches[0][1]); $divendFound = preg_match("/\/div/", $pageContent, $divendmatches, PREG_OFFSET_CAPTURE, $matches[0][1]); if ($h3Found) { $end = min($h3matches[0][1], $divendmatches[0][1]); } else { $end = $divendmatches[0][1]; } $fulltext = iconv('cp1251', 'utf8', strip_tags(substr($pageContent, $matches[0][1], $end - $matches[0][1]))); #$fulltext = html_entity_decode($fulltext); $fulltexttag = $dom->createElement('yandex:full-text'); $fulltexttag->appendChild(new DOMText($fulltext)); $item->appendChild($fulltexttag); # print "==================\n"; # print $fulltext; # print "==================\n"; # break; } } } } foreach ($toDelete as $item) { $channel->removeChild($item); } $dom->encoding = 'utf-8'; $yarss = $dom->saveXML(); file_put_contents('yarss.xml', $yarss); echo "Всё ок"?>
У меня такая же задача стоит — поставить код трастлинка на 0.4.2
Если решили вопрос — подскажите, плз, как.
Заранее благодарю!
А по поводу расширенных возможностей — так для этого модули и плагины есть.
В англоязычной википедии нет ливстрит, зато есть джумла и вордпресс. Так по-вашей логике они тоже не CMS, наверное.
ПРосто вики англ. не знает ливстрит. Но можно внести правку в Википедию.
Зато для всех известных СМS есть такие модули, кроме Livestreet…
003 $feedURL = «site.ru/rss/content/2/feed.rss»;
Вряд ли у всех этот адрес одинаков…
Вот полный текст скрипта:
{literal}
нужный код
{/literal}
Почему-то он не отображается. Первый виден, второй — нет. Сделал след. образом:
{literal}
нужный код
{/literal}
{literal}
нужный код
{/literal}
В чём может быть причина?
Я как-то ставил aceblockmanager, но он весь сайт мне «вырубил» при активации :)
Теперь предпочитаю просто вставлять код…
Получилось :)