root/trunk/wifidog-auth/wifidog/portal/index.php @ 402

Revision 402, 5.2 KB (checked in by aprilp, 8 years ago)

Some kind of virtual login (we need to talk about this).
New User and Node classes
Modified all files to work with the classes.
Remove mgmt_helpers (all done in User class now)

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
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
26define('BASEPATH','../');
27require_once BASEPATH.'include/common.php';
28require_once BASEPATH.'include/common_interface.php';
29require_once BASEPATH.'classes/Node.php';
30
31if (CONF_USE_CRON_FOR_DB_CLEANUP == false) {
32    garbage_collect();
33}
34
35if (!isset($_REQUEST['gw_id'])) {
36    $smarty->display("templates/message_unknown_hotspot.html");
37    exit;
38}
39
40$portal_template = $_REQUEST['gw_id'] . ".html";
41$node_id = $db->EscapeString($_REQUEST['gw_id']);
42
43$node = Node::getObject($node_id);
44if ($node == null) {
45    $smarty->assign("gw_id", $_REQUEST['gw_id']);
46    $smarty->display("templates/message_unknown_hotspot.html");
47    exit;
48}
49
50$smarty->assign('hotspot_name', $node->getName());
51$hotspot_rss_url = $node->getRSSURL();
52
53/* Find out who is online */
54$smarty->assign("online_users", $node->getOnlineUsers());
55
56if (RSS_SUPPORT) {
57    //      $old_error_level = error_reporting(E_ERROR);
58    define('MAGPIE_DIR', BASEPATH.MAGPIE_REL_PATH);
59    //    require_once(MAGPIE_DIR.'rss_fetch.inc');
60    //    define('MAGPIE_DEBUG', 0);
61    require_once BASEPATH.'classes/RssPressReview.inc';
62    $press_review=new RssPressReview;
63    $tokens = "/[\s,]+/";
64    $network_rss_sources = NETWORK_RSS_URL;
65    $network_rss_html = null;
66    if(!empty($network_rss_sources))
67      {
68
69        $extract_array=null;
70        $extract_array = preg_split($tokens, $network_rss_sources);
71        //print_r($extract_array);
72        foreach($extract_array as $source)
73          {
74            $network_rss_sources_array[] = array('url' => $source, 'default_publication_interval' => 7*24*3600);
75          }
76        $network_rss_html=$press_review->get_rss_html($network_rss_sources_array, 5);
77      }
78                     
79    $hotspot_rss_html=null;
80    if(!empty($hotspot_rss_url))
81      {
82        $extract_array=null;
83        $extract_array = preg_split($tokens, $hotspot_rss_url);
84        //print_r($extract_array);
85        foreach($extract_array as $source)
86          {
87            $hotspot_rss_sources_array[] = array('url' => $source, 'default_publication_interval' => 7*24*3600);
88          }
89        $hotspot_rss_html=$press_review->get_rss_html($hotspot_rss_sources_array, 5);     
90      }
91    /**
92     @return the generated html or the error message or an empty string if called without a URL.
93    */
94    function generate_rss_html ( $url ) {
95      $rss_html='';
96      if(!empty($url))
97        {
98          $rss = fetch_rss( $url );
99          $rss_html='';
100          if ( !$rss )
101            {
102              $rss_html .= _("Error: ") . magpie_error() ;
103            }
104          else 
105            {
106              //$rss->show_channel();
107              //$rss->show_list();
108              $rss_html .= "<p>"._('Channel: ') . $rss->channel['title'] . "</p>\n";
109              $rss_html .= "<ul>\n";
110              foreach ($rss->items as $item)
111                {
112                  //echo '<pre>'; print_r($item);       echo '</pre>';
113                  $href = $item['link'];
114                  $title = $item['title'];
115                  $summary =  $item['summary']; 
116                  $rss_html .= "<li><emp><a href=$href>$title</a></emp> $summary</li>\n";
117                }
118              $rss_html .= "</ul>\n";
119            }
120        }
121      return $rss_html;
122    }
123
124
125    //$network_rss_html=generate_rss_html(NETWORK_RSS_URL);   
126    //echo $networkrss_html;
127    $smarty->assign("network_rss_html", $network_rss_html);
128
129   
130    //$hotspot_rss_html=generate_rss_html($hotspot_rss_url);   
131    //echo $hotspot_rss_html;
132    $smarty->assign("hotspot_rss_html", $hotspot_rss_html);
133    //   error_reporting($old_error_level);
134}
135
136if (isset($session)) {
137    $smarty->assign("original_url_requested", $session->get(SESS_ORIGINAL_URL_VAR));
138}
139
140$smarty->display(DEFAULT_CONTENT_SMARTY_PATH."header.html");
141
142/* If we have local content, display it. Otherwise, display default */
143if (is_file(NODE_CONTENT_PHP_RELATIVE_PATH.PORTAL_PAGE_NAME)) {
144    $smarty->display(NODE_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME);
145} else {
146    $smarty->display(DEFAULT_CONTENT_SMARTY_PATH.PORTAL_PAGE_NAME);
147}
148
149$smarty->display(DEFAULT_CONTENT_SMARTY_PATH."footer.html");
150?>
Note: See TracBrowser for help on using the browser.