HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers59/ferrumbv.nl/wwwroot/xml/products.xml.php
<?php
header('Content-Type: text/html; charset=utf-8');
// Includes
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL ^ E_WARNING);
ini_set("display_errors", 1);

include_once $_SERVER['DOCUMENT_ROOT'] . '/kms/config/connect.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/kms/lib/general/db_handler.class.php';

// Get data
global $pdo;


// Generate output
$productOutput = '';

$Db = new DatabaseHandler($pdo);
$Db->setTableName('products_items');
$Db->setOrder('itemOrder','DESC');
$Db->addRule('active',1);
$Db->setActiveOnly(true,1);
if($data = $Db->select())
{
    $products = $Db->twoDimensional($data);

    // Bind images to products array
    foreach($products as $key => $product)
    {
        // Add images
        $ImageDb = new DatabaseHandler($pdo);
        $ImageDb->setTableName('products_images');
        $ImageDb->addRule('itemId',$product['id']);
        $ImageDb->setOrder('session_key','ASC');
        $products[$key]['images'] = $product['images'] = $ImageDb->select();

        if(empty($product['description'])) $product['description'] = '&nbsp;';

        // Generate Output
        $productOutput .= '<entity>';
            $productOutput .= '<title><![CDATA[' . $product['title'] . ']]></title>';
            $productOutput .= '<description><![CDATA[' . $product['description'] . ']]></description>';
            $productOutput .= '<images>';

            // make sure array structure is the same
            if((string)key($product['images']) == 'id' )$product['images'] = array($product['images']);


            foreach($product['images'] as $image)
            {
                $altTitle = FN::encodeUrl($product['title']);

                $productOutput .= '<image thumb="/public/uploads/' . $image['kms_thumb'] . '"  src="/public/uploads/' . $image['thumb'] . '" src-large="/public/uploads/' . $image['filename'] . '" alt="' . $altTitle . '"></image>';
            }

            $productOutput .= '</images>';
        $productOutput .= '</entity>';
    }
}

// Start XML
echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
?>

<entities>
    <entity root="">
        <title>Overzicht</title>
    </entity>

    <entity>
        <title>Mechatronica</title>
        <description>
            <![CDATA[
            <p>
                Ferrum levert hoogwaardige onderdelen voor de mechatronica, in de breedste zin van het woord. In
                de loop der jaren heeft Ferrum zich ontwikkeld tot vaste partner van machinebouwers in de hightech
                industrie.
            </p>
            ]]>
        </description>
        <images>
            <image src="/public/images/producten/ferrum_grootverspaning_mechatronica_01.jpg"
                   src-large="/public/images/producten/ferrum_grootverspaning_mechatronica_large_01.jpg"
                   alt="temp">
            </image>
        </images>
    </entity>

    <entity>
        <title>3D-frezen en meten</title>
        <description>
            <![CDATA[
            <p>
                Ferrum behoort tot de marktleiders op het gebied van 3D-frezen. Onze mensen hebben veel ervaring
                in het frezen van 3D-onderdelen, waarbij strakke oppervlakten de norm zijn. <strong>Ruwheden tot 0.4 Ra</strong>
                worden gerealiseerd. Ferrum verzorgt ook de engineering en het ontwerp van 3D-producten. Met
                twee moderne 3D CAM-stations en een up-to-date 3D CAD-station zijn ook uw matrijzen bij Ferrum
                in goede handen.
            </p>
            ]]>
        </description>
        <images>
            <image src="/public/images/producten/ferrum_grootverspaning_3d-frezen_01.jpg"
                   src-large="/public/images/producten/ferrum_grootverspaning_3d-frezen_large_01.jpg"
                   alt="temp">
            </image>
        </images>
    </entity>

    <?= $productOutput ?>
</entities>