root/wifidog/tags/wifidog-auth_1.0/node_export0.php

Revision 395, 5.6 kB (checked in by syrus, 1 year ago)

Version Prod 20071208

Line 
1 <?php
2 /**
3  * Permet d'afficher les statuts du r?seau.
4  *
5  * @author    Thus0 <thus0@free.fr>
6  * @author    prospere@nantes-wireless.org
7  * @author    pascal.rullier@wireless-fr.org
8  * @copyright    2007 Thus0
9  * @link    http://auth.wireless-fr.org/
10  */
11
12 /**
13  * Load required files
14  */
15 require_once(dirname(__FILE__) . '/include/common.php');
16
17 require_once('include/common_interface.php');
18 require_once('classes/Network.php');
19 require_once('classes/Node.php');
20 require_once('classes/NodeList.php');
21
22 global $db;
23 $body_html = "";
24 $network = "";
25
26 if (!empty ($_REQUEST['format'])) {
27   $format = $db->escapeString($_REQUEST['format']);
28 } else {
29   $format = "JavaScript";
30 }
31
32 if (!empty ($_REQUEST['gw_id'])) {
33   try {
34     $node = Node::getObject($db->escapeString($_REQUEST['gw_id']));
35     $network = $node->getNetwork();
36   } catch (Exception $e) {
37     exit;
38   }
39 } else {
40   $node = "";
41 }
42
43 if (!empty ($_REQUEST['network_id'])) {
44   try {
45     $network = Network::getObject($db->escapeString($_REQUEST['network_id']));
46   } catch (Exception $e) {
47     exit;
48   }
49 } else {
50   // $network = Network::getDefaultNetwork(true);
51 }
52
53
54 if ($node) {
55   $body_html .= "<div id=\"node_status\">";
56   $body_html .= "  <div id=\"node_status_title\">" . $node->getName() . "</div>";
57   $body_html .= "</div>";
58
59   $body_html .= "<div id=\"node_users_status\">";
60   $body_html .= "  <div id=\"node_users_status_title\"><a href=\"http://auth.wireless-fr.org/node_status.php\">Utilisateurs connect&eacute;s en WiFi : ";
61
62   $online_users = $node->getOnlineUsers();
63   $num_online_users = count($online_users);
64  
65   $body_html .= $num_online_users . "</a>";
66   $body_html .= "  </div>";
67  
68   $body_html .= "  <div id=\"network_users_list\">";
69   $body_html .= "    <ul> ";
70  
71   $numUser = 0;
72   if ($online_users != null){
73     foreach ($online_users as $online_user) {
74       $numUser++;
75       //$body_html .= "    <li>$online_user[username]</li>";
76       if ($numUser == $num_online_users) {
77         $body_html .= $online_user->getUserName();
78       } else {
79         $body_html .= $online_user->getUserName() . " - ";
80       }
81     }
82   } else {
83     // $body_html .= "<li>Aucune personne</li>";
84   }
85
86   $body_html .= "    </ul>";
87   $body_html .= "  </div>";
88   $body_html .= "</div>";
89 }
90
91 if ($network) {
92   $body_html .= "<div id=\"network_status\">";
93   $body_html .= "  <div id=\"network_status_title\">" . $network->getName() . "</div>";
94   $body_html .= "  <div id=\"network_nodes_deployed\">D&eacute;ploy&eacute;s&nbsp;:&nbsp;" . $network->getNumDeployedNodes() . "</div>";
95   $body_html .= "  <div id=\"network_nodes_online\">En&nbsp;fonctionnement&nbsp;:&nbsp;" . $network->getNumOnlineNodes() . "</div>";
96   $body_html .= "</div>";
97
98   $body_html .= "<div id=\"network_users_status\">";
99   $body_html .= "  <div id=\"network_users_status_title\"><a href=\"http://auth.wireless-fr.org/node_status.php\">Utilisateurs connect&eacute;s en WiFi : ";
100
101   $online_users = null;
102   $db->execSql("SELECT username,nodes.node_id FROM connections,users,nodes WHERE token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND nodes.node_id=connections.node_id AND nodes.network_id='".$network->getId()."' ORDER BY account_origin, timestamp_in DESC", $online_users);
103  
104   $Network_OnlineUsers = count($online_users);
105
106   $body_html .= $Network_OnlineUsers . "</a>";
107   $body_html .= "  </div>";
108
109   $body_html .= "  <div id=\"users_list\">";
110   $body_html .= "    <ul> ";
111
112   $numUser = 0;
113   if ($online_users != null){
114     foreach ($online_users as $online_user) {
115       $numUser++;
116       //$body_html .= "    <li>$online_user[username]</li>";
117       if ($numUser == $Network_OnlineUsers) {
118         $body_html .= "$online_user[username]";
119       } else {
120         $body_html .= "$online_user[username] - ";
121       }
122     }
123   } else {
124     // $body_html .= "<li>Aucune personne</li>";
125   }
126
127   $body_html .= "    </ul>";
128   $body_html .= "  </div>";
129   $body_html .= "</div>";
130
131 }
132
133 $network_array = Network::getAllNetworks();
134 $network_list = array();
135
136 $All_DeployedNodes=0;
137 $All_OnlineNodes=0;
138 $All_OnlineUsers=0;
139
140 foreach ($network_array as $network)
141 {
142         $All_DeployedNodes +=$network->getNumDeployedNodes();
143     $All_OnlineNodes +=$network->getNumOnlineNodes();
144 }
145
146 $body_html .= "<div id=\"nodes_status\">";
147 $body_html .= "  <div id=\"nodes_status_title\">France Wireless</div>";
148 $body_html .= "  <div id=\"nodes_deployed\">D&eacute;ploy&eacute;s&nbsp;:&nbsp;" . $All_DeployedNodes . "</div>";
149 $body_html .= "  <div id=\"nodes_online\">En&nbsp;fonctionnement&nbsp;:&nbsp;" . $All_OnlineNodes . "</div>";
150 $body_html .= "</div>";
151
152
153 $body_html .= "<div id=\"users_status\">";
154 $body_html .= "  <div id=\"users_status_title\"><a href=\"http://auth.wireless-fr.org/node_status.php\">Utilisateurs connect&eacute;s en WiFi : ";
155
156
157 $online_users = null;
158 $db->execSql("SELECT username,nodes.node_id,nodes.name FROM connections,users,nodes WHERE token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND nodes.node_id=connections.node_id ORDER BY account_origin, timestamp_in DESC", $online_users);
159
160 $All_OnlineUsers = count($online_users);
161
162 $body_html .= $All_OnlineUsers . "</a>";
163 $body_html .= "  </div>";
164
165 $body_html .= "  <div id=\"users_list\">";
166 $body_html .= "    <ul> ";
167
168 $numUser = 0;
169
170 if ($online_users != null){
171   foreach ($online_users as $online_user) {
172     $numUser++;
173     //$body_html .= "    <li>$online_user[username]</li>";
174     if ($numUser == $All_OnlineUsers) {
175       $body_html .= "$online_user[username]";
176     } else {
177       $body_html .= "$online_user[username] - ";
178     }
179   }
180 } else {
181   //   $body_html .= "<li>Aucune personne</li>";
182 }
183
184 $body_html .= "    </ul>";
185 $body_html .= "  </div>";
186 $body_html .= "</div>";
187
188 if ($format == "JavaScript") {
189   echo "document.write('".$body_html."');";
190 } else {
191   echo $body_html;
192 }
193
194 ?> 
195
Note: See TracBrowser for help on using the browser.