rss импорт

#
rss импорт
пытаюсь настроить автоматическое добавление новостей через cron
создал файл php с текстом:

<?php
ini_set('display_errors', 1);
/* Подключаем основные классы */
require_once('main_classes.php');
/* Загружаем модули */
$GLOBALS['kernel']->LoadModules();
/* Адрес RSS-канала */
$url = 'http://www.hostcms.ru/news/rss/';
/* Идентификатор информационной системы, в которую помещаются элементы */
$infsys_id = 16;
/* Группа, в которую помещается новый элемент */
$infgroup_id = 0;
$rss = new RssRead();
$result = $rss->ReadRSS($url);
$InformationSystem = new InformationSystem();
$DateClass = new DateClass();
/* Цикл по полученным элементам */
for($i = 0; $i < count($result['items']) - 1; $i++)
{
/* Если не найдено элементов с таким же именем */
if (mysql_num_rows(
$InformationSystem->GetExternalInformationSystemItem
(array('information_items_name'=>$result['items'][$i]['title'],
'information_blocks_id'=>$infsys_id))) == 0)
{
/* Формируем полный путь к источнику материала */
$link = $result['items'][$i]['link'];
/* Заголовок */
$title = $result['items'][$i]['title'];
/* Тест элемента */
$desc = $result['items'][$i]['desc'];
/* Описание элемента */
$text = $result['items'][$i]['desc'];
/* Дата */
$date = $DateClass->DateUnixToSQL (strtotime
($result['items'][$i]['pubdate']));
if (!empty($title))
{
/* Вставка элемента */
$InformationSystem->InsertInformationItems(0, 0, $infsys_id,
$infgroup_id, $date, $title, $desc, 1, $text, '', 0, $_SERVER['REMOTE_ADDR']);
}
}
}
?>


