Telegram- 👇 😉
-
. WIKIMERIONET
Merion Mertics , ,

CRM

. , , , . , callback 10% .

, callback IP Asterisk . :

  1. - HTML CSS - . , ;
  2. - , 10 . , , ( ) ;

?


Prerequisites

, , :

  1. WEB , IP Asterisk (VLAN);
  2. WEB PHP Javascript;

web , callback.js URL callback.php , (_IP:/callback.php). , , .

, AMI (Asterisk Manager Interface). SSH IP Asterisk AMI:

vim /etc/asterisk/manager.conf

, [general] enabled = yes , :

[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0
displayconnects=no ;only effects 1.6+

. , :

[_]
secret = 
deny=0.0.0.0/0.0.0.0
permit=192.168.1.7/255.255.255.255
read = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message
write = system,call,log,verbose,command,agent,user,config,command,dtmf,reporting,cdr,dialplan,originate,message

:

  • _ - . callback;
  • - , , . P@ssword;
  • permit - . IP , AMI. Asterisk, , IP (192.168.1.7/32);

3 :

  1. index.php - , (HTML + CSS). web - ;
  2. callback.js - javascript, . web - ;
  3. callback.php - php , AMI Asterisk Originate ;

, , callback.php:

mkdir /var/www/html/callback

callback.php ( ):

<?php
$strhost = "192.168.1.7"; #  IP    Asterisk.  localhost/127.0.0.1,      Asterisk;
$strport = "5038"; # AMI  - ,     [general]  manager.conf;
$timeout = "10";
$num = $_POST[<phone<]; #   ,    callback; 
$name = <Callback - <.$_POST[<name<].<<; #  ,      ,    .      : 1  callback,   ,    ,      2   ;
$cid = "111"; #  ;
$c="from-internal";
$p="1";
$errno=0 ;
$errstr=0 ;
$sconn = fsockopen($strhost, $strport, &$errno, &$errstr, $timeout) or die("Connection to $strhost:$strport failed");
if (!$sconn) { echo "$errstr ($errno)
\n"; } else { echo <OK<; fputs($sconn, "Action: login\r\n"); fputs($sconn, "Username: callback\r\n"); # manager.conf callback; fputs($sconn, "Secret: P@ssw0rd\r\n"); # manager.conf P@ssw0rd; fputs($sconn, "Events: off\r\n\r\n"); usleep(500); fputs($sconn, "Action: Originate\r\n"); fputs($sconn, "Channel: SIP/$cid\r\n"); fputs($sconn, "Callerid: $name\r\n"); fputs($sconn, "Timeout: 15000\r\n"); fputs($sconn, "Context: $c\r\n"); fputs($sconn, "Exten: $num\r\n"); fputs($sconn, "Priority: $p\r\n"); fputs($sconn, "Async: yes\r\n\r\n" ); fputs($sconn, "Action: Logoff\r\n\r\n"); usleep (500); $wrets=fgets($sconn,128); fclose($sconn); exit; } ?>
, .txt .php;
callback.php

/var/www/html/callback. IP Asterisk :

chmod 755 /var/www/html/callback/callback.php 
dos2unix /var/www/html/callback/callback.php 

(). web IP 192.168.1.8. callback.js:

jQuery(document).ready(function($) {
$("#contact").submit(function() {
var str = $(this).serialize();
var delay = 3000;
$.ajax({
type: "POST",
url: "http://192.168.1.7/callback/callback.php",
data: str,
success: function(msg) {
if(msg == <OK<) {
result = <
:)
<; } else { result = msg; } $(<#note<).html(result); } }); return false; }); });

url: "http://192.168.1.7/callback/callback.php", . IP Asterisk.

, callbackjs callback, .txt .php;
callback.js

/callback . . . HTML , CSS, . , :

WEB callback. callback.js jquery-1.11.3.min.js . :

<script type="text/javascript" src="//merionet.ru/callback/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="//merionet/callback/callback.js"></script>
<div class="container">  
  <form id="contact" action="">
    <h3> ?</h3>
    <h4>  10 .</h4>
	<div id="note"></div>
    <fieldset>
      <input placeholder=" " type="text" name="name">
    </fieldset>
    <fieldset>
      <input id="phone" placeholder="    89123456789" type="text" name="phone">
    </fieldset>
    <fieldset>
      <button type="submit" name="submit" id="contact-submit"> !</button>
    </fieldset>
  </form>
</div>
, .txt .php;
index.php

index.php /callback .

, . :

  1. callback.php /var/www/html/callback IP Asterisk;
  2. callback.js /callback web - ;
  3. index.php /callback web - ;

. URL :

WEB  callback  Asterisk

:

 -

, .