Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function handle_connection($sock) {
- global $agi;
- $msgsock = socket_accept($sock);
- $pid=pcntl_fork();
- if ($pid == 0) {
- pcntl_signal(SIGHUP,SIG_IGN);
- pcntl_signal(SIGTERM,SIG_IGN);
- // pcntl_signal(SIGHUP,"handle_signal");
- require_once("/var/lib/asterisk/agi-bin/phpagi/phpfastagi.php");
- $agi=new AGI($msgsock);
- $var=$agi->request['agi_network_script'];
- $agiurl=parse_url($var);
- parse_str($agiurl['query']);
- if (isset($agiurl['path'])) {
- require_once("/var/lib/asterisk/agi-bin/" . $agiurl['path']);
- }
- socket_close($msgsock);
- exit;
- } else {
- pcntl_signal(SIGCLD,SIG_IGN);
- pcntl_signal(SIGHUP,SIG_IGN);
- }
- }
- $sock=socket_create(AF_INET,SOCK_STREAM,0);
- if ($_SERVER['argv'][1] != "" ) {
- socket_bind($sock,$_SERVER['argv'][1],$port) or die("Bind Failed\n");
- } else {
- socket_bind ($sock,$address,$port) or die("Bind Failed\n");
- }
- socket_listen($sock,128);
- if (pcntl_fork() == 0) {
- pcntl_signal(SIGCLD,SIG_IGN);
- while(true) {
- handle_connection($sock);
- }
- } else {
- exit;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement