Exemplo n.º 1
0
function spyview($from_date = "", $to_date = "", $rows = "999", $spytype = "")
{
    global $wpdb;
    $whereis = "";
    if ($spytype == 'spider') {
        $whereis = " AND spider!=''";
    } elseif ($spytype == 'nospider') {
        $whereis = " AND spider=''";
    } elseif ($spytype == 'spam') {
        $whereis = " AND spam>0";
    } elseif ($spytype == 'nospam') {
        $whereis = " AND spam=0";
    } elseif ($spytype == 'nospamspider') {
        $whereis = " AND spam=0 AND spider=''";
    } elseif ($spytype == 'searchengine') {
        $whereis = " AND searchengine!='' AND search!=''";
    } elseif ($spytype == 'referrer') {
        $whereis = " AND referrer!='' AND referrer NOT LIKE '%{$wpurl}%' AND searchengine='' AND search=''";
    } elseif ($spytype == 'comauthor') {
        $whereis = " AND comment_author!=''";
    } elseif ($spytype == 'loggedin') {
        $whereis = " AND username!=''";
    }
    //check for arguments...
    if (empty($to_date)) {
        $to_date = wassup_get_time();
    }
    if (empty($from_date)) {
        $from_date = $to_date - 5;
    }
    $table_tmp_name = $wpdb->prefix . "wassup_tmp";
    if (function_exists('get_option')) {
        $wassup_settings = get_option('wassup_settings');
    }
    if (!empty($wassup_settings['wassup_screen_res'])) {
        $screen_res_size = (int) $wassup_settings['wassup_screen_res'];
    } else {
        $screen_res_size = 670;
    }
    $max_char_len = $screen_res_size / 10;
    if (function_exists('get_bloginfo')) {
        $wpurl = get_bloginfo('wpurl');
        $siteurl = get_bloginfo('siteurl');
    }
    $qryC = $wpdb->get_results("SELECT id, wassup_id, max(timestamp) as max_timestamp, ip, hostname, searchengine, urlrequested, agent, referrer, spider, username, comment_author FROM {$table_tmp_name} WHERE timestamp BETWEEN {$from_date} AND {$to_date} {$whereis} GROUP BY id ORDER BY max_timestamp DESC");
    if (!empty($qryC)) {
        //restrict # of rows to display when needed...
        $row_count = 0;
        //display the rows...
        foreach ($qryC as $cv) {
            if ($row_count < (int) $rows) {
                $timestamp = $cv->max_timestamp;
                $ip = @explode(",", $cv->ip);
                if ($cv->referrer != '') {
                    if (!eregi($wpurl, $cv->referrer) or $cv->searchengine != "") {
                        if (!eregi($wpurl, $cv->referrer) and $cv->searchengine == "") {
                            $referrer = '<a href="' . $cv->referrer . '" target=_"BLANK"><span style="font-weight: bold;">' . stringShortener($cv->referrer, round($max_char_len * 0.8, 0)) . '</span></a>';
                        } else {
                            $referrer = '<a href="' . $cv->referrer . '" target=_"BLANK">' . stringShortener($cv->referrer, round($max_char_len * 0.9, 0)) . '</a>';
                        }
                    } else {
                        $referrer = __('From your blog', 'wassup');
                    }
                } else {
                    $referrer = __('Direct hit', 'wassup');
                }
                // User is logged in or is a comment's author
                if ($cv->username != "") {
                    $unclass = "-log";
                    $map_icon = "marker_loggedin.png";
                } elseif ($cv->comment_author != "" and $cv->username == "") {
                    $unclass = "-aut";
                    $map_icon = "marker_author.png";
                } elseif ($cv->spider != "") {
                    $unclass = "-spider";
                    $map_icon = "marker_bot.png";
                } else {
                    $map_icon = "marker_user.png";
                }
                // Start getting GEOIP info
                $geo_url = "http://api.hostip.info/get_html.php?ip=" . $ip[0] . "&position=true";
                $data = file($geo_url);
                if (eregi("unknown", $data[0])) {
                    $loc_country = eregi_replace("country: ", "", $data[0]);
                }
                if (eregi("unknown", $data[1])) {
                    $loc_city = eregi_replace("city: ", "", $data[1]);
                }
                $geoloc = $loc_country . " " . $loc_city;
                if ($wassup_settings['wassup_geoip_map'] == 1) {
                    $gkey = $wassup_settings['wassup_googlemaps_key'];
                    if ($geoloc != "") {
                        $geocode = geocode($geoloc, $gkey);
                        if ($geocode[0] != 200) {
                            $lat = explode(":", $data[2]);
                            $lat = $lat[1];
                            $lon = explode(":", $data[3]);
                            $lon = $lon[1];
                        } else {
                            $lat = $geocode[2];
                            $lon = $geocode[3];
                        }
                    } else {
                        $lat = 0;
                        $lon = 0;
                    }
                }
                $location = $data[0] . " - " . $data[1];
                ?>
		   <div class="sum-spy">
		   <span class="sum-box<?php 
                print $unclass;
                ?>
">
		   	<?php 
                print $ip[0];
                ?>
</span>
		   <div class="sum-det-spy"><span class="det1">
		   <?php 
                print '<a href="' . wAddSiteurl(htmlspecialchars(html_entity_decode($cv->urlrequested))) . '" target="_BLANK">';
                print stringShortener(html_entity_decode($cv->urlrequested), round($max_char_len * 0.9, 0));
                ?>
		   </a></span><br />
		   <span class="det2"><strong><?php 
                print gmdate("H:i:s", $timestamp);
                ?>
 - </strong>
		   <?php 
                print $referrer;
                ?>
		   <?php 
                print "<br />" . $location;
                //DEBUG ."$geocode[0]." / ".$lat." / ".$lon;
                ?>
		   </span>
		   </div></div>
<?php 
                // Print the JS code to add marker on the map
                if ($wassup_settings['wassup_geoip_map'] == 1) {
                    if ($lat != 0 && $lon != 0) {
                        $item_id = $cv->id;
                        $img_dir = $wpurl . '/wp-content/plugins/' . WASSUPFOLDER . '/img';
                        echo "\n                <script type=\"text/javascript\">\n                var icon{$item_id} = new GIcon();\n                icon{$item_id}.image = '" . $img_dir . "/" . $map_icon . "';\n                icon{$item_id}.shadow = '{$img_dir}/shadow.png';\n                icon{$item_id}.iconSize = new GSize(20.0, 34.0);\n                icon{$item_id}.shadowSize = new GSize(38.0, 34.0);\n                icon{$item_id}.iconAnchor = new GPoint(10.0, 17.0);\n                icon{$item_id}.infoWindowAnchor = new GPoint(10.0, 17.0);\n                var point = new GLatLng({$lat},{$lon});\n                var marker{$item_id} = new GMarker(point, icon{$item_id});\n                map.addOverlay(marker{$item_id});\n                GEvent.addListener(marker{$item_id}, 'click', function() {\n                marker{$item_id}.openInfoWindowHtml('<div style=\"white-space:nowrap\"><div class=\"bubble\">Ip: " . $ip[0] . "<br />Hour: " . gmdate('H:i:s', $timestamp) . "<br />Request: <a href=" . wAddSiteurl(htmlspecialchars(html_entity_decode($cv->urlrequested))) . " target=\"_BLANK\">" . stringShortener(html_entity_decode($cv->urlrequested), round($max_char_len * 0.9, 0)) . "</a><br />" . "</div></div>');\n                });\n                map.panTo(new GLatLng({$lat},{$lon}),3);\n                </script>";
                    }
                }
            }
            //end if row_count
            $row_count = $row_count + 1;
        }
        //end foreach
    } else {
        //display "no activity" periodically so we know spy is running...
        if ((int) $to_date % 7 == 0) {
            echo '<div class="sum-spy"><span class="det3">' . gmdate("H:i:s", $to_date) . ' - ' . __("No visitor activity", "wassup") . ' &nbsp; &nbsp; :-( &nbsp; </span></div>';
        }
    }
    //end if !empty($qryC)
}
Exemplo n.º 2
0
function wassup_sidebar($before_widget='', $after_widget='', $before_title='', $after_title='', $wtitle='', $wulclass='', $wchars='', $wsearch='', $wsearchlimit='', $wref='', $wreflimit='', $wtopbr='', $wtopbrlimit='', $wtopos='', $wtoposlimit='') {
	global $wpdb;
	$wpurl =  get_bloginfo('wpurl');
	$siteurl =  get_bloginfo('siteurl');
	if ($wtitle != "") $title = $wtitle; else $title = "Visitors Online";
	if ($wulclass != "") $ulclass = $wulclass; else $ulclass = "links";
	if ($wchars != "") $chars = $wchars; else $chars = "18";
	if ($wsearchlimit != "") $searchlimit = $wsearchlimit; else $searchlimit = "5";
	if ($wreflimit != "") $reflimit = $wreflimit; else $reflimit = "5";
	if ($wtopbrlimit != "") $topbrlimit = $wtopbrlimit; else $topbrlimit = "5";
	if ($wtoposlimit != "") $toposlimit = $wtoposlimit; else $toposlimit = "5";
	$table_name = $wpdb->prefix . "wassup";
	$table_tmp_name = $wpdb->prefix . "wassup_tmp";
	$to_date = wassup_get_time();
	$from_date = strtotime('-3 minutes', $to_date);

        print $before_widget;
	if ($wsearch == 1) {
	$query_det = $wpdb->get_results("SELECT search, referrer FROM $table_tmp_name WHERE search!='' GROUP BY search ORDER BY `timestamp` DESC LIMIT $searchlimit");
	if (count($query_det) > 0) {
		print "$before_title Last searched terms $after_title";
		print "<ul class='$ulclass'>";
		foreach ($query_det as $sref) {
			print "<li>- <a href='".attribute_escape($sref->referrer)."' target='_blank' rel='nofollow'>".stringShortener(attribute_escape($sref->search), $chars)."</a></li>";
		}
		print "</ul>";
	}
	}

	if ($wref == 1) {
	$query_ref = $wpdb->get_results("SELECT referrer FROM $table_tmp_name WHERE searchengine='' AND referrer!='' AND referrer NOT LIKE '$wpurl%' GROUP BY referrer ORDER BY `timestamp` DESC LIMIT $reflimit");
	if (count($query_ref) > 0) {
		print "$before_title Last referers $after_title";
		print "<ul class='$ulclass'>";
		foreach ($query_ref as $eref) {
			print "<li>- <a href='".attribute_escape($eref->referrer)."' target='_blank' rel='nofollow'>".stringShortener(preg_replace("#https?://#", "", attribute_escape($eref->referrer)), $chars)."</a></li>";
		}
		print "</ul>";
	}
	}

	if ($wtopbr == 1) {
	$query_topbr = $wpdb->get_results("SELECT count(browser) as top_browser, browser FROM $table_name WHERE browser!='' AND browser NOT LIKE 'N/A%' GROUP BY browser ORDER BY top_browser DESC LIMIT $topbrlimit");
	if (count($query_topbr) > 0) {
		print "$before_title Top Browsers $after_title";
		print "<ul class='$ulclass'>";
		foreach ($query_topbr as $etopbr) {
			print "<li>- ".stringShortener(attribute_escape($etopbr->browser), $chars)."</li>";
		}
		print "</ul>";
	}
	}

	if ($wtopos == 1) {
	$query_topos = $wpdb->get_results("SELECT count(os) as top_os, os FROM $table_name WHERE os!='' AND os NOT LIKE 'N/A%' GROUP BY os ORDER BY top_os DESC LIMIT $toposlimit");
	if (count($query_topos) > 0) {
		print "$before_title Top OS $after_title";
		print "<ul class='$ulclass'>";
		foreach ($query_topos as $etopos) {
			print "<li>- ".stringShortener(attribute_escape($etopos->os), $chars)."</li>";
		}
		print "</ul>";
	}
	}

	$TotWid = New MainItems;
	$TotWid->tableName = $table_tmp_name;
	$TotWid->from_date = $from_date;
	$TotWid->to_date = $to_date;

	$currenttot = $TotWid->calc_tot("count", null, null, "DISTINCT");
	$currentlogged = $TotWid->calc_tot("count", null, "AND  username!=''", "DISTINCT");
	$currentauth = $TotWid->calc_tot("count", null, "AND  comment_author!=''' AND username=''", "DISTINCT");

	print $before_title . $title . $after_title;
	print "<ul class='$ulclass'>";
	if ((int)$currenttot < 10) $currenttot = "0".$currenttot;
	print "<li><strong style='padding:0 4px 0 4px;background:#ddd;color:#777'>".$currenttot."</strong> visitor(s) online</li>";
	if ((int)$currentlogged > 0 AND $wassup_settings['wassup_widget_loggedin'] == 1) {
	if ((int)$currentlogged < 10) $currentlogged = "0".$currentlogged;
		print "<li><strong style='padding:0 4px 0 4px;background:#e7f1c8;color:#777'>".$currentlogged."</strong> logged-in user(s)</li>";
	}
	if ((int)$currentauth > 0 AND $wassup_settings['wassup_widget_comauth'] == 1) {

	if ((int)$currentauth < 10) $currentauth = "0".$currentauth;
		print "<li><strong style='padding:0 4px 0 4px;background:#fbf9d3;color:#777'>".$currentauth."</strong> comment author(s)</li>";
	}
	print "<li style='font-size:6pt; color:#bbb;'>".__("powered by", "wassup")." <a style='color:#777;' href='http://www.wpwp.org/' title='WassUp - Real Time Visitors Tracking'>WassUp</a></li>";
	print "</ul>";
	print $after_widget;
} //end function wassup_sidebar
Exemplo n.º 3
0
			<li class="chartsT"><?php 
                _e("TOP VISITOR", "wassup");
                ?>
</li>
		<?php 
                if ($result) {
                    while ($top10 = mysql_fetch_array($result, MYSQL_ASSOC)) {
                        ?>
			<li class="charts"><?php 
                        echo $top10['top_visitor'] . ': ';
                        ?>
			<span class="top10" title="<?php 
                        echo $top10['visitor'];
                        ?>
"><?php 
                        echo stringShortener($top10['visitor'], $char_len);
                        ?>
</span>
			</li>
		<?php 
                    }
                    mysql_free_result($result);
                }
                //end if result
                mysql_query("DROP TABLE IF EXISTS {$tmptable}");
                ?>
		</ul>
		</td>
		<?php 
            }
            // end if topvisitor