| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | // $Id$ |
|---|
| 4 | /********************************************************************\ |
|---|
| 5 | * This program is free software; you can redistribute it and/or * |
|---|
| 6 | * modify it under the terms of the GNU General Public License as * |
|---|
| 7 | * published by the Free Software Foundation; either version 2 of * |
|---|
| 8 | * the License, or (at your option) any later version. * |
|---|
| 9 | * * |
|---|
| 10 | * This program is distributed in the hope that it will be useful, * |
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
|---|
| 13 | * GNU General Public License for more details. * |
|---|
| 14 | * * |
|---|
| 15 | * You should have received a copy of the GNU General Public License* |
|---|
| 16 | * along with this program; if not, contact: * |
|---|
| 17 | * * |
|---|
| 18 | * Free Software Foundation Voice: +1-617-542-5942 * |
|---|
| 19 | * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * |
|---|
| 20 | * Boston, MA 02111-1307, USA gnu@gnu.org * |
|---|
| 21 | * * |
|---|
| 22 | \********************************************************************/ |
|---|
| 23 | /**@file index.php Displays the portal page |
|---|
| 24 | * @author Copyright (C) 2004 Benoit Gr�goire et Philippe April |
|---|
| 25 | */ |
|---|
| 26 | |
|---|
| 27 | define('BASEPATH', '../'); |
|---|
| 28 | require_once BASEPATH.'include/common.php'; |
|---|
| 29 | require_once BASEPATH.'include/common_interface.php'; |
|---|
| 30 | require_once BASEPATH.'classes/Node.php'; |
|---|
| 31 | require_once BASEPATH.'classes/MainUI.php'; |
|---|
| 32 | define('TOOLBAR_WIDTH','250');//Must match the stylesheet for the tool section width |
|---|
| 33 | |
|---|
| 34 | $node = null; |
|---|
| 35 | if (!empty ($_REQUEST['gw_id'])) |
|---|
| 36 | $node = Node :: getObject($_REQUEST['gw_id']); |
|---|
| 37 | |
|---|
| 38 | if ($node == null) |
|---|
| 39 | { |
|---|
| 40 | $smarty->display("templates/message_unknown_hotspot.html"); |
|---|
| 41 | exit; |
|---|
| 42 | } |
|---|
| 43 | $network = $node->getNetwork(); |
|---|
| 44 | |
|---|
| 45 | /* If this node has a custom portal defined, and the network config allows it, redirect to the custom portal */ |
|---|
| 46 | $custom_portal_url = $node->getCustomPortalRedirectUrl(); |
|---|
| 47 | if(!empty($custom_portal_url) && $network->getCustomPortalRedirectAllowed()) |
|---|
| 48 | { |
|---|
| 49 | header("Location: {$custom_portal_url}"); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | $node_id = $node->getId(); |
|---|
| 54 | $portal_template = $node_id.".html"; |
|---|
| 55 | Node :: setCurrentNode($node); |
|---|
| 56 | |
|---|
| 57 | $ui = new MainUI(); |
|---|
| 58 | if (isset ($session)) |
|---|
| 59 | { |
|---|
| 60 | if(!empty($_REQUEST['gw_id'])) |
|---|
| 61 | $session->set(SESS_GW_ID_VAR, $_REQUEST['gw_id']); |
|---|
| 62 | |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | $tool_html = ''; |
|---|
| 66 | |
|---|
| 67 | $tool_html .= "<h1>"._("Online users")."</h1>"."\n"; |
|---|
| 68 | $tool_html .= '<p class="indent">'."\n"; |
|---|
| 69 | $current_node = Node :: getCurrentNode(); |
|---|
| 70 | if ($current_node != null) |
|---|
| 71 | { |
|---|
| 72 | $current_node_id = $current_node->getId(); |
|---|
| 73 | $online_users = $current_node->getOnlineUsers(); |
|---|
| 74 | $num_online_users = count($online_users); |
|---|
| 75 | if ($num_online_users > 0) |
|---|
| 76 | { |
|---|
| 77 | //$tool_html .= $num_online_users.' '._("other users online at this hotspot..."); |
|---|
| 78 | $tool_html .= "<ul class='users_list'>\n"; |
|---|
| 79 | foreach($online_users as $online_user) |
|---|
| 80 | $tool_html .= "<li>{$online_user->getUsername()}</li>\n"; |
|---|
| 81 | $tool_html .= "</ul>\n"; |
|---|
| 82 | } |
|---|
| 83 | else |
|---|
| 84 | { |
|---|
| 85 | $tool_html .= _("Nobody is online at this hotspot..."); |
|---|
| 86 | } |
|---|
| 87 | } |
|---|
| 88 | else |
|---|
| 89 | { |
|---|
| 90 | $network = Network::getCurrentNetwork(); |
|---|
| 91 | $current_node_id = null; |
|---|
| 92 | $tool_html .= _("You are not currently at a hotspot..."); |
|---|
| 93 | } |
|---|
| 94 | $tool_html .= "</p>"."\n"; |
|---|
| 95 | |
|---|
| 96 | $tool_html .= '<script type="text/javascript"> |
|---|
| 97 | function getElementById(id) { |
|---|
| 98 | if (document.all) { |
|---|
| 99 | return document.getElementById(id); |
|---|
| 100 | } |
|---|
| 101 | for (i=0;i<document.forms.length;i++) { |
|---|
| 102 | if (document.forms[i].elements[id]) {return document.forms[i].elements[id]; } |
|---|
| 103 | } |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | function getWindowSize(window) { |
|---|
| 107 | var size_array = new Array(2); |
|---|
| 108 | var myWidth = 0, myHeight = 0; |
|---|
| 109 | if( typeof( window.innerWidth ) == "number" ) { |
|---|
| 110 | //Non-IE |
|---|
| 111 | myWidth = window.innerWidth; |
|---|
| 112 | myHeight = window.innerHeight; |
|---|
| 113 | } else if( document.documentElement && |
|---|
| 114 | ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { |
|---|
| 115 | //IE 6+ in "standards compliant mode" |
|---|
| 116 | myWidth = document.documentElement.clientWidth; |
|---|
| 117 | myHeight = document.documentElement.clientHeight; |
|---|
| 118 | } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { |
|---|
| 119 | //IE 4 compatible |
|---|
| 120 | myWidth = document.body.clientWidth; |
|---|
| 121 | myHeight = document.body.clientHeight; |
|---|
| 122 | } |
|---|
| 123 | size_array[0] = myWidth; |
|---|
| 124 | size_array[1] = myHeight; |
|---|
| 125 | // window.alert( "Width = " + myWidth ); |
|---|
| 126 | // window.alert( "Height = " + myHeight ); |
|---|
| 127 | return size_array; |
|---|
| 128 | } |
|---|
| 129 | |
|---|
| 130 | |
|---|
| 131 | </script>'; |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | $tool_html .= '<p class="indent">'."\n"; |
|---|
| 135 | $tool_html .= "<a id='wifidog_portal_expand' onclick=\" |
|---|
| 136 | var wifidog_portal_expand = getElementById('wifidog_portal_expand'); |
|---|
| 137 | var wifidog_portal_collapse = getElementById('wifidog_portal_collapse'); |
|---|
| 138 | |
|---|
| 139 | wifidog_portal_expand.style.display = 'none'; |
|---|
| 140 | wifidog_portal_collapse.style.display = 'inline'; |
|---|
| 141 | var size_array = getWindowSize(window.opener); |
|---|
| 142 | window.resizeTo(size_array[0],size_array[1]); |
|---|
| 143 | \">"._("Expand portal")."</a>"."\n"; |
|---|
| 144 | |
|---|
| 145 | $tool_html .= "<a id='wifidog_portal_collapse' onclick=\" |
|---|
| 146 | var wifidog_portal_expand = getElementById('wifidog_portal_expand'); |
|---|
| 147 | var wifidog_portal_collapse = getElementById('wifidog_portal_collapse'); |
|---|
| 148 | |
|---|
| 149 | wifidog_portal_expand.style.display = 'inline'; |
|---|
| 150 | wifidog_portal_collapse.style.display = 'none'; |
|---|
| 151 | var size_array = getWindowSize(window.opener); |
|---|
| 152 | window.resizeTo('".TOOLBAR_WIDTH."',size_array[1]); |
|---|
| 153 | |
|---|
| 154 | \">"._("Collapse portal")."</a>"."\n"; |
|---|
| 155 | $tool_html .= "</p>"."\n"; |
|---|
| 156 | |
|---|
| 157 | |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | $original_url_requested=$session->get(SESS_ORIGINAL_URL_VAR); |
|---|
| 161 | if(empty($original_url_requested)) |
|---|
| 162 | { |
|---|
| 163 | $url="missing_original_url.php"; |
|---|
| 164 | } |
|---|
| 165 | else |
|---|
| 166 | { |
|---|
| 167 | $url=$original_url_requested; |
|---|
| 168 | } |
|---|
| 169 | $tool_html .= '<p class="indent">'."\n"; |
|---|
| 170 | $tool_html .= "<a id='wifidog_use_internet' href='$url' onclick=\" |
|---|
| 171 | var size_array = getWindowSize(window); |
|---|
| 172 | var original_location=window.location.href; |
|---|
| 173 | //this.target='_blank'; |
|---|
| 174 | var old_window = window; |
|---|
| 175 | var new_window = window.open('".CURRENT_REQUEST_URL."','wifidog_portal'); |
|---|
| 176 | new_window.blur(); |
|---|
| 177 | old_window.focus(); |
|---|
| 178 | new_window.resizeTo('".TOOLBAR_WIDTH."',size_array[1]); |
|---|
| 179 | |
|---|
| 180 | //old_window.location.href='test'; |
|---|
| 181 | //window.moveBy(300, 300); |
|---|
| 182 | /*if(window.open){alert('window.open enabled');} |
|---|
| 183 | else{alert('window.open DISABLED');}*/ |
|---|
| 184 | |
|---|
| 185 | \"><img src='/images/start.gif'></a>\n"; |
|---|
| 186 | $tool_html .= "</p>"."\n"; |
|---|
| 187 | |
|---|
| 188 | $tool_html .= '<script type="text/javascript"> |
|---|
| 189 | //Set up if expand/collapse functionnality is to be enabled by checking if we were called from another portal window. |
|---|
| 190 | |
|---|
| 191 | window.is_wifidog_portal=true; //This assignement may be read by another window |
|---|
| 192 | |
|---|
| 193 | var wifidog_portal_expand = document.getElementById("wifidog_portal_expand"); |
|---|
| 194 | var wifidog_portal_collapse = document.getElementById("wifidog_portal_collapse"); |
|---|
| 195 | var wifidog_use_internet = document.getElementById("wifidog_use_internet"); |
|---|
| 196 | if(window.opener && window.opener.is_wifidog_portal==true) |
|---|
| 197 | { |
|---|
| 198 | wifidog_portal_expand.style.display = "inline"; |
|---|
| 199 | wifidog_portal_collapse.style.display = "none"; |
|---|
| 200 | wifidog_use_internet.style.display = "none"; |
|---|
| 201 | } |
|---|
| 202 | else |
|---|
| 203 | { |
|---|
| 204 | wifidog_portal_expand.style.display = "none"; |
|---|
| 205 | wifidog_portal_collapse.style.display = "none"; |
|---|
| 206 | } |
|---|
| 207 | </script>'; |
|---|
| 208 | |
|---|
| 209 | $ui->setToolContent($tool_html); |
|---|
| 210 | |
|---|
| 211 | $hotspot_network_name = $network->getName(); |
|---|
| 212 | $hotspot_network_url = $network->getHomepageURL(); |
|---|
| 213 | $network_logo_url = COMMON_CONTENT_URL.NETWORK_LOGO_NAME; |
|---|
| 214 | $network_logo_banner_url = COMMON_CONTENT_URL.NETWORK_LOGO_BANNER_NAME; |
|---|
| 215 | |
|---|
| 216 | $hotspot_logo_banner_url = find_local_content_url(HOTSPOT_LOGO_BANNER_NAME); |
|---|
| 217 | |
|---|
| 218 | // Get the current user |
|---|
| 219 | $current_user = User :: getCurrentUser(); |
|---|
| 220 | |
|---|
| 221 | $html = ''; |
|---|
| 222 | |
|---|
| 223 | // While in validation period, alert user that he should validate his account ASAP |
|---|
| 224 | if($current_user && $current_user->getAccountStatus() == ACCOUNT_STATUS_VALIDATION) |
|---|
| 225 | $html .= "<div id='warning_message_area'>"._('An email with confirmation instructions was sent to your email address. Your account has been granted 15 minutes of access to retrieve your email and validate your account.')."</div>"; |
|---|
| 226 | |
|---|
| 227 | $html .= "<div id='portal_container'>\n"; |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | /* Network section */ |
|---|
| 231 | |
|---|
| 232 | // This table ( width 100% ) force each section to display on top of each other, even though the content will float |
|---|
| 233 | // Until we find a better solution CSS only... |
|---|
| 234 | $html .= "<table><tr><td>"; |
|---|
| 235 | $html .= "<div class='portal_network_section'>\n"; |
|---|
| 236 | $html .= "<a href='{$hotspot_network_url}'><img class='portal_section_logo' alt='{$hotspot_network_name} logo' src='{$network_logo_banner_url}' border='0'></a>\n"; |
|---|
| 237 | // Get all network content and EXCLUDE user subscribed content |
|---|
| 238 | if($current_user) |
|---|
| 239 | $contents = Network :: getCurrentNetwork()->getAllContent(true, $current_user); |
|---|
| 240 | else |
|---|
| 241 | $contents = Network :: getCurrentNetwork()->getAllContent(); |
|---|
| 242 | if ($contents) |
|---|
| 243 | { |
|---|
| 244 | foreach ($contents as $content) |
|---|
| 245 | { |
|---|
| 246 | if ($content->isDisplayableAt($node)) |
|---|
| 247 | { |
|---|
| 248 | $html .= "<div class='portal_content'>\n"; |
|---|
| 249 | $html .= $content->getUserUI(); |
|---|
| 250 | $html .= "</div>\n"; |
|---|
| 251 | } |
|---|
| 252 | } |
|---|
| 253 | } |
|---|
| 254 | $html .= "</div>\n"; |
|---|
| 255 | $html .= "</td></tr></table>"; |
|---|
| 256 | |
|---|
| 257 | /* Node section */ |
|---|
| 258 | // Get all node content and EXCLUDE user subscribed content |
|---|
| 259 | if($current_user) |
|---|
| 260 | $contents = $node->getAllContent(true, $current_user); |
|---|
| 261 | else |
|---|
| 262 | $contents = $node->getAllContent(); |
|---|
| 263 | if($contents) |
|---|
| 264 | { |
|---|
| 265 | $html .= "<table><tr><td>"; |
|---|
| 266 | $html .= "<div class='portal_node_section'>\n"; |
|---|
| 267 | $html .= "<span class='portal_section_title'>"._("Content from:")." "; |
|---|
| 268 | $node_homepage = $node->getHomePageURL(); |
|---|
| 269 | if (!empty ($node_homepage)) |
|---|
| 270 | { |
|---|
| 271 | $html .= "<a href='$node_homepage'>"; |
|---|
| 272 | } |
|---|
| 273 | $html .= $node->getName(); |
|---|
| 274 | if (!empty ($node_homepage)) |
|---|
| 275 | { |
|---|
| 276 | $html .= "</a>\n"; |
|---|
| 277 | } |
|---|
| 278 | $html .= "</span>"; |
|---|
| 279 | foreach ($contents as $content) |
|---|
| 280 | { |
|---|
| 281 | if ($content->isDisplayableAt($node)) |
|---|
| 282 | { |
|---|
| 283 | $html .= "<div class='portal_content'>\n"; |
|---|
| 284 | $html .= $content->getUserUI(); |
|---|
| 285 | $html .= "</div>\n"; |
|---|
| 286 | } |
|---|
| 287 | } |
|---|
| 288 | $html .= "</div>\n"; |
|---|
| 289 | $html .= "</td></tr></table>"; |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | /* User section */ |
|---|
| 293 | if($current_user) |
|---|
| 294 | { |
|---|
| 295 | $contents = User :: getCurrentUser()->getAllContent(); |
|---|
| 296 | if($contents) |
|---|
| 297 | { |
|---|
| 298 | $html .= "<table><tr><td>"; |
|---|
| 299 | $html .= "<div class='portal_user_section'>\n"; |
|---|
| 300 | $html .= "<h1>"._("My content")."</h1>\n"; |
|---|
| 301 | foreach ($contents as $content) |
|---|
| 302 | { |
|---|
| 303 | $html .= "<div class='portal_content'>\n"; |
|---|
| 304 | $html .= $content->getUserUI(); |
|---|
| 305 | $html .= "</div>\n"; |
|---|
| 306 | } |
|---|
| 307 | $html .= "</div>\n"; |
|---|
| 308 | $html .= "</td></tr></table>"; |
|---|
| 309 | } |
|---|
| 310 | } |
|---|
| 311 | |
|---|
| 312 | // Hyperlinks to full content display page |
|---|
| 313 | $html .= "<a href='/content/?gw_id={$current_node_id}'>"._("Show all available contents for this hotspot")."</a>"."\n"; |
|---|
| 314 | |
|---|
| 315 | $html .= "<div style='clear:both;'></div>"; |
|---|
| 316 | $html .= "</div>\n"; |
|---|
| 317 | |
|---|
| 318 | $ui->setMainContent($html); |
|---|
| 319 | $ui->display(); |
|---|
| 320 | ?> |
|---|