From e79c8f18947a58f03d90074f67bdf2822073d156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rainer=20G=C3=BCmpelein?= Date: Tue, 11 Jan 2022 10:53:21 +0100 Subject: [PATCH] geo_distance by geo_fencing --- copri4/main/src/Mod/APIfunc.pm | 6 ++++-- copri4/main/src/Mod/APIjsonserver.pm | 12 +++++++++--- copri4/main/src/Tpl/Karte.pm | 6 +++++- copri4/mkaccess.sh | 2 +- copri4/shareeapp-operator/src/Tpl/Contact.pm | 2 +- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/copri4/main/src/Mod/APIfunc.pm b/copri4/main/src/Mod/APIfunc.pm index 21974cc..af1715b 100755 --- a/copri4/main/src/Mod/APIfunc.pm +++ b/copri4/main/src/Mod/APIfunc.pm @@ -790,6 +790,7 @@ sub service_work { sub booking_update(){ my $self = shift; my $q = shift; + my $varenv = shift; my $auth = shift; my $owner = shift || 0; my $state = $q->escapeHTML($q->param('state')) || ""; @@ -962,7 +963,7 @@ sub booking_update(){ my $geo_distance_next = 100000; my $station_next = 0; my $geo_debug=""; - my ($stations,$stations_raw) = $self->stations_available($q,$auth); + my ($stations,$stations_raw) = $self->stations_available($q,$varenv,$auth); foreach my $id (sort { $stations_raw->{$a}->{barcode} <=> $stations_raw->{$b}->{barcode} } keys (%$stations_raw)){ my $latitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /^(\d+\.\d+)/); my $longitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /(\d+\.\d+)$/); @@ -1127,7 +1128,7 @@ sub booking_update(){ #geofencing for Ilockit my $geo_distance_next = $geo_distance; my $geo_debug=""; - my ($stations,$stations_raw) = $self->stations_available($q,$auth); + my ($stations,$stations_raw) = $self->stations_available($q,$varenv,$auth); foreach my $id (sort { $stations_raw->{$a}->{barcode} <=> $stations_raw->{$b}->{barcode} } keys (%$stations_raw)){ my $latitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /^(\d+\.\d+)/); my $longitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /(\d+\.\d+)$/); @@ -1135,6 +1136,7 @@ sub booking_update(){ $geo_debug .= "locked ERROR no user GPS: $stations_raw->{$id}->{barcode}|$latitude,$longitude,$latitude_station,$longitude_station --> $geo_distance Meter\n"; }elsif(looks_like_number($latitude) && looks_like_number($longitude) && looks_like_number($latitude_station) && looks_like_number($longitude_station)){ $geo_distance = $lb->geo_fencing($latitude,$longitude,$latitude_station,$longitude_station); + $bw->log("geo_distance by geo_fencing:$latitude,$longitude,$latitude_station,$longitude_station|$stations_raw->{$id}->{txt06}",$geo_distance,""); if($geo_distance <= $stations_raw->{$id}->{int06}){ $geo_distance_next = $geo_distance; #end-Station diff --git a/copri4/main/src/Mod/APIjsonserver.pm b/copri4/main/src/Mod/APIjsonserver.pm index 7c67cf3..49beadd 100755 --- a/copri4/main/src/Mod/APIjsonserver.pm +++ b/copri4/main/src/Mod/APIjsonserver.pm @@ -221,7 +221,7 @@ elsif($q->param('request') eq "booking_request"){ #just in time booking if(ref($response_book) eq "HASH" && $response_book->{response_state} =~ /OK/ && $q->param('state') && $q->param('state') =~ /occupied/){ - (my $rows, my $booking_values) = $apif->booking_update($q,$authraw,$aowner); + (my $rows, my $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner); $response = {%$response, %$booking_values}; }else{ $response = {%$response, %$response_book}; @@ -274,10 +274,10 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki if(ref($auth) eq "HASH" && $auth->{authcookie}){ if($q->param('bike')){ if($q->param('request') eq "booking_update" && $q->param('state') && $q->param('state') =~ /canceled/){ - ($rows, my $booking_values) = $apif->booking_update($q,$authraw,$aowner); + ($rows, my $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner); $response = {%$response, %$booking_values}; }elsif($q->param('request') eq "booking_update" && (($q->param('state') && $q->param('state') =~ /occupied|available/) || ($q->param('lock_state') && $q->param('lock_state') =~ /locking|locked|unlocked/))){ - ($rows, my $booking_values) = $apif->booking_update($q,$authraw,$aowner); + ($rows, my $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner); $response = {%$response, %$booking_values}; #keep in mind, it works on operator dependency @@ -422,6 +422,9 @@ elsif($q->param('request') eq "bikes_available"){ #my $stamp = gettimeofday; #$bw->log("X bikes_available $varenv{syshost} $stamp: $response->{user_group}",$response,""); }else{ + ($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id')); + $varenv{merchant_id} = $return_merchant->{merchant_id}; + my ($auth,$authraw) = $apif->auth_verify($q);#on operator loop select, operator adr must be select to get user_group $response = { %$response, %$auth }; $bw->log("Y bikes_available by c_id $authraw->{c_id}, Tarif:",$authraw->{txt30},""); @@ -622,6 +625,9 @@ elsif($q->param('request') eq "stations_available"){ $response = { %$response, %$auth }; ($response->{stations},$response->{uri_operator_array},$response->{user_group},$response->{user_tour}) = $jsc->loop_sharees($q,$auth,$aowner); }else{ + ($aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$q->param('merchant_id')); + $varenv{merchant_id} = $return_merchant->{merchant_id}; + my ($auth,$authraw) = $apif->auth_verify($q); $response = { %$response, %$auth }; ($response->{stations}, my $response_raw) = $apif->stations_available($q,\%varenv,$authraw); diff --git a/copri4/main/src/Tpl/Karte.pm b/copri4/main/src/Tpl/Karte.pm index e7005f5..cb308e7 100755 --- a/copri4/main/src/Tpl/Karte.pm +++ b/copri4/main/src/Tpl/Karte.pm @@ -58,6 +58,10 @@ sub tpl(){ require "Mod/KMLout.pm"; my $kmlfile = Mod::KMLout::kmlGenerator($api_return,$varenv,$users_sharee); + my $filesize = -s "$varenv->{metahost}/xml/$kmlfile"; + my $preserve_view = "false"; + $preserve_view = "true" if($filesize < 200);#it's like empty without publixc stations + print "
\n"; print "$initMap|$varenv->{dbname}|$api_return->{authcookie}|$users_sharee->{c_id}|$kmlfile" if($users_dms->{u_id} == $dbt->{copri_conf}->{superu_id}); @@ -76,7 +80,7 @@ print<{primary}->{sharee_primary}->{primaryApp}/KMLout?kml=' + (new Date()).getTime() + '$users_sharee->{c_id}', //url: '$varenv->{metahost}/xml/KMLout-3', //url: '$varenv->{wwwhost}/?kml=' + (new Date()).getTime(), diff --git a/copri4/mkaccess.sh b/copri4/mkaccess.sh index 3d21c46..e7fc6ef 100755 --- a/copri4/mkaccess.sh +++ b/copri4/mkaccess.sh @@ -36,7 +36,7 @@ for i in $(find . -type d -and -name cronjobs); do chown -R root:root $i/*;done live_sharee="ginger" echo "You are on Server with hostname: $(hostname)"; -echo ""; +echo "on main gitlab sourcen there is no live config"; #sharee echo "KEEP in mind, SHAREE autoLinking is only done if $(hostname) == ${live_sharee}"; diff --git a/copri4/shareeapp-operator/src/Tpl/Contact.pm b/copri4/shareeapp-operator/src/Tpl/Contact.pm index 648e23a..d7ec90e 100755 --- a/copri4/shareeapp-operator/src/Tpl/Contact.pm +++ b/copri4/shareeapp-operator/src/Tpl/Contact.pm @@ -103,7 +103,7 @@ sub tpl(){ } #email tag with little coding against grabber if($record_cc->{$key} =~ /(\w+\@[\w-]+\.\w+)/){ - $record_cc->{$key} =~ s/(\w+\@[\w-]+\.\w+)/\$1\<\/a\>/; + $record_cc->{$key} =~ s/([\w\.\-_]+\@[\w-]+\.\w+)/\$1\<\/a\>/; $record_cc->{$key} =~ s/\@/\&\#64\;/g; } $record_cc->{$key} =~ s/\\//g;