PHP Classes

PHP AGI: Control an Asterisk VOIP instance

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 547 All time: 5,534 This week: 101Up
Version License PHP version Categories
php-agi 2.20GNU Lesser Genera...5.2Networking, PHP 5, Audio
Description 

Author

This package can be used to control an Asterisk VOIP instance.

It can connect to the network interface of an Asterisk instance running on a given IP address and port and send commands to control Asterisk.

Currently it can send commands to control options such as the hangup timeout, set the monitoring file of a channel, monitor a channel, control the events to be sent to the instance, get the state of extensions, get channel variables, hangup a channel, list IAX peers, check the message mailbox, original calls, list parked calls, manage queues, redirect channels, manage the zap channel, list available commands, send arbitrary commands, etc..

Picture of Matthew Asham
  Performance   Level  
Name: Matthew Asham <contact>
Classes: 1 package by
Country: Canada Canada

Recommendations

Asterisk Manager Interface
Looking for a class to manage Asterisk from web

Example

#!/usr/local/bin/php -q
<?php
 
/**
  * phpagi-fastagi.php : PHP FastAGI bootstrap
  * Website: http://phpagi.sourceforge.net
  *
  * $Id: phpagi-fastagi.php,v 1.2 2005/05/25 18:43:48 pinhole Exp $
  *
  * Copyright (c) 2004, 2005 Matthew Asham <matthewa@bcwireless.net>, David Eder <david@eder.us>
  * All Rights Reserved.
  *
  * This software is released under the terms of the GNU Lesser General Public License v2.1
  * A copy of which is available from http://www.gnu.org/copyleft/lesser.html
  *
  * We would be happy to list your phpagi based application on the phpagi
  * website. Drop me an Email if you'd like us to list your program.
  *
  * @package phpAGI
  * @version 2.0
  * @example docs/fastagi.xinetd Example xinetd config file
  */

 /**
  * Written for PHP 4.3.4, should work with older PHP 4.x versions.
  * Please submit bug reports, patches, etc to http://sourceforge.net/projects/phpagi/
  * Gracias. :)
  *
  */

 
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'phpagi.php');

 
$fastagi = new AGI();

 
$fastagi->verbose(print_r($fastagi, true));

  if(!isset(
$fastagi->config['fastagi']['basedir']))
   
$fastagi->config['fastagi']['basedir'] = dirname(__FILE__);

 
// perform some security checks

 
$script = $fastagi->config['fastagi']['basedir'] . DIRECTORY_SEPARATOR . $fastagi->request['agi_network_script'];

 
// in the same directory (or subdirectory)
 
$mydir = dirname($fastagi->config['fastagi']['basedir']) . DIRECTORY_SEPARATOR;
 
$dir = dirname($script) . DIRECTORY_SEPARATOR;
  if(
substr($dir, 0, strlen($mydir)) != $mydir)
  {
   
$fastagi->conlog("$script is not allowed to execute.");
    exit;
  }

 
// make sure it exists
 
if(!file_exists($script))
  {
   
$fastagi->conlog("$script does not exist.");
    exit;
  }

 
// drop privileges
 
if(isset($fastagi->config['fastagi']['setuid']) && $fastagi->config['fastagi']['setuid'])
  {
   
$owner = fileowner($script);
   
$group = filegroup($script);
    if(!
posix_setgid($group) || !posix_setegid($group) || !posix_setuid($owner) || !posix_seteuid($owner))
    {
     
$fastagi->conlog("failed to lower privileges.");
      exit;
    }
  }

 
// make sure script is still readable
 
if(!is_readable($script))
  {
   
$fastagi->conlog("$script is not readable.");
    exit;
  }

  require_once(
$script);
?>


Details

PHPAGI README $Id: README,v 1.4 2005/05/19 13:19:37 pinhole Exp $ --------------------------------------- Welcome to PHPAGI. phpagi is a set of PHP classes for use in developing applications with the Asterisk Gateway Interface, and is licensed under the GNU Lesser General Public License (see COPYING for terms). This release (version 2) of the phpagi classes is a significant overhaul from the old version 1 library. API functions have been renamed and restructured. Version 1 of phpagi is no longer supported, but will continue to be available for historical purposes. We strongly encourage you to migrate to this new version. If you have developed software based around phpagi, we'd like to hear from you! Drop us a note, and indicate whether you'd like us to list your application on our website. FILES ----- phpagi.php - The main phpagi class. phpagi-asmanager.php - The Asterisk Manager class. phpagi-fastagi.php - FastAGI class. phpagi_1.php - Compatability class for 1.12 release docs/ - README files for the classes. api-docs/ - API Documentation (html) DOCS ---- README.phpagi - The main phpagi README README.phpagi-asmanager - The phpagi asterisk manager README README.phpagi-fastagi - phpagi fastagi README CHANGELOG - Change Log. phpagi.conf - An example configuration file for phpagi. fastagi.xinetd - xinetd.conf sample configuration for fastagi SUPPORT ------- Support for phpagi is available from the project website. * http://phpagi.sourceforge.net * http://sourceforge.net/projects/phpagi/

  Files folder image Files (4)  
File Role Description
Plain text file phpagi-asmanager.php Class asterisk manager interface
Accessible without login Plain text file phpagi-fastagi.php Example fastagi interface
Plain text file phpagi.php Class Main phpagi class
Accessible without login Plain text file README Doc. README

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:547
This week:0
All time:5,534
This week:101Up