inside view I have:

 <script type="text/javascript" 
src="http://www.google.com/jsapi?key=<YOUR_GOOGLE_API_KEY>"></script>
    <script type="text/javascript">
       if(google.loader.ClientLocation)
        {
            visitor_lat = google.loader.ClientLocation.latitude;
            visitor_lon = google.loader.ClientLocation.longitude;
            visitor_city = google.loader.ClientLocation.address.city;
            visitor_region = google.loader.ClientLocation.address.region;
            visitor_country = google.loader.ClientLocation.address.country;
            visitor_countrycode = 
google.loader.ClientLocation.address.country_code;
           ajax('{{=URL('default', 'location')}}' + '?lat=' + visitor_lat + 
'&lon=' + visitor_lon + '&city=' + visitor_city + '&region=' + 
visitor_region + '&country=' + visitor_country + '&countrycode=' + 
visitor_countrycode, [], ':eval');
        }
      </script>


controller function location is as:

def location():
    lat=request.vars.lat
    lon=request.vars.lon
    city=request.vars.city
    region=request.vars.region
    country=request.vars.country
    countrycode=request.vars.countrycode
    device=str(request.user_agent)
    start=device.find("HTTP_USER_AGENT") + 18
    end=device.find("HTTP_CONNECTION") - 3
    device=device[start:end]
    date_time=request.utcnow+datetime.timedelta(0,19800)
    date_time=str(date_time)
    
db.visitors.insert(latitude=lat,longitude=lon,city=city,region=region,country=country,countrycode=countrycode,device=device,date_time=date_time)
    mail.send('raghib....@iiits.in',
                  'Someone just checked your ePortfolio',
                  message='<html><style></style><body><h1 
style="background-color:rgb(236, 255, 136);display:inline" >Hola Amigos Mr. 
Raghib!</h1><br><div 
style="width:500px;height:100px;background-color:lightblue;opacity:0.8"><h3>You 
have a new visitor</h3><h3>From ip address: %s</h3><h3>Latitude: %s and 
longitude: %s</h3><h3>Address:  %s, %s, %s, %s </h3><h3>and device model: 
%s</h3> </div></body></html>' %(str(request.client), str(lat), str(lon), 
str(city), str(region), str(country), str(countrycode), device ))


I do get emails but a very few times!

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to