Skip to content

Instantly share code, notes, and snippets.

Avatar

Lorne Gaetz lgaetz

  • Nova Scotia, Canada
View GitHub Profile
@lgaetz
lgaetz / asterisk.py
Created December 6, 2012 21:11 — forked from jfinstrom/asterisk.py
Example of using the Asterisk Manager API in python...
View asterisk.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# asterisk.py
#
# Copyright 2012 James Finstrom<jfinstrom at gmail>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@lgaetz
lgaetz / remotehintpoll.php
Last active December 7, 2021 21:18
Simple PHP script that checks the extension status at a remote PBX and updates a custom hint on the local pbx for proper BLF operation.
View remotehintpoll.php
<?php
/**** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** ****
* remotehintpoll.php
*
* Created by Lorne Gaetz lgaetz@sangoma.com
*
* Latest version: https://gist.github.com/lgaetz/8545099
*
* Licensed under GNU GPL version 2 or any later verison.
@lgaetz
lgaetz / group2chan.php
Last active January 4, 2016 13:09
PHP function for use with FreePBX that accepts a DAHDI group as an argument, and returns an array of DAHDI channels (if any) for that goup
View group2chan.php
<?php
// This function works within FreePBX or with FreePBX 2.9+ bootstrap loader
// $astman (phpagi class) already declared
function group2chan($groupid) {
global $astman;
// strip non-digits and assume the remaining number is the group number
$groupid = preg_replace("/[^0-9]*/", "", $groupid);
@lgaetz
lgaetz / lgaetz-didloopback.php
Last active July 28, 2022 16:25
Asterisk AGI file for a FreePBX system that examines outbound dialed digits against inbound DIDs specified in inbound routes. With Asterisk dial plan, it can be used to redirect outbound calls back in for local DIDs.
View lgaetz-didloopback.php
#!/usr/bin/php -q
<?php
/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
*
* Latest Version: https://gist.github.com/lgaetz/8633920
*
* Description:
*
* Script lgaetz-didloopback.php is used on a FreePBX server, with custom dialplan that calls
@lgaetz
lgaetz / match_pattern.php
Last active June 27, 2021 00:43
Two PHP functions, match_pattern and match_pattern_all that compare a numeric string against an Asterisk dial pattern (or array of patterns) and return a modified numeric string.
View match_pattern.php
<?PHP
// Written by jkiel
// license: GNU/GPL2 or later
/*
Match a phone number against an array of patterns
return array containing
'pattern' = the pattern that matched
'number' = the number that matched, after applying rules
@lgaetz
lgaetz / create_table
Last active August 29, 2015 14:00
All in one function to create/edit a FreePBX module table for usage in install.php
View create_table
<?php
function create_table($tablename, $cols) {
global $db;
# create a table if none present
# The temp column will be automatically removed by the checking code below.
$sql = "CREATE TABLE IF NOT EXISTS `$tablename` (`zzaa` INT);";
$check = $db->query($sql);
if (DB::IsError($check)) {
@lgaetz
lgaetz / bounce.php
Last active February 10, 2016 19:49
Modification to phpList 2.0.5/6 for processing bounces from Amazon SES
View bounce.php
<?php
/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
* Modification to file /admin/bounce.php to get subscriber email address *
* from Amazon SES bounce email warnings *
* Existing code lines 0 to 136 removed for clarity *
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***/
$tables["user"],$guessedid)); // exist line 137
View hostipcheck.php
<?php
/**** **** **** **** **** **** **** **** **** **** ****
* Description:
* Script that checks the ip address of a specified
* host and sends an email alert if the host's
* ip address has changed since the last check
*
* Usage:
* Run as a cron job to monitor an IP address, generates
View confkick.php
#!/usr/bin/env php
<?php
/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
* confkick.php
* FreePBX AGI file kicks all conference participants from the conference number received as argument
*
* Usage: Call from FreePBX dialplan using single argument with conf number to be kicked
* exten => s,n,AGI(confkick.php,1000)
*
View email_notify.php
#!/usr/bin/env php
<?php
/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
* email_notify.php
* FreePBX AGI file that generates an email message to an email address or to a list of addresses
* in an external file.
*
* Latest Version: https://gist.github.com/lgaetz/16f52b10983d1b8eaae02d9ec0ddf310
*