Skip to content

Instantly share code, notes, and snippets.

View lgaetz's full-sized avatar

Lorne Gaetz lgaetz

  • Nova Scotia, Canada
View GitHub Profile
@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
<?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)) {
<?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
@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
<?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 / bounce.php
Last active February 10, 2016 19:49
Modification to phpList 2.0.5/6 for processing bounces from Amazon SES
<?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
@lgaetz
lgaetz / asterisk.py
Created December 6, 2012 21:11 — forked from jfinstrom/asterisk.py
Example of using the Asterisk Manager API in python...
#!/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
#!/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
*
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAllMB/LAdH7yor+yW+PZla0kSWMvugiM23GsKM7eOSXby/3KpOzzFYvqiYOXwIqwBY8Dx/jbCUXxxQUQHkedObr4jyN860UQTumWA8SMR4eDTB8aSUUzkb407zyvnZ763+Ul7lp3rFWw0vwCBS3mr/AU7omnaH8DTgUIx6GiQQ9j8DDiDnD/JqLvzmuhwlbHJuwuhor09skEIi0tDdQn2qTUl1wNeBGeuX2P4peBMWF+/8JWRRHApkbJCI94qpBX/DlzYQgJ0bmaVwQhS8BdsdGZpGqVZLDuz01o+DS0WlGeb2qkN3Enrsjwgit3VlEnqaLJuXAeiWj5zNQyn1vAptQ== root@pbx.local
#!/bin/bash
# Script: lgaetz-rec2email.sh automatically send all call recordings to email for FreePBX
#
# Latest version: https://gist.github.com/lgaetz/f5d2ad453c381856b1b7e00d99ed0ecb
#
# Usage: Save to /var/lib/asterisk/bin/lgaetz-rec2email.sh, owner asterisk:asterisk 777 perms.
# In FreePBX, Advanced Settings, Post Call Recording Script sub actual email send address and populate with:
#
# /var/lib/asterisk/bin/lgaetz-rec2email.sh <email@address.com> ^{MIXMONITOR_FILENAME} ^{FROMEXTEN} ^{ARG3}
#!/usr/bin/php
<?php
// script requires a command - echo help and exit if arg1
if (!isset($argv[1])) {
echo "
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
*
* Script: lgaetz-tctoggle.php
*
#!/usr/bin/php
<?php
/*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
*
* Script: lgaetz-usermandel.php
*
* Latest version: https://gist.github.com/lgaetz/a6cc6139aefcb711a9de2f634690ceb6
*
* Usage: Scipt to delete a FreePBX User Management user. Developed for FreePBX 14