/[drupal]/contributions/modules/hotspot/colubris.pages.inc
ViewVC logotype

Diff of /contributions/modules/hotspot/colubris.pages.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1, Wed Aug 19 17:16:46 2009 UTC revision 1.1.2.1, Wed Aug 19 17:16:46 2009 UTC
# Line 0  Line 1 
1    <?php
2    /**
3     * Drupal HotSpot Module * http://www.coova.org/CoovaChilli
4     * Copyright 2008-2009 (c) Coova Technologies, LLC.
5     * Licensed under the Gnu Public License.
6     */
7    
8    require_once drupal_get_path('module', 'hotspot').'/hotspot.inc';
9    
10    function hotspot_render($tid = 0) {
11      $tid = (int) $tid;
12    
13      if ($_REQUEST['page']) {
14        if ($_REQUEST['page'] == 'transport') {
15          print "<!-- Colubris -->\n";
16          print "<!-- Custom -->\n";
17          print '<html><title>Redirecting...</title><head>';
18          print '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.
19            url('hotspot/colubris',array('query'=>'res=success','absolute'=>true)).'">';
20          print '</head></html>';
21          exit;
22        }
23    
24        if ($_REQUEST['page'] == 'fail') {
25          print "<!-- Colubris -->\n";
26          print "<!-- Custom -->\n";
27          print '<html><title>Redirecting...</title><head>';
28          print '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.
29            url('hotspot/colubris',array('query'=>'res=failed','absolute'=>true)).'">';
30          print '</head></html>';
31          exit;
32        }
33    
34        if ($_REQUEST['page'] == 'session') {
35          print "<!-- Colubris -->\n";
36          print "<!-- Custom -->\n";
37          print '<html><title>Session</title></html>';
38          exit;
39        }
40    
41        if ($_REQUEST['page'] == 'logo') {
42          exit;
43        }
44      }
45    
46      if (isset($_REQUEST['_i']) && isset($_REQUEST['_p'])) {
47        $_SESSION['hotspot'] = 'true';
48        $_SESSION['controller'] = 'colubris';
49        $_SESSION['uamqs'] = $_SERVER['QUERY_STRING'];
50        $_SESSION['logouturl'] = 'http://'.$_REQUEST['_i'].':8080/goform/HtmlLogout';
51        $_SESSION['sessionurl'] = 'http://'.$_REQUEST['_i'].':8080/session.asp';
52    
53        colubris_set('ip','_c');
54        colubris_set('nasid','_n');
55        colubris_set('loginurl','_l');
56        colubris_set('uamip', '_i');
57        colubris_set('uamport','_p');
58        colubris_set('userurl','_o');
59        colubris_set('called','_C');
60        colubris_set('mac','_m');
61        colubris_set('reply','_r');
62    
63        module_invoke_all('hotspot_loginpage');
64    
65        $_SESSION['res'] = 'notyet';
66    
67        if ($_REQUEST['_r'] != '') {
68    
69          $_SESSION['res'] = 'failed';
70    
71        } else {
72          if (hotspot_setting('initial_redirect', '') != '') {
73            drupal_goto(hotspot_setting('initial_redirect', ''));
74            return;
75          }
76        }
77    
78        header('Location: '. url('hotspot/colubris', array('absolute'=>true)), TRUE, 302);
79        print '';
80        exit;
81      } else {
82        $res = $_REQUEST['res'];
83        if ($res == 'success' || $res == 'failed')
84          $_SESSION['res'] = $res;
85      }
86    
87      if ($_SESSION['res'] == 'notyet') {
88        if (hotspot_setting('method', 'redir') != 'js') {
89          if (hotspot_setting('provisioning', 'none') == 'anonymoususer') {
90            $username = hotspot_setting('auto_username', '');
91            $password = hotspot_setting('auto_password', '');
92          }
93        }
94    
95        if ($item = module_invoke_all('hotspot_dologin')) {
96          if (is_array($item)) {
97            $username = $item['username'];
98            $password = $item['password'];
99          }
100        }
101      }
102    
103      if (!$username) {
104        $username = hotspot_get_username($_REQUEST);
105      }
106    
107      if ($username) {
108        if (!$password) {
109          $password = hotspot_get_password($_REQUEST);
110        }
111    
112        $url = colubris_login_url($username, $password);
113    
114        header('Location: '. $url, TRUE, 302);
115        print hotspot_wispr_xml($url);
116    
117        exit();
118      }
119    
120      if ($_REQUEST['res'] == 'success') {
121        $success_redirect = hotspot_setting('success_redirect', '');
122        if ($success_redirect != '') {
123          if ($success_redirect == '<original>') {
124            drupal_goto(hotspot_get_param('userurl'));
125            return;
126          } else if ($success_redirect != '<popup>') {
127            drupal_goto(hotspot_setting('success_redirect', ''));
128            return;
129          }
130        }
131      }
132    
133      if ($_SESSION['renderNode']) {
134        $node = node_load(array('nid' => $_SESSION['renderNode']));
135        print theme('hotspot_page', $node);
136        return;
137      }
138    
139      print theme('page', hotspot_render_loginform());
140    }
141    
142    function colubris_login_url($u, $p) {
143      return colubris_get('loginurl') . '?username=' . $u . '&password=' . $p;
144    }
145    
146    function colubris_set($n, $k) {
147      if (isset($_REQUEST[$k])) $_SESSION[$n] = $_REQUEST[$k];
148    }
149    
150    function colubris_get($n) {
151      return $_SESSION[$n];
152    }
153    
154    function hotspot_render_loginform($tid = 0) {
155    
156      if (hotspot_setting('enabled', 'true') != 'true') {
157    
158        $content = hotspot_content($tid, 'disabled');
159    
160      } else {
161    
162        $content = hotspot_content($tid, colubris_get('res'));
163    
164      }
165    
166      return $content;
167    }
168    
169    function theme_hotspot_page(&$node) {
170      return node_view($node, false, true);
171    }
172    
173    function theme_hotspot_disabled(&$node) {
174      return '<p id="hotDisabled">HotSpot services are currently not available.</p>';
175    }
176    
177    function theme_hotspot_notyet(&$node) {
178      $userAgent = $_SERVER['HTTP_USER_AGENT'];
179    
180      if (preg_match("/profile\/midp/i", $userAgent) || preg_match("/configuration\/cldc/i", $userAgent)) {
181    
182        return theme_hotspot_loginform($node);
183    
184      } else {
185        $html = theme('hotspot_loginform', $node);
186    
187        if ($a = module_invoke_all('hotspot_links'))
188          foreach ($a as $b) $html .= $b;
189    
190        return $html;
191      }
192    }
193    
194    function theme_hotspot_failed(&$node) {
195      $reply = $_GET['reply'];
196      if ($reply == '') $reply = 'Authentication failed';
197      return '<p id="hotReply">'.$reply.'</p>'.theme('hotspot_loginform', $node);
198    }
199    
200    function theme_hotspot_success(&$node) {
201      $content = '<p>You are now on-line!</p>';
202      $url = hotspot_get_param('userurl');
203      if ($url != '') {
204        $content .= '<p>Original URL: <a href="'.$url.'">'.$url.'</a></p>';
205      }
206      $url = hotspot_get_param('logouturl');
207      if ($url != '') {
208        $content .= '<p><a href="'.$url.'">Logout</a></p>';
209      }
210      return $content;
211    }
212    
213    function theme_hotspot_loginform()
214    {
215      $html = '<div id="hotLoginForm">';
216    
217      if (hotspot_setting('loginform', 'true') == 'true') {
218        $html .= '
219    <form id="hotForm" name="form1" method="post" action="' . hotspot_get_param('loginurl') . '">
220      <table id="hotLoginFormTable" border="0" cellpadding="5" cellspacing="0">
221      <tbody>
222      <tr>
223        <td class="hotLoginFormLabel hotUsernameLabel">Username:</td>
224        <td class="hotLoginFormInput hotUsernameInput"><input id="hotUsername" type="text" name="username" size="20" maxlength="255"></td>
225      </tr>
226      <tr>
227        <td class="hotLoginFormLabel hotPasswordLabel">Password:</td>
228        <td class="hotLoginFormInput hotPasswordInput"><input id="hotPassword" type="password" name="password" size="20" maxlength="255"></td>
229      </tr>
230      <tr>
231        <td class="hotLoginFormSubmit" colspan="2"><input id="hotSubmit" type="submit" name="login" value="login"></td>
232      </tr>
233      </tbody>
234    </table>
235    </form>';
236      }
237    
238      $html .= '</div>';
239    
240      return $html;
241    }
242    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2