Tagged: PHP

Demo Webservice

A while ago I wrote a little PHP-application for demostrating webmonitors in System Center Operations Manager 2007.
It will probably work for any monitoring solution that catches http errorcodes or textstrings on a page.

Free to use, so give it a try. 🙂

You can find it at: http://snowland.se/demo/

Google: Analytics2KML

Hittade ett inlägg om hur man kan göra om Google Analytics-data till en Google Earth-KML… http://bogomip.net/blog/google-analytics-and-google-earth/

Men… vad ska man med C-kod till när man har PHP 🙂

Eftersom inlägget är på engelska och ganska så väl-digg’at så skriver jag vidare på engelska…

Sorry for the Swedish note
Since I’m track-backing the blogentry… I might need to explain this in english.
Well… I wrote a small hack to go from Google Analytics to Google Earth with a little help of PHP.

To use this… go to Google Analytics / Marketing Optimization / Visitor Segment Performance / Geo Map Overlay
Then export to XML. Save the XML-file as analytics2kml.xml and upload it next to the php-files below.

Use the 2 files below to create a nice way to link it from any webpage. You need to create the link to analytics2kml-starter.php

analytics2kml.php

';
$kml_output.='';
$kml_output.="

	Analytics 2 kml


	Analytics 2 kml
	";
echo $kml_output;

// --- Loop thru array
$initRows = 8;
$totalRows = count($xmlArr["URCHINDATA"]["0"]) - $initRows;

for ($i = 0; $i <= $totalRows; $i++) {
	$pointStr  = $xmlArr["URCHINDATA"]["0"][$i]["NAME"];
	$pointStr .= "|" . $xmlArr["URCHINDATA"]["0"][$i]["VALUE1"];
	$pointStr .= "|" . $xmlArr["URCHINDATA"]["0"][$i]["VALUE2"];

	$pointArr = explode("|", $pointStr);

	$nameArr = explode("-", $pointArr["0"]);

	$pointname = $nameArr["1"];
	$longitude = $pointArr["2"] / 10000;
	$latitude = $pointArr["1"] / 10000;

	$kml_description = "Visits: " . $pointArr["3"] . "
Pages/Visit: " . $pointArr["4"] . "
" . $nameArr["0"] . " / " . $nameArr["1"]; $kml_description = " $pointname $kml_description #googelicon $longitude,$latitude,0 "; echo $kml_output; } // -- Finnish off the kml echo "
"; ?>

analytics2kml-starter.php

';
	$kml_output.='';

	$kml_output.='
		
			Analytics 2 kml
			
				http://www.snowland.se/a2k/analytics2kml.php
				never
			
		';
	$kml_output.='';

	echo $kml_output;
?>