reupload latest seatmap main
This commit is contained in:
@@ -15,6 +15,9 @@ use feature qw/say/;
|
||||
use Encode::Deep;
|
||||
use DBD::mysql;
|
||||
use URI::Encode qw(uri_encode uri_decode);
|
||||
use URI::Split qw(uri_split uri_join);
|
||||
use Data::Dumper;
|
||||
use HTML::TreeBuilder::XPath;
|
||||
|
||||
# LWP
|
||||
my $ua = LWP::UserAgent->new(keep_alive => 1);
|
||||
@@ -31,6 +34,7 @@ my %CONFIG =
|
||||
'DEBUG' => 0,
|
||||
'DEBUG_PRINT_DATA' => 0,
|
||||
'ONLINE' => 1,
|
||||
'USE_CORSANYWHERE' => 0,
|
||||
'OFFLINE_XML' => '../seatmap-client/offline/MapTicketSales.xml',
|
||||
'OFFLINE_XML_PARKETT' => '../seatmap-client/offline/MapTicketSales_Parkett.xml',
|
||||
'OFFLINE_XML_RANG' => '../seatmap-client/offline/MapTicketSales_Rang.xml',
|
||||
@@ -47,39 +51,83 @@ my $connection;
|
||||
|
||||
# WORKFLOW
|
||||
my $t0 = Benchmark->new if $CONFIG{'DEBUG'};
|
||||
|
||||
&getParameter();
|
||||
print Dumper $DATA{'PARAMETER'} if $CONFIG{'DEBUG'};
|
||||
&checkHost();
|
||||
&generateVenueUrl();
|
||||
|
||||
my $xml;
|
||||
if ($CONFIG{'ONLINE'}) {
|
||||
print "SET AS ONLINE\n" if $CONFIG{'DEBUG'};
|
||||
|
||||
$xml = get($DATA{'PARAMETER'}{'urlVenue'});
|
||||
&loadXML($xml, \$DATA{'DOM'});
|
||||
&parseXML();
|
||||
&getSeatmaps();
|
||||
if( $DATA{'PARAMETER'}{'request_switch'} eq 'seatmapWorkflow' ) {
|
||||
say 'Switch seatmapWorkflow' if ($CONFIG{'DEBUG'});
|
||||
&generateVenueUrl();
|
||||
|
||||
my $xml;
|
||||
if ($CONFIG{'ONLINE'}) {
|
||||
print "SET AS ONLINE\n" if $CONFIG{'DEBUG'};
|
||||
|
||||
$xml = &get($DATA{'PARAMETER'}{'urlVenue'});
|
||||
&loadXML($xml, \$DATA{'DOM'});
|
||||
&parseXML();
|
||||
&getSeatmaps();
|
||||
}
|
||||
elsif (!$CONFIG{'ONLINE'}) {
|
||||
print "SET AS OFFLINE: USING LOCAL XML\n" if $CONFIG{'DEBUG'};
|
||||
$xml = $CONFIG{'OFFLINE_XML'};
|
||||
|
||||
&loadXML($xml, \$DATA{'DOM'});
|
||||
&parseXML();
|
||||
&loadXML($CONFIG{'OFFLINE_XML_PARKETT'}, \$DATA{'DOM'});
|
||||
parxeXML_section();
|
||||
&loadXML($CONFIG{'OFFLINE_XML_RANG'}, \$DATA{'DOM'});
|
||||
parxeXML_section();
|
||||
}
|
||||
my $config_ref = &getVenueConfig();
|
||||
&printOutput($config_ref);
|
||||
}
|
||||
elsif (!$CONFIG{'ONLINE'}) {
|
||||
print "SET AS OFFLINE: USING LOCAL XML\n" if $CONFIG{'DEBUG'};
|
||||
$xml = $CONFIG{'OFFLINE_XML'};
|
||||
elsif( $DATA{'PARAMETER'}{'request_switch'} eq 'checkoutCheckResponse' ) {
|
||||
say 'Switch checkoutCheckResponse' if ($CONFIG{'DEBUG'});
|
||||
my $decoded_content = &get($DATA{'PARAMETER'}{'url'});
|
||||
#print Dumper $decoded_content;
|
||||
|
||||
&loadXML($xml, \$DATA{'DOM'});
|
||||
&parseXML();
|
||||
&loadXML($CONFIG{'OFFLINE_XML_PARKETT'}, \$DATA{'DOM'});
|
||||
parxeXML_section();
|
||||
&loadXML($CONFIG{'OFFLINE_XML_RANG'}, \$DATA{'DOM'});
|
||||
parxeXML_section();
|
||||
my $tree = HTML::TreeBuilder::XPath->new_from_content($decoded_content);
|
||||
|
||||
my $xpath_alert = '//input[@id="no_timeout_error_msg"]/@value';
|
||||
if ($tree->exists($xpath_alert)) {
|
||||
#my $alert = decode('utf-8', trim($tree->findvalue($xpath_alert)));
|
||||
|
||||
my %alert;
|
||||
$alert{'no_timeout_error_msg'}{'value'} = trim($tree->findvalue($xpath_alert));
|
||||
$alert{'no_timeout_error_msg'}{'id'} = 'no_timeout_error_msg';
|
||||
|
||||
|
||||
if (!$CONFIG{'DEBUG'}) {
|
||||
print header(
|
||||
-type => 'application/json',
|
||||
-access_control_allow_origin => '*',
|
||||
-charset => 'utf-8',
|
||||
);
|
||||
|
||||
# OUTPUT JSON
|
||||
print encode_json \%alert;
|
||||
}
|
||||
elsif ($CONFIG{'DEBUG'}) {
|
||||
print Dumper \%alert;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
my $config_ref = &getVenueConfig();
|
||||
&benchmarkEnd();
|
||||
&printOutput($config_ref);
|
||||
&benchmarkEnd() if ($CONFIG{'DEBUG'});
|
||||
|
||||
|
||||
# SUBS
|
||||
|
||||
sub trim {
|
||||
my $string = shift;
|
||||
$string =~ s/^\s+|\s+$//g;
|
||||
return $string;
|
||||
}
|
||||
|
||||
sub db_getVenueConfig {
|
||||
&Delimiter((caller(0))[3]);
|
||||
|
||||
@@ -340,11 +388,9 @@ sub checkHost() {
|
||||
sub benchmarkEnd() {
|
||||
&Delimiter((caller(0))[3]);
|
||||
|
||||
if ($CONFIG{'DEBUG'}) {
|
||||
my $t1 = Benchmark->new;
|
||||
my $td = timediff($t1, $t0);
|
||||
print "BENCHMARK: ",timestr($td),"\n" if $CONFIG{'DEBUG'};
|
||||
}
|
||||
my $t1 = Benchmark->new;
|
||||
my $td = timediff($t1, $t0);
|
||||
print "BENCHMARK: ",timestr($td),"\n" if $CONFIG{'DEBUG'};
|
||||
}
|
||||
|
||||
sub generateVenueUrl() {
|
||||
@@ -581,19 +627,44 @@ sub getParameter {
|
||||
|
||||
my $url = $ENV{QUERY_STRING};
|
||||
my $decoded = uri_decode($url);
|
||||
say "decoded: " . $decoded if ($CONFIG{'DEBUG'});
|
||||
|
||||
|
||||
my $uri = URI->new($decoded);
|
||||
%{$DATA{'PARAMETER'}} = $uri->query_form;
|
||||
$DATA{'PARAMETER'}{'url'} = url_param('url');
|
||||
#$DATA{'PARAMETER'}{'url'} = url_param('url');
|
||||
$DATA{'PARAMETER'}{'url'} = $decoded;
|
||||
$DATA{'PARAMETER'}{'url'} =~ s/^url=//;
|
||||
|
||||
# Remove note, request_switch from decoded uri
|
||||
$DATA{'PARAMETER'}{'url'} =~ s/¬e(=[^&]*)?|^note(=[^&]*)?&?//;
|
||||
$DATA{'PARAMETER'}{'url'} =~ s/&request_switch(=[^&]*)?|^request_switch(=[^&]*)?&?//;
|
||||
}
|
||||
|
||||
sub get {
|
||||
&Delimiter((caller(0))[3]);
|
||||
my $url = shift;
|
||||
|
||||
if ($CONFIG{'USE_CORSANYWHERE'}) {
|
||||
say 'Generating url for cors-anywhere...';
|
||||
my ($scheme, $auth, $path, $query, $frag) = uri_split($url);
|
||||
#say "scheme: $scheme\nauth: $auth\npath: $path\nquery: $query\nfrag: $frag";
|
||||
$url = 'https://cors.zinomedia.de/purchase.tickets.com:443' . $path . '?' . $query;
|
||||
say "cors-anywhere URL: $url";
|
||||
}
|
||||
|
||||
if ($CONFIG{'ONLINE'}) {
|
||||
print "GET:\n$url\n" if $CONFIG{'DEBUG'};
|
||||
|
||||
my $response = $ua->get($url);
|
||||
|
||||
#my $response = $ua->get($url);
|
||||
my $response = $ua->get($url,
|
||||
'User-Agent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
|
||||
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
|
||||
'Accept-Language' => 'de,en-US;q=0.7,en;q=0.3',
|
||||
'Host' => 'purchase.tickets.com',
|
||||
);
|
||||
|
||||
print 'STATUS_LINE: ' . $response->status_line . "\n" if $CONFIG{'DEBUG'};
|
||||
if ($response->is_success) {
|
||||
return $response->decoded_content;
|
||||
@@ -602,6 +673,8 @@ sub get {
|
||||
$response->code();
|
||||
$response->message();
|
||||
$response->status_line();
|
||||
say 'Get unsuccessful' if $CONFIG{'DEBUG'};
|
||||
die;
|
||||
}
|
||||
}
|
||||
elsif (!$CONFIG{'ONLINE'}) {
|
||||
|
||||
Reference in New Issue
Block a user