Skip to content

Instantly share code, notes, and snippets.

@multitel
multitel / gist:d19de6b09802697c73b55e8f562a17ad
Last active June 1, 2021 23:17
asterisk sms (re)delivery
File: /etc/asterisk/extensions.conf (don't use odbc as this becomes db intensive on a large number of messages)
[websms]
exten => _X.,1,NoOp(SMS receiving dialplan invoked)
exten => _X.,n,NoOp(To ${MESSAGE(to)})
exten => _X.,n,NoOp(From ${MESSAGE(from)})
exten => _X.,n,NoOp(Body ${MESSAGE(body)})
exten => _X.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
exten => _X.,n,ExecIf($["${ACTUALTO}" != "sip:${EXTEN}"]?Set(ACTUALTO=sip:${EXTEN}))
exten => _X.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})
@multitel
multitel / gist:5abfc5d700404fb1ff73214064d08bb5
Created August 17, 2016 18:10
Asterisk 13 PJProject patch to disable codecs
---
third-party/pjproject/Makefile.rules | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/third-party/pjproject/Makefile.rules b/third-party/pjproject/Makefile.rules
index d2e7d25..1608efd 100644
--- a/third-party/pjproject/Makefile.rules
+++ b/third-party/pjproject/Makefile.rules
@@ -3,7 +3,8 @@ PJPROJECT_URL = http://www.pjsip.org/release/$(PJPROJECT_VERSION)
# Even though we're not installing pjproject, we're setting prefix to /opt/pjproject to be safe
@multitel
multitel / cache.lua
Created March 9, 2016 15:41
MySQL Proxy Cache LUA
-- The LRU-Cache is a table which maintains the insertion order of
-- values with a doubled linked list. Each new value is placed at the front of
-- this list. So the oldest values are found at the back/tail of this list.
-- A 'value' is the real data, which is going to be cached.
-- Each 'value' is wrapped by a 'entry' object.
-- This 'entry' keeps the pointers for the doubled linked list and also the lifetime.
function lru_cache_create(maxsize, max_age)
local lru_cache = {
-- Number of current cache entries
current_items = 0,
@multitel
multitel / gist:8e2b8f1c72b604ef09d0
Created January 19, 2016 19:37
Asterisk CURL realtime sample CodeIgniter controller
Controller:
# ROUTING ENGINE ("re" controller)
## THIS IS JUST A SAMPLE
## MAKE SURE YOU PUT PROPER SECURITY MEASURES IN PLACE
## Use it along with this:
## https://wiki.asterisk.org/wiki/display/AST/cURL
##
## (c) MultiTEL - https://multitel.net
@multitel
multitel / inline.html
Created December 9, 2015 16:49
2FA ( 2 Factor Authentication) sample applet (Inline)
<!DOCTYPE html>
<head>
<title>2Factor Authentication test</title>
<script type="text/javascript">
(function(d, script) {
script = d.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.onload = function(){
// remote script has loaded
@multitel
multitel / Send SMS with new line
Created October 14, 2015 19:35
Send SMS with new line testing
<?php
$server_url = "http://api.multitel.net/json/sendsms";
if(isset($_POST['submit'])) {
$data = array(
'UserName' => $_POST['username'],
'Password' => $_POST['password'],
'From' => $_POST['from'],
'To' => $_POST['to'],
'Text' => $_POST['text'],
@multitel
multitel / SendFax testing
Last active September 12, 2015 13:40
SendFax
<?php
$server_url = 'http://api.multitel.net/json/';
$method = 'sendfax';
$server_url = $server_url.$method;
if(isset($_POST['submit']))
{
$type = 'string'; //this may need editing
$file_name =$_FILES['Message']['name'];
@multitel
multitel / Two Factor Authentication
Created July 17, 2015 22:13
2Factor Authentication sample applet
<!DOCTYPE html>
<head>
<title>2Factor Authentication test</title>
<script type="text/javascript">
(function(d, script) {
script = d.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.onload = function(){
// remote script has loaded
@multitel
multitel / gist:1366a4b3ce7f672f843b
Last active March 5, 2019 00:57
JSON functions
F: json/getcountries
D: obtains list of available countries for DID service
P:
- UserName
- Password
M:
- POST : json/getcountries
- GET : json/getcountries/UserName/Password
==============================================================================================================================
@multitel
multitel / E911 Sample JSON Provisioning
Created April 2, 2015 20:10
E911 JSON/HTML Sample provisioning
<?php
$server_url = 'http://api.multitel.net/json/';
$method = 'provisionaddress';
$server_url = $server_url.$method;
if(isset($_POST['submit'])) {
$data = array(
'UserName' => $_POST['UserName'],
'Password' => $_POST['Password'],
'UniqueId' => $_POST['UniqueId'],