| 1 | <?php |
|---|
| 2 | // $Id$ |
|---|
| 3 | /********************************************************************\ |
|---|
| 4 | * This program is free software; you can redistribute it and/or * |
|---|
| 5 | * modify it under the terms of the GNU General Public License as * |
|---|
| 6 | * published by the Free Software Foundation; either version 2 of * |
|---|
| 7 | * the License, or (at your option) any later version. * |
|---|
| 8 | * * |
|---|
| 9 | * This program is distributed in the hope that it will be useful, * |
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
|---|
| 12 | * GNU General Public License for more details. * |
|---|
| 13 | * * |
|---|
| 14 | * You should have received a copy of the GNU General Public License* |
|---|
| 15 | * along with this program; if not, contact: * |
|---|
| 16 | * * |
|---|
| 17 | * Free Software Foundation Voice: +1-617-542-5942 * |
|---|
| 18 | * 59 Temple Place - Suite 330 Fax: +1-617-542-2652 * |
|---|
| 19 | * Boston, MA 02111-1307, USA gnu@gnu.org * |
|---|
| 20 | * * |
|---|
| 21 | \********************************************************************/ |
|---|
| 22 | /**@file index.php Displays the portal page |
|---|
| 23 | * @author Copyright (C) 2004 Benoit Gr�goire et Philippe April |
|---|
| 24 | */ |
|---|
| 25 | |
|---|
| 26 | define('BASEPATH','../'); |
|---|
| 27 | require_once BASEPATH.'include/common.php'; |
|---|
| 28 | require_once BASEPATH.'classes/Style.php';//Required to write http headers |
|---|
| 29 | require_once BASEPATH.'classes/SmartyWifidog.php'; |
|---|
| 30 | require_once (BASEPATH.'include/user_management_menu.php'); |
|---|
| 31 | require_once BASEPATH.'classes/Session.php'; |
|---|
| 32 | |
|---|
| 33 | if(CONF_USE_CRON_FOR_DB_CLEANUP == false) |
|---|
| 34 | { |
|---|
| 35 | garbage_collect(); |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | $smarty = new SmartyWifidog; |
|---|
| 39 | |
|---|
| 40 | $portal_template = $_REQUEST['gw_id'] . ".html"; |
|---|
| 41 | $node_id = $db->EscapeString($_REQUEST['gw_id']); |
|---|
| 42 | $db->ExecSqlUniqueRes("SELECT * FROM nodes WHERE node_id='$node_id'", $node_info); |
|---|
| 43 | if($node_info==null) |
|---|
| 44 | { |
|---|
| 45 | $smarty->assign('hotspot_name', UNKNOWN_HOSTPOT_NAME); |
|---|
| 46 | $hotspot_rss_url = UNKNOWN_HOTSPOT_RSS_URL; |
|---|
| 47 | } |
|---|
| 48 | else |
|---|
| 49 | { |
|---|
| 50 | $smarty->assign('hotspot_name', $node_info['name']); |
|---|
| 51 | $hotspot_rss_url = $node_info['rss_url']; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | /* Find out who is online */ |
|---|
| 55 | $db->ExecSql("SELECT users.user_id FROM users,connections " . |
|---|
| 56 | "WHERE connections.token_status='" . TOKEN_INUSE . "' " . |
|---|
| 57 | "AND users.user_id=connections.user_id AND connections.node_id='$node_id' " |
|---|
| 58 | ,$users, false); |
|---|
| 59 | if($users!=null) |
|---|
| 60 | { |
|---|
| 61 | foreach ($users as $user_info) |
|---|
| 62 | { |
|---|
| 63 | $smarty->append("online_users", $user_info); |
|---|
| 64 | } |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | if(RSS_SUPPORT) |
|---|
| 68 | { |
|---|
| 69 | $old_error_level = error_reporting(E_ERROR); |
|---|
| 70 | define('MAGPIE_DIR', BASEPATH.MAGPIE_REL_PATH); |
|---|
| 71 | require_once(MAGPIE_DIR.'rss_fetch.inc'); |
|---|
| 72 | define('MAGPIE_DEBUG', 0); |
|---|
| 73 | |
|---|
| 74 | /** |
|---|
| 75 | @return the generated html or the error message or an empty string if called without a URL. |
|---|
| 76 | */ |
|---|
| 77 | function generate_rss_html ( $url ) { |
|---|
| 78 | $rss_html=''; |
|---|
| 79 | if(!empty($url)) |
|---|
| 80 | { |
|---|
| 81 | $rss = fetch_rss( $url ); |
|---|
| 82 | $rss_html=''; |
|---|
| 83 | if ( !$rss ) |
|---|
| 84 | { |
|---|
| 85 | $rss_html .= _("Error: ") . magpie_error() ; |
|---|
| 86 | } |
|---|
| 87 | else |
|---|
| 88 | { |
|---|
| 89 | //$rss->show_channel(); |
|---|
| 90 | //$rss->show_list(); |
|---|
| 91 | $rss_html .= "<p>"._('Channel: ') . $rss->channel['title'] . "</p>\n"; |
|---|
| 92 | $rss_html .= "<ul>\n"; |
|---|
| 93 | foreach ($rss->items as $item) |
|---|
| 94 | { |
|---|
| 95 | //echo '<pre>'; print_r($item); echo '</pre>'; |
|---|
| 96 | $href = $item['link']; |
|---|
| 97 | $title = $item['title']; |
|---|
| 98 | $summary = $item['summary']; |
|---|
| 99 | $rss_html .= "<li><emp><a href=$href>$title</a></emp> $summary</li>\n"; |
|---|
| 100 | } |
|---|
| 101 | $rss_html .= "</ul>\n"; |
|---|
| 102 | } |
|---|
| 103 | } |
|---|
| 104 | return $rss_html; |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | $network_rss_html=generate_rss_html(NETWORK_RSS_URL); |
|---|
| 109 | //echo $networkrss_html; |
|---|
| 110 | $smarty->assign("network_rss_html", $network_rss_html); |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | $hotspot_rss_html=generate_rss_html($hotspot_rss_url); |
|---|
| 114 | //echo $hotspot_rss_html; |
|---|
| 115 | $smarty->assign("hotspot_rss_html", $hotspot_rss_html); |
|---|
| 116 | error_reporting($old_error_level); |
|---|
| 117 | } |
|---|
| 118 | $smarty->assign("user_management_menu", get_user_management_menu()); |
|---|
| 119 | $smarty->assign("user_management_url", BASE_SSL_PATH.USER_MANAGEMENT_PAGE); |
|---|
| 120 | |
|---|
| 121 | $session = new Session(); |
|---|
| 122 | $smarty->assign("original_url_requested",$session->get(SESS_ORIGINAL_URL_VAR)); |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) |
|---|
| 126 | { |
|---|
| 127 | $smarty->display(NODE_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME); |
|---|
| 128 | } |
|---|
| 129 | else |
|---|
| 130 | { |
|---|
| 131 | $smarty->display(DEFAULT_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME); |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | ?> |
|---|