From: <abe...@us...> - 2013-11-01 03:05:57
|
Revision: 6254 http://sourceforge.net/p/astlinux/code/6254 Author: abelbeck Date: 2013-11-01 03:05:53 +0000 (Fri, 01 Nov 2013) Log Message: ----------- dialproxy.php, add support for POST method with number filtering Modified Paths: -------------- branches/1.0/package/webinterface/altweb/dialproxy.php Modified: branches/1.0/package/webinterface/altweb/dialproxy.php =================================================================== --- branches/1.0/package/webinterface/altweb/dialproxy.php 2013-10-31 00:18:21 UTC (rev 6253) +++ branches/1.0/package/webinterface/altweb/dialproxy.php 2013-11-01 03:05:53 UTC (rev 6254) @@ -1,6 +1,6 @@ <?php -// Copyright (C) 2008-2009 Lonnie Abelbeck +// Copyright (C) 2008-2013 Lonnie Abelbeck // This is free software, licensed under the GNU General Public License // version 3 as published by the Free Software Foundation; you can // redistribute it and/or modify it under the terms of the GNU @@ -8,13 +8,16 @@ // dialproxy.php for AstLinux // 09-03-2009 +// 10-31-2013, Add POST method // -// With permissions 'nobody' (by default) +// GET Method: // Usage: http://pbx/dialproxy.php?num=2223334444&ext=default -// -// With permissions 'root' // Usage: https://pbx/dialproxy.php?num=2223334444&ext=default // +// POST Method: +// Usage: curl --data-urlencode 'num=2223334444' --data-urlencode 'ext=default' http://pbx/dialproxy.php +// Usage: curl --data-urlencode 'num=2223334444' --data-urlencode 'ext=default' --insecure https://pbx/dialproxy.php +// // [webinterface] manager.conf context must contain // read = command,call,originate // write = command,call,originate @@ -171,9 +174,48 @@ return($info['timed_out'] ? 3 : 0); } -$num = isset($_GET['num']) ? $_GET['num'] : ''; -$ext = isset($_GET['ext']) ? $_GET['ext'] : ''; +// Function: normalize_phone_number +// +function normalize_phone_number($num) { + if ($num !== '') { + if (($df = trim(shell_exec('. /etc/rc.conf; echo "$DIALING_PREFIX_NUMBERS"'))) !== '') { + $df_opts = explode('~', $df); + $internationalprefix = isset($df_opts[0]) ? $df_opts[0] : ''; + $nationalprefix = isset($df_opts[1]) ? $df_opts[1] : ''; + $countryprefix = isset($df_opts[2]) ? $df_opts[2] : ''; + + if ($nationalprefix !== '') { + $num = preg_replace('/\('.$nationalprefix.'\)/', '', $num); + } + $num = preg_replace('/[^0-9+]/', '', $num); + if ($countryprefix !== '') { + $match = '+'.$countryprefix; + if (strncmp($num, $match, strlen($match)) == 0) { + $num = $nationalprefix.substr($num, strlen($match)); + } + } + if (strncmp($num, '+', 1) == 0) { + $num = $internationalprefix.substr($num, 1); + } + } else { + $num = preg_replace('/[^0-9]/', '', $num); + } + } + return($num); +} + +if (isset($_POST['num'], $_POST['ext'])) { + $num = normalize_phone_number($_POST['num']); + $ext = $_POST['ext']; +} elseif (isset($_GET['num'], $_GET['ext'])) { + $num = $_GET['num']; + $ext = $_GET['ext']; +} else { + $num = ''; + $ext = ''; +} + if ($num === '' || $ext === '') { myexit(1, 'Error'); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <abe...@us...> - 2013-11-01 18:08:14
|
Revision: 6255 http://sourceforge.net/p/astlinux/code/6255 Author: abelbeck Date: 2013-11-01 18:08:12 +0000 (Fri, 01 Nov 2013) Log Message: ----------- dialproxy.php, add outgoinglineprefix to DIALING_PREFIX_NUMBERS and filter POST's and GET's the same Modified Paths: -------------- branches/1.0/package/webinterface/altweb/dialproxy.php Modified: branches/1.0/package/webinterface/altweb/dialproxy.php =================================================================== --- branches/1.0/package/webinterface/altweb/dialproxy.php 2013-11-01 03:05:53 UTC (rev 6254) +++ branches/1.0/package/webinterface/altweb/dialproxy.php 2013-11-01 18:08:12 UTC (rev 6255) @@ -176,7 +176,7 @@ // Function: normalize_phone_number // -function normalize_phone_number($num) { +function normalize_phone_number($num, &$opts) { if ($num !== '') { if (($df = trim(shell_exec('. /etc/rc.conf; echo "$DIALING_PREFIX_NUMBERS"'))) !== '') { @@ -184,37 +184,44 @@ $internationalprefix = isset($df_opts[0]) ? $df_opts[0] : ''; $nationalprefix = isset($df_opts[1]) ? $df_opts[1] : ''; $countryprefix = isset($df_opts[2]) ? $df_opts[2] : ''; + $outgoinglineprefix = isset($df_opts[3]) ? $df_opts[3] : ''; + if ($outgoinglineprefix !== '') { + $opts['dialprefix'] = $outgoinglineprefix; + } if ($nationalprefix !== '') { $num = preg_replace('/\('.$nationalprefix.'\)/', '', $num); } - $num = preg_replace('/[^0-9+]/', '', $num); + $num = preg_replace('/[^0-9*#+]/', '', $num); if ($countryprefix !== '') { $match = '+'.$countryprefix; if (strncmp($num, $match, strlen($match)) == 0) { $num = $nationalprefix.substr($num, strlen($match)); } } - if (strncmp($num, '+', 1) == 0) { - $num = $internationalprefix.substr($num, 1); + if ($internationalprefix !== '') { + if (strncmp($num, '+', 1) == 0) { + $num = $internationalprefix.substr($num, 1); + } } } else { - $num = preg_replace('/[^0-9]/', '', $num); + $num = preg_replace('/[^0-9*#]/', '', $num); } } return($num); } if (isset($_POST['num'], $_POST['ext'])) { - $num = normalize_phone_number($_POST['num']); + $num = normalize_phone_number($_POST['num'], $opts); $ext = $_POST['ext']; } elseif (isset($_GET['num'], $_GET['ext'])) { - $num = $_GET['num']; + $num = normalize_phone_number($_GET['num'], $opts); $ext = $_GET['ext']; } else { $num = ''; $ext = ''; } +//myexit(0, "Debug: num=$num ext=$ext dialprefix=".$opts['dialprefix']); if ($num === '' || $ext === '') { myexit(1, 'Error'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <abe...@us...> - 2013-11-01 21:53:40
|
Revision: 6257 http://sourceforge.net/p/astlinux/code/6257 Author: abelbeck Date: 2013-11-01 21:53:37 +0000 (Fri, 01 Nov 2013) Log Message: ----------- dialproxy.php, add debug=1 option, useful for testing DIALING_PREFIX_NUMBERS prefix settings without dialing Modified Paths: -------------- branches/1.0/package/webinterface/altweb/dialproxy.php Modified: branches/1.0/package/webinterface/altweb/dialproxy.php =================================================================== --- branches/1.0/package/webinterface/altweb/dialproxy.php 2013-11-01 18:38:05 UTC (rev 6256) +++ branches/1.0/package/webinterface/altweb/dialproxy.php 2013-11-01 21:53:37 UTC (rev 6257) @@ -26,6 +26,11 @@ // Required value channel, ie. SIP/1234 // with ~ seprated options context=, timeout=, callerid=, localcallerid=, dialprefix= and allow= // +// Debug Mode: (set debug=1) +// Useful for testing DIALING_PREFIX_NUMBERS prefix settings without dialing. +// Usage: curl "http://pbx/dialproxy.php?num=2223334444&ext=default&debug=1" +// Usage: curl --data-urlencode 'num=2223334444' --data-urlencode 'ext=default' -d 'debug=1' http://pbx/dialproxy.php +// $remote_addr = $_SERVER['REMOTE_ADDR']; @@ -221,7 +226,9 @@ $num = ''; $ext = ''; } -//myexit(0, "Debug: num=$num ext=$ext dialprefix=".$opts['dialprefix']); +if (isset($_POST['debug']) || isset($_GET['debug'])) { + myexit(0, "Debug: num=$num ext=$ext dialprefix=".$opts['dialprefix']); +} if ($num === '' || $ext === '') { myexit(1, 'Error'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <abe...@us...> - 2015-12-11 14:41:22
|
Revision: 7393 http://sourceforge.net/p/astlinux/code/7393 Author: abelbeck Date: 2015-12-11 14:41:19 +0000 (Fri, 11 Dec 2015) Log Message: ----------- web interface, dialproxy, support GET/POST variables 'phone' and 'exten' synonymous for 'num' and 'ext' Modified Paths: -------------- branches/1.0/package/webinterface/altweb/dialproxy.php Modified: branches/1.0/package/webinterface/altweb/dialproxy.php =================================================================== --- branches/1.0/package/webinterface/altweb/dialproxy.php 2015-12-10 18:03:45 UTC (rev 7392) +++ branches/1.0/package/webinterface/altweb/dialproxy.php 2015-12-11 14:41:19 UTC (rev 7393) @@ -9,6 +9,7 @@ // dialproxy.php for AstLinux // 09-03-2009 // 10-31-2013, Add POST method +// 12-11-2015, Add GET/POST variables 'phone' and 'exten' synonymous for 'num' and 'ext' // // GET Method: // Usage: http://pbx/dialproxy.php?num=2223334444&ext=default @@ -216,16 +217,33 @@ return($num); } -if (isset($_POST['num'], $_POST['ext'])) { - $num = normalize_phone_number($_POST['num'], $opts); +if (isset($_POST['num'])) { + $num = $_POST['num']; +} elseif (isset($_POST['phone'])) { + $num = $_POST['phone']; +} elseif (isset($_GET['num'])) { + $num = $_GET['num']; +} elseif (isset($_GET['phone'])) { + $num = $_GET['phone']; +} else { + $num = ''; +} +if ($num !== '') { + $num = normalize_phone_number($num, $opts); +} + +if (isset($_POST['ext'])) { $ext = $_POST['ext']; -} elseif (isset($_GET['num'], $_GET['ext'])) { - $num = normalize_phone_number($_GET['num'], $opts); +} elseif (isset($_POST['exten'])) { + $ext = $_POST['exten']; +} elseif (isset($_GET['ext'])) { $ext = $_GET['ext']; +} elseif (isset($_GET['exten'])) { + $ext = $_GET['exten']; } else { - $num = ''; $ext = ''; } + if (isset($_POST['debug']) || isset($_GET['debug'])) { myexit(0, "Debug: num=$num ext=$ext dialprefix=".$opts['dialprefix']); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |