Oldtimer-Ticker

<?php
/*
Plugin Name: GoStats 
Plugin URI: http://gostats.com
Description: Add web tracking to your blog in seconds. 
Version: 1.4
Author: Richard Chmura
Author URI: http://gostats.com/
*/




add_action('admin_menu','gostats_admin');

function gostats_admin()
{

	if ( function_exists('add_submenu_page') ) {
		add_options_page('GoStats', 'GoStats', 9, basename(__FILE__), 'gostats_manage');
	}
}

function gostats_manage()
{
	if (isset($_POST['gostats_siteid'])) {
		update_option('gostats_siteid', $_POST['gostats_siteid']);
		update_option('gostats_server', substr($_POST['gostats_server'],0,7));

		echo '<div class="updated"><p><strong>Options saved</strong></p></div>';
	}

	$gostats_siteid = get_option('gostats_siteid');
        $gostats_server = get_option('gostats_server');

?>
<div class="wrap">
<h2>GoStats Options
</h2>
	
<form name="form1" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
	<fieldset class="options">Enter your Site id<br/>
	<input type="text" name="gostats_siteid" value="<?php echo stripslashes($gostats_siteid);?>">	
        <fieldset class="options">Enter your GoStats server (c1, monster, c3 or c4).  If 
		you do not see a server id in your summary url (login at <a href="http://gostats.com">      	        http://gostats.com</a> to see), try entering c1 as your server id.<br/>
        <input type="text" name="gostats_server" value="<?php echo stripslashes($gostats_server);?>">
<?php

	$gostats_siteid = get_option('gostats_siteid');
        $gostats_server = get_option('gostats_server');
	if (!empty($gostats_siteid)) {
		echo "&nbsp;<span>(<a href=\"http://";
                if (!empty($gostats_server)){
                    echo $gostats_server;
                }else{
                    echo "monster";
                }
                echo ".gostats.com/click.xml?";
		echo $gostats_siteid;
		echo "\">View stats &raquo;</a>)</span>";
	}else{
/*
		$file = file_get_contents("http://login.gostats.com/goapi/signup");
		$depth = array();

		function startElement($parser, $name, $attrs) 
		{
		   global $depth;
		   for ($i = 0; $i < $depth[$parser]; $i++) {
		       echo "  ";
		   }
		   echo "$name\n";
		   $depth[$parser]++;
		}

		function endElement($parser, $name) 
		{
		   global $depth;
		   $depth[$parser]--;
		}

		$xml_parser = xml_parser_create();
		xml_set_element_handler($xml_parser, "startElement", "endElement");
		echo $file;

		if (!xml_parse($xml_parser, $file)) {
		   die(sprintf("XML error: %s at line %d",
		               xml_error_string(xml_get_error_code($xml_parser)),
		               xml_get_current_line_number($xml_parser)));
		}
		
		xml_parser_free($xml_parser);
*/
	}
?>
	</fieldset>
	<p class="submit">
	<input type="submit" name="Submit" value="Update Options &raquo;" />
	</p>
</form>
</div>
<?php
}

add_action('wp_footer','gostats_getcode');

function gostats_getcode()
{
	global $gostats_siteid;
	global $gostats_server;

	$gostats_siteid = get_option('gostats_siteid');
	$gostats_server   = get_option('gostats_server');
	if (!empty($gostats_siteid)) {
echo "<!-- GoStats.com -->
<!-- GoStats JavaScript Based Code -->
<div id=\"gostats-code-for-wordpress-target\" class=\"site-footer\"><a href=\"http://gostats.com\">Analytics powered by GoStats</a><br /></div>
<script type='text/javascript' src='//gostats.com/js/counter.wp.js'></script>
<script type='text/javascript' src='//gostats.com/js/clickmap/clickmap.js'></script>
<script type='text/javascript'>
/* <![CDATA[ */
_gos='";
echo urlencode($gostats_server);
echo ".gostats.com';_goa=";
echo urlencode($gostats_siteid);
echo ";
_got=1;_goi=65;_gol='GoStats Web Analytics for WordPress';_GoStatsRun();
/* ]]> */
</script>
<noscript><a target=\"_blank\" title=\"GoStats Web Analytics for WordPress\" 
href=\"http://gostats.com\"><img alt=\"GoStats Web Analytics for WordPress\" 
src=\"//";
echo urlencode($gostats_server);
echo ".gostats.com/bin/count/a_";
echo urlencode($gostats_siteid);
echo "/t_1/i_65/counter.png\" 
style=\"border-width:0\" /></a></noscript>

<!-- End GoStats JavaScript Based Code -->
";

	}
}
?>