Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php5
- <?php
- $connect = mysql_connect("localhost", "user", "password") or die(mysql_error());
- $connect = mysql_select_db("asterisk") or die(mysql_error());
- $arq = fopen("/var/log/asterisk/queue_log", "r") or exit("Error when try to read file.");
- while(!feof($arq)) {
- $get_line = fgets($arq);
- if(!isset($get_line)) { break; }
- $get_line = explode("\n", $get_line);
- $line = explode("|", $get_line[0]);
- if(isset($line[5]) || isset($line[6]) || isset($line[7])) {
- if(isset($line[6])) {
- $data = $line[5]."|".$line[6];
- if(isset($line[7])) {
- $data = $data."|".$line[7];
- }
- } else {
- if(isset($line[7])) {
- $data = $line[5]."|".$line[7];
- }
- }
- if(!isset($data)) {
- $data = "|";
- }
- }
- //echo "$line[0] $line[1] $line[2] $line[3] $line[4] $data \n";
- $insert = "INSERT INTO queue_log(time,callid,queuename,agent,event,data) VALUES('".$line[0]."','".$line[1]."','".$line[2]."','".$line[3]."','".$line[4]."','".$data."')";
- $insert = mysql_query($insert);
- $line = NULL;
- $data = NULL;
- }
- $update = "UPDATE queue_log SET data = 0 WHERE event = 'RINGNOANSWER' AND data = '|'";
- $update = mysql_query($update);
- fclose($arq);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement