#!/usr/bin/perl
package main;
use IO::Socket;
use Sys::Hostname;
use Socket;
use 5.008;
#use strict;
#use warnings;
my($ipaddr)=inet_ntoa((gethostbyname(hostname))[4]);
$| = 1;
my $app = Demo::App->new;
# create the WxApplication
#$self->SetSize($text->GetSizeWH);
$app->MainLoop;
package Demo::App;
#use strict;
#use warnings;
use base 'Wx::App';
sub OnInit {
my $frame = Demo::App::Frame->new;
$frame->Show(1);
}
package Demo::App::Frame;
#use strict;
#use warnings;
use Wx qw(:everything);
use base 'Wx::Frame';
sub new {
my ($class) = @_;
my $self = $class->SUPER::new(
undef, -1,
'Demo::App',
wxDefaultPosition, wxDefaultSize,
);
my $text = Wx::StaticText->new( $self, -1, "For X10 Voice Commander Use IP $ipaddr\n Port 8086\n");
#sub serv {
$local = IO::Socket::INET->new(
Proto => 'tcp', # protocol
LocalAddr => "$ipaddr:8086",
) or die "$!";
my $addr;
$local->listen();
$local->autoflush(1);
while ($addr = $local->accept() ) {
print "Connection from: ", $addr->peerhost(),"\n";
while (<$addr>)
{
$path = "C:/Program Files (x86)/Common Files/X10/Common";
chdir($path) or die "Cant chdir to $path $!";
~s/GET//,~s/~/ /g,~s/%20/ /g,~s/%22/ /g,~s/x10command=DEVICE//,~s/\//\ /g,~s/[?]//g ,~s/'/ /g,~s/HTTP/ /,~s/1.1/ /g,~s/sh://;
system(AHCMD. "$_");
print "Received: $_";
print $addr $_;
print $path $_;
close $addr;
chomp;
return $self;
}
}
}