package POEDaemon::TCPServer::Main::Cmds::FastCGI; use strict; use warnings FATAL => 'all'; no warnings 'redefine'; use POE; use POEDaemon; sub states { return $_[0], [qw( tcpserver_client_commands_fastcgi )]; } sub tcpserver_client_commands_fastcgi { my ($kernel, $session, $heap, $args) = @_[KERNEL, SESSION, HEAP, ARG0]; return unless ref $args eq 'HASH'; my $wheel_id = $args->{wheel_id} || return; my $input = $args->{input}; return unless defined $input; my $client = $heap->{tcpserver}->{connections}->{$wheel_id}; return unless $client && $client->{fastcgi}; my ($output, $no_output_log); return unless $input =~ s/^\s*(?:s(?:witch)?|fastcgi)\s*//i; if ($input =~ /^\s*(?:(\w{1,256}|all)(?:\s*=\s*(on|off))?)?\s*$/i) { my $name = lc($1 || ''); my $value = lc($2 || ''); my @outargs; if (!$name || $name eq 'all') { foreach (sort keys %{cfg->{eventmap}}) { next unless /^fastcgi:(\w{1,256})$/; my $curr_name = lc $1; my $curr_value = $heap->{eventsystem}->{input}->{fastcgi}->{$curr_name}->{value}; $curr_value = 0 unless defined $curr_value; $curr_value =~ s/^1$/on/; $curr_value =~ s/^0$/off/; push @outargs, sprintf "%s=%s", $curr_name, $curr_value; } } else { my $value_conv = $value; $value_conv =~ s/^on$/1/i; $value_conv =~ s/^off$/0/i; $kernel->call($session => eventsystem_input => { type => 'fastcgi', name => $name, value => $value_conv, time => time_hires, }); push @outargs, sprintf "%s=%s", $name, $value; } $output = sprintf "%s %s", FASTCGI_CMD_PREFIX, join ' ', @outargs; } return unless $output && $client->{wheel}; $kernel->call($session => tcpserver_output => { wheel_id => $wheel_id, output => $output, no_log => $no_output_log, }); } 1;