захожу по http://test.langooy.ru/112.php
и выдаёт мне.  
Warning: require_once(main_classes.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/lang/data/www/test.langooy.ru/112.php on line 17

Fatal error: require_once() [function.require]: Failed opening required 'main_classes.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/lang/data/www/test.langooy.ru/112.php on line 17


что это может быть? никак не пойму. Все что нашёл по нету это ошибки в регистре(специально назвал цифрами)
как это можно исправить?
Модератор
#
Re: rss импорт
у Вас 6 версия? Это код от пятой версии, здесь он работать не будет.
#
Re: rss импорт
да 6 версия
а какой код будет?
что в скрипте нужно изменить.
этой информации я нигде не нашёл...
#
Re: rss импорт
я думаю это будет интересно многим.
Модератор
#
Re: rss импорт
Код для размещения файла import_rss.php в ./cron/
<?php

require_once(dirname(__FILE__) . '/../' . 'bootstrap.php');

/* Адреса RSS-каналов */
$aSourcesList = array(
   'http://www.hostcms.ru/news/rss/',
);

/* Идентификатор информационной системы, в которую помещаются элементы */
$informationsystem_id = 1;

/* Группа, в которую помещается новый элемент */
$informationsystem_group_id = 0;

$oInformationsystem = Core_Entity::factory('Informationsystem', $informationsystem_id);
$oInformationsystem_Group = Core_Entity::factory('Informationsystem_Group')->find($informationsystem_group_id);

$oSite = $oInformationsystem->Site;

define('CURRENT_SITE', $oSite->id);
Core::initConstants($oSite);

$iImported = 0;

$oCore_Rss_Read = new Core_Rss_Read();

foreach ($aSourcesList as $url)
{
   $aRssData = $oCore_Rss_Read
      ->clear()
      ->loadUrl($url)
      ->parse();

   foreach ($aRssData['items'] as $itemKey => $aItem)
   {
      $oSameItem = $oInformationsystem->Informationsystem_Items->getByName($aItem['title']);

      /* Если не найдено элементов с таким же именем */
      if (is_null($oSameItem))
      {
         $oInformationsystem_Item = Core_Entity::factory('Informationsystem_Item');
         $oInformationsystem_Item->name = $aItem['title'];
         $oInformationsystem_Item->description = $aItem['description'];
         $oInformationsystem_Item->text = $aItem['description'] . "<p>Источник: <a href=\"{$aItem['link']}\">{$aItem['link']}</a>";
         $oInformationsystem_Item->datetime = Core_Date::timestamp2sql(strtotime($aItem['pubdate']));

         $oInformationsystem_Item->informationsystem_group_id = !is_null($oInformationsystem_Group)
            ? intval($oInformationsystem_Group->id) : 0;

         if (strlen($oInformationsystem_Item->name))
         {
            // Save informationsystem item
            $oInformationsystem->add($oInformationsystem_Item);

            if (isset($aItem['enclosure']['url']))
            {
               $Core_Http = Core_Http::instance()
                  ->url($aItem['enclosure']['url'])
                  ->execute();

               // Определяем расширение файла
               $ext = Core_File::getExtension($aItem['enclosure']['url']);

               $temp_file = tempnam(TMP_DIR, "rss") . '.' . $ext;
               Core_File::write($temp_file, $Core_Http->getBody());

               $param = array();

               // Путь к файлу-источнику большого изображения;
               $param['large_image_source'] = $temp_file;

               $large_image = 'information_items_' . $oInformationsystem_Item->id . '.' . $ext;
               $small_image = 'small_' . $large_image;

               // Оригинальное имя файла большого изображения
               $param['large_image_name'] = $large_image;

               // Оригинальное имя файла малого изображения
               $param['small_image_name'] = $small_image;

               // Путь к создаваемому файлу большого изображения;
               $param['large_image_target'] = $oInformationsystem_Item->getItemPath() . Core_File::convertFileNameToLocalEncoding($large_image);

               // Путь к создаваемому файлу малого изображения;
               $param['small_image_target'] = $oInformationsystem_Item->getItemPath() . Core_File::convertFileNameToLocalEncoding($small_image);

               // Использовать большое изображение для создания малого
               $param['create_small_image_from_large'] = TRUE;
               $param['watermark_file_path'] = $oInformationsystem->getWatermarkFilePath();
               $param['watermark_position_x'] = $oInformationsystem->watermark_default_position_x;
               $param['watermark_position_y'] = $oInformationsystem->watermark_default_position_y;
               $param['large_image_preserve_aspect_ratio'] = $oInformationsystem->preserve_aspect_ratio;
               $param['small_image_max_width'] = $oInformationsystem->group_image_small_max_width;
               $param['small_image_max_height'] = $oInformationsystem->group_image_small_max_height;
               $param['small_image_watermark'] = $oInformationsystem->watermark_default_use_small_image;
               $param['small_image_preserve_aspect_ratio'] = $param['large_image_preserve_aspect_ratio'];
               $param['large_image_max_width'] = $oInformationsystem->group_image_large_max_width;
               $param['large_image_max_height'] = $oInformationsystem->group_image_large_max_height;
               $param['large_image_watermark'] = $oInformationsystem->watermark_default_use_large_image;

               $oInformationsystem_Item->createDir();

               $result = Core_File::adminUpload($param);

               if ($result['large_image'])
               {
                  $oInformationsystem_Item->image_large = $large_image;
                  $oInformationsystem_Item->setLargeImageSizes();
               }

               if ($result['small_image'])
               {
                  $oInformationsystem_Item->image_small = $small_image;
                  $oInformationsystem_Item->setSmallImageSizes();
               }

               $oInformationsystem_Item->save();

               Core_File::delete($temp_file);

               $iImported++;
            }
         }
      }
   }
}

printf('Imported %d items', $iImported);

Если размещаете в корне, то
require_once(dirname(__FILE__) . '/../' . 'bootstrap.php');
заменяете на
require_once(dirname(__FILE__) . '/' . 'bootstrap.php');
#
Re: rss импорт
положил в корень по адресу http://test.langooy.ru/113.php

проверяю. выдаёт ошибку  
Модератор
#
Re: rss импорт
Поправил код выше.
#
Re: rss импорт
теперь все работает. спасибо
Модератор
#
Re: rss импорт
Пожалуйста
#
Re: rss импорт
Не импортируются новости.
Первая строчка в адресах источников с красной строки почему то...
При переходе в /import/ выдаёт ошибку:
Предупреждение:
require_once(/home/users/k/kamardindg/domains/detskaya-mebel.com/hostcmsfiles/lib/lib_15/bootstrap.php): failed to open stream: Нет такого файла или каталога в файле /home/users/k/kamardindg/domains/detskaya-mebel.com/hostcmsfiles/lib/lib_15/lib_15.php (строка 2)
Fatal error
: require_once(): Failed opening required '/home/users/k/kamardindg/domains/detskaya-mebel.com/hostcmsfiles/lib/lib_15/bootstrap.php' (include_path='.:/usr/local/zend-7.2/share/pear') in
/home/users/k/kamardindg/domains/detskaya-mebel.com/hostcmsfiles/lib/lib_15/lib_15.php on line 2

Помогите!...
Авторизация