|
#!/usr/bin/perl use LWP::Simple; use HTML::TokeParser; use URI; $pathtodata='/home/mydir/'; $gpsfilename='GPSinfo.txt'; $camurl='http://myweb.com/webcam.jpg'; #URL for webcam #Get the all the values for current time ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time); @Days = ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); @Months = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $dayText = $Days[$WeekDay]; $dateText = $Day + 0; $yearText = 1900 + $Year; $monthText = $Months[$Month]; $file=$pathtodata.$gpsfilename; open (GPSDATA, "<$file"); $GPSrecord = <GPSDATA>; close(GPSDATA); #assign variables $_ = $GPSrecord; ($latitude) = /Latitude=(\d*\.\d{1,5})/g; ($longitude) = /Longitude=(-?\d*\.\d{1,5})/g; ($altitude) = /Altitude=(\d*)/g; ($speed) = /Speed=(\d*)/g; ($direction) = /Direction=(\d*)/g; ($GPStime) = /Time=(.*)Latitude/g; ($refresh) = /Refresh=(\d*)/g; if ($refresh < 10){ $refresh = 60; } # begin web page HTML print "Content-type: text/html\n\n"; print "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"$refresh\">\n"; print "<title>CPS - Chase Positioning System</title>\n"; print "<html><body><pre>\n"; print "<b>My last reported position is indicated by the star in the map below\n"; print "Click on map image for a zoomable version\n"; if ($altitude > 0){ print "Altitude = $altitude ft.\n"; } if ($speed > 5){ print "Speed = $speed MPH Direction = $direction°\n"; } else { print "Speed < 5 MPH Direction = Not Accurate\n"; } print "GPS Time = $GPStime GMT</b><hr>"; ###################################################################### my ($page, $localfile) = ("http://www.mapquest.com/maps/map.adp?latlongtype=decimal&latitude=$latitude&longitude=$longitude&zoom=5","pic.html"); $page = "http://$page" unless $page =~ m{^http://}; $url = URI->new($page); # Get requested page from Mapquest and save it locally $html = get($page) || ''; # Parse the Web page to identify images $parser = HTML::TokeParser->new(\$html); while ( $img_info = $parser->get_tag('img')) { # Look for input tags $image_name = $img_info->[1]->{'src'}; # Get img filename from src param $image_url = URI->new($image_name); $image_file = $image_url->abs($url);# Determine the full URL for this image $imagefiles{$image_file} = 1; # Save it } # Find image url containing 'mq-mapgend' foreach $this_image (keys %imagefiles) { # For each image URL that we saved if ($this_image =~ /mq-mapgend/) { # Display image and link to Mapquest print "<a target=\"_blank\" href=$page>\n<img src=$this_image></a> <img src=$camurl>\n"; } } ##################################################################### print "</pre></body></html>\n"; exit(0); |
|
|