[asterisk-users] Custom PHP for Call Files

Scott Griepentrog sgriepentrog at digium.com
Mon Dec 28 07:37:08 CST 2015


I happen to have some old crufty code in PHP that generates a call file to
trigger an AGI.

Look at function callagi() in
https://github.com/stgnet/stgagi/blob/master/stgagi.php

This works in a FreePBX environment where the Asterisk process is running
as user "asterisk".  There are several other hard coded assumptions such as
paths, but the code should give you an idea how to make it work for you.

Note that Asterisk will normally delete the call file as soon as it sees it
and begins the call.  There is an exception to this where the Archive flag
in the call file instructs Asterisk to move the file to another directory
and update it with the completion status.

For full details on the call file contents, see:
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Call+Files


On Sun, Dec 27, 2015 at 9:14 PM, er ic <email.eherr9633 at gmail.com> wrote:

> I am hoping to get some help here with building custom PHP to manage a
> 'wake up call' system.
>
> I have the script where the user can set the schedule for an extension
> wake up call.
>
> It appears to write to the /var/spool/asterisk/outgoing/ directory.
>
> My two issues:
>
> 1 - when the files do get moved over to outgoing/ directory via a cron
> job, the permissions show "-rw-r--r-- 1 apache apache 100 Jan  1  2016
> 5680a312a28b2.call" and the calls get sent when the date comes to pass. But
> my question is, if I mv 3 files from my php script,  'll
> /var/spool/asterisk/outgoing/' shows 'total 12' when there are only three
> files in the directory. What does total mean? Is my perl script doing
> something that I am not aware of and really there are 12 files overlapped
> or something funky?
>
> --- cron job perl script
> my @list = glob("/tmp/*.call");
> for( 0 .. $#list )
> {
>         system "mv $list[$_] /var/spool/asterisk/outgoing/";
> }
> -------------------------------
>
> 2 - I would like to view and delete call files but as it currently stands,
> php gets a permission denied.
> obviously php is running as apache and the outgoing/ directory is
> asterisk:asterisk but the call files are apache:apache. My question is,
> what is the best way, without risking security, to allow php to list and
> delete the files? I know my scripts themselves work because when I chown
> apache:apache /var/spool/asterisk/outgoing the script works. I have seen
> front ends work with all the same permissions on outgoing/ and the files
> but I dont know how they are able to read/delete the files for monitor/
> which is the same as the outgoing/ directory.
>
> Thanks for your help in advance all!
> --Eric
>
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>                http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
>



-- 
[image: Digium logo]
Scott Griepentrog
Digium, Inc · Software Developer
445 Jan Davis Drive NW · Huntsville, AL 35806 · US
direct/fax: +1 256 428 6239 · mobile: +1 256 580 6090
Check us out at: http://digium.com · http://asterisk.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20151228/d673124f/attachment.html>


More information about the asterisk-users mailing list