Bruce Nik
2009-Dec-18 01:29 UTC
[asterisk-users] To Asterisk AMI Gurus - Tacking issue with originate
Hello Everyone, I am making a simple index.php file which will allow a web user to enter his $phoneNumb, $dialNumb, and callerID ($spoofNumb) and get the call bridged. Following is the index.php and the contents of extensions_custom.conf. When I submit the form nothing happens. I don't even see Manager Connected msg. Your input will be much appreciated. I am thinking I have some syntax problem. /etc/asterisk/extensions_custom.conf *[testphp] exten => _X.,1,Answer() exten => _X.,n,Dial(SIP/testTrunk/${EXTEN}) exten => _X.,n,Hangup()* * * * * * ***************************************************************************************************** * /var/www/html/clickncall/index.php <html> <head> <title>ClicknCall</title> </head> <body><br><br> <div align="center"> <?php $sys_ip = "127.0.0.1"; $User_str = "testphp"; $Secret_str = "testphp"; if ($_POST['x']) { $oSocket = fsockopen($sys_ip, 5038, $errnum, $errdesc) or die("Connection to host failed"); fputs($oSocket, "Action: login\r\n"); fputs($oSocket, "Username: $User_str\r\n"); fputs($oSocket, "Secret: $Secret_str\r\n\r\n"); fputs($oSocket, "Events: off\r\n\r\n"); fputs($oSocket, "Action: originate\r\n"); fputs($oSocket, "Channel: SIP/testTrunk/$phoneNumb\r\n"); fputs($oSocket, "Exten: $dialNumb\r\n"); fputs($oSocket, "Context: testphp\r\n"); fputs($oSocket, "Priority: 1\r\n\r\n"); fputs($oSocket, "Timeout: 10000\r\n"); fputs($oSocket, "CallerId: $spoofNumb\r\n"); fputs($oSocket, "Async: true\r\n"); fputs($oSocket, "Action: Logoff\r\n\r\n"); fclose($oSocket); print $_POST['x']; } else { print "<form method=\"post\"action=\"$_SERVER[PHP_SELF]\">"; print "<br>"; print "PHONE Number: <input type=\"text\"name=\"phoneNumb\">"; print "<br>"; print "PARTY Number: <input type=\"text\"name=\"dialNumb\">"; print "<br>"; print "FORGE Number: <input type=\"text\"name=\"spoofNumb\">"; print "<br>"; print "<input type=\"Submit\" value=\" Dial \">"; print "</form>"; } ?> </div> </body> </html> ************************************************************************************ */etc/asterisk/manager_custom.conf* [testphp] secret = testphp deny=0.0.0.0/0.0.0.0 permit=127.0.0.1/255.255.255.0 read = system,call,log,verbose,command,agent,user write = system,call,log,verbose,command,agent,user Thanks, -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20091217/146fef51/attachment.htm
Tzafrir Cohen
2009-Dec-18 10:20 UTC
[asterisk-users] To Asterisk AMI Gurus - Tacking issue with originate
On Thu, Dec 17, 2009 at 08:29:55PM -0500, Bruce Nik wrote:> Hello Everyone, > > I am making a simple index.php file which will allow a web user to enter his > $phoneNumb, $dialNumb, and callerID ($spoofNumb) and get the call bridged. > Following is the index.php and the contents of extensions_custom.conf. When > I submit the form nothing happens. I don't even see Manager Connected msg. > Your input will be much appreciated. I am thinking I have some syntax > problem.Time to debug the PHP part, then. This looks like an apache/PHP question...> > /etc/asterisk/extensions_custom.conf > *[testphp] > exten => _X.,1,Answer() > exten => _X.,n,Dial(SIP/testTrunk/${EXTEN}) > exten => _X.,n,Hangup()* > > * > * > * > * > * > ***************************************************************************************************** > * > /var/www/html/clickncall/index.php > <html> > <head> > <title>ClicknCall</title> > </head> > <body><br><br> > <div align="center"> > > <?php > > $sys_ip = "127.0.0.1"; > $User_str = "testphp"; > $Secret_str = "testphp"; > > if ($_POST['x']) { > $oSocket = fsockopen($sys_ip, 5038, $errnum, $errdesc) or die("Connection to > host failed"); > > fputs($oSocket, "Action: login\r\n"); > fputs($oSocket, "Username: $User_str\r\n"); > fputs($oSocket, "Secret: $Secret_str\r\n\r\n"); > fputs($oSocket, "Events: off\r\n\r\n"); > fputs($oSocket, "Action: originate\r\n"); > fputs($oSocket, "Channel: SIP/testTrunk/$phoneNumb\r\n"); > fputs($oSocket, "Exten: $dialNumb\r\n");And you get those variables from where? Are they submitted in the form? (And if so: if you don't remove strange characters such as '\r\n' from them, the user can use them to submit complete manager requests).> fputs($oSocket, "Context: testphp\r\n"); > fputs($oSocket, "Priority: 1\r\n\r\n"); > fputs($oSocket, "Timeout: 10000\r\n"); > fputs($oSocket, "CallerId: $spoofNumb\r\n"); > fputs($oSocket, "Async: true\r\n"); > fputs($oSocket, "Action: Logoff\r\n\r\n"); > > fclose($oSocket); > > print $_POST['x']; > > } else { > print "<form method=\"post\"action=\"$_SERVER[PHP_SELF]\">"; > print "<br>"; > print "PHONE Number: <input type=\"text\"name=\"phoneNumb\">"; > print "<br>"; > print "PARTY Number: <input type=\"text\"name=\"dialNumb\">"; > print "<br>"; > print "FORGE Number: <input type=\"text\"name=\"spoofNumb\">"; > print "<br>"; > print "<input type=\"Submit\" value=\" Dial > \">"; > print "</form>"; > > } ?> > > </div> > </body> > </html> > > ************************************************************************************ > */etc/asterisk/manager_custom.conf* > [testphp] > secret = testphp > deny=0.0.0.0/0.0.0.0 > permit=127.0.0.1/255.255.255.0 > read = system,call,log,verbose,command,agent,user > write = system,call,log,verbose,command,agent,userTo slightly reduce the chance of abuse: readwrite=call -- Tzafrir Cohen icq#16849755 jabber:tzafrir.cohen at xorcom.com +972-50-7952406 mailto:tzafrir.cohen at xorcom.com http://www.xorcom.com iax:guest at local.xorcom.com/tzafrir
Prince Singh
2009-Dec-18 13:33 UTC
[asterisk-users] To Asterisk AMI Gurus - Tacking issue with originate
Obvious debugging steps at this point:- 1. Manually connecting to AMI and testing the commands 1. telnet 127.0.0.1 5038 2. Login command 3. Originate command 2. Use a dummy AMI listener instead of actual asterisk to see if the events are going through 1. Stop asterisk (or change the manager port) 2. nc -l -k 127.0.0.1 5038 3. Confirm that 'nc' has taken the tcp port 5038 netstat -nlp | grep 5038 4. Test the php application to see if the login request can be seen on the console from where 'nc' was started 3. Edit /etc/php.ini (or similar file) to enable logging and then check the log file :) On Fri, Dec 18, 2009 at 6:59 AM, Bruce Nik <brucevoip at gmail.com> wrote:> Hello Everyone, > > I am making a simple index.php file which will allow a web user to enter > his $phoneNumb, $dialNumb, and callerID ($spoofNumb) and get the call > bridged. Following is the index.php and the contents of > extensions_custom.conf. When I submit the form nothing happens. I don't even > see Manager Connected msg. Your input will be much appreciated. I am > thinking I have some syntax problem. > > /etc/asterisk/extensions_custom.conf > *[testphp] > exten => _X.,1,Answer() > exten => _X.,n,Dial(SIP/testTrunk/${EXTEN}) > exten => _X.,n,Hangup()* > > * > * > * > * > * > ***************************************************************************************************** > * > /var/www/html/clickncall/index.php > <html> > <head> > <title>ClicknCall</title> > </head> > <body><br><br> > <div align="center"> > > <?php > > $sys_ip = "127.0.0.1"; > $User_str = "testphp"; > $Secret_str = "testphp"; > > if ($_POST['x']) { > $oSocket = fsockopen($sys_ip, 5038, $errnum, $errdesc) or die("Connection > to host failed"); > > fputs($oSocket, "Action: login\r\n"); > fputs($oSocket, "Username: $User_str\r\n"); > fputs($oSocket, "Secret: $Secret_str\r\n\r\n"); > fputs($oSocket, "Events: off\r\n\r\n"); > fputs($oSocket, "Action: originate\r\n"); > fputs($oSocket, "Channel: SIP/testTrunk/$phoneNumb\r\n"); > fputs($oSocket, "Exten: $dialNumb\r\n"); > fputs($oSocket, "Context: testphp\r\n"); > fputs($oSocket, "Priority: 1\r\n\r\n"); > fputs($oSocket, "Timeout: 10000\r\n"); > fputs($oSocket, "CallerId: $spoofNumb\r\n"); > fputs($oSocket, "Async: true\r\n"); > fputs($oSocket, "Action: Logoff\r\n\r\n"); > > fclose($oSocket); > > print $_POST['x']; > > } else { > print "<form method=\"post\"action=\"$_SERVER[PHP_SELF]\">"; > print "<br>"; > print "PHONE Number: <input type=\"text\"name=\"phoneNumb\">"; > print "<br>"; > print "PARTY Number: <input type=\"text\"name=\"dialNumb\">"; > print "<br>"; > print "FORGE Number: <input type=\"text\"name=\"spoofNumb\">"; > print "<br>"; > print "<input type=\"Submit\" value=\" Dial > \">"; > print "</form>"; > > } ?> > > </div> > </body> > </html> > > > ************************************************************************************ > */etc/asterisk/manager_custom.conf* > [testphp] > secret = testphp > deny=0.0.0.0/0.0.0.0 > permit=127.0.0.1/255.255.255.0 > read = system,call,log,verbose,command,agent,user > write = system,call,log,verbose,command,agent,user > > > Thanks, > > > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- Regards, Prince Singh Drishti-Soft Solutions Pvt Ltd 62-A, First Floor, Maruti Industrial Area, Sector - 18, Gurgaon - 122016 Haryana, India. P: 91 124 4771000 F: 91 124 4039120 W: http://www.drishti-soft.com B: http://blog.drishti-soft.com ---- DISCLAIMER This message may contain confidential, proprietary or legally Privileged information. In case you are not the original intended Recipient of the message, you must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message and you are requested to delete it and inform the sender. Any views expressed in this message are those of the individual sender unless otherwise stated. Nothing contained in this message shall be construed as an offer or acceptance of any offer by Drishti-Soft Solutions Pvt Ltd ("Drishti") unless sent with that express intent and with due authority of Drishti. Drishti has taken enough precautions to prevent the spread of viruses. However the company accepts no liability for any damage caused by any virus transmitted by this email. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20091218/83db2a5d/attachment.htm