Changeset 726

Show
Ignore:
Timestamp:
09/09/05 02:36:34 (8 years ago)
Author:
aprilp
Message:

* New stats system with graphs
* Changed the UI a bit to reflect this change
* Updated stylesheet

Location:
trunk/wifidog-auth
Files:
12 added
4 removed
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/ChangeLog

    r723 r726  
     12005-09-08 Philippe April  <philippe@ilesansfil.org> 
     2        * New stats system with graphs 
     3        * Changed the UI a bit to reflect this change 
     4        * Updated stylesheet 
     5 
    162005-09-08 Benoit Grégoire  <bock@step.polymtl.ca> 
    27        * portal/index.php:  Custom portal redirect now operational. 
  • trunk/wifidog-auth/wifidog/admin/online_users.php

    r568 r726  
    4141$ui->setMainContent($smarty->fetch("admin/templates/online_users.html")); 
    4242$ui->display(); 
    43 //$smarty->display("admin/templates/online_users.html"); 
    4443?> 
  • trunk/wifidog-auth/wifidog/admin/templates/online_users.html

    r647 r726  
    55{else} 
    66 
    7 <div id="node_list"> 
     7<fieldset class='pretty_fieldset'> 
     8<legend>Online users</legend> 
    89<table> 
     10 
     11<thead> 
    912<tr> 
    10         <th>Node</th> 
    11         <th>Username</th> 
    12         <th>Origin</th> 
    13         <th>Logged in Since</th> 
    14         <th>Traffic IN/OUT</th> 
     13  <th>Node</th> 
     14  <th>Username</th> 
     15  <th>Origin</th> 
     16  <th>Logged in Since</th> 
     17  <th>Traffic IN/OUT</th> 
    1518</tr> 
     19</thead> 
     20 
    1621{section name=i loop=$users_array} 
    17 <tr> 
     22<tr class='{cycle values="odd,even"}'> 
    1823    <td>{$users_array[i].name}</td> 
    1924    <td><a href="user_log.php?user_id={$users_array[i].user_id}">{$users_array[i].username}</a></td> 
     
    2530{/section} 
    2631</table> 
    27 </div> 
    28 <br> 
     32</fieldset> 
    2933 
    3034{/if} 
  • trunk/wifidog-auth/wifidog/classes/MainUI.php

    r722 r726  
    108108                                        $html .= "<li><a href='user_log.php'>"._("User logs")."</a></li>\n"; 
    109109                                        $html .= "<li><a href='online_users.php'>"._("Online Users")."</a></li>\n"; 
    110                                         $html .= "<li><a href='user_stats.php'>"._("Cumulative user statistics")."</a></li>\n"; 
    111                                         $html .= "<li><a href='hotspot_log.php'>"._("Hotspot logs")."</a></li>\n"; 
     110                                        $html .= "<li><a href='stats.php'>"._("Statistics")."</a></li>\n"; 
    112111                                        $html .= "<li><a href='import_user_database.php'>"._("Import NoCat user database")."</a></li>\n"; 
    113112                                        $html .= "<li><a href='content_admin.php'>"._("Content manager")."</a></li>\n"; 
  • trunk/wifidog-auth/wifidog/classes/Network.php

    r721 r726  
    244244        } 
    245245 
     246        /** 
     247     * Retrieves the network's creation date 
     248         * @return A string 
     249     */ 
     250        public function getCreationDate() 
     251        { 
     252                return $this->mRow['creation_date']; 
     253        } 
     254 
    246255        /** Retreives the network's homepage url  
    247256         * @return The id */ 
     
    402411        public function getMultipleLoginAllowed() 
    403412        { 
    404                 ($this->mRow['allow_multiple_login']=='t')?$retval=true:$retval=false; 
    405                 return $retval; 
     413                return ($this->mRow['allow_multiple_login'] == 't') ? true : false; 
    406414        } 
    407415 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r716 r726  
    320320        } 
    321321 
     322    function getCreationDate() 
     323    { 
     324        return $this->mRow['creation_date']; 
     325    } 
     326 
    322327        function getHomePageURL() 
    323328        { 
     
    473478                $status = $this->mDb->EscapeString($status); 
    474479                $this->mDb->ExecSqlUpdate("UPDATE nodes SET node_deployment_status = '{$status}' WHERE node_id = '{$this->getId()}'"); 
     480                $this->refresh(); 
     481        } 
     482 
     483        function getLastPaged() 
     484        { 
     485                return $this->mRow['last_paged']; 
     486        } 
     487 
     488        function getLastHeartbeatIP() 
     489        { 
     490                return $this->mRow['last_heartbeat_ip']; 
     491        } 
     492 
     493        function getLastHeartbeatUserAgent() 
     494        { 
     495                return $this->mRow['last_heartbeat_user_agent']; 
     496        } 
     497 
     498        function getLastHeartbeatTimestamp() 
     499        { 
     500                return $this->mRow['last_heartbeat_timestamp']; 
     501        } 
     502 
     503        function setLastHeartbeatTimestamp($timestamp) 
     504        { 
     505                $status = $this->mDb->EscapeString($status); 
     506                $this->mDb->ExecSqlUpdate("UPDATE nodes SET last_heartbeat_timestamp = '{$timestamp}' WHERE node_id = '{$this->getId()}'"); 
    475507                $this->refresh(); 
    476508        } 
     
    534566        } 
    535567         
    536         /** Retreives the admin interface of this object. 
     568        /** Retrieves the admin interface of this object. 
    537569         * @return The HTML fragment for this interface */ 
    538570        public function getAdminUI() 
     
    9891021                $name = "node_{$this->id}_get_stats"; 
    9901022                if (!empty ($_REQUEST[$name])) 
    991                         header("Location: hotspot_log.php?node_id=".urlencode($this->getId())); 
     1023                        header("Location: stats.php?node_id=".urlencode($this->getId())); 
    9921024 
    9931025                // Node configuration section 
  • trunk/wifidog-auth/wifidog/classes/Statistics.php

    r553 r726  
    9191  } 
    9292 
    93   public static function getRegistrationsPerMonth() { 
     93  public static function getRegistrationsPerMonth($from = '', $to = '', $order = "DESC") { 
    9494    global $db; 
    95     $db->ExecSql("SELECT COUNT(users) AS num_users, date_trunc('month', reg_date) AS month FROM users  WHERE account_status = ".ACCOUNT_STATUS_ALLOWED." GROUP BY date_trunc('month', reg_date) ORDER BY month DESC",$results, false); 
     95 
     96    if ($from != '' && $to != '') 
     97        $date_constraint = "AND reg_date >= '$from' AND reg_date <= '$to'"; 
     98    else 
     99        $date_constraint = ''; 
     100 
     101    $db->ExecSql("SELECT COUNT(users) AS num_users, date_trunc('month', reg_date) AS month FROM users  WHERE account_status = ".ACCOUNT_STATUS_ALLOWED." ${date_constraint} GROUP BY date_trunc('month', reg_date) ORDER BY month $order",$results, false); 
    96102    return $results; 
    97103  } 
    98104 
    99   public static function getMostMobileUsers($limit) { 
     105  public static function getRegistrationsPerNode($from = '', $to = '') { 
    100106    global $db; 
    101     $db->ExecSql("SELECT COUNT(DISTINCT node_id) AS num_hotspots_visited, user_id, username, account_origin FROM users NATURAL JOIN connections WHERE (incoming!=0 OR outgoing!=0) GROUP BY account_origin, username,user_id ORDER BY num_hotspots_visited DESC LIMIT $limit", $results, false); 
     107 
     108    if ($from != '' && $to != '') 
     109        $date_constraint = "AND timestamp_in BETWEEN '$from' AND '$to'"; 
     110    else 
     111        $date_constraint = ''; 
     112 
     113    $db->ExecSql("SELECT nodes.name,connections.node_id,COUNT(user_id) as registrations FROM connections,nodes WHERE timestamp_in IN (SELECT MIN(timestamp_in) as first_connection FROM connections GROUP BY user_id) ${date_constraint} AND nodes.node_id=connections.node_id GROUP BY connections.node_id,nodes.name ORDER BY registrations DESC", $results, false); 
    102114    return $results; 
    103115  } 
    104116 
    105   public static function getMostFrequentUsers($limit) { 
     117  public static function getNodesUsage($from = '', $to = '') { 
    106118    global $db; 
    107     $db->ExecSql("SELECT COUNT(user_active_days.user_id) AS active_days, user_active_days.user_id, username, account_origin FROM (SELECT DISTINCT user_id, date_trunc('day', timestamp_in) AS date FROM connections WHERE (incoming!=0 OR outgoing!=0) GROUP BY date,user_id) user_active_days JOIN users ON (users.user_id = user_active_days.user_id) GROUP BY account_origin, username, user_active_days.user_id ORDER BY active_days DESC LIMIT $limit",$results, false); 
     119 
     120    if ($from != '' && $to != '') 
     121        $date_constraint = "AND timestamp_in BETWEEN '$from' AND '$to'"; 
     122    else 
     123        $date_constraint = ''; 
     124 
     125    $db->ExecSql("SELECT nodes.name,connections.node_id,COUNT(connections.node_id) AS connections FROM connections,nodes WHERE nodes.node_id=connections.node_id ${date_constraint} GROUP BY connections.node_id,nodes.name ORDER BY connections DESC;", $results, false); 
    108126    return $results; 
    109127  } 
    110128 
    111   public static function getMostGreedyUsers($limit) { 
     129  public static function getMostMobileUsers($limit, $from = '', $to = '') { 
    112130    global $db; 
    113     $db->ExecSql("SELECT DISTINCT connections.user_id, SUM((incoming+outgoing)/1048576) AS total, SUM((incoming/1048576)) AS total_incoming, SUM((outgoing/1048576)) AS total_outgoing, username, account_origin FROM connections JOIN users ON (users.user_id = connections.user_id) WHERE incoming IS NOT NULL AND outgoing IS NOT NULL GROUP BY account_origin, username,connections.user_id ORDER BY total DESC limit $limit", $results, false); 
     131 
     132    if ($from != '' && $to != '') 
     133        $date_constraint = "AND timestamp_in >= '$from' AND timestamp_out <= '$to'"; 
     134    else 
     135        $date_constraint = ''; 
     136 
     137    $db->ExecSql("SELECT COUNT(DISTINCT node_id) AS num_hotspots_visited, user_id, username, account_origin FROM users NATURAL JOIN connections WHERE (incoming!=0 OR outgoing!=0) ${date_constraint} GROUP BY account_origin, username,user_id ORDER BY num_hotspots_visited DESC LIMIT $limit", $results, false); 
     138    return $results; 
     139  } 
     140 
     141  public static function getMostFrequentUsers($limit, $from = '', $to = '') { 
     142    global $db; 
     143 
     144    if ($from != '' && $to != '') 
     145        $date_constraint = "AND timestamp_in >= '$from' AND timestamp_out <= '$to'"; 
     146    else 
     147        $date_constraint = ''; 
     148 
     149    $db->ExecSql("SELECT COUNT(user_active_days.user_id) AS active_days, user_active_days.user_id, username, account_origin FROM (SELECT DISTINCT user_id, date_trunc('day', timestamp_in) AS date FROM connections WHERE (incoming!=0 OR outgoing!=0)  ${date_constraint} GROUP BY date,user_id) user_active_days JOIN users ON (users.user_id = user_active_days.user_id) GROUP BY account_origin, username, user_active_days.user_id ORDER BY active_days DESC LIMIT $limit",$results, false); 
     150    return $results; 
     151  } 
     152 
     153  public static function getMostGreedyUsers($limit, $from = '', $to = '') { 
     154    global $db; 
     155 
     156    if ($from != '' && $to != '') 
     157        $date_constraint = "AND timestamp_in >= '$from' AND timestamp_out <= '$to'"; 
     158    else 
     159        $date_constraint = ''; 
     160 
     161    $db->ExecSql("SELECT DISTINCT connections.user_id, SUM(incoming+outgoing) AS total, SUM(incoming) AS total_incoming, SUM(outgoing) AS total_outgoing, username, account_origin FROM connections JOIN users ON (users.user_id = connections.user_id) WHERE incoming IS NOT NULL AND outgoing IS NOT NULL  ${date_constraint} GROUP BY account_origin, username,connections.user_id ORDER BY total DESC limit $limit", $results, false); 
    114162    return $results; 
    115163  } 
  • trunk/wifidog-auth/wifidog/local_content/default/stylesheet.css

    r685 r726  
    481481#std_table td.item { font-weight: bold; } 
    482482 
     483.pretty_fieldset { 
     484    background-color: #e1f5da; 
     485    font-family: Verdana, Arial, Helvetica, sans-serif; 
     486    } 
     487.pretty_fieldset legend { 
     488    font-size: 14pt; 
     489    } 
     490.pretty_fieldset table { 
     491    width: 100%; 
     492    border-collapse: collapse; 
     493    } 
     494.pretty_fieldset tr.odd { 
     495    background-color: #d1e5ca; 
     496    } 
     497.pretty_fieldset th { 
     498    text-align: left; 
     499    text-transform: uppercase; 
     500    width: 200px; 
     501    } 
     502 
     503.pretty_fieldset div { 
     504    border: 1px dotted black; 
     505    background-color: #fff; 
     506    } 
     507 
     508.pretty_fieldset .red { 
     509    background-color: red; 
     510    } 
     511 
     512.smaller { 
     513    font-size: 80%; 
     514    } 
     515 
    483516/* Google Maps stuff */ 
    484517#map_hotspots_list {