1<?php
2/**
3 * modified for GroURL by Krzysztof Burghardt <krzysztof@burghardt.pl>
4 */
5/**
6 * Google Analytics for DokuWiki
7 *
8 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 * @author     Terence J. Grant<tjgrant@tatewake.com>
10 */
11
12$gu_loaded = 0;
13
14function gu_load()
15{
16	global $gu_loaded, $gu_settings;
17
18	$gu_file = dirname(__FILE__).'/local_pref.php';
19
20	if ($gu_loaded == 0)
21	{
22		if(file_exists($gu_file))
23		{
24			include($gu_file);
25
26			$gu_loaded = 1;
27		}
28	}
29}
30
31function gu_write($fp, $name, $val)
32{
33	fwrite($fp, '$gu_settings[\''.$name.'\'] = \''.$val.'\';'."\n");
34}
35
36function gu_save()
37{
38	global $gu_loaded, $gu_settings;
39
40	$gu_file = dirname(__FILE__).'/local_pref.php';
41
42	if (is_writable($gu_file))
43	{
44		$fp = fopen($gu_file, "w");
45		fwrite($fp, '<?php'."\n// This file is automatically generated\n");
46		gu_write($fp, 'latitude', $gu_settings['latitude']);
47		gu_write($fp, 'longitude', $gu_settings['longitude']);
48		fclose($fp);
49
50		ptln('<div class="success">'.'GeoURL pref saved successfully.'.'</div>');
51	}
52	else
53	{
54		ptln('<div class="error">'.'GeoURL pref is not writable by the server.'.'</div>');
55	}
56}
57
58function gu_geourl_code()
59{
60	global $gu_loaded, $gu_settings, $conf;
61
62	if ($gu_settings['latitude'])
63	    if ($gu_settings['longitude'])
64	    {
65		ptln('  <meta name="ICBM" content="'.$gu_settings['latitude'].', '.$gu_settings['longitude'].'" />');
66		ptln('  <meta name="DC.title" content="'.$conf['title'].'" />');
67	    }
68}
69
70//Load settings
71gu_load();
72