root/wifidogadmin/wifidog/hotspots_map.php

Revision 479, 7.4 kB (checked in by insultant, 8 months ago)

--

Line 
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 // +-------------------------------------------------------------------+
6 // | WiFiDog Authentication Server                                     |
7 // | =============================                                     |
8 // |                                                                   |
9 // | The WiFiDog Authentication Server is part of the WiFiDog captive  |
10 // | portal suite.                                                     |
11 // +-------------------------------------------------------------------+
12 // | PHP version 5 required.                                           |
13 // +-------------------------------------------------------------------+
14 // | Homepage:     http://www.wifidog.org/                             |
15 // | Source Forge: http://sourceforge.net/projects/wifidog/            |
16 // +-------------------------------------------------------------------+
17 // | This program is free software; you can redistribute it and/or     |
18 // | modify it under the terms of the GNU General Public License as    |
19 // | published by the Free Software Foundation; either version 2 of    |
20 // | the License, or (at your option) any later version.               |
21 // |                                                                   |
22 // | This program is distributed in the hope that it will be useful,   |
23 // | but WITHOUT ANY WARRANTY; without even the implied warranty of    |
24 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the     |
25 // | GNU General Public License for more details.                      |
26 // |                                                                   |
27 // | You should have received a copy of the GNU General Public License |
28 // | along with this program; if not, contact:                         |
29 // |                                                                   |
30 // | Free Software Foundation           Voice:  +1-617-542-5942        |
31 // | 59 Temple Place - Suite 330        Fax:    +1-617-542-2652        |
32 // | Boston, MA  02111-1307,  USA       gnu@gnu.org                    |
33 // |                                                                   |
34 // +-------------------------------------------------------------------+
35
36 /**
37  * Network map/status page.
38  *
39  * @package    WiFiDogAuthServer
40  * @author     Francois Proulx <francois.proulx@gmail.com>
41  * @author     Max Horváth <max.horvath@freenet.de>
42  * @copyright  2005-2006 Francois Proulx, Technologies Coeus inc.
43  * @copyright  2006 Max Horváth, Horvath Web Consulting
44  * @version    Subversion $Id: hotspots_map.php 1316 2008-01-07 00:25:20Z benoitg $
45  * @link       http://www.wifidog.org/
46  */
47
48 /**
49  * Load required files
50  */
51 require_once(dirname(__FILE__) . '/include/common.php');
52
53 require_once('classes/MainUI.php');
54 require_once('classes/Network.php');
55 require_once('classes/Node.php');
56 require_once('classes/User.php');
57 require_once('classes/Server.php');
58 $smarty = SmartyWifidog::getObject();
59 // Get information about user
60 $currentUser = User::getCurrentUser();
61
62 // Check if Google maps support has been enabled
63 if (!defined("GMAPS_HOTSPOTS_MAP_ENABLED") || (defined("GMAPS_HOTSPOTS_MAP_ENABLED") && GMAPS_HOTSPOTS_MAP_ENABLED == false)) {
64     header("Location: hotspot_status.php");
65     exit();
66 }
67
68 // Check if user is at a Hotspot and if he is authenticated
69 /*This code is definitely not ready for prime time
70  * if (!is_null(Node::getCurrentRealNode()) && !$currentUser) {
71  header("Location: hotspot_status.php");
72  exit();
73  }*/
74
75 // Init ALL smarty SWITCH values
76 $smarty->assign('sectionMAINCONTENT', false);
77
78 // Init ALL smarty values
79 $smarty->assign('DEPRECATEDisSuperAdmin', false);
80 $smarty->assign('selectNetworkUI', null);
81
82 /**
83  * Define user security levels for the template
84  *
85  * These values are used in the default template of WiFoDog but could be used
86  * in a customized template to restrict certain links to specific user
87  * access levels.
88  */
89 $smarty->assign('DEPRECATEDisSuperAdmin', $currentUser && $currentUser->DEPRECATEDisSuperAdmin());
90
91 /*
92  * Header JavaScripts
93  */
94
95 // Add Google Maps JavaScript (must set config values)
96 if(!$vhost=VirtualHost::getCurrentVirtualHost()) {
97     throw new Exception(_("Unable to get the google API key, because I couldn't find a vhost matching the current hostname"));
98 }
99 $html_headers  = "<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;&key=" . $vhost->getGoogleAPIKey() . "' type='text/javascript'></script>";
100 $html_headers .= "<script src='js/hotspots_status_map.js' type='text/javascript'></script>";
101
102 $html = null;
103 /*
104  * Main content
105  */
106
107 // Set section of Smarty template
108 $smarty->assign('sectionMAINCONTENT', true);
109
110 // Set network selector
111 $preSelectedObject = (!empty($_REQUEST['network_map']) ? Network::getObject($_REQUEST['network_map']) : Network::getCurrentNetwork());
112 $selectNetworkUI = Network::getSelectUI('network_map', array('preSelectedObject' => $preSelectedObject));
113 $smarty->assign('selectNetworkUI', $selectNetworkUI . (count(Network::getAllNetworks()) > 1 ? '<input class="submit" type="submit" name="submit" value="' . _("Change network") . '">' : ""));
114
115 // Compile HTML code
116 $html_body = $smarty->fetch("templates/sites/hotspots_map.tpl");
117
118 /*
119  * Footer JavaScripts
120  */
121
122 // Get GIS data to set
123 if (!empty($_REQUEST['network_map'])) {
124     $network = Network::getObject($_REQUEST['network_map']);
125 } else {
126     $network = Network::getCurrentNetwork();
127 }
128
129 $gis_data = $network->getGisLocation();
130
131 // The onLoad code should only be called once all DIV are created.
132 $script  = "<script type=\"text/javascript\">//<![CDATA[\n";
133 $script .= "    function toggleOverlay(name)\n";
134 $script .= "    {\n";
135 $script .= "        o = document.getElementById('map_postalcode_overlay');\n";
136 $script .= "        if (o != undefined) {\n";
137 $script .= "            if (o.style.display == 'block') {\n";
138 $script .= "                o.style.display = 'none';\n";
139 $script .= "            } else {\n";
140 $script .= "                o.style.display = 'block';\n";
141 $script .= "            }\n";
142 $script .= "        }\n";
143 $script .= "    }\n";
144 $script .= "    translations = new HotspotsMapTranslations('" . addcslashes(_("Sorry, your browser does not support Google Maps."), "'") . "', '" . addcslashes(_("Homepage"), "'") . "', '" . addcslashes(_("Show me on the map"), "'") . "', '" . addcslashes(_("Loading, please wait..."), "'") . "');\n";
145 $script .= "    hotspots_map = new HotspotsMap('map_frame', 'hotspots_map', translations, '" . COMMON_IMAGES_URL . "');\n";
146 $script .= "    hotspots_map.setXmlSourceUrl('" . GMAPS_XML_SOURCE_URL . "');\n";
147 $script .= "    hotspots_map.setHotspotsInfoList('map_hotspots_list');\n";
148 $script .= "    hotspots_map.setInitialPosition(" . $gis_data->getLatitude() . ", " . $gis_data->getLongitude() . ", " . $gis_data->getAltitude() . ");\n";
149 $script .= "    hotspots_map.setMapType(" . $network->getGisMapType() . ");\n";
150 $script .= "    hotspots_map.redraw();\n";
151 $script .= "//]]>\n";
152 $script .= "</script>\n";
153
154 /*
155  * Render output
156  */
157 $ui = MainUI::getObject();
158 $ui->setTitle(_("Hotspots status map"));
159 $ui->appendHtmlHeadContent($html_headers);
160 $ui->addContent('left_area_middle', $html);
161 $ui->addContent('main_area_middle', $html_body);
162 $ui->addFooterScript($script);
163 $ui->display();
164
165 /*
166  * Local variables:
167  * tab-width: 4
168  * c-basic-offset: 4
169  * c-hanging-comment-ender-p: nil
170  * End:
171  */
172
173 ?>
Note: See TracBrowser for help on using the browser.