Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.64.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : ImageRoot.php
<?php

namespace WebPExpress;

use \WebPExpress\PathHelper;

class ImageRoot
{
    public $id;
    private $imageRootDef;

    /**
     * Constructor.
     *
     * @param  array  $imageRootDef   assoc array containing "id", "url" and either "abs-path", "rel-path" or both.
     */
    public function __construct($imageRootDef)
    {
        $this->imageRootDef = $imageRootDef;
        $this->id = $imageRootDef['id'];
    }

    /**
     *  Get / calculate abs path.
     *
     *  If "rel-path" is set and document root is available, the abs path will be calculated from the relative path.
     *  Otherwise the "abs-path" is returned.
     *  @throws Exception In case rel-path is not
     */
    public function getAbsPath()
    {
        $def = $this->imageRootDef;
        if (isset($def['rel-path']) && PathHelper::isDocRootAvailable()) {
            return rtrim($_SERVER["DOCUMENT_ROOT"], '/') . '/' . $def['rel-path'];
        } elseif (isset($def['abs-path'])) {
            return $def['abs-path'];
        } else {
            if (!isset($def['rel-path'])) {
                throw new \Exception(
                    'Image root definition in config file is must either have a "rel-path" or "abs-path" property defined. ' .
                    'Probably your system setup has changed. Please re-save WebP Express options and regenerate .htaccess'
                );
            } else {
                throw new \Exception(
                    'Image root definition in config file is defined by "rel-path". However, DOCUMENT_ROOT is unavailable so we ' .
                    'cannot use that (as the rel-path is relative to that. ' .
                    'Probably your system setup has changed. Please re-save WebP Express options and regenerate .htaccess'
                );
            }
        }
    }

}
© 2025 XylotrechusZ