Permalink
Browse files

Statext: Generate case sensitive statistics

Important for string data like Auth / ESSID / Key

Examples:
- admin:admin
- Admin:Admin
- admin:Admin
  • Loading branch information...
binarymaster committed Apr 7, 2018
1 parent 34ec12c commit f145e3267af950a11a56f0157259fe0b9ad0ce80
Showing with 5 additions and 5 deletions.
  1. +5 −5 statext.php
View
@@ -173,7 +173,7 @@ function getCountStats($db, $col, $top, $useloc = false, $where = array(), $post
$result['top'] = $top;
$where[] = "IFNULL(`$col`, '') != ''";
$where = implode(' AND ', $where);
$sql = "SELECT COUNT(DISTINCT `$col`) FROM BASE_TABLE ";
$sql = "SELECT COUNT(DISTINCT BINARY `$col`) FROM BASE_TABLE ";
if ($useloc)
$sql .= "JOIN radius_ids USING(id) ";
$sql .= "WHERE $where";
@@ -185,10 +185,10 @@ function getCountStats($db, $col, $top, $useloc = false, $where = array(), $post
}
else
return false;
$sql = "SELECT `$col`, COUNT($col) FROM BASE_TABLE ";
$sql = "SELECT BINARY `$col`, COUNT(BINARY $col) FROM BASE_TABLE ";
if ($useloc)
$sql .= "JOIN radius_ids USING(id) ";
$sql .= "WHERE $where GROUP BY `$col` HAVING COUNT($col) > 1 ORDER BY COUNT($col) DESC LIMIT $top";
$sql .= "WHERE $where GROUP BY BINARY `$col` HAVING COUNT(BINARY $col) > 1 ORDER BY COUNT(BINARY $col) DESC LIMIT $top";
if ($res = QuerySql($sql))
{
$result['data'] = array();
@@ -230,15 +230,15 @@ function getMultiStats($db, $cols, $top, $useloc = false, $where = array(), $pos
$from[] = $sql;
}
$from = implode(' UNION ALL ', $from);
if ($res = QuerySql("SELECT COUNT(DISTINCT `{$cols[0]}`) FROM ($from) TmpTable"))
if ($res = QuerySql("SELECT COUNT(DISTINCT BINARY `{$cols[0]}`) FROM ($from) TmpTable"))
{
$row = $res->fetch_row();
$result['total'] = (int)$row[0];
$res->close();
}
else
return false;
if ($res = QuerySql("SELECT `{$cols[0]}`, COUNT({$cols[0]}) FROM ($from) TmpTable GROUP BY `{$cols[0]}` HAVING COUNT({$cols[0]}) > 1 ORDER BY COUNT({$cols[0]}) DESC LIMIT $top"))
if ($res = QuerySql("SELECT BINARY `{$cols[0]}`, COUNT(BINARY {$cols[0]}) FROM ($from) TmpTable GROUP BY BINARY `{$cols[0]}` HAVING COUNT(BINARY {$cols[0]}) > 1 ORDER BY COUNT(BINARY {$cols[0]}) DESC LIMIT $top"))
{
$result['data'] = array();
while ($row = $res->fetch_row())

0 comments on commit f145e32

Please sign in to comment.