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

Revision 368, 5.4 KB (checked in by aprilp, 8 years ago)

Merged templates

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