<?php

/**
 * This Software is the property of Data Development and is protected
 * by copyright law - it is NOT Freeware.
 *
 * Any unauthorized use of this software without a valid license
 * is a violation of the license agreement and will be prosecuted by
 * civil and criminal law.
 *
 * http://www.shopmodule.com
 *
 * @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
 * @author    D3 Data Development - Daniel Seifert <support@shopmodule.com>
 * @link      http://www.oxidmodule.com
 */

namespace D3\ModCfg\dirpublic;

$oImageLogo = new d3logo;
$oImageLogo->getLogo();

/**
 * Class d3logo
 */
class d3logo
{
    public function getLogo()
    {
        if ($_GET && isset($_GET['cl']) && $_GET['cl']) {
            switch (strtolower($_GET['cl'])) {
                case 'module_main':
                    $sFncName = '_getEmptyPic';
                    break;
                default:
                    $sFncName = '_getSizeXXS';
            }
        } else {
            $sFncName = '_getSizeXXS';
        }

        if ($_REQUEST && isset($_REQUEST['size']) && $_REQUEST['size']) {
            switch (strtolower($_REQUEST['size'])) {
                case 'xxs':
                    $sFncName = '_getSizeXXS';
                    break;
                case 'xs':
                    $sFncName = '_getSizeXS';
                    break;
                case 's':
                    $sFncName = '_getSizeS';
                    break;
                case 'm':
                    $sFncName = '_getSizeM';
                    break;
                case 'l':
                    $sFncName = '_getSizeL';
                    break;
                case 'xl':
                    $sFncName = '_getSizeXL';
                    break;
                case 'xxl':
                    $sFncName = '_getSizeXXL';
                    break;
            }
        }

        if (!defined('OXID_PHP_UNIT')) {
            header("Content-type: image/png");
            echo base64_decode($this->{$sFncName}());
            exit;
        }
    }

    /**
     * 12px x 13px
     *
     * @return string
     */
    protected function _getSizeXXS()
    {
        $img_data =
            "iVBORw0KGgoAAAANSUhEUgAAAAwAAAANCAYAAACdKY9CAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAilJREFUeNocUt1LVEEcPTN37pfaXbYWUTdaDFw/IAhMkD58KioKKjGfoiCip1h6D+rBt/4IexMhsh58KJLyISLwISEWI1NZXfJz2dab9+6dO3OnuTvwm4GZcw7nd35DXpVjLO0S7EYENU7GdgIyvhNgUAEk76rvQzmy/amK636M3P1+PGH6AZYBr+pjanlfPY6kcmCktwSNI3XFSoCrefrt6x5xNv/hGHUZaLmmppaqspQI4bhUwFUSiAQyhoRFFSwhRp8PI9uXwS+28Te5vLAmSp1tBO/GbZxwCDpMgvKBxGIlwe0iRaT5R1x2151kkL0u8wcqSNDfRTGqa+swwZdKjBt9JoY7KZ5+bELECT5UJLoz9B79XYtHIDiKHlrrzU+OyekG3q9yZF2CrQbHzFKA2lGMzXo8wvyQe9AKg8fdFuHHnwjgHF3tBFL33giETkV7gsRhSDxqC9GEFCjmjBbB5BKPxlycL1hYXI+wWg01NtYiAo4UTXa6Q61UQlEY6GQtwstbWXg2wXI1wrP5A/gBB2wKhAn6euwVdrFgza5th9dezO9rIIVp6CH6OqH1AHv61LkitZzWhVPts+xs3p5byZsTM58PbraUSDozvelokbpMwaHApWLH/Jkee47mPepPjniloV5nAYZ+ZLpMraxEyzcijqEea+HuOa+Uzxg+018B2Ta2MdBlT9hMPazW4zv1puxN+8m6xsbJrPm2N+dMa0wjEgr/BRgADWz27ZRhGX8AAAAASUVORK5CYII=";

        return $img_data;
    }

