HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //var/www/innodrive/cron/feed.php
<?php

define('CRON_ROOT', __DIR__ . '/');
define('SHORTINIT', false);
define( 'BASE_PATH', realpath(CRON_ROOT . '../public/') . '/' );
define('WP_USE_THEMES', false);

if( php_sapi_name() !== 'cli' ) {
    die("Meant to be run from command line");
}

if (!empty($argv[1])) {
    define('APPLICATION_ENV', $argv[1]);
} else {
    define('APPLICATION_ENV', 'production');
}

require(CRON_ROOT . 'wp-mock-const.php');
require(BASE_PATH . 'wp-load.php');
require(BASE_PATH . 'wp-content/plugins/polylang/polylang.php');
require(BASE_PATH . 'wp-content/plugins/import/import.php');
global $wp, $wp_query, $wp_the_query, $wp_rewrite, $wp_did_header, $wpdb;

$lang = new Polylang();
$lang->init();

function fixUrl($url) {
    return str_replace('http://', 'https://', $url);
}

$items = [];

$args = [
    'post_type' => 'news',
    'lang' => 'ru',
];

$loop = new WP_Query( $args );
if ($loop->have_posts()) {
    while ($loop->have_posts()) {
        $loop->the_post();
        $item = [
            'title' => $post->post_title,
            'url' => 'https://innodrive.ru/articles/news/' . $post->post_name,
            'slug' => $post->post_name,
            'content' => $post->post_content,
            'updated' => $post->post_modified,
            'date' => $post->post_date,
        ];
        $items[] = $item;
    }
}

ob_start();
echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
echo '<feed xmlns="http://www.w3.org/2005/Atom">' . PHP_EOL;
echo '<title>Innodrive feed</title>' . PHP_EOL;
echo '<id>https://innodrive.ru/</id>' . PHP_EOL;
echo '<link rel="alternate" href="https://innodrive.ru"/>' . PHP_EOL;
echo '<link href="https://innodrive.ru/news.rss" rel="self"/>' . PHP_EOL;
echo '<updated>' . date('c') . '</updated>' . PHP_EOL;
echo '<author><name>Innodrive</name></author>' . PHP_EOL;

foreach($items as $item) {
    ?>
    <entry>
        <title><?=$item['title'];?></title>
        <link rel="alternate" type="text/html" href="<?=$item['url'];?>"/>
        <id><?=$item['url'];?></id>
        <published><?=date('c', strtotime($item['date']));?></published>
        <updated><?=date('c', strtotime($item['updated']));?></updated>
        <content type="html"><![CDATA[ <?=trim( htmlspecialchars($item['content'],ENT_NOQUOTES, 'UTF-8'));?> ]]></content>
    </entry>
    <?php
}

echo '</feed>' . PHP_EOL;

$rssFile = ob_get_clean();
file_put_contents(BASE_PATH . 'news.rss', $rssFile);
exit;