O
O
okovalev2019-01-27 18:41:31
linux
okovalev, 2019-01-27 18:41:31

How to understand where the php script is executed?

In the extensions.conf of the Asterisk configuration file, we call:

exten => h,1,Agi(update.php,${trunk},${CDR(billsec)})

What can be freely translated. Send the data in the $argv array to the update.php
php script. There is a line in the php script itself:
file_put_contents('/var/lib/asterisk/agi-bin/log.txt', exec('pwd'));

If you run the command script from the command line, log.txt will contain:
/var/lib/asterisk/agi-bin
And if you run it from under Asterisk PBX:
/tmp
Attention, the question is:
Where is the php script executed directly?
It puzzles me, because if you specify a relative path, and not an absolute one, the data in log.txt does not arrive ... :(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
bkosun, 2019-01-27
@okovalev

The full path to the current file or directory can be obtained using magic constants __FILE__/ __DIR__
php.net/manual/en/language.constants.predefined.php
Use the realpath function to expand symbolic links and get the absolute path to a file.
php.net/manual/en/function.realpath.php

R
Ruslan Fedoseev, 2019-01-27
@martin74ua

read the asterisk documentation.
Why don't you like the absolute path?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question