Share » Forums » Developer » how to use ezurl() equivalent in a...

how to use ezurl() equivalent in a php script (launched by CLI...)

how to use ezurl() equivalent in a php script (launched by CLI...)

Tuesday 28 June 2011 10:52:40 am - 2 replies

Author Message

Marko Žmak

Wednesday 29 June 2011 3:52:32 am

The eZURI::transformURI() method, when used with 'full' parameter gets the hostname from the server HTTP_* variables.

Since this variables are not available when runing cli scripts (this is a restriction of Apache/PHP and not eZP), you cannot get the hostname in such a case.

One soultion would be to get the hostname from an INI setting.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Jerome Despatis

Friday 01 July 2011 12:59:33 am

Exactly, from INI settings

But, even by using ini settings, it's impossible to use eZURI::transformURI(), as it checks only server variables

As a result, I've added a feature request:

http://issues.ez.no/IssueView.php?Id=18423

Maybe it would be interesting to have ?

Because, the only way I've found for now to make ezurl() and eZURI::transformURI() work with 'full' parameter is to add a very ugly hack:

<code>

 if (eZSys::isShellExecution())
        {
            if (!eZSys::serverVariable('HTTP_HOST', true))
            {
                $siteIni = eZINI::instance();
                // Won't work if SiteURL contains other things than just hostname...
                eZSys::setServerVariable('HTTP_HOST', $siteIni->variable('SiteSettings', 'SiteURL'));
            }
            if (!eZSys::serverVariable('SERVER_PORT', true))
            {
                eZSys::setServerVariable('SERVER_PORT', 80);
            }
        }

</code>

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu