exten => _X.,n,Dial(SIP/gsm1/${EXTEN},,tT) exten => _X.,n,Dial(SIP/gsm2/${EXTEN},,tT) exten => _X.,n,Dial(SIP/gsm3/${EXTEN},,tT)
53 */1 * * * root php %path-to-script%/getbalance.php
action: login username: ****** secret: ******* action: smscommand command: gsm send ussd 2 *255*0# action: logoff
Asterisk Call Manager/1.1 Response: Success Message: Authentication accepted Response: Follows Privilege: SMSCommand 1:Received USSD success on span: 2 USSD Responses: 2 USSD Code: 64 USSD Len: 85 USSD Message: Ostatok v pakete: 968 min./mes., 5000 SMS/mes., 20480 MB/mes. Parametry' tarifa *107# --END COMMAND-- Response: Goodbye Message: Thanks for all the fish.
exten => _X.,n,set(SIMNUM1=${SHELL(/usr/bin/php -f %pathtoscript%/getsim1.php)}) exten => _X.,n,set(SIMNUM2=${SHELL(/usr/bin/php -f %pathtoscript%/getsim2.php)}) exten => _X.,n,set(SIMNUM3=${SHELL(/usr/bin/php -f %pathtoscript%/getsim3.php)}) exten => _X.,n,set(SIMNUM4=${SHELL(/usr/bin/php -f %pathtoscript%/getsim4.php)}) exten => _X.,n,set(SIMNUM5=${SHELL(/usr/bin/php -f %pathtoscript%/getsim5.php)}) exten => _X.,n,set(SIMNUM6=${SHELL(/usr/bin/php -f %pathtoscript%/getsim6.php)}) exten => _X.,n,set(SIMNUM7=${SHELL(/usr/bin/php -f %pathtoscript%/getsim7.php)}) exten => _X.,n,set(SIMNUM8=${SHELL(/usr/bin/php -f %pathtoscript%/getsim8.php)}) exten => _X.,n,Dial(SIP/gsm${SIMNUM1}/${EXTEN},,tT) exten => _X.,n,Dial(SIP/gsm${SIMNUM2}/${EXTEN},,tT) exten => _X.,n,Dial(SIP/gsm${SIMNUM3}/${EXTEN},,tT) exten => _X.,n,Dial(SIP/gsm${SIMNUM4}/${EXTEN},,tT) exten => _X.,n,Dial(SIP/gsm${SIMNUM5}/${EXTEN},,tT) exten => _X.,n,Dial(SIP/gsm${SIMNUM6}/${EXTEN},,tT) exten => _X.,n,Dial(SIP/gsm${SIMNUM7}/${EXTEN},,tT) exten => _X.,n,Dial(SIP/gsm${SIMNUM8}/${EXTEN},,tT)
<?php $t = file_get_contents('%pathtoscript%/out1.txt'); echo $t[0]; return $t[0]; ?>
<?php include '/var/lib/asterisk/agi-bin/lib.php'; $s=0; a2: $s++; if ($s>10) exit; system('nc 10.10.1.1 5038 < %pathtoscript%/nc2.txt > %pathtoscript%/nc2out.txt'); $text = file_get_contents('%pathtoscript%/nc2out.txt'); if(preg_match('/te:\ (.*)\ min/',$text,$matches)) $text2 = $matches[1]; else goto a2; $s=0; a3: $s++; if ($s>10) exit; system('nc 10.10.1.1 5038 < %pathtoscript%/nc3.txt > %pathtoscript%/nc3out.txt'); $text = file_get_contents('%pathtoscript%/nc3out.txt'); if(preg_match('/te:\ (.*)\ min/',$text,$matches)) $text3 = $matches[1]; else goto a3; $s=0; a4: $s++; if ($s>10) exit; system('nc 10.10.1.1 5038 < %pathtoscript%/nc4.txt > %pathtoscript%/nc4out.txt'); $text = file_get_contents('%pathtoscript%/nc4out.txt'); if(preg_match('/te:\ (.*)\ min/',$text,$matches)) $text4 = $matches[1]; else goto a4; $s=0; a5: $s++; if ($s>10) exit; system('nc 10.10.1.1 5038 < %pathtoscript%/nc5.txt > %pathtoscript%/nc5out.txt'); $text = file_get_contents('%pathtoscript%/nc5out.txt'); if(preg_match('/te:\ (.*)\ min/',$text,$matches)) $text5 = $matches[1]; else goto a5; $s=0; a6: $s++; if ($s>10) exit; system('nc 10.10.1.1 5038 < %pathtoscript%/nc6.txt > %pathtoscript%/nc6out.txt'); $text = file_get_contents('%pathtoscript%/nc6out.txt'); if(preg_match('/te:\ (.*)\ min/',$text,$matches)) $text6 = $matches[1]; else goto a6; $s=0; a7: $s++; if ($s>10) exit; system('nc 10.10.1.1 5038 < %pathtoscript%/nc7.txt > %pathtoscript%/nc7out.txt'); $text = file_get_contents('%pathtoscript%/nc7out.txt'); if(preg_match('/te:\ (.*)\ min/',$text,$matches)) $text7 = $matches[1]; else goto a7; $s=0; a8: $s++; if ($s>10) exit; system('nc 10.10.1.1 5038 < %pathtoscript%/nc8.txt > %pathtoscript%/nc8out.txt'); $text = file_get_contents('%pathtoscript%/nc8out.txt'); if(preg_match('/te:\ (.*)\ min/',$text,$matches)) $text8 = $matches[1]; else goto a8; $s=0; a9: $s++; if ($s>10) exit; system('nc 10.10.1.1 5038 < %pathtoscript%/nc9.txt > %pathtoscript%/nc9out.txt'); $text = file_get_contents('%pathtoscript%/nc9out.txt'); if(preg_match('/te:\ (.*)\ min/',$text,$matches)) $text9 = $matches[1]; else goto a9; $text10 = "0"; system('echo "'.date('l dS FY h:i:s A').' '.$text2.' '.$text3.' '.$text4.' '.$text5.' '.$text6.' '.$text7.' '.$text8.' '.$text9.'" >>%pathtoscript%/balance.txt'); $row = mysql_query("select minutes from `lines` where clid like '%2636'",$link); $row1 = mysql_fetch_assoc($row); $old1 = $row1['minutes']+0; $new1 = $text2+0; if ($old1 < $new1) $row = mysql_query("update `lines` set balancedate=NOW()",$link); $row = mysql_query("update `lines` set balance=".$text10.", minutesdate=NOW(), minutes=".$text2." where clid like '%2636'",$link); $row = mysql_query("update `lines` set balance=".$text10.", minutesdate=NOW(), minutes=".$text3." where clid like '%4036'",$link); $row = mysql_query("update `lines` set balance=".$text10.", minutesdate=NOW(), minutes=".$text4." where clid like '%4977'",$link); $row = mysql_query("update `lines` set balance=".$text10.", minutesdate=NOW(), minutes=".$text5." where clid like '%2414'",$link); $row = mysql_query("update `lines` set balance=".$text10.", minutesdate=NOW(), minutes=".$text6." where clid like '%2451'",$link); $row = mysql_query("update `lines` set balance=".$text10.", minutesdate=NOW(), minutes=".$text7." where clid like '%2536'",$link); $row = mysql_query("update `lines` set balance=".$text10.", minutesdate=NOW(), minutes=".$text8." where clid like '%2581'",$link); $row = mysql_query("update `lines` set balance=".$text10.", minutesdate=NOW(), minutes=".$text9." where clid like '%4056'",$link); $n[1] = $text2+0; $n[2] = $text3+0; $n[3] = $text4+0; $n[4] = $text5+0; $n[5] = $text6+0; $n[6] = $text7+0; $n[7] = $text8+0; $n[8] = $text9+0; $p[1] = 1; $p[2] = 2; $p[3] = 3; $p[4] = 4; $p[5] = 5; $p[6] = 6; $p[7] = 7; $p[8] = 8; for($i=1;$i<=7;$i++) for($j=$i+1;$j<=8;$j++) if ($n[$i]<$n[$j]) { $t = $n[$i]; $n[$i] = $n[$j]; $n[$j] = $t; $t = $p[$i]; $p[$i] = $p[$j]; $p[$j] = $t; } system('echo "'.$p[1].'" >%pathtoscript%/out1.txt'); system('echo "'.$p[2].'" >%pathtoscript%/out2.txt'); system('echo "'.$p[3].'" >%pathtoscript%/out3.txt'); system('echo "'.$p[4].'" >%pathtoscript%/out4.txt'); system('echo "'.$p[5].'" >%pathtoscript%/out5.txt'); system('echo "'.$p[6].'" >%pathtoscript%/out6.txt'); system('echo "'.$p[7].'" >%pathtoscript%/out7.txt'); system('echo "'.$p[8].'" >%pathtoscript%/out8.txt'); system('asterisk -rx "dialplan reload"'); ?>
<?php $dbuser = "*******"; $dbpass = "*******"; $dbserv = "localhost"; $dbname = "*******"; $dbengn = "mysql"; function sql_connect($host, $login, $password, $dbname) { $link = mysql_connect($host, $login, $password, true); mysql_select_db($dbname, $link); mysql_query("SET NAMES cp1251"); return $link; } function sql_query($query, $link) { $res = mysql_query($query, $link); return $res; } function sql_fetch_assoc($result) { return mysql_fetch_assoc($result); } $link = sql_connect($dbserv, $dbuser, $dbpass, $dbname); ?>
Source: https://habr.com/ru/post/318004/
All Articles