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

Revision 395, 5.7 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 = "<div id=\"node_export\">";
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
97   $body_html .= "<div id=\"network_users_status\">";
98   $body_html .= "  <div id=\"network_users_status_title\"><a href=\"http://auth.wireless-fr.org/node_status.php\">Utilisateurs connect&eacute;s en WiFi : ";
99
100   $online_users = null;
101   $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);
102  
103   $Network_OnlineUsers = count($online_users);
104
105   $body_html .= $Network_OnlineUsers . "</a>";
106   $body_html .= "  </div>";
107
108   $body_html .= "  <div id=\"users_list\">";
109   $body_html .= "    <ul> ";
110
111   $numUser = 0;
112   if ($online_users != null){
113     foreach ($online_users as $online_user) {
114       $numUser++;
115       //$body_html .= "    <li>$online_user[username]</li>";
116       if ($numUser == $Network_OnlineUsers) {
117         $body_html .= "$online_user[username]";
118       } else {
119         $body_html .= "$online_user[username] - ";
120       }
121     }
122   } else {
123     // $body_html .= "<li>Aucune personne</li>";
124   }
125
126   $body_html .= "    </ul>";
127   $body_html .= "  </div>";
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
151
152 $body_html .= "<div id=\"users_status\">";
153 $body_html .= "  <div id=\"users_status_title\"><a href=\"http://auth.wireless-fr.org/node_status.php\">Utilisateurs connect&eacute;s en WiFi : ";
154
155
156 $online_users = null;
157 $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);
158
159 $All_OnlineUsers = count($online_users);
160
161 $body_html .= $All_OnlineUsers . "</a>";
162 $body_html .= "  </div>";
163
164 $body_html .= "  <div id=\"users_list\">";
165 $body_html .= "    <ul> ";
166
167 $numUser = 0;
168
169 if ($online_users != null){
170   foreach ($online_users as $online_user) {
171     $numUser++;
172     //$body_html .= "    <li>$online_user[username]</li>";
173     if ($numUser == $All_OnlineUsers) {
174       $body_html .= "$online_user[username]";
175     } else {
176       $body_html .= "$online_user[username] - ";
177     }
178   }
179 } else {
180   //   $body_html .= "<li>Aucune personne</li>";
181 }
182
183 $body_html .= "    </ul>";
184 $body_html .= "  </div>";
185 $body_html .= "</div>";
186 $body_html .= "</div>";
187
188 $body_html .= "</div>";
189 $body_html .= "</div>";
190
191 if ($format == "JavaScript") {
192   echo "document.write('".$body_html."');";
193 } else {
194   echo $body_html;
195 }
196
197 ?> 
198
Note: See TracBrowser for help on using the browser.