Changeset 149
- Timestamp:
- 07/13/08 22:14:55 (4 months ago)
- Location:
- trunk
- Files:
-
- 5 added
- 5 modified
-
img/marker_author.png (added)
-
img/marker_bot.png (added)
-
img/marker_loggedin.png (added)
-
img/marker_user.png (added)
-
img/shadow.png (added)
-
lib/main.php (modified) (3 diffs)
-
lib/settings.php (modified) (1 diff)
-
lib/wassup.class.php (modified) (2 diffs)
-
wassup.css (modified) (2 diffs)
-
wassup.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/main.php
r147 r149 611 611 } 612 612 // User is logged in or is a comment's author 613 if ($cv->username != "" AND $cv->comment_author != "") {613 if ($cv->username != "") { 614 614 $unclass = "-log"; 615 } elseif ($cv->comment_author != "") { 615 $map_icon = "marker_loggedin.png"; 616 } elseif ($cv->comment_author != "" AND $cv->username == "") { 616 617 $unclass = "-aut"; 618 $map_icon = "marker_author.png"; 617 619 } elseif ($cv->spider != "") { 618 620 $unclass = "-spider"; 619 } 621 $map_icon = "marker_bot.png"; 622 } else { 623 $map_icon = "marker_user.png"; 624 } 620 625 // Start getting GEOIP info 621 /* 622 // TODO 623 $ch = curl_init("http://api.hostip.info/get_html.php?ip=".$ip[0]."&position=true"); 624 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 625 curl_setopt($ch, CURLOPT_HEADER, 0); 626 $data = curl_exec($ch); 627 curl_close($ch); 628 */ 626 $geo_url = "http://api.hostip.info/get_html.php?ip=".$ip[0]."&position=true"; 627 $data = file($geo_url); 628 $location = $data[0]." ".$data[1]; 629 $location = eregi_replace("country: ", "", $location); 630 $location = eregi_replace("city: ", "", $location); 631 if ($wassup_settings['wassup_geoip_map'] == 1) { 632 $gkey = $wassup_settings['wassup_googlemaps_key']; 633 if (trim($location) != "") { 634 $geocode = explode(",", geocode($location, $gkey)); 635 if(array_search("Error", $geocode) == "") { 636 $lat = explode(":", $data[2]); 637 $lat = $lat[1]; 638 $lon = explode(":", $data[3]); 639 $lon = $lon[1]; 640 } else { 641 $lat = $geocode[0]; 642 $lon = $geocode[1]; 643 } 644 } else { 645 $lat = 0; 646 $lon = 0; 647 } 648 } 629 649 ?> 630 650 <div class="sum-spy"> 631 632 651 <span class="sum-box<?php print $unclass; ?>"> 633 652 <?php print $ip[0]; ?></span> 634 <div class="sum-det "><span class="det1">653 <div class="sum-det-spy"><span class="det1"> 635 654 <?php 636 655 print '<a href="'.wAddSiteurl(htmlspecialchars(html_entity_decode($cv->urlrequested))).'" target="_BLANK">'; … … 638 657 </a></span><br /> 639 658 <span class="det2"><strong><?php print gmdate("H:i:s", $timestamp); ?> - </strong> 640 <?php print $referrer; ?></span> 659 <?php print $referrer; ?> 660 <?php print "<br />".$location; 661 ?> 662 </span> 641 663 </div></div> 642 <?php } //end if row_count 664 <?php 665 if ($wassup_settings['wassup_geoip_map'] == 1) { 666 if ($lat!=0 && $lon!=0) { 667 $item_id = $cv->id; 668 $img_dir = $wpurl.'/wp-content/plugins/'.WASSUPFOLDER.'/img'; 669 echo " 670 <script type=\"text/javascript\"> 671 var icon$item_id = new GIcon(); 672 icon$item_id.image = '".$img_dir."/".$map_icon."'; 673 icon$item_id.shadow = '$img_dir/shadow.png'; 674 icon$item_id.iconSize = new GSize(20.0, 34.0); 675 icon$item_id.shadowSize = new GSize(38.0, 34.0); 676 icon$item_id.iconAnchor = new GPoint(10.0, 17.0); 677 icon$item_id.infoWindowAnchor = new GPoint(10.0, 17.0); 678 var point = new GLatLng($lat,$lon); 679 var marker$item_id = new GMarker(point, icon$item_id); 680 map.addOverlay(marker$item_id); 681 GEvent.addListener(marker$item_id, 'click', function() { 682 marker$item_id.openInfoWindowHtml('<div style=\"white-space:nowrap\"><div class=\"bubble\">Ip: ". 683 $ip[0] 684 ."<br />Hour: ". 685 gmdate('H:i:s', $timestamp) 686 ."<br />Request: <a href=". 687 wAddSiteurl(htmlspecialchars(html_entity_decode($cv->urlrequested))) 688 ." target=\"_BLANK\">". 689 stringShortener(html_entity_decode($cv->urlrequested), round($max_char_len*.9,0)) 690 ."</a></div></div>'); 691 }); 692 map.panTo(new GLatLng($lat,$lon),3); 693 </script>"; 694 } 695 } 696 697 } //end if row_count 643 698 $row_count=$row_count+1; 644 699 } //end foreach … … 650 705 } //end if !empty($qryC) 651 706 } //end function spyview 707 708 // Geocoding location with Google Maps 709 function geocode($location, $key) { 710 //Three parts to the querystring: q is address, output is the format ( 711 $address = urlencode($location); 712 $url = "http://maps.google.com/maps/geo?q=".$address."&output=csv&key=".$key; 713 714 $ch = curl_init(); 715 716 curl_setopt($ch, CURLOPT_URL, $url); 717 curl_setopt($ch, CURLOPT_HEADER,0); 718 curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER[HTTP_USER_AGEN]); 719 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 720 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 721 722 $data = curl_exec($ch); 723 curl_close($ch); 724 725 $data = explode(",",$data); 726 if ($data[0] == 200) 727 { 728 $lat = $data[2]; 729 $lon = $data[3]; 730 $coords = $lat.":".$lon; 731 return $coords; 732 733 } else { 734 $coords = $data[0]; 735 return $coords; 736 } 737 } 652 738 653 739 // How many digits have an integer -
trunk/lib/settings.php
r147 r149 89 89 <p><input type="checkbox" name="wassup_dashboard_chart" value="1" <?php if($wassup_options->wassup_dashboard_chart == 1) print "CHECKED"; ?> /> <strong><?php _e('Display small chart in the dashboard','wassup'); ?></strong> 90 90 </p><br /> 91 92 <?php // Test Google Maps Key If the test fails deactivate *map options 93 if ($wassup_options->wassup_geoip_map == 1 && $wassup_options->wassup_googlemaps_key != "") { 94 $code = geocode("Ancona", $wassup_options->wassup_googlemaps_key); 95 if ($code != "200") { 96 $style_key = "style='background:red'"; 97 $code_error = "<p>--->> <strong>WARNING</strong> Activation problem >> Error code: <a href='http://code.google.com/apis/maps/documentation/reference.html#GGeoStatusCode' target='_BLANK'>".$code."</a> <<---</p>"; 98 $wassup_options->wassup_geoip_map = 0; 99 $wassup_options->wassup_googlemaps_key = ""; 100 $wassup_options->saveSettings(); 101 } 102 } 103 ?> 104 <br /><h3><?php _e('GEO IP Map (Spy view)','wassup'); ?></h3> 105 <?php echo $code_error; ?> 106 <p><input type="checkbox" name="wassup_geoip_map" value="1" <?php if($wassup_options->wassup_geoip_map == 1) print "CHECKED"; ?> /> <strong><?php _e('Display a GEO IP Map in the spy visitors view','wassup'); ?></strong> 107 </p> 108 <p><strong>Google Maps API key:</strong> <input <?php echo $style_key; ?> type="text" name="wassup_googlemaps_key" size="40" value="<?php print $wassup_options->wassup_googlemaps_key; ?>" /> - <a href="http://www.google.com/maps/api_signup?url=<?php echo $wpurl; ?>">signup for your key</a></p></br /> 91 109 92 110 <br /><h3><?php _e('Time format','wassup'); ?></h3> -
trunk/lib/wassup.class.php
r147 r149 16 16 var $wassup_top10 ; 17 17 var $wassup_dashboard_chart; 18 var $wassup_geoip_map; 19 var $wassup_googlemaps_key; 18 20 var $wassup_time_format; //new 19 21 … … 98 100 $this->wassup_default_limit = "10"; 99 101 $this->wassup_dashboard_chart = "0"; 102 $this->wassup_geoip_map = "0"; 103 $this->wassup_googlemaps_key = ""; 100 104 $this->wassup_time_format = "24"; 101 105 $this->wassup_widget_title = "Visitors Online"; -
trunk/wassup.css
r122 r149 53 53 } 54 54 .sum-spy { 55 min-height: 54px; 55 56 position: relative; 56 57 clear: left; … … 96 97 width: 100%; 97 98 } 99 .sum-det-spy { 100 float:left; 101 margin: 0px 0 0px 0; 102 padding: 0; 103 line-height: 20px; 104 font-size: 14px; 105 } 98 106 .sum-det { 99 107 margin: 0px 0 0px 0; -
trunk/wassup.php
r148 r149 4 4 Plugin URI: http://www.wpwp.org 5 5 Description: Wordpress plugin to analyze your visitors traffic with real time stats, chart and a lot of chronological informations. It has sidebar Widget support to show current online visitors and other statistics. 6 Version: 1.6. 16 Version: 1.6.2b 7 7 Author: Michele Marcucci, Helene D. 8 8 Author URI: http://www.michelem.org/ … … 460 460 $wassup_options->wassup_userlevel = $_POST['wassup_userlevel']; 461 461 $wassup_options->wassup_dashboard_chart = $_POST['wassup_dashboard_chart']; 462 $wassup_options->wassup_geoip_map = $_POST['wassup_geoip_map']; 463 $wassup_options->wassup_googlemaps_key = $_POST['wassup_googlemaps_key']; 462 464 $wassup_options->wassup_time_format = $_POST['wassup_time_format']; 463 465 $wassup_options->wassup_default_type = $_POST['wassup_default_type']; … … 647 649 <a href="#?" onclick="return playSpy();"><span id="spy-play"><?php _e("Play", "wassup"); ?></span></a> 648 650 <br /> <br /></div> 651 652 <?php // GEO IP Map 653 if ($wassup_options->wassup_geoip_map == 1 AND $wassup_options->wassup_googlemaps_key != "") { ?> 654 <script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo $wassup_options->wassup_googlemaps_key; ?>" type="text/javascript"></script> 655 <div id="map" style="width: <?php echo ($screen_res_size*95/100); ?>px; height: 220px;border:2px solid #999;"></div> 656 <script type="text/javascript"> 657 //<![CDATA[ 658 if (GBrowserIsCompatible()) { 659 // Display the map, with some controls and set the initial location 660 var map = new GMap2(document.getElementById("map")); 661 map.addControl(new GSmallMapControl()); 662 map.addControl(new GMapTypeControl()); 663 //map.enableScrollWheelZoom(); 664 map.setCenter(new GLatLng(0,0),3); 665 } 666 // display a warning if the browser was not compatible 667 else { 668 alert("Sorry, the Google Maps API is not compatible with this browser"); 669 } 670 //]]> 671 </script> 672 <p> </p> 673 <? } //end if geoip_map ?> 649 674 <div id="spyContainer"> 650 675 <?php
