Page 1 of 1

Vicidial asterisk with php

PostPosted: Thu Dec 05, 2019 10:22 am
by bbakirtas
hi
i'm try to making new report for vicidial.
my purpose showing agents sip peers (asterisk -rx "sip show peers") my report will show agents connections ping values.
but i couldn't run with php asterisk command. Can i make with agi? or what is yours suggestions.
Thanks

VERSION: 2.14-730a
BUILD: 191121-2256

Re: Vicidial asterisk with php

PostPosted: Thu Dec 05, 2019 10:35 am
by williamconley
1) This is not a "General Discussion". It's a Support request. I will move the thread to the Support board.

2) Apache (which initiates php to generate html web pages) does not have permission to run command line programs as root. Adding the ability for apache/php to run the command "asterisk" as root is not a simple task, but can be done.

3) It might be simpler to run a crontab script that runs your command and stores the result in a txt or html page which you can then merely access with a web browser. If you run it every 10 minutes and store it in a web accessible folder the only thing you lose is the ability to generate it on demand.

Happy Hunting! 8-)

Re: Vicidial asterisk with php

PostPosted: Thu Dec 05, 2019 1:19 pm
by ambiorixg12
You wont be able to run such command Asterisk command from a php script executed by the apache user, in this case use AMI action and it will run fine doing Socket connection, and it will be real time adding some Jquery or Ajax auto refresh script

Re: Vicidial asterisk with php

PostPosted: Thu Dec 05, 2019 3:13 pm
by williamconley
ambiorixg12 wrote:You wont be able to run such command Asterisk command from a php script executed by the apache user, in this case use AMI action and it will run fine doing Socket connection, and it will be real time adding some Jquery or Ajax auto refresh script

beware jquery access to ami. credentials will be exposed to the end user along with the requirement to open the port for ami access to the end user. put those together and anyone using that page can take over your system if you're not careful. Be sure you trust anyone on that page.

Re: Vicidial asterisk with php

PostPosted: Thu Dec 05, 2019 8:28 pm
by ambiorixg12
williamconley wrote:
ambiorixg12 wrote:You wont be able to run such command Asterisk command from a php script executed by the apache user, in this case use AMI action and it will run fine doing Socket connection, and it will be real time adding some Jquery or Ajax auto refresh script

beware jquery access to ami. credentials will be exposed to the end user along with the requirement to open the port for ami access to the end user. put those together and anyone using that page can take over your system if you're not careful. Be sure you trust anyone on that page.



It wont, Jquery will only access to the content of an external script and update it every 1 sec, Nothing will be exposed

Code: Select all
<html>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script>
var auto_refresh = setInterval(
function()
{

  $('#loaddiv').load('call.php');
}, 1000);
</script>
<body>
<div id="loaddiv">
</div>

</body>
</html>

Re: Vicidial asterisk with php

PostPosted: Mon Dec 09, 2019 3:51 pm
by williamconley
Which is why I said to beware jQuery access to AMI. The solution is to hard-code the AMI access into the back end, of course.