23 августа 2012 г.

Asterisk - Web

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru" dir="ltr"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> 
</head>
<form action="str.php" method="post">
Ваш номер телефона +7 
<SELECT NAME=kod>
<OPTION>3012
<OPTION>950
<OPTION>951
<OPTION>914
<OPTION>924
<OPTION>964
</SELECT>
<input type="text" name="nomer" /><br/>
<input type="submit" value="Позвонить" />
</form>

<?php
$nomer_you = $_POST['nomer'];
$kodg = $_POST['kod'];
$number_phone="sipnet_202";        //Имя транка
$time=""; 
$nomer_caller="83012463097";     //Набираемый абонент
$outg="/var/spool/asterisk/outgoing"; 
$data=date("YmdHi")+$time;

if (empty($nomer_you)) die(''); else { 
    if(strlen($nomer_you)==7 || strlen($nomer_you)==6) { 
        if(!is_numeric($nomer_you)) die('Введите цифры'); else {

$a=exec ("/usr/local/bin/sudo touch -t $data /usr/local/www/data/voip/temp/$nomer_caller");
$b=exec ("/usr/local/bin/sudo chmod 777 /usr/local/www/data/voip/temp/$nomer_caller");

$c_1=exec ("/usr/local/bin/sudo /bin/echo Channel: SIP/$number_phone/8$kodg$nomer_you >> /usr/local/www/data/voip/temp/$nomer_caller");
$c_2=exec ("/usr/local/bin/sudo /bin/echo Application: Dial >> /usr/local/www/data/voip/temp/$nomer_caller");
$c_3=exec ("/usr/local/bin/sudo /bin/echo Data: SIP/$number_phone/$nomer_caller >> /usr/local/www/data/voip/temp/$nomer_caller");

$d=exec ("/usr/local/bin/sudo touch -t $data /usr/local/www/data/voip/temp/$nomer_caller");
$c=exec ("/usr/local/bin/sudo /bin/mv /usr/local/www/data/voip/temp/$nomer_caller $outg/$nomer_caller.call");
echo "Звонок пошел... на номер: 8".$kodg."".$nomer_you ."<br>";
echo $data;
        }
    } else { echo "Введите 7 цифр вашего телефона"; }
}

?>