| 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/SmartyWifidog.php'; |
|---|
| 29 | require_once (BASEPATH.'include/user_management_menu.php'); |
|---|
| 30 | require_once BASEPATH.'classes/Session.php'; |
|---|
| 31 | |
|---|
| 32 | if(CONF_USE_CRON_FOR_DB_CLEANUP == false) |
|---|
| 33 | { |
|---|
| 34 | garbage_collect(); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | $smarty = new SmartyWifidog; |
|---|
| 38 | |
|---|
| 39 | $portal_template = $_REQUEST['gw_id'] . ".html"; |
|---|
| 40 | |
|---|
| 41 | $db->ExecSqlUniqueRes("SELECT * FROM nodes WHERE node_id='". $db->EscapeString($_REQUEST['gw_id'])."'", $node_info); |
|---|
| 42 | if($node_info==null) |
|---|
| 43 | { |
|---|
| 44 | $smarty->assign('hotspot_name', UNKNOWN_HOSTPOT_NAME); |
|---|
| 45 | $hotspot_rss_url = UNKNOWN_HOTSPOT_RSS_URL; |
|---|
| 46 | } |
|---|
| 47 | else |
|---|
| 48 | { |
|---|
| 49 | $smarty->assign('hotspot_name', $node_info['name']); |
|---|
| 50 | $hotspot_rss_url = $node_info['rss_url']; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | /* Find out who is online */ |
|---|
| 54 | $db->ExecSql("SELECT users.user_id FROM users,connections " . |
|---|
| 55 | "WHERE connections.token_status='" . TOKEN_INUSE . "' " . |
|---|
| 56 | "AND users.user_id=connections.user_id " |
|---|
| 57 | ,$users, false); |
|---|
| 58 | if($users!=null) |
|---|
| 59 | { |
|---|
| 60 | foreach ($users as $user_info) |
|---|
| 61 | { |
|---|
| 62 | $smarty->append("online_users", $user_info); |
|---|
| 63 | } |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | if(RSS_SUPPORT) |
|---|
| 67 | { |
|---|
| 68 | $old_error_level = error_reporting(E_ERROR); |
|---|
| 69 | define('MAGPIE_DIR', BASEPATH.MAGPIE_REL_PATH); |
|---|
| 70 | require_once(MAGPIE_DIR.'rss_fetch.inc'); |
|---|
| 71 | define('MAGPIE_DEBUG', 0); |
|---|
| 72 | |
|---|
| 73 | /** |
|---|
| 74 | @return the generated html or the error message or an empty string if called without a URL. |
|---|
| 75 | */ |
|---|
| 76 | function generate_rss_html ( $url ) { |
|---|
| 77 | $rss_html=''; |
|---|
| 78 | if(!empty($url)) |
|---|
| 79 | { |
|---|
| 80 | $rss = fetch_rss( $url ); |
|---|
| 81 | $rss_html=''; |
|---|
| 82 | if ( !$rss ) |
|---|
| 83 | { |
|---|
| 84 | $rss_html .= _("Error: ") . magpie_error() ; |
|---|
| 85 | } |
|---|
| 86 | else |
|---|
| 87 | { |
|---|
| 88 | //$rss->show_channel(); |
|---|
| 89 | //$rss->show_list(); |
|---|
| 90 | $rss_html .= "<p>"._('Channel: ') . $rss->channel['title'] . "</p>\n"; |
|---|
| 91 | $rss_html .= "<ul>\n"; |
|---|
| 92 | foreach ($rss->items as $item) |
|---|
| 93 | { |
|---|
| 94 | //echo '<pre>'; print_r($item); echo '</pre>'; |
|---|
| 95 | $href = $item['link']; |
|---|
| 96 | $title = $item['title']; |
|---|
| 97 | $summary = $item['summary']; |
|---|
| 98 | $rss_html .= "<li><emp><a href=$href>$title</a></emp> $summary</li>\n"; |
|---|
| 99 | } |
|---|
| 100 | $rss_html .= "</ul>\n"; |
|---|
| 101 | } |
|---|
| 102 | } |
|---|
| 103 | return $rss_html; |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | $network_rss_html=generate_rss_html(NETWORK_RSS_URL); |
|---|
| 108 | //echo $networkrss_html; |
|---|
| 109 | $smarty->assign("network_rss_html", $network_rss_html); |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | $hotspot_rss_html=generate_rss_html($hotspot_rss_url); |
|---|
| 113 | //echo $hotspot_rss_html; |
|---|
| 114 | $smarty->assign("hotspot_rss_html", $hotspot_rss_html); |
|---|
| 115 | error_reporting($old_error_level); |
|---|
| 116 | } |
|---|
| 117 | $smarty->assign("user_management_menu", get_user_management_menu()); |
|---|
| 118 | $smarty->assign("user_management_url", BASE_SSL_PATH.USER_MANAGEMENT_PAGE); |
|---|
| 119 | |
|---|
| 120 | $session = new Session(); |
|---|
| 121 | $smarty->assign("original_url_requested",$session->get(SESS_ORIGINAL_URL_VAR)); |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) |
|---|
| 125 | { |
|---|
| 126 | $smarty->display(NODE_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME); |
|---|
| 127 | } |
|---|
| 128 | else |
|---|
| 129 | { |
|---|
| 130 | $smarty->display(DEFAULT_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME); |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | ?> |
|---|