Exemple #1
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
Exemple #2
0
            //bad date sent
            echo '<span style="color:red;">Action.php ' . __("ERROR: bad date", "wassup") . ', ' . $to_date . '</span>';
            exit;
        }
        //#perform action and display output
        //
        // ACTION: RUN SPY VIEW
        if ($_GET['action'] == "spy") {
            if (empty($rows)) {
                $rows = 999;
            }
            spyview($from_date, $to_date, $rows, $wassup_options->wassup_default_spy_type);
            // ACTION: SUMMARY PIE CHART
        } elseif ($_GET['action'] == "piechart") {
            // Prepare Pie Chart
            $Tot = new MainItems();
            $Tot->tableName = $table_name;
            $Tot->from_date = $from_date;
            $Tot->to_date = $to_date;
            $items_pie[] = $Tot->calc_tot("count", $search, "AND spam>0", "DISTINCT");
            $items_pie[] = $Tot->calc_tot("count", $search, "AND searchengine!='' AND spam=0", "DISTINCT");
            $items_pie[] = $Tot->calc_tot("count", $search, "AND searchengine='' AND referrer NOT LIKE '%" . $this->WpUrl . "%' AND referrer!='' AND spam=0", "DISTINCT");
            $items_pie[] = $Tot->calc_tot("count", $search, "AND searchengine='' AND (referrer LIKE '%" . $this->WpUrl . "%' OR referrer='') AND spam=0", "DISTINCT");
            ?>
		<div style="text-align: center"><img src="http://chart.apis.google.com/chart?cht=p3&amp;chco=0000ff&amp;chs=600x300&amp;chl=Spam|Search%20Engine|Referrer|Direct&amp;chd=<?php 
            chart_data($items_pie, null, null, null, 'pie');
            ?>
" /></div>


	<?php