    /**
     * 16px x 17px
     *
     * @return string
     */
    protected function _getSizeXS()
    {
        $img_data =
            "iVBORw0KGgoAAAANSUhEUgAAABAAAAARCAYAAADUryzEAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA0tJREFUeNpMU11oVEcU/mbu7N7dZJMYs+tPoqnpJjFQ01SCNq0IFqEPEixBseBPKe1DKW2pD0V8qg++FBQkfZT2JeRBJa3VFkWsCNUgIkJM8CcRsTTZTdI0ySa5u3v37swdz9y7VQfOZZh7znfO9803bOiZgm0B4wvA/XmgIFlizmUfLpX0rkyBNYFWUxUyDTF9rTrKIneyOLYs0dJai5sHWvGFMAmMIkYg80X0PVrAiWxBd/maDrkf/M0VNGoi+OarTmCliCtPHTbyfBlfTjo4wVFZD+fx3Y2//V+ncqrLVwrwKRQBmD0Brbg+fhiW2FLvb/+sHXubE/iFMTwT66uA8+P+x2dH/VOUikREI0RlwdeVgJfX6NnE0V7HcHVCJs/1MgiLr3MVtJhx/DVDT8qnVVmjsYbhjz4btbYpZwHEgqtxeULBIorfvy9wcYKhM8UwnlPNnOuUOPfQO5jNqQ2mW7qaY+uasH+RAE1RSx1H91qOC48ljl530b3ewrd/ehgYkxv3dlgHxci03AOfuEqNltro/5Lg8MU8xmYkBvclsL1JYPcmC5//7qB/mNQlYFgMY9N6D59ZLrdBE9EyCdQQdnc8jXtZD08nPdyZksEZJz51EVJJVAIS08uyTTglGQ8y6N7aV4fCTS0p/Ot41EVjc/1rZyshGLQORHaUinPbVxKeRNRSSNdb4ZXOllGaLeGDtMCuN0Na18aLKOfLdK0EImkCKWFrJXnK1hmUJNbFNN6oAHSkBAY+TeLyJ0nEBMM/OYkf/1oiHuplsWmaiuoM39YkbiHvoW0VR40davDW2giOdFfDJp/emCB7/jSDycWS4Rkay4julrGtUdwSPRvtgSsj+PrRrGv3/Zwl8+nAAT40MosSD4iKMSWiPOxe0SAuUOppjg6I1qQ1ur+r+szg8OLx3+bclw6krFD6CIUZTIXvIhCw6GPfe6vOtCbFKCeK6O1MnNy5uepSMJpFETGhw33wJipBV00Ow862+KXetxMnTS03r05pFD56p/bQjnS8P2ZM4Rmh/FeFZk9nMfhyR7qq3+TSQAVTKyoWgGbIdzTGjiZibOj5f97heUe+u+TqlJm6Ls7mGhKRuy3J6OCG1fZtyg1qzHohwACVM4XQA6QqzQAAAABJRU5ErkJggg==";

        return $img_data;
    }

    /**
     * 32px x 33px
     *
     * @return string
     */
    protected function _getSizeS()
    {
        $img_data =
            "iVBORw0KGgoAAAANSUhEUgAAACAAAAAhCAYAAAC4JqlRAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAACGFJREFUeNqMV32MVFcV/933MZ+787HdWZhlWbbLtnQpZRFEQ1ktam1rhTRr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m6YVNxibAKkrqbw3VNyjakwgoC7/qa/lSMqKeVxKU012pwPkd66KHHFInKwtk4XyJ04dFudluo/kc9c3ybVK6O8AWucOlXtvH+dxX4DyDSe6Oe6OHpE6p2zmaTRN9PQ37NrYHz5MW12p5qWReCWXe++JYuaDYlfwu025V7tfwQMGE1NG3oWGf7VVFRSVhsqVj2vRTW5N72pq0MRhWpTpyXt/KCsunrBoXdYTj9IkZ25L62FO9yT3puDbt6KUDLeaTQchsiWkXnn04tXNVQhulOPgE1pZS3z9fahzV60mWlPnsI807Wxq1C1KX/0JdubNRfFck9OM7e5v6uluD7xHaXOpdyghR6wm/Ed6YzAiS0d0aem9nb7JvRUI7LnXU3uirqrRBQGtp1M9t3xDfvm1N9CB9LRclcBbpevHryHfi2r5XL+ReKWN7T3y7lGmYoo5flvw4lbxvWny8Z2V4793Lg69dHsnvvjZufIXSdZmQp5K0rfholpcBSEOUlsmIMn73suDJ9W3hQ2FdPU2yHJlLfgTjU7JXElFDWDm9pSt6OhFRuwumeGA2b31+fNbqLpZ465zJnQPFgqoI6Wx0WVwbiEe0s3QRPUVuH5CTtIc+8T+ZV/8vwABOvaKKV48bWwAAAABJRU5ErkJggg==";

        return $img_data;
    }

    /**
     * 50px x 51px
     *
     * @return string
     */
    protected function _getSizeM()
    {
        $img_data =
            "[encoded data, 5192 characters]";

        return $img_data;
    }

    /**
     * 70px x 71px
     *
     * @return string
     */
    protected function _getSizeL()
    {
        $img_data =
            "[encoded data, 7852 characters]";

        return $img_data;
    }

    /**
     * 120px x 122px
     *
     * @return string
     */
    protected function _getSizeXL()
    {
        $img_data =
            "[encoded data, 15932 characters]";

        return $img_data;
    }

    /**
     * 220px x 224px
     *
     * @return string
     */

    protected function _getSizeXXL()
    {
        $img_data =
            "[encoded data, 29696 characters]";

        return $img_data;
    }

    /**
     * 1px x 1px
     *
     * @return string
     */
    protected function _getEmptyPic()
    {
        $img_data =
            "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABBJREFUeNpi+P//PwNAgAEACPwC/tuiTRYAAAAASUVORK5CYII=";

        return $img_data;
    }
}

/**
 * @param $imagefile
 *
 * @return string
 */
function base64_encode_image($imagefile)
{
    $imgtype  = array('jpg', 'gif', 'png');
    $filename = file_exists($imagefile) ? htmlentities($imagefile) : die('Image file name does not exist');
    $filetype = pathinfo($filename, PATHINFO_EXTENSION);

    if (in_array($filetype, $imgtype)) {
        $imgbinary = fread(fopen($filename, "r"), filesize($filename));
    } else {
        die ('Invalid image type, jpg, gif, and png is only allowed');
    }

    return 'data:image/' . $filetype . ';base64,' . base64_encode($imgbinary);
}
