Changeset 5779
- Timestamp:
- 06/17/08 13:18:37 (4 months ago)
- Files:
-
- freepbx/trunk/amp_conf/htdocs_panel/op_server.cfg (modified) (1 diff)
- freepbx/trunk/amp_conf/htdocs_panel/op_server.pl (modified) (212 diffs)
- freepbx/trunk/amp_conf/htdocs_panel/operator_panel.swf (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/trunk/amp_conf/htdocs_panel/op_server.cfg
r2505 r5779 8 8 9 9 [general] 10 use_amportal_conf=1 10 11 ; host or ip address of asterisk 11 12 manager_host=127.0.0.1 freepbx/trunk/amp_conf/htdocs_panel/op_server.pl
r4993 r5779 1 #!/usr/bin/perl -w1 #!/usr/bin/perl 2 2 3 3 # Flash Operator Panel. http://www.asternic.org … … 22 22 23 23 use strict; 24 use warnings; 24 25 use integer; 25 26 26 use constant DEBUG => 1;27 use constant DEBUG => 0; 27 28 use constant BYTES_TO_READ => 256; 28 29 … … 34 35 use POSIX qw(setsid EWOULDBLOCK); 35 36 36 my $FOP_VERSION = " 0.27";37 my $FOP_VERSION = "SVNVERSION"; 37 38 my %datos = (); 39 my %chanvar = (); 40 my %monitoring = (); 41 my %passvar = (); 38 42 my %sesbot = (); 39 43 my %linkbot = (); … … 143 147 my %mailbox; 144 148 my %tovoicemail; 149 my %tospy; 145 150 my %instancias; 146 151 my %agent_to_channel; … … 167 172 my $web_hostname; 168 173 my $listen_port; 174 my $park_exten; 175 my $parktimeout; 169 176 my $listen_addr; 170 177 my $security_code; … … 188 195 my $queue_hide; 189 196 my $enable_restart; 197 my $passvars = ""; 190 198 my $change_led; 191 199 my $cdial_nosecure; … … 213 221 my %total_legends; 214 222 my %total_images; 215 my @btninclude = (); 216 my @styleinclude = (); 217 my $command = ""; 218 my $daemonized = 0; 219 my $pidfile = "/var/run/op_panel.pid"; 220 my $logdir = ""; 221 my $confdir = ""; 222 my $tab = ""; 223 my @serverinclude = (); 224 my @btninclude = (); 225 my @styleinclude = (); 226 my $command = ""; 227 my $daemonized = 0; 228 my $pidfile = "/var/run/op_panel.pid"; 229 my $logdir = ""; 230 my $confdir = ""; 231 my $tab = ""; 223 232 224 233 my $PADDING = join( … … 393 402 } 394 403 395 sub parse_amportal_config ($){396 my $filename = $_[0];404 sub parse_amportal_config { 405 my $filename = shift; 397 406 my %ampconf; 398 407 399 open(AMPCONF, $filename) || die "Cannot open $filename"; 400 401 while (<AMPCONF>) 402 { 403 if ($_ =~ /^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/) { 404 $ampconf{$1} = $2; 405 } 406 } 408 open( AMPCONF, $filename ) || die "Cannot open $filename"; 409 410 while (<AMPCONF>) { 411 if ( $_ =~ /^\s*([a-zA-Z0-9]+)\s*=\s*(.*)\s*([;#].*)?/ ) { 412 $ampconf{$1} = $2; 413 } 414 } 407 415 408 416 close(AMPCONF); … … 412 420 sub read_server_config() { 413 421 my $context = ""; 422 my @distinct_files; 414 423 $counter_servers = -1; 415 424 416 425 $/ = "\n"; 417 426 418 # get some variables from the amportal config 419 my %ampconf; 420 %ampconf = parse_amportal_config("/etc/amportal.conf"); 421 422 open( CONFIG, "<$directorio/op_server.cfg" ) 423 or die("Could not open op_server.cfg. Aborting..."); 424 425 while (<CONFIG>) { 426 chomp; 427 $_ =~ s/^\s+//g; 428 $_ =~ s/([^;]*)[;](.*)/$1/g; 429 $_ =~ s/\s+$//g; 430 431 if ( /^#/ || /^;/ || /^$/ ) { 432 next; 433 } # Ignores comments and empty lines 434 435 if (/^\Q[\E/) { 436 s/\[(.*)\]/$1/g; 437 tr/a-z/A-Z/; 438 $context = $_; 439 } 440 else { 441 if ( $context ne "" ) { 442 my ( $variable_name, $value ) = split( /=/, $_ ); 443 $variable_name =~ tr/A-Z/a-z/; 444 $variable_name =~ s/\s+//g; 445 $value =~ s/^\s+//g; 446 $value =~ s/\s+$//g; 447 $value =~ s/\"//g; 448 $config->{$context}{$variable_name} = $value; 449 450 if ( $variable_name eq "manager_host" ) { 451 $counter_servers++; 452 $manager_host[$counter_servers] = $value; 453 } 454 455 if ( $variable_name eq "manager_user" ) { 456 $manager_user[$counter_servers] = $ampconf{"AMPMGRUSER"}; 457 } 458 459 if ( $variable_name eq "manager_secret" ) { 460 $manager_secret[$counter_servers] = $ampconf{"AMPMGRPASS"}; 461 } 462 463 if ( $variable_name eq "manager_port" ) { 464 $manager_port[$counter_servers] = $value; 465 } 466 467 if ( $variable_name eq "event_mask" ) { 468 $event_mask[$counter_servers] = $value; 469 } 470 471 if ( $variable_name eq "astmanproxy_server" ) { 472 push @astmanproxy_servers, $value; 473 } 474 475 } 476 } 477 } 478 close(CONFIG); 479 480 # replace some config values by the corresponding ones from amportal 481 if ( exists $ampconf{"FOPWEBADDRESS"} ) { 482 $config->{"GENERAL"}{"web_hostname"} = $ampconf{"FOPWEBADDRESS"}; 483 } else { 484 $config->{"GENERAL"}{"web_hostname"} = $ampconf{"AMPWEBADDRESS"}; 485 } 486 $config->{"GENERAL"}{"security_code"} = $ampconf{"FOPPASSWORD"}; 487 $config->{"GENERAL"}{"flash_dir"} = $ampconf{"FOPWEBROOT"}; 427 @distinct_files = unique(@serverinclude); 428 429 foreach my $archivo (@distinct_files) { 430 431 open( CONFIG, "<$directorio/$archivo" ) 432 or die("Could not open op_server.cfg. Aborting..."); 433 434 while (<CONFIG>) { 435 chomp; 436 $_ =~ s/^\s+//g; 437 $_ =~ s/([^;]*)[;](.*)/$1/g; 438 $_ =~ s/\s+$//g; 439 440 if ( /^#/ || /^;/ || /^$/ ) { 441 next; 442 } # Ignores comments and empty lines 443 444 if (/^\Q[\E/) { 445 s/\[(.*)\]/$1/g; 446 tr/a-z/A-Z/; 447 $context = $_; 448 } 449 else { 450 if ( $context ne "" ) { 451 my ( $variable_name, $value ) = split( /=/, $_ ); 452 $variable_name =~ tr/A-Z/a-z/; 453 $variable_name =~ s/\s+//g; 454 $value =~ s/^\s+//g; 455 $value =~ s/\s+$//g; 456 $value =~ s/\"//g; 457 $config->{$context}{$variable_name} = $value; 458 459 if ( $variable_name eq "manager_host" ) { 460 $counter_servers++; 461 $manager_host[$counter_servers] = $value; 462 } 463 464 if ( $variable_name eq "manager_user" ) { 465 $manager_user[$counter_servers] = $value; 466 } 467 468 if ( $variable_name eq "manager_secret" ) { 469 $manager_secret[$counter_servers] = $value; 470 } 471 472 if ( $variable_name eq "manager_port" ) { 473 $manager_port[$counter_servers] = $value; 474 } 475 476 if ( $variable_name eq "event_mask" ) { 477 $event_mask[$counter_servers] = $value; 478 } 479 480 if ( $variable_name eq "astmanproxy_server" ) { 481 push @astmanproxy_servers, $value; 482 } 483 484 } 485 } 486 } 487 close(CONFIG); 488 } 489 490 if ( defined( $config->{GENERAL}{use_amportal_conf} ) ) { 491 if ( $config->{GENERAL}{use_amportal_conf} == 1 ) { 492 my $freepbx_config = "/etc/amportal.conf"; 493 my %ampconf; 494 495 if ( -e $freepbx_config ) { 496 %ampconf = parse_amportal_config($freepbx_config); 497 $config->{"GENERAL"}{"web_hostname"} = $ampconf{"AMPWEBADDRESS"}; 498 $config->{"GENERAL"}{"security_code"} = $ampconf{"FOPPASSWORD"}; 499 $config->{"GENERAL"}{"flash_dir"} = $ampconf{"FOPWEBROOT"}; 500 $manager_user[0] = $ampconf{"AMPMGRUSER"}; 501 $manager_secret[0] = $ampconf{"AMPMGRPASS"}; 502 } 503 } 504 } 488 505 489 506 $web_hostname = $config->{GENERAL}{web_hostname}; … … 513 530 $enable_restart = $config->{GENERAL}{enable_restart}; 514 531 $defaultlanguage = $config->{GENERAL}{language}; 532 $passvars = $config->{GENERAL}{passvars}; 533 $park_exten = $config->{GENERAL}{parkexten}; 534 $parktimeout = $config->{GENERAL}{parktimeout}; 515 535 516 536 if ( $debuglevel == -1 ) { … … 539 559 540 560 $clid_format = $config->{GENERAL}{clid_format}; 541 561 if ( !defined($flash_dir) ) { $flash_dir = '/var/www/html' } 542 562 $flash_file = $flash_dir . "/variables.txt"; 543 563 push @all_flash_files, $flash_file; … … 588 608 } 589 609 610 if ( !defined $config->{GENERAL}{monitor_filename} ) { 611 $config->{GENERAL}{monitor_filename} = "\${UNIQUEID}"; 612 } 613 614 if ( !defined $config->{GENERAL}{monitor_format} ) { 615 $config->{GENERAL}{monitor_format} = "wav"; 616 } 617 590 618 if ( !defined $clid_privacy ) { 591 619 $clid_privacy = 0; … … 650 678 if ( !defined $clid_format ) { 651 679 $clid_format = "(xxx) xxx-xxxx"; 680 } 681 682 if ( !defined $passvars ) { 683 $passvars = ""; 684 } 685 686 if ( !defined $park_exten ) { 687 $park_exten = "700"; 688 } 689 690 if ( !defined $parktimeout ) { 691 $parktimeout = 45000; 692 } 693 else { 694 $parktimeout = $parktimeout * 1000; 652 695 } 653 696 … … 674 717 675 718 if ( $tipo eq "buttons" ) { 676 if ( ! inArray( $filename, @btninclude )) {719 if ( !grep { $filename eq $_ } @btninclude ) { 677 720 push( @btninclude, $filename ); 678 721 } … … 683 726 } 684 727 if ( $tipo eq "style" ) { 685 if ( ! inArray( $filename, @styleinclude )) {728 if ( !grep { $filename eq $_ } @styleinclude ) { 686 729 push( @styleinclude, $filename ); 730 } 731 else { 732 log_debug( "** $filename already included", 16 ) if DEBUG; 733 return; 734 } 735 } 736 if ( $tipo eq "server" ) { 737 if ( !grep { $filename eq $_ } @serverinclude ) { 738 push( @serverinclude, $filename ); 687 739 } 688 740 else { … … 1153 1205 my $pos = $tmphash{position}; 1154 1206 $pos =~ s/(\d+),(\d+)/$1/g; 1155 $tmphash{position} = "$pos,$pos"; 1207 my $countpos = 2; 1208 $tmphash{position} = ""; 1209 if ( defined( $tmphash{count} ) ) { 1210 $countpos = $tmphash{count}; 1211 } 1212 my $a = 0; 1213 for ( $a = 0 ; $a < $countpos ; $a++ ) { 1214 $tmphash{position} .= "$pos,"; 1215 } 1216 $tmphash{position} = substr( $tmphash{position}, 0, -1 ); 1156 1217 $no_counter = 1; 1157 1218 } … … 1218 1279 $buttons{ uc("$tmphash{server}^$chan_trunk") } = $pos; 1219 1280 $textos{$indice_contexto} = $tmphash{label}; 1220 if ( $no_counter == 0 ) { 1281 if ( !defined( $tmphash{no_label_counter} ) ) { $tmphash{no_label_counter} = 0; } 1282 if ( $no_counter == 0 && $tmphash{no_label_counter} == 0 ) { 1221 1283 $textos{$indice_contexto} .= " " . $count; 1222 1284 } … … 1376 1438 $tovoicemail{$indicevm} = $tmphash{voicemailext}; 1377 1439 } 1440 if ( defined( $tmphash{spyext} ) ) { 1441 my $indicespy = $lastposition{ $tmphash{panel_context} }; 1442 if ( $tmphash{panel_context} ne "" ) { 1443 $indicespy .= "\@$tmphash{panel_context}"; 1444 } 1445 $tospy{$indicespy} = $tmphash{spyext}; 1446 } 1447 1378 1448 $/ = "\0"; 1379 1449 } … … 1536 1606 my $contextoboton = $key; 1537 1607 if ( $contextoboton =~ m/\@/ ) { 1538 my @parte = split( /\@/, $contextoboton, 2 ); 1539 $contextoboton = $parte[1]; 1608 ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); 1540 1609 $contextoboton =~ tr/a-z/A-Z/; 1541 1610 } … … 1555 1624 my $contextoboton = $key; 1556 1625 if ( $contextoboton =~ m/\@/ ) { 1557 my @parte = split( /\@/, $contextoboton, 2 ); 1558 $contextoboton = $parte[1]; 1626 ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); 1559 1627 $contextoboton =~ tr/a-z/A-Z/; 1560 1628 } … … 1574 1642 my $contextoboton = $key; 1575 1643 if ( $contextoboton =~ m/\@/ ) { 1576 my @parte = split( /\@/, $contextoboton, 2 ); 1577 $contextoboton = $parte[1]; 1644 ($contextoboton) = split( /\@/, $contextoboton, 2 ); 1578 1645 $contextoboton =~ tr/a-z/A-Z/; 1579 1646 } … … 1594 1661 my $contextoboton = $key; 1595 1662 if ( $contextoboton =~ m/\@/ ) { 1596 my @parte = split( /\@/, $contextoboton, 2 ); 1597 $contextoboton = $parte[1]; 1663 ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); 1598 1664 $contextoboton =~ tr/a-z/A-Z/; 1599 1665 } … … 1614 1680 my $contextoboton = $key; 1615 1681 if ( $contextoboton =~ m/\@/ ) { 1616 my @parte = split( /\@/, $contextoboton, 2 ); 1617 $contextoboton = $parte[1]; 1682 ( undef, $contextoboton ) = split( /\@/, $contextoboton, 2 ); 1618 1683 $contextoboton =~ tr/a-z/A-Z/; 1619 1684 } … … 1782 1847 # a trunk button. 1783 1848 1784 log_debug( "$heading START SUB canalid $canalid contexto $contexto server $server canalsesion $canalsesion", 16 ) if DEBUG; 1849 log_debug( "$heading START SUB canalid $canalid contexto $contexto server $server canalsesion $canalsesion", 16 ) 1850 if DEBUG; 1785 1851 1786 1852 if ( $canalid eq "" ) { … … 1831 1897 } 1832 1898 log_debug( "$heading contexto $contexto", 32 ) if DEBUG; 1833 my ( $nada, $ses ) = separate_session_from_channel($canalsesion);1899 my ( undef, $ses ) = separate_session_from_channel($canalsesion); 1834 1900 $sesion = $ses; 1835 1901 } … … 1853 1919 } 1854 1920 1855 my $canalconcontextosinserver = $canalconcontexto;1856 $canalconcontextosinserver =~ s/(\d+)\^(.*)/$2/g;1857 1921 if ( $canalconcontexto !~ /\^/ ) { 1858 1922 $canalconcontexto = $server . "^" . $canalconcontexto; … … 1904 1968 } 1905 1969 } 1906 if ( $elemento =~ /^mISDN/i ) { 1907 if ( $elemento !~ /XXXY/ ) { 1908 $elemento .= "-XXXY"; 1909 } 1910 1911 # $elemento =~ s/(.*)\/(.*)/\U$1\E\/${2}-${2}/g; 1970 if ( $elemento =~ /^(?i:mISDN)(?!.*XXXY)/ ) { 1971 $elemento .= "-XXXY"; 1912 1972 } 1913 1973 elsif ( $elemento =~ /^SRX/i ) { … … 1915 1975 } 1916 1976 elsif ( $elemento =~ /^CAPI\//i ) { 1917 $elemento =~ s/(CAPI\/)(.*)\/(.*)-(.*)/$1$2-$4/g; 1918 } 1919 1977 $elemento =~ s/(CAPI\/)(.*)\/.*-(.*)/$1$2-$3/g; 1978 } 1979 1980 $elemento =~ s/^asyncgoto\///gi; 1920 1981 $elemento =~ s/(.*)[-\/](.*)/$1\t$2/g; 1921 1982 log_debug( "$heading elemento2 $elemento", 32 ) if DEBUG; 1922 1983 my $canal = $1; 1923 1984 my $sesion = $2; 1924 log_debug( "$heading canal $canal sesion $sesion", 32 ) if DEBUG;1925 1985 1926 1986 if ( defined($canal) && defined($sesion) ) { 1927 1987 $canal =~ tr/a-z/A-Z/; 1928 1988 $elemento = $canal . "\t" . $sesion; 1989 log_debug( "$heading canal $canal sesion $sesion", 32 ) if DEBUG; 1929 1990 } 1930 1991 $elemento =~ s/IAX2\[(.*)@(.*)\]\t(.*)/IAX2\[$1\]\t$3/; 1931 1992 $elemento =~ s/IAX2\/(.*)@(.*)\t(.*)/IAX2\/$1\t$3/; 1932 1993 1933 my @partes = split( /\t/, $elemento ); 1934 return @partes; 1994 return split( /\t/, $elemento ); 1935 1995 } 1936 1996 … … 1957 2017 sub erase_instances_for_trunk_buttons { 1958 2018 1959 my $canalid = shift; 1960 my $canal = shift; 1961 my $server = shift; 1962 my $canalidsinserver = ""; 2019 my $canalid = shift; 2020 my $canal = shift; 2021 my $server = shift; 1963 2022 my $canalglobal; 1964 my $valor;1965 my @new = ();1966 2023 my $heading = "** ERASE_INSTANCE_TRUNK"; 1967 2024 1968 $canalidsinserver = $canalid; 1969 $canalid = "$server^$canalid"; 2025 my $solocanal = $canalid; 2026 $solocanal =~ s/[^\w]//g; 2027 2028 $canalid = "$server^$canalid"; 1970 2029 $canalid =~ s/(.*)<(.*)>/$1/g; #discards ZOMBIE or MASQ 1971 2030 … … 1977 2036 $canalglobal =~ s/IAX2\[(.*)@(.*)\]/IAX2\[$1\]/g; 1978 2037 1979 my ( $nada, $contexto ) = split( /\&/, $canal ); 1980 if ( !defined($contexto) ) { $contexto = ""; } 1981 1982 my $canalconcontexto = ""; 1983 if ( $contexto ne "" ) { 1984 $canalconcontexto = "$canalglobal&$contexto"; 1985 $contexto = "&$contexto"; 1986 } 1987 else { 1988 $canalconcontexto = $canalglobal; 1989 $contexto = ""; 1990 } 2038 my ( undef, $contexto ) = split( /\&/, $canal ); 2039 $contexto = $contexto ? "&$contexto" : ""; 1991 2040 1992 2041 my $sesiontemp = $canalid; … … 1994 2043 log_debug( "$heading looking for $canalid on instancias to erase it", 128 ) if DEBUG; 1995 2044 1996 foreach my $key1 ( sort ( keys(%instancias) )) {1997 foreach my $key2 ( sort ( keys( %{ $instancias{$key1} } ) ) ) {1998 if ( $key2 eq $canalid ) {1999 delete $instancias{$key1}{$key2};2000 log_debug( "$heading Erasing $canalid from instanacias!", 128 ) if DEBUG;2001 }2002 }2045 if ( $canal =~ m/^DID|^CLID/ ) { 2046 $canal =~ s/(.*)=.*/$1/g; 2047 $canalid = $server . "^" . $canal . "-" . $solocanal; 2048 } 2049 foreach my $key1 ( keys(%instancias) ) { 2050 delete $instancias{$key1}{$canalid}; 2051 log_debug( "$heading Erasing $canalid from instanacias!", 128 ) if DEBUG; 2003 2052 } 2004 2053 } … … 2017 2066 } 2018 2067 2019 my ( $nada1, $contexto1 ) = split( /\&/, $nroboton );2068 my ( undef, $contexto1 ) = split( /\&/, $nroboton ); 2020 2069 if ( !defined($contexto1) ) { $contexto1 = ""; } 2021 2070 … … 2033 2082 my @linkbotones = find_panel_buttons( $canal1, $canalsesion, $server ); 2034 2083 foreach my $cual (@linkbotones) { 2035 my ( $nada2, $contexto2 ) = split( /\&/, $cual );2084 my ( undef, $contexto2 ) = split( /\&/, $cual ); 2036 2085 if ( !defined($contexto2) ) { $contexto2 = ""; } 2037 2086 if ( $contexto1 eq $contexto2 ) { … … 2101 2150 log_debug( "$heading borro cache_hit($indice_cache)", 128 ) if DEBUG; 2102 2151 delete $cache_hit{$indice_cache}; 2152 delete $monitoring{$canalsesion}; 2103 2153 if ( keys(%cache_hit) ) { 2104 2154 for ( keys %cache_hit ) { … … 2176 2226 log_debug( "** Found a match $canalid=$val ($quehay) - Cleared!", 16 ) if DEBUG; 2177 2227 delete $datos{$quehay}; 2228 delete $chanvar{$quehay}; 2229 delete $passvar{$quehay}; 2178 2230 } 2179 2231 } … … 2201 2253 # Removes the context if its set 2202 2254 2203 my @pedazos = split( /&/, $canal ); 2204 $canal = $pedazos[0]; 2255 ($canal) = split( /&/, $canal ); 2205 2256 2206 2257 # Checks if the channel name has an equal sign … … 2253 2304 my $server = ""; 2254 2305 2255 my @pedazos = split( /&/, $canal ); 2256 $canal = $pedazos[0]; 2306 ($canal) = split( /&/, $canal ); 2257 2307 2258 2308 if ( $canal =~ /\^/ ) { 2259 @pedazos = split( /\^/, $canal ); 2260 $server = $pedazos[0]; 2261 $canal = $pedazos[1]; 2309 ( $server, $canal ) = split( /\^/, $canal ); 2262 2310 } 2263 2311 … … 2296 2344 print_datos(1); 2297 2345 2298 my @pedazos = split( /&/, $canal ); 2299 $canal = $pedazos[0]; 2346 ($canal) = split( /&/, $canal ); 2300 2347 2301 2348 if ( $canal =~ /\^/ ) { 2302 @pedazos = split( /\^/, $canal ); 2303 $server = $pedazos[0]; 2304 $canal = $pedazos[1]; 2349 ( $server, $canal ) = split( /\^/, $canal ); 2305 2350 } 2306 2351 … … 2323 2368 $canalaqui = 1; 2324 2369 } 2325 if ( $key =~ /^Server/i && $val eq $server) {2370 if ( $key =~ /^Server/i && ( $val eq $server || $server eq "-1" ) ) { 2326 2371 $serveraqui = 1; 2327 2372 log_debug( "$heading server coincide $server = $val\n", 16 ) if DEBUG; … … 2364 2409 my $heading = "** FIND_PANEL_BUT"; 2365 2410 my $calleridnum = "noexiste"; 2411 my $didnum = "noexiste"; 2366 2412 my %trunk_matched = (); 2367 2413 … … 2375 2421 2376 2422 my $uniqueid = find_uniqueid( $canalsesion, $server ); 2377 if ( $uniqueid ne "" ) { 2378 if ( defined( $datos{$uniqueid}{"CallerID"} ) ) { 2379 $calleridnum = $datos{$uniqueid}{"CallerID"}; 2423 if ($uniqueid) { 2424 if ( defined( $datos{$uniqueid}{CallerID} ) ) { 2425 $calleridnum = $datos{$uniqueid}{CallerID}; 2426 } 2427 if ( defined( $datos{$uniqueid}{Extension} ) 2428 && defined( $datos{$uniqueid}{AppData} ) 2429 && $datos{$uniqueid}{AppData} =~ m/^FROM_DID/ ) 2430 { 2431 $didnum = $datos{$uniqueid}{"Extension"}; 2380 2432 } 2381 2433 } … … 2495 2547 # Attemp to match a button from cache 2496 2548 $indice_cache = $canalsesion . "-" . $canal . "-" . $server; 2497 if ( !defined( $cache_hit{$indice_cache} ) ) {2549 if ( !defined( $cache_hit{$indice_cache} ) || $didnum ne "noexiste" ) { 2498 2550 log_debug( "$heading CACHE MISS $indice_cache", 32 ) if DEBUG; 2499 2551 for ( keys %buttons ) { 2500 2552 $server = $server_original; 2501 2553 $canalfinal = ""; 2502 my ( $nada, $contexto ) = split( "\&", $_ );2554 my ( undef, $contexto ) = split( "\&", $_ ); 2503 2555 if ( !defined($contexto) ) { $contexto = ""; } 2504 2556 if ( $contexto ne "" ) { $contexto = "&" . $contexto; } … … 2528 2580 } 2529 2581 } 2582 elsif ( $_ =~ /^$server\^CLID\/\Q$calleridnum\E=/ ) { 2583 my $solocanal = $canalsesion; 2584 $solocanal =~ s/[^\w]//g; 2585 my $tcanal = "CLID/" . $calleridnum . "-" . $solocanal; 2586 if ( !exists( $trunk_matched{"$server^CLID/$calleridnum"} ) ) { 2587 $canalfinal = get_next_trunk_button( $tcanal, $contexto, $server, $tcanal ); 2588 if ( $canalfinal ne "" ) { 2589 log_debug( "$heading clid match trunk ( $_ ) $canal $contexto", 32 ) if DEBUG; 2590 $trunk_matched{"$server^CLID/$calleridnum"} = 1; 2591 $canalfinal =~ s/(.*)\^(.*)/$2/g; 2592 } 2593 } 2594 } 2530 2595 elsif ( $_ =~ /^$server\^CLID\/\Q$calleridnum\E\&?/ ) { 2531 2532 2596 log_debug( "$heading clid match ( $_ ) $canal $contexto", 32 ) if DEBUG; 2533 2597 $canalfinal = "CLID/$calleridnum"; 2598 } 2599 elsif ( $_ =~ /^$server\^DID\/\Q$didnum\E=/ ) { 2600 my $solocanal = $canalsesion; 2601 $solocanal =~ s/[^\w]//g; 2602 my $tcanal = "DID/" . $didnum . "-" . $solocanal; 2603 if ( !exists( $trunk_matched{"$server^DID/$didnum"} ) ) { 2604 $canalfinal = get_next_trunk_button( $tcanal, $contexto, $server, $tcanal ); 2605 if ( $canalfinal ne "" ) { 2606 log_debug( "$heading did match trunk ( $_ ) $canal $contexto", 32 ) if DEBUG; 2607 $trunk_matched{"$server^DID/$didnum"} = 1; 2608 $canalfinal =~ s/(.*)\^(.*)/$2/g; 2609 } 2610 } 2611 } 2612 elsif ( $_ =~ /^$server\^DID\/\Q$didnum\E\&?/ ) { 2613 log_debug( "$heading did match ( $_ ) $canal $contexto", 32 ) if DEBUG; 2614 $canalfinal = "DID/$didnum"; 2534 2615 } 2535 2616 … … 2559 2640 $canalfinal = ""; 2560 2641 2561 my $nada1 = "";2562 2642 my $contextemp = ""; 2563 2643 my %contextosencontrados; 2564 2644 for my $val (@canales) { 2565 ( $nada1, $contextemp ) = split( "&", $val );2645 ( undef, $contextemp ) = split( "&", $val ); 2566 2646 if ( !defined($contextemp) ) { $contextemp = ""; } 2567 2647 $contextosencontrados{"&$contextemp"} = 1; … … 2677 2757 while ( my ( $key, $val ) = each(%bloque) ) { 2678 2758 if ( defined($val) ) { 2679 $val =~ s/ (.*)\s+$/$1/g;2759 $val =~ s/\s+$//; 2680 2760 } 2681 2761 else { … … 2685 2765 } 2686 2766 2767 if ( defined( $hash_temporal{Application} ) ) { 2768 2769 # Chanvar hash stores the complete list of channel variables 2770 # that are "SET" in the dialplan for a given Uniqueid 2771 if ( $hash_temporal{Application} eq "Set" ) { 2772 my @vardata = split( /\|/, $hash_temporal{AppData} ); 2773 foreach my $vara (@vardata) { 2774 my ( $vari, $valu ) = split( /=/, $vara ); 2775 $vari =~ s/^_.?//g; 2776 $chanvar{ $hash_temporal{Uniqueid} }{$vari} = $valu; 2777 } 2778 } 2779 } 2687 2780 if ( defined( $hash_temporal{Channel} ) ) { 2688 2781 if ( $hash_temporal{Channel} =~ /^Agent/ ) { … … 2724 2817 while ( my ( $key, $val ) = each(%hash_temporal) ) { 2725 2818 if ( defined($val) && $val =~ /\^/ ) { 2726 my @partes = split( /\^/, $val, 2 ); 2727 $hash_temporal{$key} = $partes[0]; 2728 my $resto_de_parametros = $partes[1]; 2729 @partes = split( /\^/, $resto_de_parametros ); 2819 2820 #my @partes = split( /\^/, $val, 2 ); 2821 #$hash_temporal{$key} = $partes[0]; 2822 #my $resto_de_parametros = $partes[1]; 2823 ( $hash_temporal{$key}, my $resto ) = split( /\^/, $val, 2 ); 2824 my @partes = split( /\^/, $resto ); 2730 2825 foreach my $value (@partes) { 2731 2826 my @partes2 = split( /: /, $value ); … … 2787 2882 if ( defined( $hash_temporal{"ActionID"} ) ) { 2788 2883 if ( $hash_temporal{"ActionID"} =~ /^timeout/i ) { 2789 my @partes = split( /\|/, $hash_temporal{"ActionID"} ); 2790 $canalid = $partes[1]; 2791 $timeout = $partes[2]; 2884 ( $canalid, $timeout ) = split( /\|/, $hash_temporal{"ActionID"} ); 2792 2885 $evento = "Timeout"; 2793 2886 $unico_id = "YYYY-$server"; … … 2825 2918 } 2826 2919 2920 # Convert Asterisk 1.4 Originate responses to 1.2 format so attendant transfers work 2921 if ( $evento eq "OriginateResponse" ) { 2922 if ( $hash_temporal{Response} eq "Success" ) { 2923 $evento = "OriginateSuccess"; 2924 } 2925 else { 2926 $evento = "OriginateFailure"; 2927 } 2928 } 2929 2930 # Convert Asterisk 1.4 ParkedCalltimeout to UnParkedCall 2931 if ( $evento eq "ParkedCallTimeOut" ) { 2932 $evento = "UnParkedCall"; 2933 } 2934 2827 2935 $evento =~ s/UserEvent//g; 2828 if ( $evento =~ /Newchannel/ ) { $evento = "newchannel"; } 2829 elsif ( $evento =~ /Newcallerid/ ) { $evento = "newcallerid"; } 2830 elsif ( $evento =~ /^Status$/ ) { $evento = "status"; } 2831 elsif ( $evento =~ /^StatusComplete/ ) { $evento = "statuscomplete"; } 2832 elsif ( $evento =~ /Newexten/ ) { $evento = "newexten"; } 2833 elsif ( $evento =~ /^ParkedCall$/ ) { $evento = "parkedcall"; } 2834 elsif ( $evento =~ /^UnParkedCall$/ ) { $evento = "unparkedcall"; } 2835 elsif ( $evento =~ /Newstate/ ) { $evento = "newstate"; } 2836 elsif ( $evento =~ /Hangup/ ) { $evento = "hangup"; } 2837 elsif ( $evento =~ /Rename/ ) { $evento = "rename"; } 2838 elsif ( $evento =~ /MessageWaiting/ ) { $evento = "voicemail"; } 2839 elsif ( $evento =~ /Regstatus/ ) { $evento = "regstatus"; } 2840 elsif ( $evento =~ /^Unlink/ ) { $evento = "unlink"; } 2841 elsif ( $evento =~ /QueueParams/ ) { $evento = "queueparams"; } 2842 elsif ( $evento =~ /PeerEntry/ ) { $evento = "peerentry"; } 2843 elsif ( $evento =~ /QueueEntry/ ) { $evento = "queueentry"; } 2844 elsif ( $evento =~ /^QueueMember$/ ) { $evento = "queuemember"; } 2845 elsif ( $evento =~ /^QueueMemberStatus$/ ) { $evento = "queuememberstatus"; } 2846 elsif ( $evento =~ /QueueMemberAdded/ ) { $evento = "queuememberadded"; } 2847 elsif ( $evento =~ /QueueMemberRemoved/ ) { $evento = "queuememberremoved"; } 2848 elsif ( $evento =~ /QueueMemberPaused/ ) { $evento = "queuememberpaused"; } 2849 elsif ( $evento =~ /QueueStatus$/ ) { $evento = "queuestatus"; } 2850 elsif ( $evento =~ /QueueStatusComplete/ ) { $evento = "queuestatuscomplete"; } 2851 elsif ( $evento =~ /^Link/ ) { $evento = "link"; } 2852 elsif ( $evento =~ /^Join/ ) { $evento = "join"; } 2853 elsif ( $evento =~ /^MeetmeJoin/ ) { $evento = "meetmejoin"; } 2854 elsif ( $evento =~ /^MeetmeLeave/ ) { $evento = "meetmeleave"; } 2855 elsif ( $evento =~ /^meetmemute/ ) { $evento = "meetmemute"; } 2856 elsif ( $evento =~ /^meetmeunmute/ ) { $evento = "meetmeunmute"; } 2857 elsif ( $evento =~ /^Agentlogin/ ) { $evento = "agentlogin"; } 2858 elsif ( $evento =~ /^RefreshQueue/ ) { $evento = "refreshqueue"; } 2859 elsif ( $evento =~ /^Timeout/ ) { $evento = "timeout"; } 2860 elsif ( $evento =~ /^AgentCalled/ ) { $evento = "agentcalled"; } 2861 elsif ( $evento =~ /^AgentConnect/ ) { $evento = "agentconnect"; } 2862 elsif ( $evento =~ /^AgentComplete/ ) { $evento = "agentcomplete"; } 2863 elsif ( $evento =~ /^Agentcallbacklogin/ ) { $evento = "agentcblogin"; } 2864 elsif ( $evento =~ /^Agentcallbacklogoff/ ) { $evento = "agentlogoff"; } 2865 elsif ( $evento =~ /^Agentlogoff/ ) { $evento = "agentlogoff"; } 2866 elsif ( $evento =~ /^IsMeetmeMember/ ) { $evento = "fakeismeetmemember"; } 2867 elsif ( $evento =~ /^PeerStatus/ ) { $evento = "peerstatus"; } 2868 elsif ( $evento =~ /^Leave/ ) { $evento = "leave"; } 2869 elsif ( $evento =~ /^FOP_Popup/i ) { $evento = "foppopup"; } 2870 elsif ( $evento =~ /^FOP_LedColor/i ) { $evento = "fopledcolor"; } 2871 elsif ( $evento =~ /^Dial/ ) { $evento = "dial"; } 2872 elsif ( $evento =~ /^ASTDB/ ) { $evento = "astdb"; } 2873 elsif ( $evento =~ /^DNDState/ ) { $evento = "zapdndstate"; } 2874 elsif ( $evento =~ /^ZapShowChannels$/ ) { $evento = "zapdndstate"; } 2875 elsif ( $evento =~ /^ExtensionStatus$/ ) { $evento = "extensionstatus"; } 2876 elsif ( $evento =~ /^OriginateSuccess$/ ) { $evento = "originatesuccess"; } 2877 elsif ( $evento =~ /^OriginateFailure$/ ) { $evento = "originatefailure"; } 2878 elsif ( $evento =~ /^ChannelReload$/ ) { $evento = "channelreload"; } 2936 if ( $evento =~ /Newchannel/ ) { $evento = "newchannel"; } 2937 elsif ( $evento =~ /Newcallerid/ ) { $evento = "newcallerid"; } 2938 elsif ( $evento =~ /^Status$/ ) { $evento = "status"; } 2939 elsif ( $evento =~ /^StatusComplete/ ) { $evento = "statuscomplete"; } 2940 elsif ( $evento =~ /Newexten/ ) { $evento = "newexten"; } 2941 elsif ( $evento =~ /^ParkedCall$/ ) { $evento = "parkedcall"; } 2942 elsif ( $evento =~ /^UnParkedCall$/ ) { $evento = "unparkedcall"; } 2943 elsif ( $evento =~ /^virtualvaletparkedcall/i ) { $evento = "parkedcall"; } 2944 elsif ( $evento =~ /^virtualvaletunparkedcall$/i ) { $evento = "unparkedcall"; } 2945 elsif ( $evento =~ /Newstate/ ) { $evento = "newstate"; } 2946 elsif ( $evento =~ /Hangup/ ) { $evento = "hangup"; } 2947 elsif ( $evento =~ /Rename/ ) { $evento = "rename"; } 2948 elsif ( $evento =~ /MessageWaiting/ ) { $evento = "voicemail"; } 2949 elsif ( $evento =~ /Regstatus/ ) { $evento = "regstatus"; } 2950 elsif ( $evento =~ /^Unlink/ ) { $evento = "unlink"; } 2951 elsif ( $evento =~ /QueueParams/ ) { $evento = "queueparams"; } 2952 elsif ( $evento =~ /PeerEntry/ ) { $evento = "peerentry"; } 2953 elsif ( $evento =~ /QueueEntry/ ) { $evento = "queueentry"; } 2954 elsif ( $evento =~ /^QueueMember$/ ) { $evento = "queuemember"; } 2955 elsif ( $evento =~ /^QueueMemberStatus$/ ) { $evento = "queuememberstatus"; } 2956 elsif ( $evento =~ /QueueMemberAdded/ ) { $evento = "queuememberadded"; } 2957 elsif ( $evento =~ /QueueMemberRemoved/ ) { $evento = "queuememberremoved"; } 2958 elsif ( $evento =~ /QueueMemberPaused/ ) { $evento = "queuememberpaused"; } 2959 elsif ( $evento =~ /QueueStatus$/ ) { $evento = "queuestatus"; } 2960 elsif ( $evento =~ /QueueStatusComplete/ ) { $evento = "queuestatuscomplete"; } 2961 elsif ( $evento =~ /^Link/ ) { $evento = "link"; } 2962 elsif ( $evento =~ /^Join/ ) { $evento = "join"; } 2963 elsif ( $evento =~ /^MeetmeJoin/ ) { $evento = "meetmejoin"; } 2964 elsif ( $evento =~ /^MeetmeLeave/ ) { $evento = "meetmeleave"; } 2965 elsif ( $evento =~ /^meetmemute/ ) { $evento = "meetmemute"; } 2966 elsif ( $evento =~ /^meetmeunmute/ ) { $evento = "meetmeunmute"; } 2967 elsif ( $evento =~ /^Agentlogin/ ) { $evento = "agentlogin"; } 2968 elsif ( $evento =~ /^Agents$/ ) { $evento = "agents"; } 2969 elsif ( $evento =~ /^RefreshQueue/ ) { $evento = "refreshqueue"; } 2970 elsif ( $evento =~ /^Timeout/ ) { $evento = "timeout"; } 2971 elsif ( $evento =~ /^AgentCalled/ ) { $evento = "agentcalled"; } 2972 elsif ( $evento =~ /^AgentConnect/ ) { $evento = "agentconnect"; } 2973 elsif ( $evento =~ /^AgentComplete/ ) { $evento = "agentcomplete"; } 2974 elsif ( $evento =~ /^Agentcallbacklogin/ ) { $evento = "agentcblogin"; } 2975 elsif ( $evento =~ /^Agentcallbacklogoff/ ) { $evento = "agentlogoff"; } 2976 elsif ( $evento =~ /^Agentlogoff/ ) { $evento = "agentlogoff"; } 2977 elsif ( $evento =~ /^IsMeetmeMember/ ) { $evento = "fakeismeetmemember"; } 2978 elsif ( $evento =~ /^PeerStatus/ ) { $evento = "peerstatus"; } 2979 elsif ( $evento =~ /^Leave/ ) { $evento = "leave"; } 2980 elsif ( $evento =~ /^FOP_Popup/i ) { $evento = "foppopup"; } 2981 elsif ( $evento =~ /^FOP_LedColor/i ) { $evento = "fopledcolor"; } 2982 elsif ( $evento =~ /^Dial/ ) { $evento = "dial"; } 2983 elsif ( $evento =~ /^ASTDB/ ) { $evento = "astdb"; } 2984 elsif ( $evento =~ /^DNDState/ ) { $evento = "zapdndstate"; } 2985 elsif ( $evento =~ /^ZapShowChannels$/ ) { $evento = "zapdndstate"; } 2986 elsif ( $evento =~ /^ExtensionStatus$/ ) { $evento = "extensionstatus"; } 2987 elsif ( $evento =~ /^OriginateSuccess$/ ) { $evento = "originatesuccess"; } 2988 elsif ( $evento =~ /^OriginateFailure$/ ) { $evento = "originatefailure"; } 2989 elsif ( $evento =~ /^ChannelReload$/ ) { $evento = "channelreload"; } 2990 elsif ( $evento =~ /^response-/ ) { $evento = "monitor"; } 2879 2991 else { log_debug( "$heading No event match ($evento)", 32 ); } 2880 2992 … … 2895 3007 } 2896 3008 2897 if ( $evento eq "channelreload" ) { 3009 if ( $evento eq "monitor" ) { 3010 my $botinro = ""; 3011 ( undef, $estado_final, undef ) = split( /-/, $hash_temporal{ActionID}, 3 ); 3012 ( $canal, undef ) = separate_session_from_channel( $hash_temporal{Channel} ); 3013 $canalid = $hash_temporal{Channel}; 3014 $estado_final =~ tr/A-Z/a-z/; 3015 } 3016 elsif ( $evento eq "channelreload" ) { 2898 3017 2899 3018 # Event: ChannelReload … … 2917 3036 my $indice = $hash_temporal{Uniqueid} . "-" . $hash_temporal{Server}; 2918 3037 if ( exists( $datos{"$indice"} ) ) { 2919 log_debug( "** ATTENDANT we had that uniqueid before, extract the channel from there", 16 ) if DEBUG; 3038 log_debug( "** ATTENDANT we had that uniqueid before, extract the channel from there", 16 ) 3039 if DEBUG; 2920 3040 if ( defined( $datos{$indice}{Extension} ) ) { 2921 3041 … … 2930 3050 } 2931 3051 else { 2932 log_debug( "** ATTENDANT we do not have any event with that uniqueid, save for later", 16 ) if DEBUG; 3052 log_debug( "** ATTENDANT we do not have any eve
