0
votes

I have [root]/includes/helpdesk/pipe.php with this code:

#!/opt/cpanel/ea-php55/root/usr/bin/php
<?php
require_once("pipeprocess.php");

In the same location in pipeprocess.php in first line I include another file still in the same location: helpdesk.php

then in [root]/includes/helpdesk/helpdesk.php in the first line I have:

require_once ("../../config.php");

config.php is in [root], this is why I have twice ../../, helpdesk.php works fine with direct access, but if run pipe.php via pipe command setup in cPanel I get a bounce error that config. php is not found:

PHP Warning: require_once(../../config.php): failed to open stream: No such file or directory in /home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on line 21

Warning: require_once(../../config.php): failed to open stream: No such file or directory in /home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on line 21 PHP Fatal error: require_once(): Failed opening required '../../config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on line 21

Fatal error: require_once(): Failed opening required '../../config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/[user]/public_html/[root]/includes/helpdesk/helpdesk.php on line 21

Why I am getting this pipe error as direct access to helpdesk.php works fine? does pipe not accept ../ or ../../ as parth of the path? or is there an EasyApache4 issue? I did several tests and noticed this is because of ../ as part of including path. Does pipe/EasyApache4 have problem with this?

1

1 Answers

2
votes

What if you used __DIR__, based on where your currently running script file's folder?

As of PHP 5.3.0, you could use something like this:

require_once (__DIR__ . "/../../config.php");