root/trunk/wifidog-auth/wifidog/admin/user_log.php @ 380

Revision 380, 3.9 KB (checked in by aprilp, 8 years ago)

*** empty log message ***

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
RevLine 
[174]1<?php
2  /********************************************************************\
3   * This program is free software; you can redistribute it and/or    *
4   * modify it under the terms of the GNU General Public License as   *
5   * published by the Free Software Foundation; either version 2 of   *
6   * the License, or (at your option) any later version.              *
7   *                                                                  *
8   * This program is distributed in the hope that it will be useful,  *
9   * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
10   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
11   * GNU General Public License for more details.                     *
12   *                                                                  *
13   * You should have received a copy of the GNU General Public License*
14   * along with this program; if not, contact:                        *
15   *                                                                  *
16   * Free Software Foundation           Voice:  +1-617-542-5942       *
17   * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       *
18   * Boston, MA  02111-1307,  USA       gnu@gnu.org                   *
19   *                                                                  *
20   \********************************************************************/
21  /**@file
22   * @author Copyright (C) 2004 Philippe April.
23   */
24 
[376]25require_once 'admin_common.php';
[174]26
[194]27$total = array();
28$total['incoming'] = 0;
29$total['outgoing'] = 0;
30
[345]31if (!empty($_REQUEST['user_id'])) {
[174]32    $db->ExecSqlUniqueRes("SELECT * FROM users WHERE user_id='$_REQUEST[user_id]'",$userinfo,false);
[345]33    if (!$userinfo) {
[369]34        $smarty->assign("error", _("Unable to locate ") . $_REQUEST['user_id'] . _(" in the database."));
[345]35    } else {
36            $userinfo['account_status_description'] = $account_status_to_text[$userinfo['account_status']]; 
37            $smarty->assign("userinfo", $userinfo);
[174]38       
[371]39            $db->ExecSql("SELECT * FROM connections,nodes WHERE user_id='{$_REQUEST['user_id']}' AND nodes.node_id=connections.node_id ORDER BY timestamp_in", $connection_array, false);
[345]40            if ($connection_array) {
41                foreach($connection_array as $connection) {
42                    $total['incoming'] += $connection['incoming'];
43                $total['outgoing'] += $connection['outgoing'];
44                    $connection['token_status_description'] = $token_to_text[$connection['token_status']];
45                    $smarty->append("connections", $connection);
46                }
47                $smarty->assign("total", $total);
48            } else {
[369]49                //No connections from user yet
[345]50            }
51    }
52    $smarty->display("admin/templates/user_log_detailed.html");
53} else {
[379]54    $smarty->assign('sort_ids', array('user_id','email','reg_date'));
55    $smarty->assign('direction_ids', array('asc','desc'));
56
57    $sort      = isset($_REQUEST['sort'])      ? $_REQUEST['sort']      : "user_id";
58    $direction = isset($_REQUEST['direction']) ? $_REQUEST['direction'] : "asc";
59
60    $smarty->assign("sort",      $sort);
61    $smarty->assign("direction", $direction);
62
[369]63    if (isset($_REQUEST["page"]) && is_numeric($_REQUEST["page"])) {
64        $current_page = $_REQUEST["page"];
65    } else {
66        $current_page = 1;
67    }
[379]68    $smarty->assign("page", $current_page);
[369]69
[370]70    $per_page = 100;
[369]71    $offset = (($current_page * $per_page) - $per_page + 1);
72    $pages = $stats->getNumUsers() / $per_page;
73    for ($i = 1; $i <= $pages+1; $i++) {
74        $smarty->append("pages", array(
75                'number' => $i,
76                'selected' => ($i == $current_page),
77            ));
78    }
79
[380]80    $db->ExecSql("SELECT user_id,email,reg_date,account_status FROM users ORDER BY $sort $direction LIMIT $per_page OFFSET $offset", $users_res);
[345]81    if ($users_res) {
[369]82            $smarty->assign("users_array", $users_res);
[345]83    } else {
[369]84        $smarty->assign("error", _('Internal error.'));
[345]85    }
[174]86
[380]87    $smarty->assign("account_status_to_text", $account_status_to_text);
[345]88    $smarty->display("admin/templates/user_log.html");
89}
[174]90?>
Note: See TracBrowser for help on using the browser.